Beispiel #1
0
        static void Main()
        {
            bool  created;
            Mutex mutex = new Mutex(false, APPNAME, out created);

            if (!created)
            {
                MessageBox.Show("You can (and should) only run one 'copy' of this program at a time.",
                                "You are already running a copy of this!",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Environment.Exit(1);
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Program gram = new Program();

            gram.createPronunciations();
            PronunciationsForm instance = new PronunciationsForm();

            instance.Visible          = false;
            gram._ni                  = new NotifyIcon();
            gram._ni.Visible          = true;
            gram._ni.ContextMenuStrip = new ContextMenuStrip();
            gram._ni.MouseClick      += new MouseEventHandler(gram.ico_MouseClick);
            gram._ni.ContextMenuStrip.Items.Add("Re-Read", new Bitmap("No Image.png"));
            gram._ni.ContextMenuStrip.Items.Add("Pronunciations", new Bitmap("No image.png"));
            gram._ni.ContextMenuStrip.Items.Add("Pause", new Bitmap("No image.png"));
            gram._ni.ContextMenuStrip.Items.Add("Stop", new Bitmap("No image.png"));
            gram._ni.ContextMenuStrip.Items.Add("Voice", new Bitmap("No image.png"));
            gram._ni.ContextMenuStrip.Items.Add("Exit", new Bitmap("No image.png"));


            gram._ni.ContextMenuStrip.Items[0].MouseUp += new MouseEventHandler(gram.ReRead_MouseUp);
            gram._ni.ContextMenuStrip.Items[0].Enabled  = false;
            gram._ni.ContextMenuStrip.Items[1].MouseUp += new MouseEventHandler(gram.pro_MouseUp);
            gram._ni.ContextMenuStrip.Items[2].MouseUp += new MouseEventHandler(gram.play_MouseUp);
            gram._ni.ContextMenuStrip.Items[4].MouseUp += new MouseEventHandler(gram.voice_MouseUp);
            gram._ni.ContextMenuStrip.Items[3].MouseUp += new MouseEventHandler(gram.stop_MouseUp);
            gram._ni.ContextMenuStrip.Items[5].MouseUp += new MouseEventHandler(gram.exit_MouseUp);
            gram._ni.BalloonTipClicked += gram.booleanTipClicked;;
            // sub menu
            string[] voiceNames = SpeechController.getInstalledVoiceNames();
            foreach (string voiceName in voiceNames)
            {
                (gram._ni.ContextMenuStrip.Items[4] as ToolStripMenuItem).DropDownItems.
                Add(voiceName);
            }
            S_voiceMenu = gram._ni.ContextMenuStrip.Items[4] as ToolStripMenuItem;
            ToolStripItemCollection tsic = (gram._ni.ContextMenuStrip.Items[4] as ToolStripMenuItem).DropDownItems;

            for (int counter = 0; counter < tsic.Count; counter++)
            {
                tsic[counter].MouseUp += new MouseEventHandler(gram.voiceName_MouseUp);
            }

            gram._ni.Icon = new Icon("cr.ico");
            S_win         = new SpeechController(gram);
            S_win.CreateHandle(new CreateParams());
            SetClipboardViewer(S_win.Handle);
            // first run.
            if (String.IsNullOrEmpty(Properties.Voice.Default.VoiceHeard))
            {
                ToolStripMenuItem tsmi = gram._ni.ContextMenuStrip.Items[4] as ToolStripMenuItem;
                Debug.Write("First run.");
                setToDefaultVoice(tsmi);
            }
            else
            {
                String voice = Properties.Voice.Default.VoiceHeard;
                S_win.changeVoice(voice);
                ToolStripItem     tsi  = gram._ni.ContextMenuStrip.Items[4];
                ToolStripMenuItem tsmi = gram._ni.ContextMenuStrip.Items[4] as ToolStripMenuItem;
                bool voiceFound        = setVoiceTick(voice);
                if (!voiceFound)
                {
                    Debug.Write("No voice found, first run?");
                    setToDefaultVoice(tsmi);
                }
            }
            gram.notifyUser("ClipReader is ready to read to you!", "Your reader is ready!",
                            ToolTipIcon.Info);
            Application.Run(gram);
        }
Beispiel #2
0
        private void pro_MouseUp(object sender, MouseEventArgs e)
        {
            PronunciationsForm pf = new PronunciationsForm();

            pf.Show();
        }