private void StartNetworkMonitor() { NetworkModel.logger.Log(0, "Network throughput monitoring active"); this._networkStateMonitor = ServiceLocatorExtensions.ResolveType <INetworkStateMonitorFactory>(ObjectExtensions.GetServiceLocator(this), null).Create(TimeSpan.FromSeconds(2.0), string.Format("NetworkModel {0}", this.GetHashCode())); this._networkStateMonitor.add_MeasurementCollected(new EventHandler <NetworkSnapshotEventArgs>(this.NetworkStateMonitorOnMeasurementCollected)); this._networkStateMonitor.Start(); }
private void NetworkStateMonitorOnMeasurementCollected(object sender, NetworkSnapshotEventArgs args) { IVyprVPNController vyprVPNController = ServiceLocatorExtensions.ResolveType <IVyprVPNController>(ServiceLocator.get_Default(), null); ThroughputMeasurement throughputMeasurement; if (vyprVPNController.ConnectionStatus == 4) { throughputMeasurement = new ThroughputMeasurement(args.get_TimeOfSnapshot(), args.get_Bandwidths()[3], vyprVPNController.ConnectionStatus); } else { throughputMeasurement = new ThroughputMeasurement(args.get_TimeOfSnapshot(), args.get_Bandwidths()[1], vyprVPNController.ConnectionStatus); } if (vyprVPNController.KillSwitchActive) { this.ThroughputMeasurements.Enqueue(new ThroughputMeasurement(DateTime.Now, new BandwidthSnapshot(), vyprVPNController.ConnectionStatus)); } else { this.ThroughputMeasurements.Enqueue(throughputMeasurement); } while (this.ThroughputMeasurements.Count > 1000) { ThroughputMeasurement throughputMeasurement2; if (!this.ThroughputMeasurements.TryDequeue(out throughputMeasurement2)) { NetworkModel.logger.Log(3, "Could not dequeue throughput measurement after queue exceeded maximum capacity. Will try to dequeue again at next iteration."); break; } throughputMeasurement2 = null; } this.UpstreamRate = throughputMeasurement.Snapshot.get_UpstreamBitsPerSecond(); this.DownstreamRate = throughputMeasurement.Snapshot.get_DownstreamBitsPerSecond(); MessageBase <ThroughputMeasuredMessage, ThroughputMeasurement> .SendWith(throughputMeasurement, null); }
public QuitDialog(string title, string message, string question, string affirmativeText = "", string negativeText = "", string checkBoxText = "", bool isCheckBoxVisibile = false, bool checkBoxEnabled = true, bool checkBoxChecked = false) { this.InitializeComponent(); ServiceLocatorExtensions.ResolveType <IUIHelper>(ServiceLocator.get_Default(), null).LocalizeUI(this, Thread.CurrentThread, false); if (string.IsNullOrEmpty(affirmativeText)) { affirmativeText = VyprVPN.Properties.Resources.Yes; } if (string.IsNullOrEmpty(negativeText)) { negativeText = VyprVPN.Properties.Resources.No; } base.DataContext = this; base.Title = title; this.Message = message; this.Question = question; this.AffirmativeText = affirmativeText; this.NegativeText = negativeText; this.CheckBoxText = checkBoxText; this.IsCheckBoxVisibile = isCheckBoxVisibile; this.CheckBoxEnabled = checkBoxEnabled; this.CheckBoxChecked = checkBoxChecked; base.CommandBindings.Add(new CommandBinding(this.YesCommand, new ExecutedRoutedEventHandler(this.YesExecuted))); base.CommandBindings.Add(new CommandBinding(this.NoCommand, new ExecutedRoutedEventHandler(this.NoExecuted))); }
public PaymentMethodExpiredDialog() { this.InitializeComponent(); ServiceLocatorExtensions.ResolveType <IUIHelper>(ServiceLocator.get_Default(), null).LocalizeUI(this, Thread.CurrentThread, false); base.DataContext = this; base.CommandBindings.Add(new CommandBinding(this.ManageAccountCommand, new ExecutedRoutedEventHandler(this.ManageAccountExecuted))); base.CommandBindings.Add(new CommandBinding(this.CloseCommand, new ExecutedRoutedEventHandler(this.CloseExecuted))); }
public ConfigureKillSwitchDialogViewModel() { this.PreferencesModel = ServiceLocatorExtensions.ResolveType <IPreferencesModel>(ObjectExtensions.GetServiceLocator(this), null); if (this.PreferencesModel != null) { this.KillSwitchMode = this.PreferencesModel.KillSwitchMode; this.KillLanTrafficEnabled = this.PreferencesModel.KillLanTrafficEnabled; } }
public NewFeatureModalView() { this.InitializeComponent(); if (!DesignerProperties.GetIsInDesignMode(this)) { ServiceLocatorExtensions.ResolveType <IUIHelper>(ServiceLocator.get_Default(), null).LocalizeUI(this, Thread.CurrentThread, false); } MessageBase <NewFeatureModalCloseWindowMessage, object> .Register(this, new Action <NewFeatureModalCloseWindowMessage>(this.DispatchClose), base.Tag); }
protected virtual void Dispose(bool disposing) { if (!this.isDisposed) { ServiceLocatorExtensions.ResolveType <IUIHelper>(ObjectExtensions.GetServiceLocator(this), null).Dispatch(delegate { MessageBase <NewFeatureModalCloseWindowMessage, object> .Unregister(this, new Action <NewFeatureModalCloseWindowMessage>(this.DispatchClose), base.Tag); MessageBase <NewFeatureModalCloseWindowMessage, object> .Unregister(this, new Action <NewFeatureModalCloseWindowMessage>(this.DispatchClose), null); }); this.isDisposed = true; } }
public FeedbackWindow() { try { this.InitializeComponent(); ServiceLocatorExtensions.ResolveType <IUIHelper>(ServiceLocator.get_Default(), null).LocalizeUI(this, Thread.CurrentThread, false); } catch (InvalidOperationException) { FileLogger.get_Instance().Log(3, "Failed to initialize FeedbackWindow"); } }
public AddParametersDialogViewModel() { this.PreferencesModel = ServiceLocatorExtensions.ResolveType <IPreferencesModel>(ObjectExtensions.GetServiceLocator(this), null); if (this.PreferencesModel != null) { OpenVpnCommandLineConfig expr_30 = new OpenVpnCommandLineConfig(); expr_30.set_SelectedMtu(this.PreferencesModel.SelectedMtu); expr_30.set_SelectedOpenVpnLogVerbosityLevel(this.PreferencesModel.SelectedOpenVpnLogVerbosityLevel); expr_30.set_SelectedRouteDelay(this.PreferencesModel.SelectedRouteDelay); expr_30.set_SelectedTlsTimeout(this.PreferencesModel.SelectedTlsTimeout); OpenVpnCommandLineConfig commandLineConfig = expr_30; this._dummyCommandLine = base.VyprVPNController.GetDummyOpenVpnCommandLine(this.PreferencesModel.Protocol, commandLineConfig); this.ParametersInput = this.PreferencesModel.AdditionalOpenVpnParameters; } }
public QuitDialog() { this.InitializeComponent(); ServiceLocatorExtensions.ResolveType <IUIHelper>(ServiceLocator.get_Default(), null).LocalizeUI(this, Thread.CurrentThread, false); }
public WirelessNetworkSelectorWindow(WirelessNetworkSelectorWindowViewModel viewModel) { base.DataContext = viewModel; this.InitializeComponent(); ServiceLocatorExtensions.ResolveType <IUIHelper>(ServiceLocator.get_Default(), null).LocalizeUI(this, Thread.CurrentThread, false); }
private void DispatchClose(NewFeatureModalCloseWindowMessage msg) { ServiceLocatorExtensions.ResolveType <IUIHelper>(ObjectExtensions.GetServiceLocator(this), null).Dispatch(new Action(base.Close)); }
private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e) { string absoluteUri = e.Uri.AbsoluteUri; ServiceLocatorExtensions.ResolveType <IGeneralUtilities>(ServiceLocator.get_Default(), null).StartWebUri(absoluteUri); }
public FeedbackWindow(FeedbackViewModel vm) { this.InitializeComponent(); ServiceLocatorExtensions.ResolveType <IUIHelper>(ServiceLocator.get_Default(), null).LocalizeUI(this, Thread.CurrentThread, false); base.DataContext = vm; }
public ConnectionLogWindow(ConnectionLogViewModel viewModel) { this.InitializeComponent(); ServiceLocatorExtensions.ResolveType <IUIHelper>(ServiceLocator.get_Default(), null).LocalizeUI(this, Thread.CurrentThread, false); base.DataContext = viewModel; }