Exemplo n.º 1
0
        public void setup()
        {
            ContextMenuStrip  rightMenu  = new ContextMenuStrip();
            ToolStripMenuItem itemUpdate = new ToolStripMenuItem
            {
                Text = LocaleFactory.get().localize("Check for Update…", "Main")
            };
            PeriodicUpdateChecker updater = PeriodicUpdateCheckerFactory.get();

            itemUpdate.Enabled = updater.hasUpdatePrivileges();
            itemUpdate.Click  += delegate { updater.check(false); };
            ToolStripMenuItem itemDonate = new ToolStripMenuItem
            {
                Text = LocaleFactory.get().localize("Donate…", "Main")
            };

            itemDonate.Click +=
                delegate { BrowserLauncherFactory.get().open(PreferencesFactory.get().getProperty("website.donate")); };
            ToolStripMenuItem itemKey = new ToolStripMenuItem {
                Text = LicenseFactory.find().ToString(), Enabled = false
            };
            ToolStripMenuItem itemExit = new ToolStripMenuItem
            {
                Text = LocaleFactory.get().localize("Exit", "Localizable")
            };

            itemExit.Click += delegate { MainController.Exit(false); };
            rightMenu.Items.AddRange(new ToolStripItem[]
                                     { itemUpdate, new ToolStripSeparator(), itemDonate, itemKey, new ToolStripSeparator(), itemExit });

            try
            {
                _icon.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            }
            catch (ArgumentException)
            {
            }
            _icon.Visible          = true;
            _icon.ContextMenuStrip = rightMenu;

            _icon.MouseClick += delegate(object sender, MouseEventArgs args)
            {
                if (args.Button == MouseButtons.Left)
                {
                    foreach (BrowserController browser in MainController.Browsers)
                    {
                        browser.View.Activate();
                        browser.View.BringToFront();
                    }
                }
            };
        }