Register for your free account! | Forgot your password?

You last visited: Today at 08:45

  • Please register to post and access all features, it's quick, easy and FREE!


Reader with code source

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2012
Posts: 134
Received Thanks: 30
Reader with code source

it's reader with code source , nothing fancy , some methods of copy,past,cut,select,delete,read,readAndClean also catching ctrl+a to select all , ctrl+r to read
it read throw instance of SpVoice at SpeechLib. , it's voice is so damn weird and talking pretty fast but it helps me when im multi tasking or too lazy to read :P

feel free to correct any mistakes in the code (if there :P)
it may not be the best way to get it done but im still learning

code source
P.S add the SpeechLib as ref. u will find it at COMponent refs
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SpeechLib;

namespace Reader
{
    public partial class Form1 : Form
    {
        public Form1(){InitializeComponent();}
        string toread;
        void talk(string tosay){
            SpVoice voice = new SpVoice();voice.Volume = 100;
            voice.Speak(tosay, SpeechVoiceSpeakFlags.SVSFDefault);}
        private void readToolStripMenuItem_Click(object sender, EventArgs e){
            if (textBox1.SelectedText == "")toread = textBox1.Text;else toread = textBox1.SelectedText;talk(toread);}
        private void readAndCleanToolStripMenuItem_Click(object sender, EventArgs e){
            if (textBox1.SelectedText == "")toread = textBox1.Text;
            else toread = textBox1.SelectedText;talk(toread);textBox1.Text = "";}
        private void readOnlyToolStripMenuItem_Click(object sender, EventArgs e){
            if (textBox1.SelectedText == "")toread = textBox1.Text;
            else toread = textBox1.SelectedText;talk(toread);}
        private void selectAllToolStripMenuItem1_Click(object sender, EventArgs e){
            textBox1.SelectionStart = 0;textBox1.SelectionLength = textBox1.TextLength;}
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e){
            if (e.KeyChar == (char)1){textBox1.SelectionStart = 0;textBox1.SelectionLength = textBox1.TextLength;}
            if (e.KeyChar == (char)18){readOnlyToolStripMenuItem_Click(this.textBox1, e);}}
        private void deselectAllToolStripMenuItem_Click(object sender, EventArgs e){textBox1.SelectionLength = 0;}
        private void deleteAllToolStripMenuItem_Click(object sender, EventArgs e){textBox1.SelectedText = "";}
        private void deleteSelectedToolStripMenuItem_Click(object sender, EventArgs e){textBox1.SelectedText = "";}
        private void deleteAllToolStripMenuItem1_Click(object sender, EventArgs e){textBox1.Text = "";}
        private void cutSelectedToolStripMenuItem_Click(object sender, EventArgs e){
            Clipboard.SetText(textBox1.SelectedText, System.Windows.Forms.TextDataFormat.UnicodeText);textBox1.SelectedText = "";}
        private void cutToolStripMenuItem_Click(object sender, EventArgs e){
            try { Clipboard.SetText(textBox1.SelectedText, System.Windows.Forms.TextDataFormat.UnicodeText); textBox1.SelectedText = ""; }catch { };}
        private void cutAllToolStripMenuItem_Click(object sender, EventArgs e){
            Clipboard.SetText(textBox1.Text, TextDataFormat.UnicodeText);textBox1.Text = "";}
        private void copyAllToolStripMenuItem_Click(object sender, EventArgs e){Clipboard.SetText(textBox1.Text, TextDataFormat.UnicodeText);}
        private void copySelectedToolStripMenuItem_Click(object sender, EventArgs e){
            Clipboard.SetText(textBox1.SelectedText, System.Windows.Forms.TextDataFormat.UnicodeText);}
        private void copyToolStripMenuItem_Click(object sender, EventArgs e){
            Clipboard.SetText(textBox1.SelectedText, System.Windows.Forms.TextDataFormat.UnicodeText);}
        private void pasteToolStripMenuItem1_Click(object sender, EventArgs e){textBox1.Paste(Clipboard.GetText());Clipboard.Clear();}
        }
}
i don't use spaces at methods so i can see as many as possible (sorry if u don't like it that way or not used to it like that )
P.S design is just strip menu and textbox , ill upload it anyway


for ss



DyjgK64J451Jhv0 is offline  
Old 04/28/2012, 09:53   #2
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 783
Messy code.


I don't have a username is offline  
Old 04/28/2012, 11:07   #3
 
elite*gold: 0
Join Date: Apr 2012
Posts: 134
Received Thanks: 30
yup that's true , wish to do it better next time
DyjgK64J451Jhv0 is offline  
Old 04/28/2012, 18:02   #4
 
elite*gold: 0
Join Date: Mar 2005
Posts: 1,307
Received Thanks: 1,363
you should really label your functions and uses spaces in them & seperate lines


Ultimation is offline  
Old 04/28/2012, 19:11   #5
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,877
Good code first starts with legibility.
InfamousNoone is offline  
Thanks
1 User
Old 04/28/2012, 21:31   #6
 
elite*gold: 20
Join Date: Jun 2006
Posts: 3,293
Received Thanks: 919
You may be able to see as much as possible this way but is it of any use when it's ridiculously hard to read?
Kiyono is offline  
Old 04/28/2012, 23:26   #7
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,124
Received Thanks: 2,503
Well i glanced at your code, and i havent got a ******* clue what it does. Which is awkward cos if it was written properly it would be simple im sure.

My Advice, if you wanna see more of you code at the same time, get a bigger screen
Korvacs is offline  
Old 04/29/2012, 02:25   #8
 
elite*gold: 0
Join Date: Apr 2012
Posts: 134
Received Thanks: 30
i thought this was clear enough to read but maybe you are not used to read it like that so to simplify this , here is the style you used to read
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SpeechLib;

namespace Reader
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string toread;

        void talk(string tosay)
        {

            SpVoice voice = new SpVoice();
            voice.Volume = 100;
            voice.Speak(tosay, SpeechVoiceSpeakFlags.SVSFDefault);

        }

        private void readToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (textBox1.SelectedText == "")
                toread = textBox1.Text;
            else toread = textBox1.SelectedText;
            talk(toread);

        }
        private void readAndCleanToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (textBox1.SelectedText == "")
                toread = textBox1.Text;
            else toread = textBox1.SelectedText;
            talk(toread);
            textBox1.Text = "";

        }
        private void readOnlyToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (textBox1.SelectedText == "")
                toread = textBox1.Text;
            else toread = textBox1.SelectedText;
            talk(toread);

        }
        private void selectAllToolStripMenuItem1_Click(object sender, EventArgs e)
        {

            textBox1.SelectionStart = 0;
            textBox1.SelectionLength = textBox1.TextLength;

        }
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)1)
            {

                textBox1.SelectionStart = 0;
                textBox1.SelectionLength = textBox1.TextLength;

            }

            if (e.KeyChar == (char)18)
            {

                readOnlyToolStripMenuItem_Click(this.textBox1, e);

            }

        }
        private void deselectAllToolStripMenuItem_Click(object sender, EventArgs e)
        {

            textBox1.SelectionLength = 0;

        }
        private void deleteAllToolStripMenuItem_Click(object sender, EventArgs e)
        {

            textBox1.SelectedText = "";

        }
        private void deleteSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {

            textBox1.SelectedText = "";

        }
        private void deleteAllToolStripMenuItem1_Click(object sender, EventArgs e)
        {

            textBox1.Text = "";

        }
        private void cutSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {

            Clipboard.SetText(textBox1.SelectedText, System.Windows.Forms.TextDataFormat.UnicodeText);textBox1.SelectedText = "";

        }
        private void cutToolStripMenuItem_Click(object sender, EventArgs e)
        {

            try {
                Clipboard.SetText(textBox1.SelectedText, System.Windows.Forms.TextDataFormat.UnicodeText); textBox1.SelectedText = ""; 
                }

            catch { };

        }
        private void cutAllToolStripMenuItem_Click(object sender, EventArgs e)
        {

            Clipboard.SetText(textBox1.Text, TextDataFormat.UnicodeText);textBox1.Text = "";
        }

        private void copyAllToolStripMenuItem_Click(object sender, EventArgs e)
        {

            Clipboard.SetText(textBox1.Text, TextDataFormat.UnicodeText);
        }

        private void copySelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {

            Clipboard.SetText(textBox1.SelectedText, System.Windows.Forms.TextDataFormat.UnicodeText);
        }

        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {

            Clipboard.SetText(textBox1.SelectedText, System.Windows.Forms.TextDataFormat.UnicodeText);
        }

        private void pasteToolStripMenuItem1_Click(object sender, EventArgs e)
        {

            textBox1.Paste(Clipboard.GetText());Clipboard.Clear();

        }
        }
}
the first style wasn't meant to be more complicated but to be able to trace the whole thing without searching for definitions or refs
@hybird @kyn @kov @ulti @buss , is it clear enough now ?

P.S at read and clean , if u selected some text to read and clean it will read what u selected and clean all
how to fix
Quote:
if (textBox1.SelectedText == "")
toread = textBox1.Text;
else toread = textBox1.SelectedText;
talk(toread);
textBox1.Text = "";
change the textBox1.Text = ""; to textBox1.SelectedText = "";
thanks everyone , wish i do it better on the next project , back to books ^^


DyjgK64J451Jhv0 is offline  
Reply



« NPC flags problem | [IdiotRelease]1st RB StatPoints formula »

Similar Threads
[Java Release with Source] Account Info Saver & Reader
09/13/2008 - CO2 Programming - 5 Replies
Okay, i've updated the Acount Info Saver to make the files un-readable unless you use this, or just right click and open with notepad xD. So, anyways, pretty simple, i just had it remove the .txt extension, and made this program to read the text file itself. How to use - Just type your login ID you used to save the file with, and it should read it :) Note to a Mod: You can delete my old thread of the Saver, or you can keep it so people can learn how to write text files in java, doesnt...



All times are GMT +1. The time now is 08:45.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2018 elitepvpers All Rights Reserved.