Reader with code source

04/28/2012 01:25 DyjgK64J451Jhv0#1
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 :rolleyes:)
P.S design is just strip menu and textbox , ill upload it anyway
[Only registered and activated users can see links. Click Here To Register...]

for ss
[Only registered and activated users can see links. Click Here To Register...]
04/28/2012 09:53 I don't have a username#2
Messy code.
04/28/2012 11:07 DyjgK64J451Jhv0#3
yup that's true , wish to do it better next time
04/28/2012 18:02 Ultimation#4
you should really label your functions and uses spaces in them :) & seperate lines
04/28/2012 19:11 InfamousNoone#5
Good code first starts with legibility.
04/28/2012 21:31 Kiyono#6
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?
04/28/2012 23:26 Korvacs#7
Well i glanced at your code, and i havent got a fucking 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 :rolleyes:
04/29/2012 02:25 DyjgK64J451Jhv0#8
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 ^^