コード例 #1
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            Window.Delegate = new MainWindowDelegate(this);

            Window.AcceptsMouseMovedEvents = true;

            TabProviders = TabMain.Items[1];

            CreateMenuBarIcon();

            LblVersion.StringValue = "Version " + Constants.VersionDesc;
            CmdUpdater.Hidden      = true;
            MnuTrayUpdate.Hidden   = true;

            ChkRemember.State       = Engine.Storage.GetBool("remember") ? NSCellStateValue.On : NSCellStateValue.Off;
            ChkServersShowAll.State = NSCellStateValue.Off;
            GuiUtils.SetCheck(ChkServersLockCurrent, Engine.Storage.GetBool("servers.locklast"));
            GuiUtils.SetSelected(CboServersScoringRule, Engine.Storage.Get("servers.scoretype"));

            CboSpeedResolutions.RemoveAllItems();
            CboSpeedResolutions.AddItem(LanguageManager.GetText("WindowsMainSpeedResolution1"));
            CboSpeedResolutions.AddItem(LanguageManager.GetText("WindowsMainSpeedResolution2"));
            CboSpeedResolutions.AddItem(LanguageManager.GetText("WindowsMainSpeedResolution3"));
            CboSpeedResolutions.AddItem(LanguageManager.GetText("WindowsMainSpeedResolution4"));
            CboSpeedResolutions.AddItem(LanguageManager.GetText("WindowsMainSpeedResolution5"));
            CboSpeedResolutions.SelectItem(0);

            CmdConnect.Title       = LanguageManager.GetText("CommandConnect");
            LblConnect.StringValue = LanguageManager.GetText("CommandConnectSubtitle");
            CmdDisconnect.Title    = LanguageManager.GetText("CommandDisconnect");
            CmdCancel.Title        = LanguageManager.GetText("CommandCancel");

            CboServersScoringRule.ToolTip = LanguageManager.GetText("TooltipServersScoreType");
            ChkServersLockCurrent.ToolTip = LanguageManager.GetText("TooltipServersLockCurrent");
            ChkServersShowAll.ToolTip     = LanguageManager.GetText("TooltipServersShowAll");
            CmdServersConnect.ToolTip     = LanguageManager.GetText("TooltipServersConnect");
            CmdServersUndefined.ToolTip   = LanguageManager.GetText("TooltipServersUndefined");
            CmdServersBlackList.ToolTip   = LanguageManager.GetText("TooltipServersBlackList");
            CmdServersWhiteList.ToolTip   = LanguageManager.GetText("TooltipServersWhiteList");
            CmdServersRename.ToolTip      = LanguageManager.GetText("TooltipServersRename");
            CmdServersMore.ToolTip        = LanguageManager.GetText("TooltipServersMore");
            CmdServersRefresh.ToolTip     = LanguageManager.GetText("TooltipServersRefresh");
            CmdAreasUndefined.ToolTip     = LanguageManager.GetText("TooltipAreasUndefined");
            CmdAreasBlackList.ToolTip     = LanguageManager.GetText("TooltipAreasBlackList");
            CmdAreasWhiteList.ToolTip     = LanguageManager.GetText("TooltipAreasWhiteList");
            CmdLogsCommand.ToolTip        = LanguageManager.GetText("TooltipLogsCommand");
            CmdLogsClean.ToolTip          = LanguageManager.GetText("TooltipLogsClean");
            CmdLogsCopy.ToolTip           = LanguageManager.GetText("TooltipLogsCopy");
            CmdLogsSave.ToolTip           = LanguageManager.GetText("TooltipLogsSave");
            CmdLogsSupport.ToolTip        = LanguageManager.GetText("TooltipLogsSupport");

            if (Engine.Storage.GetBool("remember"))
            {
                ChkRemember.State       = NSCellStateValue.On;
                TxtLogin.StringValue    = Engine.Storage.Get("login");
                TxtPassword.StringValue = Engine.Storage.Get("password");
            }

            CmdMainMenu.Activated += (object sender, EventArgs e) =>
            {
                CoreGraphics.CGPoint p = new CoreGraphics.CGPoint(this.Window.Frame.Left + 10, this.Window.Frame.Bottom - 40);
                //CoreGraphics.CGPoint p = new CoreGraphics.CGPoint(CmdMainMenu.Frame.Left + 10, CmdMainMenu.Frame.Top + 10);
                MnuTray.PopUpMenu(MnuTrayStatus, p, null);
            };

            CmdUpdater.Activated += (object sender, EventArgs e) =>
            {
                Core.Platform.Instance.OpenUrl(Constants.WebSite + "/" + Core.Platform.Instance.GetCode().ToLowerInvariant() + "/");
            };

            ChkRemember.Activated += (object sender, EventArgs e) =>
            {
                Engine.Storage.SetBool("remember", ChkRemember.State == NSCellStateValue.On);
            };

            CmdLogin.Activated += (object sender, EventArgs e) =>
            {
                if (Engine.IsLogged() == false)
                {
                    Login();
                }
                else
                {
                    Logout();
                }
            };

            TxtLogin.Activated += (object sender, EventArgs e) =>
            {
                EnabledUI();
            };

            TxtPassword.Activated += (object sender, EventArgs e) =>
            {
                EnabledUI();
            };

            CboKey.Activated += (object sender, EventArgs e) =>
            {
                if (Engine.Instance.Storage.Get("key") != CboKey.SelectedItem.Title)
                {
                    Engine.Instance.Storage.Set("key", CboKey.SelectedItem.Title);
                }
            };

            CmdConnect.Activated += (object sender, EventArgs e) =>
            {
                Connect();
            };

            CmdDisconnect.Activated += (object sender, EventArgs e) =>
            {
                Disconnect();
            };

            CmdCancel.Activated += (object sender, EventArgs e) =>
            {
                Disconnect();
            };

            CmdNetworkLock.Activated += (object sender, EventArgs e) =>
            {
                if (Engine.Instance.NetworkLockManager.IsActive())
                {
                    NetworkLockDeactivation();
                }
                else
                {
                    NetworkLockActivation();
                }
            };

            TableProvidersController     = new TableProvidersController(this.TableProviders);
            this.TableProviders.Delegate = new TableProvidersDelegate(this);

            CmdProviderAdd.Activated += (object sender, EventArgs e) =>
            {
                ProviderAdd();
            };

            CmdProviderRemove.Activated += (object sender, EventArgs e) =>
            {
                ProviderRemove();
            };

            CmdProviderEdit.Activated += (object sender, EventArgs e) =>
            {
                ProviderEdit();
            };

            TableProviders.DoubleClick += (object sender, EventArgs e) =>
            {
                ProviderEdit();
            };

            TableServers.DoubleClick += (object sender, EventArgs e) =>
            {
                ConnectManual();
            };

            CmdServersConnect.Activated += (object sender, EventArgs e) =>
            {
                ConnectManual();
            };

            CmdServersWhiteList.Activated += (object sender, EventArgs e) =>
            {
                ServersWhiteList();
            };

            CmdServersBlackList.Activated += (object sender, EventArgs e) =>
            {
                ServersBlackList();
            };

            CmdServersUndefined.Activated += (object sender, EventArgs e) =>
            {
                ServersUndefinedList();
            };

            CmdServersRename.Activated += (object sender, EventArgs e) =>
            {
                ServersRename();
            };

            CmdServersMore.Activated += (object sender, EventArgs e) =>
            {
                ServersMore();
            };

            CmdServersRefresh.Activated += (object sender, EventArgs e) =>
            {
                ServersRefresh();
            };

            MnuServersConnect.Activated += (object sender, EventArgs e) =>
            {
                ConnectManual();
            };

            MnuServersWhitelist.Activated += (object sender, EventArgs e) =>
            {
                ServersWhiteList();
            };

            MnuServersBlacklist.Activated += (object sender, EventArgs e) =>
            {
                ServersBlackList();
            };

            MnuServersUndefined.Activated += (object sender, EventArgs e) =>
            {
                ServersUndefinedList();
            };

            MnuServersRename.Activated += (object sender, EventArgs e) =>
            {
                ServersRename();
            };

            MnuServersMore.Activated += (object sender, EventArgs e) =>
            {
                ServersMore();
            };

            MnuServersRefresh.Activated += (object sender, EventArgs e) =>
            {
                ServersRefresh();
            };

            CmdAreasWhiteList.Activated += (object sender, EventArgs e) =>
            {
                AreasWhiteList();
            };

            CmdAreasBlackList.Activated += (object sender, EventArgs e) =>
            {
                AreasBlackList();
            };

            CmdAreasUndefined.Activated += (object sender, EventArgs e) =>
            {
                AreasUndefinedList();
            };

            MnuAreasWhitelist.Activated += (object sender, EventArgs e) =>
            {
                AreasWhiteList();
            };

            MnuAreasBlacklist.Activated += (object sender, EventArgs e) =>
            {
                AreasBlackList();
            };

            MnuAreasUndefined.Activated += (object sender, EventArgs e) =>
            {
                AreasUndefinedList();
            };

            ChkServersShowAll.Activated += (object sender, EventArgs e) =>
            {
                TableServersController.ShowAll = (ChkServersShowAll.State == NSCellStateValue.On);
                TableServersController.RefreshUI();
            };

            /*
             * Xamarin Bug: https://bugzilla.xamarin.com/show_bug.cgi?id=12467
             * Resolved with delegate
             *
             * TableServers.SelectionDidChange += (object sender, EventArgs e) => {
             *      EnabledUI();
             * };
             *
             * TableAreas.SelectionDidChange += (object sender, EventArgs e) => {
             *      EnabledUI();
             * };
             */

            ChkServersLockCurrent.Activated += (object sender, EventArgs e) =>
            {
                Engine.Storage.SetBool("servers.locklast", ChkServersLockCurrent.State == NSCellStateValue.On);
            };

            CboServersScoringRule.Activated += (object sender, EventArgs e) =>
            {
                Engine.Storage.Set("servers.scoretype", GuiUtils.GetSelected(CboServersScoringRule));

                RefreshUi(Engine.RefreshUiMode.Full);
            };

            CboSpeedResolutions.Activated += (object sender, EventArgs e) =>
            {
                (PnlChart as ChartView).Switch((int)CboSpeedResolutions.IndexOfItem(CboSpeedResolutions.SelectedItem));
            };


            CmdLogsClean.Activated += (object sender, EventArgs e) =>
            {
                TableLogsController.Clear();
            };

            CmdLogsSave.Activated += (object sender, EventArgs e) =>
            {
                LogsDoSave(false);
            };

            CmdLogsCopy.Activated += (object sender, EventArgs e) =>
            {
                LogsDoCopy(false);
            };

            CmdLogsSupport.Activated += (object sender, EventArgs e) =>
            {
                SupportReport();
            };

            MnuLogsCopyAll.Activated += (object sender, EventArgs e) =>
            {
                LogsDoCopy(false);
            };

            MnuLogsSaveAll.Activated += (object sender, EventArgs e) =>
            {
                LogsDoSave(false);
            };
            MnuLogsCopySelected.Activated += (object sender, EventArgs e) =>
            {
                LogsDoCopy(true);
            };
            MnuLogsSaveSelected.Activated += (object sender, EventArgs e) =>
            {
                LogsDoSave(true);
            };

            CmdLogsCommand.Activated += (object sender, EventArgs e) =>
            {
                WindowCommandController w = new WindowCommandController();
                NSApplication.SharedApplication.RunModalForWindow(w.Window);
                if (w.Command != "")
                {
                    UiClient.Instance.Command(w.Command);
                }
            };

            TableServersController     = new TableServersController(this.TableServers);
            this.TableServers.Delegate = new TableServersDelegate(this);

            TableAreasController     = new TableAreasController(this.TableAreas);
            this.TableAreas.Delegate = new TableAreasDelegate(this);

            TableLogsController  = new TableLogsController(this.TableLogs);
            TableStatsController = new TableStatsController(this.TableStats);

            TableStats.DoubleClick += (object sender, EventArgs e) =>
            {
                TableStatsController.DoubleClickItem();
            };

            // Topbar Menu

            MnuTrayStatus.Activated += (object sender, EventArgs e) =>
            {
                Restore(sender);
            };

            MnuTrayConnect.Activated += (object sender, EventArgs e) =>
            {
                if (m_mainActionCommand == "")
                {
                    Restore(sender);
                }
                else
                {
                    UiClient.Instance.Command(m_mainActionCommand);
                }
            };

            MnuTrayAbout.Activated += (object sender, EventArgs e) =>
            {
                ShowAbout();
            };

            MnuTrayPreferences.Activated += (object sender, EventArgs e) =>
            {
                ShowPreferences();
            };

            MnuTrayHome.Activated += (object sender, EventArgs e) =>
            {
                ShowHome();
            };

            MnuTrayClientArea.Activated += (object sender, EventArgs e) =>
            {
                ShowClientArea();
            };

            MnuTrayForwardingPorts.Activated += (object sender, EventArgs e) =>
            {
                ShowForwardingPorts();
            };

            MnuTrayRestore.Activated += (object sender, EventArgs e) =>
            {
                /* // 2.8
                 * if(Window.IsVisible)
                 *      Minimize();
                 * else
                 */
                if (Window.IsVisible)
                {
                    Minimize();
                }
                else
                {
                    Restore(sender);
                }
            };

            MnuTrayQuit.Activated += (object sender, EventArgs e) =>
            {
                Shutdown();
            };

            CboServersScoringRule.ToolTip = LanguageManager.GetText("TooltipServersScoreType");
            CmdAreasBlackList.ToolTip     = LanguageManager.GetText("TooltipAreasBlackList");

            Engine.OnRefreshUi();

            SettingsChanged();

            RequestAttention();
        }
コード例 #2
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            Window.Delegate = new MainWindowDelegate(this);

            Window.AcceptsMouseMovedEvents = true;

            TabProviders = TabMain.Items[1];

            CreateMenuBarIcon();

            ChkRemember.State       = Engine.Storage.GetBool("remember") ? NSCellStateValue.On : NSCellStateValue.Off;
            ChkServersShowAll.State = NSCellStateValue.Off;
            GuiUtils.SetCheck(ChkServersLockCurrent, Engine.Storage.GetBool("servers.locklast"));
            GuiUtils.SetSelected(CboServersScoringRule, Engine.Storage.Get("servers.scoretype"));

            CboSpeedResolutions.RemoveAllItems();
            CboSpeedResolutions.AddItem(Messages.WindowsMainSpeedResolution1);
            CboSpeedResolutions.AddItem(Messages.WindowsMainSpeedResolution2);
            CboSpeedResolutions.AddItem(Messages.WindowsMainSpeedResolution3);
            CboSpeedResolutions.AddItem(Messages.WindowsMainSpeedResolution4);
            CboSpeedResolutions.AddItem(Messages.WindowsMainSpeedResolution5);
            CboSpeedResolutions.SelectItem(0);

            CmdConnect.Title       = Messages.CommandConnect;
            LblConnect.StringValue = Messages.CommandConnectSubtitle;
            CmdDisconnect.Title    = Messages.CommandDisconnect;
            CmdCancel.Title        = Messages.CommandCancel;

            CboServersScoringRule.ToolTip    = Messages.TooltipServersScoreType;
            ChkServersLockCurrent.ToolTip    = Messages.TooltipServersLockCurrent;
            ChkServersShowAll.ToolTip        = Messages.TooltipServersShowAll;
            CmdServersConnect.ToolTip        = Messages.TooltipServersConnect;
            CmdServersUndefined.ToolTip      = Messages.TooltipServersUndefined;
            CmdServersBlackList.ToolTip      = Messages.TooltipServersBlackList;
            CmdServersWhiteList.ToolTip      = Messages.TooltipServersWhiteList;
            CmdServersRename.ToolTip         = Messages.TooltipServersRename;
            CmdServersMore.ToolTip           = Messages.TooltipServersMore;
            CmdServersRefresh.ToolTip        = Messages.TooltipServersRefresh;
            CmdAreasUndefined.ToolTip        = Messages.TooltipAreasUndefined;
            CmdAreasBlackList.ToolTip        = Messages.TooltipAreasBlackList;
            CmdAreasWhiteList.ToolTip        = Messages.TooltipAreasWhiteList;
            CmdLogsOpenVpnManagement.ToolTip = Messages.TooltipLogsOpenVpnManagement;
            CmdLogsClean.ToolTip             = Messages.TooltipLogsClean;
            CmdLogsCopy.ToolTip    = Messages.TooltipLogsCopy;
            CmdLogsSave.ToolTip    = Messages.TooltipLogsSave;
            CmdLogsSupport.ToolTip = Messages.TooltipLogsSupport;

            if (Engine.Storage.GetBool("remember"))
            {
                ChkRemember.State       = NSCellStateValue.On;
                TxtLogin.StringValue    = Engine.Storage.Get("login");
                TxtPassword.StringValue = Engine.Storage.Get("password");
            }



            ChkRemember.Activated += (object sender, EventArgs e) =>
            {
                Engine.Storage.SetBool("remember", ChkRemember.State == NSCellStateValue.On);
            };

            CmdLogin.Activated += (object sender, EventArgs e) =>
            {
                if (Engine.IsLogged() == false)
                {
                    Login();
                }
                else
                {
                    Logout();
                }
            };

            TxtLogin.Activated += (object sender, EventArgs e) =>
            {
                EnabledUI();
            };

            TxtPassword.Activated += (object sender, EventArgs e) =>
            {
                EnabledUI();
            };

            CboKey.Activated += (object sender, EventArgs e) =>
            {
                Engine.Instance.Storage.Set("key", CboKey.SelectedItem.Title);
            };

            CmdConnect.Activated += (object sender, EventArgs e) =>
            {
                Connect();
            };

            CmdDisconnect.Activated += (object sender, EventArgs e) =>
            {
                Disconnect();
            };

            CmdCancel.Activated += (object sender, EventArgs e) =>
            {
                Disconnect();
            };

            CmdNetworkLock.Activated += (object sender, EventArgs e) =>
            {
                if (Engine.Instance.NetworkLockManager.IsActive())
                {
                    NetworkLockDeactivation();
                }
                else
                {
                    NetworkLockActivation();
                }
            };

            TableProvidersController     = new TableProvidersController(this.TableProviders);
            this.TableProviders.Delegate = new TableProvidersDelegate(this);

            CmdProviderAdd.Activated += (object sender, EventArgs e) =>
            {
                ProviderAdd();
            };

            CmdProviderRemove.Activated += (object sender, EventArgs e) =>
            {
                ProviderRemove();
            };

            CmdProviderEdit.Activated += (object sender, EventArgs e) =>
            {
                ProviderEdit();
            };

            TableProviders.DoubleClick += (object sender, EventArgs e) =>
            {
                ProviderEdit();
            };

            TableServers.DoubleClick += (object sender, EventArgs e) =>
            {
                ConnectManual();
            };

            CmdServersConnect.Activated += (object sender, EventArgs e) =>
            {
                ConnectManual();
            };

            CmdServersWhiteList.Activated += (object sender, EventArgs e) =>
            {
                ServersWhiteList();
            };

            CmdServersBlackList.Activated += (object sender, EventArgs e) =>
            {
                ServersBlackList();
            };

            CmdServersUndefined.Activated += (object sender, EventArgs e) =>
            {
                ServersUndefinedList();
            };

            CmdServersRename.Activated += (object sender, EventArgs e) =>
            {
                ServersRename();
            };

            CmdServersMore.Activated += (object sender, EventArgs e) =>
            {
                ServersMore();
            };

            CmdServersRefresh.Activated += (object sender, EventArgs e) =>
            {
                ServersRefresh();
            };

            MnuServersConnect.Activated += (object sender, EventArgs e) =>
            {
                ConnectManual();
            };

            MnuServersWhitelist.Activated += (object sender, EventArgs e) =>
            {
                ServersWhiteList();
            };

            MnuServersBlacklist.Activated += (object sender, EventArgs e) =>
            {
                ServersBlackList();
            };

            MnuServersUndefined.Activated += (object sender, EventArgs e) =>
            {
                ServersUndefinedList();
            };

            MnuServersRename.Activated += (object sender, EventArgs e) =>
            {
                ServersRename();
            };

            MnuServersMore.Activated += (object sender, EventArgs e) =>
            {
                ServersMore();
            };

            MnuServersRefresh.Activated += (object sender, EventArgs e) =>
            {
                ServersRefresh();
            };

            CmdAreasWhiteList.Activated += (object sender, EventArgs e) =>
            {
                AreasWhiteList();
            };

            CmdAreasBlackList.Activated += (object sender, EventArgs e) =>
            {
                AreasBlackList();
            };

            CmdAreasUndefined.Activated += (object sender, EventArgs e) =>
            {
                AreasUndefinedList();
            };

            MnuAreasWhitelist.Activated += (object sender, EventArgs e) =>
            {
                AreasWhiteList();
            };

            MnuAreasBlacklist.Activated += (object sender, EventArgs e) =>
            {
                AreasBlackList();
            };

            MnuAreasUndefined.Activated += (object sender, EventArgs e) =>
            {
                AreasUndefinedList();
            };

            ChkServersShowAll.Activated += (object sender, EventArgs e) =>
            {
                TableServersController.ShowAll = (ChkServersShowAll.State == NSCellStateValue.On);
                TableServersController.RefreshUI();
            };

            /*
             * Xamarin Bug: https://bugzilla.xamarin.com/show_bug.cgi?id=12467
             * Resolved with delegate
             *
             * TableServers.SelectionDidChange += (object sender, EventArgs e) => {
             *      EnabledUI();
             * };
             *
             * TableAreas.SelectionDidChange += (object sender, EventArgs e) => {
             *      EnabledUI();
             * };
             */

            ChkServersLockCurrent.Activated += (object sender, EventArgs e) =>
            {
                Engine.Storage.SetBool("servers.locklast", ChkServersLockCurrent.State == NSCellStateValue.On);
            };

            CboServersScoringRule.Activated += (object sender, EventArgs e) =>
            {
                Engine.Storage.Set("servers.scoretype", GuiUtils.GetSelected(CboServersScoringRule));

                RefreshUi(Engine.RefreshUiMode.Full);
            };

            CboSpeedResolutions.Activated += (object sender, EventArgs e) =>
            {
                (PnlChart as ChartView).Switch((int)CboSpeedResolutions.IndexOfItem(CboSpeedResolutions.SelectedItem));
            };


            CmdLogsClean.Activated += (object sender, EventArgs e) =>
            {
                TableLogsController.Clear();
            };

            CmdLogsSave.Activated += (object sender, EventArgs e) =>
            {
                LogsDoSave(false);
            };

            CmdLogsCopy.Activated += (object sender, EventArgs e) =>
            {
                LogsDoCopy(false);
            };

            CmdLogsSupport.Activated += (object sender, EventArgs e) =>
            {
                SupportReport();
            };

            MnuLogsCopyAll.Activated += (object sender, EventArgs e) =>
            {
                LogsDoCopy(false);
            };

            MnuLogsSaveAll.Activated += (object sender, EventArgs e) =>
            {
                LogsDoSave(false);
            };
            MnuLogsCopySelected.Activated += (object sender, EventArgs e) =>
            {
                LogsDoCopy(true);
            };
            MnuLogsSaveSelected.Activated += (object sender, EventArgs e) =>
            {
                LogsDoSave(true);
            };

            CmdLogsOpenVpnManagement.Activated += (object sender, EventArgs e) =>
            {
                if (Engine.IsConnected())
                {
                    WindowOpenVpnManagementCommandController w = new WindowOpenVpnManagementCommandController();
                    NSApplication.SharedApplication.RunModalForWindow(w.Window);
                    if (w.Command != "")
                    {
                        Core.UI.Actions.SendOpenVpnManagementCommand(w.Command);
                    }
                }
            };

            TableServersController     = new TableServersController(this.TableServers);
            this.TableServers.Delegate = new TableServersDelegate(this);

            TableAreasController     = new TableAreasController(this.TableAreas);
            this.TableAreas.Delegate = new TableAreasDelegate(this);

            TableLogsController  = new TableLogsController(this.TableLogs);
            TableStatsController = new TableStatsController(this.TableStats);

            TableStats.DoubleClick += (object sender, EventArgs e) =>
            {
                TableStatsController.DoubleClickItem();
            };

            // Topbar Menu

            MnuTrayStatus.Activated += (object sender, EventArgs e) =>
            {
                Restore(sender);
            };

            MnuTrayConnect.Activated += (object sender, EventArgs e) =>
            {
                if (Engine.IsWaiting())
                {
                    Disconnect();
                }
                else if (Engine.IsConnected())
                {
                    Disconnect();
                }
                else if (Engine.CanConnect())
                {
                    Connect();
                }
                else
                {
                    Restore(sender);
                }
            };

            MnuTrayAbout.Activated += (object sender, EventArgs e) =>
            {
                ShowAbout();
            };

            MnuTrayPreferences.Activated += (object sender, EventArgs e) =>
            {
                ShowPreferences();
            };

            MnuTrayHome.Activated += (object sender, EventArgs e) =>
            {
                ShowHome();
            };

            MnuTrayClientArea.Activated += (object sender, EventArgs e) =>
            {
                ShowClientArea();
            };

            MnuTrayForwardingPorts.Activated += (object sender, EventArgs e) =>
            {
                ShowForwardingPorts();
            };

            MnuTraySpeedTest.Activated += (object sender, EventArgs e) =>
            {
                ShowSpeedTest();
            };

            MnuTrayRestore.Activated += (object sender, EventArgs e) =>
            {
                /* // 2.8
                 * if(Window.IsVisible)
                 *      Minimize();
                 * else
                 */
                Restore(sender);
            };

            MnuTrayQuit.Activated += (object sender, EventArgs e) =>
            {
                Shutdown();
            };

            CboServersScoringRule.ToolTip = Messages.TooltipServersScoreType;
            CmdAreasBlackList.ToolTip     = Messages.TooltipAreasBlackList;

            Engine.MainWindow = this;
            Engine.UiStart();

            Engine.OnRefreshUi();

            SettingsChanged();

            RequestAttention();
        }