예제 #1
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Settings.Initialize();

                SettingsForm settings = null;
                EventHandler evt = new EventHandler(delegate(object sender, EventArgs e)
                {
                    if (settings != null && !settings.IsDisposed)
                    {
                        if (settings.WindowState == FormWindowState.Minimized) settings.WindowState = FormWindowState.Normal;
                        settings.BringToFront();
                        settings.Focus();
                    }
                    else
                    {
                        settings = new SettingsForm();
                        settings.Show();
                    }
                });

                ico = new NotifyIcon();
                ico.Text = "Midori";
                ico.Icon = Properties.Resources.icon;
                ico.DoubleClick += evt;

                ContextMenu cm = new ContextMenu();

                MenuItem i1 = new MenuItem("Settings");
                i1.DefaultItem = true;
                i1.Click += evt;
                cm.MenuItems.Add(i1);

                cm.MenuItems.Add(new MenuItem("-"));

                MenuItem i2 = new MenuItem("Exit");
                i2.Click += delegate { Application.Exit(); };
                cm.MenuItems.Add(i2);

                ico.ContextMenu = cm;
                ico.Visible = true;

                HookManager.KeyDown += KeyDown;
                HookManager.KeyUp += KeyUp;
                ico.ShowBalloonTip(3, "Info", "Midori's running now!", ToolTipIcon.Info);

                ThreadChoke choke = new ThreadChoke();
                STAThread = SynchronizationContext.Current;
                choke.Dispose();

                Application.Run();
                /*while (!closing)
                {
                    Application.DoEvents();

                    if (intermediateimgflag)
                    {
                        Clipboard.SetImage(intermediateimg);
                        intermediateimg.Dispose();
                        intermediateimgflag = false;
                    }

                    Thread.Sleep(50);
                }*/
            }
            catch (Exception e)
            {
                Error error = new Error(e.ToString());
            }
            finally
            {
                if (ico != null)
                {
                    ico.Visible = false;
                    ico.Dispose();
                }

                HookManager.KeyDown -= KeyDown;
                HookManager.KeyUp -= KeyUp;
            }
        }
예제 #2
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Settings.Initialize();

                SettingsForm settings = null;
                EventHandler evt      = new EventHandler(delegate(object sender, EventArgs e)
                {
                    if (settings != null && !settings.IsDisposed)
                    {
                        if (settings.WindowState == FormWindowState.Minimized)
                        {
                            settings.WindowState = FormWindowState.Normal;
                        }
                        settings.BringToFront();
                        settings.Focus();
                    }
                    else
                    {
                        settings = new SettingsForm();
                        settings.Show();
                    }
                });

                ico              = new NotifyIcon();
                ico.Text         = "Midori";
                ico.Icon         = Properties.Resources.icon;
                ico.DoubleClick += evt;

                ContextMenu cm = new ContextMenu();

                MenuItem i1 = new MenuItem("Settings");
                i1.DefaultItem = true;
                i1.Click      += evt;
                cm.MenuItems.Add(i1);

                cm.MenuItems.Add(new MenuItem("-"));

                MenuItem i2 = new MenuItem("Exit");
                i2.Click += delegate { Application.Exit(); };
                cm.MenuItems.Add(i2);

                ico.ContextMenu = cm;
                ico.Visible     = true;

                HookManager.KeyDown += KeyDown;
                HookManager.KeyUp   += KeyUp;
                ico.ShowBalloonTip(3, "Info", "Midori's running now!", ToolTipIcon.Info);

                ThreadChoke choke = new ThreadChoke();
                STAThread = SynchronizationContext.Current;
                choke.Dispose();

                Application.Run();

                /*while (!closing)
                 * {
                 *  Application.DoEvents();
                 *
                 *  if (intermediateimgflag)
                 *  {
                 *      Clipboard.SetImage(intermediateimg);
                 *      intermediateimg.Dispose();
                 *      intermediateimgflag = false;
                 *  }
                 *
                 *  Thread.Sleep(50);
                 * }*/
            }
            catch (Exception e)
            {
                Error error = new Error(e.ToString());
            }
            finally
            {
                if (ico != null)
                {
                    ico.Visible = false;
                    ico.Dispose();
                }

                HookManager.KeyDown -= KeyDown;
                HookManager.KeyUp   -= KeyUp;
            }
        }