public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            Window.Title = Constants.Name + " - " + Messages.WindowsProviderEditManifestTitle;

            LblTitle.Title          = Provider.DefinitionTitle;
            LblSubtitle.StringValue = Provider.DefinitionSubTitle;

            GuiUtils.SetCheck(ChkEnabled, Provider.Enabled);

            LblTitle.Activated += (object sender, EventArgs e) =>
            {
                Core.Platform.Instance.OpenUrl(Provider.DefinitionHref);
            };

            CmdOk.Activated += (object sender, EventArgs e) =>
            {
                Provider.Enabled = GuiUtils.GetCheck(ChkEnabled);

                Window.Close();
                NSApplication.SharedApplication.StopModal();
            };

            CmdCancel.Activated += (object sender, EventArgs e) =>
            {
                Provider = null;

                Window.Close();
                NSApplication.SharedApplication.StopModal();
            };
        }
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            Window.Title = Constants.Name + " - " + Messages.WindowsSettingsEventTitle;

            TxtFilename.StringValue  = Item.Filename;
            TxtArguments.StringValue = Item.Arguments;
            GuiUtils.SetCheck(ChkWaitEnd, Item.WaitEnd);

            CmdSave.Activated += (object sender, EventArgs e) =>
            {
                Accepted = true;

                Item.Filename  = TxtFilename.StringValue;
                Item.Arguments = TxtArguments.StringValue;
                Item.WaitEnd   = GuiUtils.GetCheck(ChkWaitEnd);

                Window.Close();
                NSApplication.SharedApplication.StopModal();
            };

            CmdCancel.Activated += (object sender, EventArgs e) =>
            {
                Accepted = false;

                Window.Close();
                NSApplication.SharedApplication.StopModal();
            };

            CmdBrowse.Activated += (object sender, EventArgs e) =>
            {
                GuiUtils.SelectFile(this.Window, TxtFilename);
            };
        }
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            Window.Title = Constants.Name + " - " + Messages.WindowsProviderNoBootstrapTitle;

            GuiUtils.SetCheck(ChkDontShowAgain, false);
            LblBody.StringValue       = Common.MessagesFormatter.Format(Messages.WindowsProviderNoBootstrapBody, Provider.Title);
            TxtManualUrls.StringValue = Engine.Instance.Storage.Get("bootstrap.urls");

            CmdOk.Activated += (object sender, EventArgs e) =>
            {
                Engine.Instance.Storage.SetBool("ui.skip.provider.manifest.failed", GuiUtils.GetCheck(ChkDontShowAgain));
                Engine.Instance.Storage.Set("bootstrap.urls", TxtManualUrls.StringValue);
                Engine.Instance.RefreshProvidersInvalidateConnections();

                Window.Close();
                NSApplication.SharedApplication.StopModal();
                Singleton = null;
            };

            CmdCancel.Activated += (object sender, EventArgs e) =>
            {
                Engine.Instance.Storage.SetBool("ui.skip.provider.manifest.failed", GuiUtils.GetCheck(ChkDontShowAgain));

                Window.Close();
                NSApplication.SharedApplication.StopModal();
                Singleton = null;
            };
        }
Ejemplo n.º 4
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            Window.Title = Constants.Name + " - " + LanguageManager.GetText("WindowsProviderEditOpenVPNTitle");

            GuiUtils.SetButtonCancel(Window, CmdCancel);
            GuiUtils.SetButtonDefault(Window, CmdOk);

            LblTitle.Title          = Provider.DefinitionTitle;
            LblSubtitle.StringValue = Provider.DefinitionSubTitle;

            GuiUtils.SetCheck(ChkEnabled, Provider.Enabled);
            TxtTitle.StringValue = Provider.Title;
            TxtPath.StringValue  = Provider.Path;

            ChkSupportIPv6.Title = LanguageManager.GetText("WindowsProviderEditOpenVPNSupportIPv6");
            GuiUtils.SetCheck(ChkSupportIPv6, Provider.SupportIPv6);

            TxtAuthPassUsername.StringValue = Provider.AuthPassUsername;
            TxtAuthPassPassword.StringValue = Provider.AuthPassPassword;

            LblTitle.Activated += (object sender, EventArgs e) =>
            {
                Core.Platform.Instance.OpenUrl(Provider.DefinitionHref);
            };

            CmdPathBrowse.Activated += (object sender, EventArgs e) =>
            {
                GuiUtils.SelectPath(this.Window, TxtPath);
            };

            CmdOk.Activated += (object sender, EventArgs e) =>
            {
                Provider.Enabled     = GuiUtils.GetCheck(ChkEnabled);
                Provider.Title       = TxtTitle.StringValue;
                Provider.Path        = TxtPath.StringValue;
                Provider.SupportIPv6 = GuiUtils.GetCheck(ChkSupportIPv6);

                Provider.AuthPassUsername = TxtAuthPassUsername.StringValue;
                Provider.AuthPassPassword = TxtAuthPassPassword.StringValue;

                Window.Close();
                NSApplication.SharedApplication.StopModal();
            };

            CmdCancel.Activated += (object sender, EventArgs e) =>
            {
                Provider = null;

                Window.Close();
                NSApplication.SharedApplication.StopModal();
            };
        }
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            Window.Title = Constants.Name + " - " + Messages.WindowsProviderEditOpenVPNTitle;

            LblTitle.Title          = Provider.DefinitionTitle;
            LblSubtitle.StringValue = Provider.DefinitionSubTitle;

            GuiUtils.SetCheck(ChkEnabled, Provider.Enabled);
            TxtTitle.StringValue = Provider.Title;
            TxtPath.StringValue  = Provider.Path;

            TxtAuthPassUsername.StringValue = Provider.AuthPassUsername;
            TxtAuthPassPassword.StringValue = Provider.AuthPassPassword;

            LblTitle.Activated += (object sender, EventArgs e) =>
            {
                Core.Platform.Instance.OpenUrl(Provider.DefinitionHref);
            };

            CmdPathBrowse.Activated += (object sender, EventArgs e) =>
            {
                GuiUtils.SelectFile(this.Window, TxtPath);
            };

            CmdOk.Activated += (object sender, EventArgs e) =>
            {
                Provider.Enabled = GuiUtils.GetCheck(ChkEnabled);
                Provider.Title   = TxtTitle.StringValue;
                Provider.Path    = TxtPath.StringValue;

                Provider.AuthPassUsername = TxtAuthPassUsername.StringValue;
                Provider.AuthPassPassword = TxtAuthPassPassword.StringValue;

                Window.Close();
                NSApplication.SharedApplication.StopModal();
            };

            CmdCancel.Activated += (object sender, EventArgs e) =>
            {
                Provider = null;

                Window.Close();
                NSApplication.SharedApplication.StopModal();
            };
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
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();
        }
Ejemplo n.º 8
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            Window.Title = Constants.Name + " - " + Messages.WindowsSettingsTitle;

            TableTabsController = new TableTabsController(TableTabs, TabMain);

            ChkNetLock.Activated += (object sender, EventArgs e) =>
            {
                if (GuiUtils.GetCheck(ChkNetLock))
                {
                    if ((Engine.Instance as UI.Cocoa.Osx.Engine).MainWindow.NetworkLockKnowledge() == false)
                    {
                        GuiUtils.SetCheck(ChkNetLock, false);
                    }
                }
            };

            TableRoutes.Delegate = new TableRoutingDelegate(this);

            LblDnsServers.StringValue = Messages.WindowsSettingsDnsServers;
            TableDnsServers.Delegate  = new TableDnsServersDelegate(this);

            TableAdvancedEvents.Delegate = new TableAdvancedEventsDelegate(this);

            LblLoggingHelp.StringValue = Messages.WindowsSettingsLoggingHelp;

            TableRoutingController        = new TableRoutingController(this.TableRoutes);
            TableDnsServersController     = new TableDnsServersController(this.TableDnsServers);
            TableAdvancedEventsController = new TableAdvancedEventsController(this.TableAdvancedEvents);

            CmdSave.Activated += (object sender, EventArgs e) =>
            {
                try
                {
                    if (Check())
                    {
                        SaveOptions();
                        Close();
                    }
                }
                catch (Exception ex)
                {
                    Core.Engine.Instance.Logs.Log(LogType.Fatal, ex);
                }
            };

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

            // General

            CmdGeneralTos.Activated += (object sender, EventArgs e) =>
            {
                WindowTosController tos = new WindowTosController();
                tos.Window.ReleasedWhenClosed = true;
                NSApplication.SharedApplication.RunModalForWindow(tos.Window);
                tos.Window.Close();
            };

            CmdResetToDefault.Activated += (object sender, EventArgs e) =>
            {
                if (Engine.Instance.OnAskYesNo(Messages.ResetSettingsConfirm))
                {
                    Engine.Instance.Storage.ResetAll(false);
                    ReadOptions();
                    GuiUtils.MessageBoxInfo(Messages.ResetSettingsDone);
                }
            };

            // UI

            CboUiUnit.RemoveAllItems();
            CboUiUnit.AddItem(Messages.WindowsSettingsUiUnit0);
            CboUiUnit.AddItem(Messages.WindowsSettingsUiUnit1);
            CboUiUnit.AddItem(Messages.WindowsSettingsUiUnit2);

            // Protocols

            CmdProtocolsHelp1.Activated += (object sender, EventArgs e) =>
            {
                Engine.Instance.Command("ui.show.docs.protocols");
            };

            CmdProtocolsHelp2.Activated += (object sender, EventArgs e) =>
            {
                Engine.Instance.Command("ui.show.docs.udp_vs_tcp");
            };

            ChkProtocolsAutomatic.Activated += (object sender, EventArgs e) =>
            {
                EnableIde();
            };

            TableProtocols.Delegate  = new TableProtocolsDelegate(this);
            TableProtocolsController = new TableProtocolsController(this.TableProtocols);

            // Proxy
            CboProxyType.RemoveAllItems();
            CboProxyType.AddItem("None");
            CboProxyType.AddItem("Http");
            CboProxyType.AddItem("Socks");
            CboProxyType.AddItem("Tor");
            CboProxyWhen.RemoveAllItems();
            CboProxyWhen.AddItem(Messages.WindowsSettingsProxyWhenAlways);
            CboProxyWhen.AddItem(Messages.WindowsSettingsProxyWhenWeb);
            CboProxyWhen.AddItem(Messages.WindowsSettingsProxyWhenOpenVPN);
            CboProxyWhen.AddItem(Messages.WindowsSettingsProxyWhenNone);

            CmdProxyTorHelp.Activated += (object sender, EventArgs e) =>
            {
                Engine.Instance.Command("ui.show.docs.tor");
            };
            CboProxyType.Activated += (object sender, EventArgs e) =>
            {
                EnableIde();

                if (GuiUtils.GetSelected(CboProxyType) == "Tor")
                {
                    TxtProxyPort.StringValue = "9150";
                }
                else
                {
                    TxtProxyPort.StringValue = "8080";
                }
            };
            CboProxyAuthentication.Activated += (object sender, EventArgs e) =>
            {
                EnableIde();
            };
            CmdProxyTorTest.Activated += (object sender, EventArgs e) =>
            {
                string result = TorControl.Test(TxtProxyHost.StringValue, Conversions.ToInt32(TxtProxyTorControlPort.StringValue), TxtProxyTorControlPassword.StringValue);
                GuiUtils.MessageBoxInfo(result);
            };

            // Routes
            CboRoutesOtherwise.RemoveAllItems();
            CboRoutesOtherwise.AddItem(RouteDirectionToDescription("in"));
            CboRoutesOtherwise.AddItem(RouteDirectionToDescription("out"));
            CboRoutesOtherwise.Activated += (object sender, EventArgs e) =>
            {
                EnableIde();
            };

            TableRoutes.DoubleClick += (object sender, EventArgs e) =>
            {
                RouteEdit();
            };

            CmdRouteAdd.Activated += (object sender, EventArgs e) =>
            {
                RouteAdd();
            };

            CmdRouteRemove.Activated += (object sender, EventArgs e) =>
            {
                RouteRemove();
            };

            CmdRouteEdit.Activated += (object sender, EventArgs e) =>
            {
                RouteEdit();
            };

            // Advanced - General

            CmdAdvancedHelp.Activated += (object sender, EventArgs e) =>
            {
                Engine.Instance.Command("ui.show.docs.advanced");
            };

            CboIpV6.RemoveAllItems();
            CboIpV6.AddItem("None");
            CboIpV6.AddItem("Disable");

            CboAdvancedManifestRefresh.RemoveAllItems();
            CboAdvancedManifestRefresh.AddItem("Automatic");
            CboAdvancedManifestRefresh.AddItem("Never");
            CboAdvancedManifestRefresh.AddItem("Every minute");
            CboAdvancedManifestRefresh.AddItem("Every ten minute");
            CboAdvancedManifestRefresh.AddItem("Every one hour");

            LblOpenVpnRcvBuf.StringValue = Messages.WindowsSettingsOpenVpnRcvBuf + ":";
            LblOpenVpnSndBuf.StringValue = Messages.WindowsSettingsOpenVpnSndBuf + ":";
            CboOpenVpnRcvBuf.RemoveAllItems();
            CboOpenVpnRcvBuf.AddItem(Messages.Automatic);
            CboOpenVpnRcvBuf.AddItem(Messages.WindowsSettingsOpenVpnDefault);
            CboOpenVpnRcvBuf.AddItem("8 KB");
            CboOpenVpnRcvBuf.AddItem("16 KB");
            CboOpenVpnRcvBuf.AddItem("32 KB");
            CboOpenVpnRcvBuf.AddItem("64 KB");
            CboOpenVpnRcvBuf.AddItem("128 KB");
            CboOpenVpnRcvBuf.AddItem("256 KB");
            CboOpenVpnRcvBuf.AddItem("512 KB");
            CboOpenVpnSndBuf.RemoveAllItems();
            CboOpenVpnSndBuf.AddItem(Messages.Automatic);
            CboOpenVpnSndBuf.AddItem(Messages.WindowsSettingsOpenVpnDefault);
            CboOpenVpnSndBuf.AddItem("8 KB");
            CboOpenVpnSndBuf.AddItem("16 KB");
            CboOpenVpnSndBuf.AddItem("32 KB");
            CboOpenVpnSndBuf.AddItem("64 KB");
            CboOpenVpnSndBuf.AddItem("128 KB");
            CboOpenVpnSndBuf.AddItem("256 KB");
            CboOpenVpnSndBuf.AddItem("512 KB");

            CmdAdvancedOpenVpnPath.Activated += (object sender, EventArgs e) =>
            {
                GuiUtils.SelectFile(this.Window, TxtAdvancedOpenVpnPath);
            };


            // Advanced - DNS
            TableDnsServers.DoubleClick += (object sender, EventArgs e) =>
            {
                DnsServersEdit();
            };

            CmdDnsAdd.Activated += (object sender, EventArgs e) =>
            {
                DnsServersAdd();
            };

            CmdDnsRemove.Activated += (object sender, EventArgs e) =>
            {
                DnsServersRemove();
            };

            CmdDnsEdit.Activated += (object sender, EventArgs e) =>
            {
                DnsServersEdit();
            };

            // Advanced - Net Lock
            CmdLockHelp.Activated += (object sender, EventArgs e) =>
            {
                Engine.Instance.Command("ui.show.docs.lock");
            };
            CboLockMode.RemoveAllItems();
            CboLockMode.AddItem("None");
            CboLockMode.AddItem("Automatic");
            foreach (NetworkLockPlugin lockPlugin in Engine.Instance.NetworkLockManager.Modes)
            {
                CboLockMode.AddItem(lockPlugin.GetName());
            }

            LblRoutesNetworkLockWarning.StringValue = Messages.WindowsSettingsRouteLockHelp;
            LblLockRoutingOutWarning.StringValue    = Messages.NetworkLockNotAvailableWithRouteOut;

            // Advanced - Logging

            TxtLoggingPath.Changed += (object sender, EventArgs e) =>
            {
                RefreshLogPreview();
            };

            CmdLoggingOpen.Activated += (object sender, EventArgs e) =>
            {
                List <string> paths = Engine.Instance.Logs.ParseLogFilePath(TxtLoggingPath.StringValue);
                foreach (string path in paths)
                {
                    if (Core.Platform.Instance.OpenDirectoryInFileManager(path) == false)
                    {
                        GuiUtils.MessageBoxError(MessagesFormatter.Format(Messages.WindowsSettingsLogsCannotOpenDirectory, path));
                    }
                }
            };

            // Directives
            CboOpenVpnDirectivesSkipDefault.RemoveAllItems();
            CboOpenVpnDirectivesSkipDefault.AddItem(Messages.WindowsSettingsOpenVpnDirectivesDefaultSkip1);
            CboOpenVpnDirectivesSkipDefault.AddItem(Messages.WindowsSettingsOpenVpnDirectivesDefaultSkip2);
            CmdOpenVpnDirectivesHelp.Activated += (object sender, EventArgs e) =>
            {
                Engine.Instance.Command("ui.show.docs.directives");
            };
            CmdOpenVpnDirectivesCustomPathBrowse.Activated += (object sender, EventArgs e) =>
            {
                GuiUtils.SelectFile(this.Window, TxtOpenVpnDirectivesCustomPath);
            };

            // Advanced - Events

            TableAdvancedEvents.DoubleClick += (object sender, EventArgs e) =>
            {
                AdvancedEventEdit();
            };

            CmdAdvancedEventsEdit.Activated += (object sender, EventArgs e) =>
            {
                AdvancedEventEdit();
            };

            CmdAdvancedEventsClear.Activated += (object sender, EventArgs e) =>
            {
                AdvancedEventClear();
            };

            ReadOptions();

            EnableIde();

            RefreshLogPreview();
        }
Ejemplo n.º 9
0
        void ReadOptions()
        {
            Storage s = Engine.Instance.Storage;

            // General

            GuiUtils.SetCheck(ChkConnect, s.GetBool("connect"));
            GuiUtils.SetCheck(ChkNetLock, s.GetBool("netlock"));

            GuiUtils.SetCheck(ChkGeneralStartLast, s.GetBool("servers.startlast"));
            GuiUtils.SetCheck(ChkGeneralOsxVisible, s.GetBool("gui.osx.visible"));
            // GuiUtils.SetCheck (ChkGeneralOsxDock, s.GetBool ("gui.osx.dock")); // See this FAQ: https://airvpn.org/topic/13331-its-possible-to-hide-the-icon-in-dock-bar-under-os-x/
            GuiUtils.SetCheck(ChkGeneralOsxNotifications, s.GetBool("gui.osx.notifications"));
            GuiUtils.SetCheck(ChkUiSystemBarShowInfo, s.GetBool("gui.osx.sysbar.show_info"));
            GuiUtils.SetCheck(ChkUiSystemBarShowSpeed, s.GetBool("gui.osx.sysbar.show_speed"));
            GuiUtils.SetCheck(ChkUiSystemBarShowServer, s.GetBool("gui.osx.sysbar.show_server"));

            GuiUtils.SetCheck(ChkExitConfirm, s.GetBool("gui.exit_confirm"));

            // UI
            string uiUnit = s.Get("ui.unit");

            if (uiUnit == "bytes")
            {
                GuiUtils.SetSelected(CboUiUnit, Messages.WindowsSettingsUiUnit1);
            }
            else if (uiUnit == "bits")
            {
                GuiUtils.SetSelected(CboUiUnit, Messages.WindowsSettingsUiUnit2);
            }
            else
            {
                GuiUtils.SetSelected(CboUiUnit, Messages.WindowsSettingsUiUnit0);
            }
            GuiUtils.SetCheck(ChkUiIEC, s.GetBool("ui.iec"));

            /*
             * string interfaceMode = GuiUtils.InterfaceColorMode ();
             * if (interfaceMode == "Dark")
             *      GuiUtils.SetSelected (CboGeneralOsxInterfaceStyle,"Dark");
             * else
             *      GuiUtils.SetSelected (CboGeneralOsxInterfaceStyle,"Default");
             */

            // Protocols
            String protocol = s.Get("mode.protocol").ToUpperInvariant();
            int    port     = s.GetInt("mode.port");
            int    entryIP  = s.GetInt("mode.alt");

            if (protocol == "AUTO")
            {
                GuiUtils.SetCheck(ChkProtocolsAutomatic, true);
            }
            else
            {
                bool found = false;

                int iRow = 0;
                foreach (TableProtocolsControllerItem itemProtocol in TableProtocolsController.Items)
                {
                    if ((itemProtocol.Protocol == protocol) &&
                        (itemProtocol.Port == port) &&
                        (itemProtocol.IP == entryIP))
                    {
                        found = true;
                        TableProtocols.SelectRow(iRow, false);
                        TableProtocols.ScrollRowToVisible(iRow);
                        break;
                    }
                    iRow++;
                }

                if (found == false)
                {
                    GuiUtils.SetCheck(ChkProtocolsAutomatic, true);
                }
                else
                {
                    GuiUtils.SetCheck(ChkProtocolsAutomatic, false);
                }
            }

            // Proxy

            GuiUtils.SetSelected(CboProxyType, s.Get("proxy.mode"));
            if (s.Get("proxy.when") == "always")
            {
                GuiUtils.SetSelected(CboProxyWhen, Messages.WindowsSettingsProxyWhenAlways);
            }
            else if (s.Get("proxy.when") == "web")
            {
                GuiUtils.SetSelected(CboProxyWhen, Messages.WindowsSettingsProxyWhenWeb);
            }
            else if (s.Get("proxy.when") == "openvpn")
            {
                GuiUtils.SetSelected(CboProxyWhen, Messages.WindowsSettingsProxyWhenOpenVPN);
            }
            else if (s.Get("proxy.when") == "none")
            {
                GuiUtils.SetSelected(CboProxyWhen, Messages.WindowsSettingsProxyWhenNone);
            }
            else
            {
                GuiUtils.SetSelected(CboProxyWhen, Messages.WindowsSettingsProxyWhenAlways);
            }
            TxtProxyHost.StringValue = s.Get("proxy.host");
            TxtProxyPort.StringValue = s.Get("proxy.port");
            GuiUtils.SetSelected(CboProxyAuthentication, s.Get("proxy.auth"));
            TxtProxyLogin.StringValue              = s.Get("proxy.login");
            TxtProxyPassword.StringValue           = s.Get("proxy.password");
            TxtProxyTorControlPort.StringValue     = s.Get("proxy.tor.control.port");
            TxtProxyTorControlPassword.StringValue = s.Get("proxy.tor.control.password");

            // Routes
            GuiUtils.SetSelected(CboRoutesOtherwise, RouteDirectionToDescription(s.Get("routes.default")));

            string routes = s.Get("routes.custom");

            string[] routes2 = routes.Split(';');
            foreach (string route in routes2)
            {
                string[] routeEntries = route.Split(',');
                if (routeEntries.Length < 2)
                {
                    continue;
                }

                TableRoutingControllerItem item = new TableRoutingControllerItem();
                item.Ip     = routeEntries[0];
                item.Action = routeEntries[1];
                item.Icon   = routeEntries[1];
                if (routeEntries.Length == 3)
                {
                    item.Notes = routeEntries[2];
                }
                TableRoutingController.Items.Add(item);
            }

            TableRoutingController.RefreshUI();

            // Advanced - General

            GuiUtils.SetCheck(ChkAdvancedExpertMode, s.GetBool("advanced.expert"));
            GuiUtils.SetCheck(ChkAdvancedCheckRoute, s.GetBool("advanced.check.route"));
            string ipV6Mode = s.Get("ipv6.mode");

            if (ipV6Mode == "none")
            {
                GuiUtils.SetSelected(CboIpV6, "None");
            }
            else if (ipV6Mode == "disable")
            {
                GuiUtils.SetSelected(CboIpV6, "Disable");
            }
            else
            {
                GuiUtils.SetSelected(CboIpV6, "None");
            }

            GuiUtils.SetCheck(ChkAdvancedPingerEnabled, s.GetBool("pinger.enabled"));
            GuiUtils.SetCheck(ChkRouteRemoveDefaultGateway, s.GetBool("routes.remove_default"));

            TxtAdvancedOpenVpnPath.StringValue = s.Get("tools.openvpn.path");
            GuiUtils.SetCheck(ChkAdvancedSkipAlreadyRun, s.GetBool("advanced.skip_alreadyrun"));
            GuiUtils.SetCheck(ChkAdvancedProviders, s.GetBool("advanced.providers"));

            int manifestRefresh = s.GetInt("advanced.manifest.refresh");

            if (manifestRefresh == 60)
            {
                GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Every one hour");
            }
            else if (manifestRefresh == 10)
            {
                GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Every ten minute");
            }
            else if (manifestRefresh == 1)
            {
                GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Every minute");
            }
            else if (manifestRefresh == 0)
            {
                GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Never");
            }
            else
            {
                GuiUtils.SetSelected(CboAdvancedManifestRefresh, "Automatic");
            }

            int openVpnSndBuf = s.GetInt("openvpn.sndbuf");

            if (openVpnSndBuf == -2)
            {
                GuiUtils.SetSelected(CboOpenVpnSndBuf, Messages.Automatic);
            }
            else if (openVpnSndBuf == -1)
            {
                GuiUtils.SetSelected(CboOpenVpnSndBuf, Messages.WindowsSettingsOpenVpnDefault);
            }
            else if (openVpnSndBuf == 1024 * 8)
            {
                GuiUtils.SetSelected(CboOpenVpnSndBuf, "8 KB");
            }
            else if (openVpnSndBuf == 1024 * 16)
            {
                GuiUtils.SetSelected(CboOpenVpnSndBuf, "16 KB");
            }
            else if (openVpnSndBuf == 1024 * 32)
            {
                GuiUtils.SetSelected(CboOpenVpnSndBuf, "32 KB");
            }
            else if (openVpnSndBuf == 1024 * 64)
            {
                GuiUtils.SetSelected(CboOpenVpnSndBuf, "64 KB");
            }
            else if (openVpnSndBuf == 1024 * 128)
            {
                GuiUtils.SetSelected(CboOpenVpnSndBuf, "128 KB");
            }
            else if (openVpnSndBuf == 1024 * 256)
            {
                GuiUtils.SetSelected(CboOpenVpnSndBuf, "256 KB");
            }
            else if (openVpnSndBuf == 1024 * 512)
            {
                GuiUtils.SetSelected(CboOpenVpnSndBuf, "512 KB");
            }

            int openVpnRcvBuf = s.GetInt("openvpn.rcvbuf");

            if (openVpnRcvBuf == -2)
            {
                GuiUtils.SetSelected(CboOpenVpnRcvBuf, Messages.Automatic);
            }
            else if (openVpnRcvBuf == -1)
            {
                GuiUtils.SetSelected(CboOpenVpnRcvBuf, Messages.WindowsSettingsOpenVpnDefault);
            }
            else if (openVpnRcvBuf == 1024 * 8)
            {
                GuiUtils.SetSelected(CboOpenVpnRcvBuf, "8 KB");
            }
            else if (openVpnRcvBuf == 1024 * 16)
            {
                GuiUtils.SetSelected(CboOpenVpnRcvBuf, "16 KB");
            }
            else if (openVpnRcvBuf == 1024 * 32)
            {
                GuiUtils.SetSelected(CboOpenVpnRcvBuf, "32 KB");
            }
            else if (openVpnRcvBuf == 1024 * 64)
            {
                GuiUtils.SetSelected(CboOpenVpnRcvBuf, "64 KB");
            }
            else if (openVpnRcvBuf == 1024 * 128)
            {
                GuiUtils.SetSelected(CboOpenVpnRcvBuf, "128 KB");
            }
            else if (openVpnRcvBuf == 1024 * 256)
            {
                GuiUtils.SetSelected(CboOpenVpnRcvBuf, "256 KB");
            }
            else if (openVpnRcvBuf == 1024 * 512)
            {
                GuiUtils.SetSelected(CboOpenVpnRcvBuf, "512 KB");
            }

            // Advanced - DNS

            string dnsMode = s.Get("dns.mode");

            if (dnsMode == "none")
            {
                GuiUtils.SetSelected(CboDnsSwitchMode, "Disabled");
            }
            else
            {
                GuiUtils.SetSelected(CboDnsSwitchMode, "Automatic");
            }

            GuiUtils.SetCheck(ChkDnsCheck, s.GetBool("dns.check"));

            TableDnsServersController.Clear();
            string[] dnsServers = s.Get("dns.servers").Split(',');
            foreach (string dnsServer in dnsServers)
            {
                if (IpAddress.IsIP(dnsServer))
                {
                    TableDnsServersController.Add(dnsServer);
                }
            }

            // Advanced - Lock
            string lockMode = s.Get("netlock.mode");

            GuiUtils.SetSelected(CboLockMode, "None");
            if (lockMode == "auto")
            {
                GuiUtils.SetSelected(CboLockMode, "Automatic");
            }
            else
            {
                foreach (NetworkLockPlugin lockPlugin in Engine.Instance.NetworkLockManager.Modes)
                {
                    if (lockPlugin.GetCode() == lockMode)
                    {
                        GuiUtils.SetSelected(CboLockMode, lockPlugin.GetName());
                    }
                }
            }
            GuiUtils.SetCheck(ChkLockAllowPrivate, s.GetBool("netlock.allow_private"));
            GuiUtils.SetCheck(ChkLockAllowPing, s.GetBool("netlock.allow_ping"));
            GuiUtils.SetCheck(ChkLockAllowDNS, s.GetBool("netlock.allow_dns"));
            TxtLockAllowedIPS.StringValue = s.Get("netlock.allowed_ips");

            // Advanced - Logging
            GuiUtils.SetCheck(ChkLoggingEnabled, s.GetBool("log.file.enabled"));
            GuiUtils.SetCheck(ChkLogLevelDebug, s.GetBool("log.level.debug"));
            TxtLoggingPath.StringValue = s.Get("log.file.path");

            // Advanced - OVPN Directives
            GuiUtils.SetSelected(CboOpenVpnDirectivesSkipDefault, (s.GetBool("openvpn.skip_defaults") ? Messages.WindowsSettingsOpenVpnDirectivesDefaultSkip2 : Messages.WindowsSettingsOpenVpnDirectivesDefaultSkip1));
            TxtAdvancedOpenVpnDirectivesDefault.StringValue = s.Get("openvpn.directives");
            TxtAdvancedOpenVpnDirectivesCustom.StringValue  = s.Get("openvpn.custom");
            TxtOpenVpnDirectivesCustomPath.StringValue      = s.Get("openvpn.directives.path");

            // Advanced - Events
            ReadOptionsEvent("app.start", 0);
            ReadOptionsEvent("app.stop", 1);
            ReadOptionsEvent("session.start", 2);
            ReadOptionsEvent("session.stop", 3);
            ReadOptionsEvent("vpn.pre", 4);
            ReadOptionsEvent("vpn.up", 5);
            ReadOptionsEvent("vpn.down", 6);

            TableAdvancedEventsController.RefreshUI();
        }