bool Check() { if ((RouteDescriptionToDirection(GuiUtils.GetSelected(CboRoutesOtherwise)) == "out") && (TableRoutingController.Items.Count == 0)) { if (GuiUtils.MessageYesNo(Messages.WindowsSettingsRouteOutEmptyList) == false) { return(false); } } if (GuiUtils.GetCheck(ChkLockAllowDNS) == false) { bool hostNameUsed = false; foreach (TableRoutingControllerItem item in TableRoutingController.Items) { if (IpAddress.IsIP(item.Ip) == false) { hostNameUsed = true; break; } } if (hostNameUsed) { if (Engine.Instance.OnAskYesNo(Messages.WindowsSettingsRouteWithHostname) == false) { return(false); } } } return(true); }
public void EnableIde() { // Protocols TableProtocols.Enabled = (GuiUtils.GetCheck(ChkProtocolsAutomatic) == false); // Proxy bool proxy = (GuiUtils.GetSelected(CboProxyType) != "None"); bool tor = (GuiUtils.GetSelected(CboProxyType) == "Tor"); TxtProxyHost.Enabled = proxy; TxtProxyPort.Enabled = proxy; CboProxyAuthentication.Enabled = (proxy && !tor); TxtProxyLogin.Enabled = ((proxy) && (!tor) && (GuiUtils.GetSelected(CboProxyAuthentication) != "None")); TxtProxyPassword.Enabled = TxtProxyLogin.Enabled; TxtProxyTorControlPort.Enabled = tor; TxtProxyTorControlPassword.Enabled = tor; CmdProxyTorTest.Enabled = tor; // Routing CmdRouteAdd.Enabled = true; CmdRouteRemove.Enabled = (TableRoutes.SelectedRowCount > 0); CmdRouteEdit.Enabled = (TableRoutes.SelectedRowCount == 1); // DNS CmdDnsAdd.Enabled = true; CmdDnsRemove.Enabled = (TableDnsServers.SelectedRowCount > 0); CmdDnsEdit.Enabled = (TableDnsServers.SelectedRowCount == 1); // Lock LblLockRoutingOutWarning.Hidden = (GuiUtils.GetSelected(CboRoutesOtherwise) == RouteDirectionToDescription("in")); // Events CmdAdvancedEventsClear.Enabled = (TableAdvancedEvents.SelectedRowCount == 1); CmdAdvancedEventsEdit.Enabled = (TableAdvancedEvents.SelectedRowCount == 1); }
public override void AwakeFromNib() { base.AwakeFromNib(); Window.Title = Constants.Name + " - " + Messages.WindowsLoginTitle; CboRemember.RemoveAllItems(); CboRemember.AddItem(Messages.WindowsCredentialsRememberNo); CboRemember.AddItem(Messages.WindowsCredentialsRememberRun); CboRemember.AddItem(Messages.WindowsCredentialsRememberPermanent); GuiUtils.SetSelected(CboRemember, Messages.WindowsCredentialsRememberRun); TxtUsername.Changed += (object sender, EventArgs e) => { EnableIde(); }; TxtPassword.Changed += (object sender, EventArgs e) => { EnableIde(); }; CmdLogin.Activated += (object sender, EventArgs e) => { Credentials = new Credentials(); Credentials.Username = TxtUsername.StringValue; Credentials.Password = TxtPassword.StringValue; string rememberText = GuiUtils.GetSelected(CboRemember); if (rememberText == Messages.WindowsCredentialsRememberNo) { Credentials.Remember = "no"; } else if (rememberText == Messages.WindowsCredentialsRememberRun) { Credentials.Remember = "run"; } else if (rememberText == Messages.WindowsCredentialsRememberPermanent) { Credentials.Remember = "permanent"; } else { Credentials.Remember = "no"; } Window.Close(); NSApplication.SharedApplication.StopModal(); }; CmdCancel.Activated += (object sender, EventArgs e) => { Credentials = null; Window.Close(); NSApplication.SharedApplication.StopModal(); }; EnableIde(); }
bool Check() { if ((RouteDescriptionToDirection(GuiUtils.GetSelected(CboRoutesOtherwise)) == "out") && (TableRoutingController.Items.Count == 0)) { if (GuiUtils.MessageYesNo(Messages.WindowsSettingsRouteOutEmptyList) == false) { return(false); } } return(true); }
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(); }
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(); }
public override void AwakeFromNib() { base.AwakeFromNib(); Window.Title = Constants.Name + " - " + Messages.WindowsSettingsRouteTitle; LblHelp.StringValue = Messages.WindowsSettingsRouteTitle; CboAction.RemoveAllItems(); CboAction.AddItem(WindowPreferencesController.RouteDirectionToDescription("in")); CboAction.AddItem(WindowPreferencesController.RouteDirectionToDescription("out")); TxtIP.Changed += (object sender, EventArgs e) => { EnableIde(); }; CmdOk.Activated += (object sender, EventArgs e) => { Accepted = true; Item.Ip = TxtIP.StringValue; Item.Action = WindowPreferencesController.RouteDescriptionToDirection(GuiUtils.GetSelected(CboAction)); Item.Icon = Item.Action; Item.Notes = TxtNotes.StringValue; Window.Close(); NSApplication.SharedApplication.StopModal(); }; CmdCancel.Activated += (object sender, EventArgs e) => { Accepted = false; Window.Close(); NSApplication.SharedApplication.StopModal(); }; TxtIP.StringValue = Item.Ip; GuiUtils.SetSelected(CboAction, WindowPreferencesController.RouteDirectionToDescription(Item.Action)); TxtNotes.StringValue = Item.Notes; EnableIde(); }
void SaveOptions() { Storage s = Engine.Instance.Storage; // General s.SetBool("connect", GuiUtils.GetCheck(ChkConnect)); s.SetBool("netlock", GuiUtils.GetCheck(ChkNetLock)); s.SetBool("servers.startlast", GuiUtils.GetCheck(ChkGeneralStartLast)); s.SetBool("gui.osx.visible", GuiUtils.GetCheck(ChkGeneralOsxVisible)); // s.SetBool ("gui.osx.dock", GuiUtils.GetCheck (ChkGeneralOsxDock)); // See this FAQ: https://airvpn.org/topic/13331-its-possible-to-hide-the-icon-in-dock-bar-under-os-x/ s.SetBool("gui.osx.notifications", GuiUtils.GetCheck(ChkGeneralOsxNotifications)); s.SetBool("gui.osx.sysbar.show_info", GuiUtils.GetCheck(ChkUiSystemBarShowInfo)); s.SetBool("gui.osx.sysbar.show_speed", GuiUtils.GetCheck(ChkUiSystemBarShowSpeed)); s.SetBool("gui.osx.sysbar.show_server", GuiUtils.GetCheck(ChkUiSystemBarShowServer)); s.SetBool("gui.exit_confirm", GuiUtils.GetCheck(ChkExitConfirm)); // UI string uiUnit = ""; if (GuiUtils.GetSelected(CboUiUnit) == Messages.WindowsSettingsUiUnit1) { uiUnit = "bytes"; } else if (GuiUtils.GetSelected(CboUiUnit) == Messages.WindowsSettingsUiUnit2) { uiUnit = "bits"; } s.Set("ui.unit", uiUnit); s.SetBool("ui.iec", GuiUtils.GetCheck(ChkUiIEC)); // Protocols if (GuiUtils.GetCheck(ChkProtocolsAutomatic)) { s.Set("mode.protocol", "AUTO"); s.SetInt("mode.port", 443); s.SetInt("mode.alt", 0); } else if (TableProtocols.SelectedRowCount == 1) { TableProtocolsControllerItem itemProtocol = TableProtocolsController.Items[(int)TableProtocols.SelectedRow]; s.Set("mode.protocol", itemProtocol.Protocol); s.SetInt("mode.port", itemProtocol.Port); s.SetInt("mode.alt", itemProtocol.IP); } else { s.Set("mode.protocol", "AUTO"); s.SetInt("mode.port", 443); s.SetInt("mode.alt", 0); } // Proxy s.Set("proxy.mode", GuiUtils.GetSelected(CboProxyType)); if (GuiUtils.GetSelected(CboProxyWhen) == Messages.WindowsSettingsProxyWhenAlways) { s.Set("proxy.when", "always"); } else if (GuiUtils.GetSelected(CboProxyWhen) == Messages.WindowsSettingsProxyWhenWeb) { s.Set("proxy.when", "web"); } else if (GuiUtils.GetSelected(CboProxyWhen) == Messages.WindowsSettingsProxyWhenOpenVPN) { s.Set("proxy.when", "openvpn"); } else if (GuiUtils.GetSelected(CboProxyWhen) == Messages.WindowsSettingsProxyWhenNone) { s.Set("proxy.when", "none"); } else { s.Set("proxy.when", "always"); } s.Set("proxy.host", TxtProxyHost.StringValue); s.SetInt("proxy.port", Conversions.ToInt32(TxtProxyPort.StringValue)); s.Set("proxy.auth", GuiUtils.GetSelected(CboProxyAuthentication)); s.Set("proxy.login", TxtProxyLogin.StringValue); s.Set("proxy.password", TxtProxyPassword.StringValue); s.SetInt("proxy.tor.control.port", Conversions.ToInt32(TxtProxyTorControlPort.StringValue)); s.Set("proxy.tor.control.password", TxtProxyTorControlPassword.StringValue); // Routes s.Set("routes.default", RouteDescriptionToDirection(GuiUtils.GetSelected(CboRoutesOtherwise))); string routes = ""; foreach (TableRoutingControllerItem item in TableRoutingController.Items) { if (routes != "") { routes += ";"; } routes += item.Ip + "," + item.Action + "," + item.Notes; } s.Set("routes.custom", routes); // Advanced - General s.SetBool("advanced.expert", GuiUtils.GetCheck(ChkAdvancedExpertMode)); s.SetBool("advanced.check.route", GuiUtils.GetCheck(ChkAdvancedCheckRoute)); string ipV6Mode = GuiUtils.GetSelected(CboIpV6); if (ipV6Mode == "None") { s.Set("ipv6.mode", "none"); } else if (ipV6Mode == "Disable") { s.Set("ipv6.mode", "disable"); } else { s.Set("ipv6.mode", "disable"); } s.SetBool("pinger.enabled", GuiUtils.GetCheck(ChkAdvancedPingerEnabled)); s.SetBool("routes.remove_default", GuiUtils.GetCheck(ChkRouteRemoveDefaultGateway)); s.Set("tools.openvpn.path", TxtAdvancedOpenVpnPath.StringValue); s.SetBool("advanced.skip_alreadyrun", GuiUtils.GetCheck(ChkAdvancedSkipAlreadyRun)); s.SetBool("advanced.providers", GuiUtils.GetCheck(ChkAdvancedProviders)); string manifestRefresh = GuiUtils.GetSelected(CboAdvancedManifestRefresh); if (manifestRefresh == "Automatic") // Auto { s.SetInt("advanced.manifest.refresh", -1); } else if (manifestRefresh == "Never") // Never { s.SetInt("advanced.manifest.refresh", 0); } else if (manifestRefresh == "Every minute") // One minute { s.SetInt("advanced.manifest.refresh", 1); } else if (manifestRefresh == "Every ten minute") // Ten minute { s.SetInt("advanced.manifest.refresh", 10); } else if (manifestRefresh == "Every one hour") // One hour { s.SetInt("advanced.manifest.refresh", 60); } string openVpnSndBuf = GuiUtils.GetSelected(CboOpenVpnSndBuf); if (openVpnSndBuf == Messages.Automatic) { s.SetInt("openvpn.sndbuf", -2); } else if (openVpnSndBuf == Messages.WindowsSettingsOpenVpnDefault) { s.SetInt("openvpn.sndbuf", -1); } else if (openVpnSndBuf == "8 KB") { s.SetInt("openvpn.sndbuf", 1024 * 8); } else if (openVpnSndBuf == "16 KB") { s.SetInt("openvpn.sndbuf", 1024 * 16); } else if (openVpnSndBuf == "32 KB") { s.SetInt("openvpn.sndbuf", 1024 * 32); } else if (openVpnSndBuf == "64 KB") { s.SetInt("openvpn.sndbuf", 1024 * 64); } else if (openVpnSndBuf == "128 KB") { s.SetInt("openvpn.sndbuf", 1024 * 128); } else if (openVpnSndBuf == "256 KB") { s.SetInt("openvpn.sndbuf", 1024 * 256); } else if (openVpnSndBuf == "512 KB") { s.SetInt("openvpn.sndbuf", 1024 * 512); } string openVpnRcvBuf = GuiUtils.GetSelected(CboOpenVpnRcvBuf); if (openVpnRcvBuf == Messages.Automatic) { s.SetInt("openvpn.rcvbuf", -2); } else if (openVpnRcvBuf == Messages.WindowsSettingsOpenVpnDefault) { s.SetInt("openvpn.rcvbuf", -1); } else if (openVpnRcvBuf == "8 KB") { s.SetInt("openvpn.rcvbuf", 1024 * 8); } else if (openVpnRcvBuf == "16 KB") { s.SetInt("openvpn.rcvbuf", 1024 * 16); } else if (openVpnRcvBuf == "32 KB") { s.SetInt("openvpn.rcvbuf", 1024 * 32); } else if (openVpnRcvBuf == "64 KB") { s.SetInt("openvpn.rcvbuf", 1024 * 64); } else if (openVpnRcvBuf == "128 KB") { s.SetInt("openvpn.rcvbuf", 1024 * 128); } else if (openVpnRcvBuf == "256 KB") { s.SetInt("openvpn.rcvbuf", 1024 * 256); } else if (openVpnRcvBuf == "512 KB") { s.SetInt("openvpn.rcvbuf", 1024 * 512); } // Advanced - DNS string dnsMode = GuiUtils.GetSelected(CboDnsSwitchMode); if (dnsMode == "Disabled") { s.Set("dns.mode", "none"); } else { s.Set("dns.mode", "auto"); } s.SetBool("dns.check", GuiUtils.GetCheck(ChkDnsCheck)); string dnsServers = ""; for (int i = 0; i < TableDnsServersController.GetCount(); i++) { if (dnsServers != "") { dnsServers += ","; } dnsServers += TableDnsServersController.Get(i); } s.Set("dns.servers", dnsServers); // Advanced - Lock string lockMode = GuiUtils.GetSelected(CboLockMode); s.Set("netlock.mode", "none"); if (lockMode == "Automatic") { s.Set("netlock.mode", "auto"); } else { foreach (NetworkLockPlugin lockPlugin in Engine.Instance.NetworkLockManager.Modes) { if (lockPlugin.GetName() == lockMode) { s.Set("netlock.mode", lockPlugin.GetCode()); } } } s.SetBool("netlock.allow_private", GuiUtils.GetCheck(ChkLockAllowPrivate)); s.SetBool("netlock.allow_ping", GuiUtils.GetCheck(ChkLockAllowPing)); s.SetBool("netlock.allow_dns", GuiUtils.GetCheck(ChkLockAllowDNS)); s.Set("netlock.allowed_ips", TxtLockAllowedIPS.StringValue); // Advanced - Logging s.SetBool("log.file.enabled", GuiUtils.GetCheck(ChkLoggingEnabled)); s.SetBool("log.level.debug", GuiUtils.GetCheck(ChkLogLevelDebug)); s.Set("log.file.path", TxtLoggingPath.StringValue); // Advanced - OVPN Directives s.SetBool("openvpn.skip_defaults", GuiUtils.GetSelected(CboOpenVpnDirectivesSkipDefault) == Messages.WindowsSettingsOpenVpnDirectivesDefaultSkip2); s.Set("openvpn.directives", TxtAdvancedOpenVpnDirectivesDefault.StringValue); s.Set("openvpn.custom", TxtAdvancedOpenVpnDirectivesCustom.StringValue); s.Set("openvpn.directives.path", TxtOpenVpnDirectivesCustomPath.StringValue); // Advanced - Events SaveOptionsEvent("app.start", 0); SaveOptionsEvent("app.stop", 1); SaveOptionsEvent("session.start", 2); SaveOptionsEvent("session.stop", 3); SaveOptionsEvent("vpn.pre", 4); SaveOptionsEvent("vpn.up", 5); SaveOptionsEvent("vpn.down", 6); Engine.Instance.OnSettingsChanged(); }
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(); }