void __MainViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (!NSThread.IsMain) { InvokeOnMainThread(() => __MainViewModel_PropertyChanged(sender, e)); return; } switch (e.PropertyName) { case nameof(__MainViewModel.ConnectionError): if (!string.IsNullOrEmpty(__MainViewModel.ConnectionError)) { IVPNAlert.Show(LocalizedStrings.Instance.LocalizedString("Error_ConnectionError"), __MainViewModel.ConnectionError, NSAlertStyle.Warning); } break; case nameof(__MainViewModel.IsKillSwitchEnabled): case nameof(__MainViewModel.KillSwitchIsPersistent): case nameof(__MainViewModel.PauseStatus): case nameof(__MainViewModel.ConnectionState): case nameof(__MainViewModel.IsAntiTrackerEnabled): case nameof(__MainViewModel.IsIsAntiTrackerChangingStatus): UpdateUI(); break; } }
partial void OnGuiPauseDlgOkBtnPressed(Foundation.NSObject sender) { double seconds = 0; try { string sh = string.IsNullOrEmpty(GuiPauseDlgHoursTextBlock.StringValue) ? "0" : GuiPauseDlgHoursTextBlock.StringValue; string sm = string.IsNullOrEmpty(GuiPauseDlgMinutesTextBlock.StringValue) ? "0" : GuiPauseDlgMinutesTextBlock.StringValue; double hours = double.Parse(sh); double minutes = double.Parse(sm); seconds = hours * 60 * 60 + minutes * 60; } catch { IVPNAlert.Show(AppDelegate.GetMainWindowController()?.Window, "Please, enter correct values"); return; } GuiSetPauseIntervalWindow.Close(); if (__MainViewModel.PauseStatus == MainViewModel.PauseStatusEnum.Paused) { __MainViewModel.SetPauseTime(seconds); } else { __MainViewModel.PauseCommand.Execute(seconds); } }
private void SetSettings(AppSettings settings) { __Settings = settings; __Settings.PropertyChanged += __Settings_PropertyChanged; Settings = new AppSettingsAdapter(__Settings); NetworkActions = new ObservableObject(__Settings.NetworkActions); __NetworksViewModel = new ViewModelNetworksSettings(__Settings.NetworkActions, this); NetworksViewModelObservable = new ObservableObject(__NetworksViewModel); __Observers = new List <IDisposable>(); __Observers.Add(Settings.AddObserver(new NSString("ProxyTypeId"), NSKeyValueObservingOptions.New, (NSObservedChange e) => { if (Window.FirstResponder is NSTextView) { UnfocusElement(); } })); __Observers.Add(Settings.AddObserver(new NSString("FirewallAllowLAN"), NSKeyValueObservingOptions.New, (NSObservedChange e) => { __MainViewModel.KillSwitchAllowLAN = __Settings.FirewallAllowLAN; })); __Observers.Add(Settings.AddObserver(new NSString("FirewallAllowLANMulticast"), NSKeyValueObservingOptions.New, (NSObservedChange e) => { __MainViewModel.KillSwitchAllowLANMulticast = __Settings.FirewallAllowLANMulticast; })); __Observers.Add(Settings.AddObserver(new NSString("ServiceUseObfsProxy"), NSKeyValueObservingOptions.New, (NSObservedChange e) => { __Service.Proxy.SetPreference("enable_obfsproxy", settings.ServiceUseObfsProxy ? "1" : "0"); })); __Observers.Add(Settings.AddObserver(new NSString("IsLoggingEnabled"), NSKeyValueObservingOptions.New, (NSObservedChange e) => { __Service.Proxy.SetPreference("enable_logging", settings.IsLoggingEnabled ? "1" : "0"); })); __Observers.Add(Settings.AddObserver(new NSString("FirewallTypeId"), NSKeyValueObservingOptions.New, (NSObservedChange e) => { bool isPersistent = settings.FirewallType == IVPNFirewallType.Persistent; __MainViewModel.KillSwitchIsPersistent = isPersistent; })); __Observers.Add(Settings.AddObserver(new NSString("OpenVPNExtraParameters"), NSKeyValueObservingOptions.New, (NSObservedChange e) => { if (!Helpers.OpenVPN.OpenVPNConfigChecker.IsIsUserParametersAllowed(settings.OpenVPNExtraParameters, out string errorDesc)) { IVPNAlert.Show(//this.Window, - do not use window argument (alert will be possible to show when window closing) __MainViewModel.AppServices.LocalizedString("OpenVPNParamsNotSupported", "Some OpenVPN additional parameters are not supported"), errorDesc, NSAlertStyle.Warning); return; } __Service.Proxy.SetPreference("open_vpn_extra_parameters", settings.OpenVPNExtraParameters); })); __Observers.Add(Settings.AddObserver(new NSString("StopServerOnClientDisconnect"), NSKeyValueObservingOptions.New, (NSObservedChange e) => { __Service.Proxy.SetPreference("is_stop_server_on_client_disconnect", __Settings.StopServerOnClientDisconnect ? "1" : "0"); })); }
void __LogInViewModel_OnError(string errorText, string errorDescription = "") { if (string.IsNullOrEmpty(errorDescription)) { IVPNAlert.Show(errorText); } else { IVPNAlert.Show(errorText, errorDescription); } }
void __WireguardSetingsViewModel_OnError(string errorText, string errorDescription = "") { if (GuiPanelWireguardConfigDetails.IsVisible) { IVPNAlert.Show(GuiPanelWireguardConfigDetails, errorText, errorDescription, NSAlertStyle.Warning); } else { IVPNAlert.Show(Window, errorText, errorDescription, NSAlertStyle.Warning); } }
void __Model_OnError(string errorText, string errorDescription = "") { if (Window.IsVisible) { if (string.IsNullOrEmpty(errorDescription)) { IVPNAlert.Show(errorText); } else { IVPNAlert.Show(errorText, errorDescription); } } Close(); }
private bool CheckIsPossibleToChangeVpnType(VpnProtocols.VpnType t) { if (__Settings.VpnProtocolType == t) { return(false); } if (__MainViewModel.ConnectionState != ServiceState.Disconnected) { IVPNAlert.Show(LocalizedStrings.Instance.LocalizedString("Message_DisconnectToSwitchVPNProtocol")); return(false); } return(true); }
public async Task Navigated(bool showSessionLimit) { try { GuiProgressSpinner.StartAnimation(this); await __LogOutViewModel.DoLogOut(showSessionLimit); } catch (Exception ex) { IVPNAlert.Show(LocalizedStrings.Instance.LocalizedString("WG_Error_FailedToDeleteKeyOnLogout"), ex.Message, NSAlertStyle.Critical); } finally { GuiProgressSpinner.StopAnimation(this); } }
void __MainViewModel_OnError(string errorText, string errorDescription = "") { if (!NSThread.IsMain) { InvokeOnMainThread(() => __MainViewModel_OnError(errorText, errorDescription)); return; } if (string.IsNullOrEmpty(errorDescription)) { IVPNAlert.Show(errorText); } else { IVPNAlert.Show(errorText, errorDescription); } }
partial void OnEdit(Foundation.NSObject sender) { int row = (int)GuiTableEmails.SelectedRow; if (row < 0) { return; } PrivateEmailInfo email = __Model.PrivateEmails [row]; string newNotes = IVPNAlert.ShowInputBox(string.Format(LocalizedStrings.Instance.LocalizedString("Label_PrivateEmail_NotesDialog_PARAMETRIZED"), email.Email), "", email.Notes, true); if (newNotes == null || (email.Notes != null && newNotes.Equals(email.Notes))) { return; } __Model.UpdateNotes(email, newNotes); }
public override void AwakeFromNib() { base.AwakeFromNib(); // Disable title-bar (but keep close/minimize/expand buttons on content-view) Window.TitleVisibility = NSWindowTitleVisibility.Hidden; Window.TitlebarAppearsTransparent = true; Window.StyleMask |= NSWindowStyle.FullSizeContentView; // set window background color //if (!Colors.IsDarkMode) // Window.BackgroundColor = NSColor.FromRgba (255, 255, 255, 0.95f); // Stylyze buttons CustomButtonStyles.ApplyStyleGreyButtonV2(GuiBtnEdit, LocalizedStrings.Instance.LocalizedString("Button_PrivateEmail_Notes")); CustomButtonStyles.ApplyStyleGreyButtonV2(GuiBtnCopy, LocalizedStrings.Instance.LocalizedString("Button_PrivateEmail_Copy")); CustomButtonStyles.ApplyStyleGreyButtonV2(GuiBtnAdd, LocalizedStrings.Instance.LocalizedString("Button_PrivateEmail_Create")); CustomButtonStyles.ApplyStyleGreyButtonV2(GuiBtnDelete, LocalizedStrings.Instance.LocalizedString("Button_PrivateEmail_Delete")); GuiProgressSpiner.StopAnimation(this); GuiProgressSpiner.Hidden = true; GuiBtnRefresh.Hidden = false; // Model event handlers __Model.OnError += (errorText, errorDescription) => { if (Window.IsVisible) { if (string.IsNullOrEmpty(errorDescription)) { IVPNAlert.Show(errorText); } else { IVPNAlert.Show(errorText, errorDescription); } } }; __Model.OnWillExecute += (sender) => { InvokeOnMainThread(() => { __IsUpdateInProgress = true; SetEnableButtons(); GuiInfoLabel.StringValue = LocalizedStrings.Instance.LocalizedString("Label_PrivateEmail_UdpatingProgress"); GuiProgressSpiner.Hidden = false; GuiBtnRefresh.Hidden = true; GuiProgressSpiner.StartAnimation(this); EnableView.Disable(this.GuiTableScrollView); }); }; __Model.OnDidExecute += (sender) => { InvokeOnMainThread(() => { __IsUpdateInProgress = false; SetEnableButtons(); GuiProgressSpiner.Hidden = true; GuiBtnRefresh.Hidden = false; GuiInfoLabel.StringValue = LocalizedStrings.Instance.LocalizedString("Label_PrivateEmail_Title"); EnableView.Enable(this.GuiTableScrollView); }); }; __Model.PropertyChanged += __Model_PropertyChanged; GuiTableEmails.DoubleClick += (sender, e) => OnEdit(null); UpdateGui(); }