public SettingsWindowViewModel(IClipboardRepository clipboardRepository, IAppSettingsService appSettingsService) { if (clipboardRepository == null) { throw new ArgumentNullException(nameof(clipboardRepository)); } if (appSettingsService == null) { throw new ArgumentNullException(nameof(appSettingsService)); } _clipboardRepository = clipboardRepository; _appSettingsService = appSettingsService; HotKey = appSettingsService.HotKey; MaxSavedCopiesCount = appSettingsService.MaxSavedCopiesCount; RefreshDatabase(); Submitted += (sender, e) => { if (!_appSettingsService.HotKey.Equals(HotKey)) { _appSettingsService.HotKey = HotKey; HotKeyChanged?.Invoke(this, HotKey); } _appSettingsService.MaxSavedCopiesCount = MaxSavedCopiesCount; _appSettingsService.Culture = Thread.CurrentThread.CurrentCulture.Name; _appSettingsService.Save(); }; }
private void ToggleClipboardMonitor(bool activate) { var viewModel = (MainWindowViewModel)DataContext; _isClipboardMonitorDisconnected = !activate; // Starts/stops the clipboard if (activate) { _clipboardMonitor.Start(); } else { _clipboardMonitor.Stop(); } // Update the application title and color when it is active or not _notifyIcon.Text = viewModel.DisplayName; UpdateLocalizedToggleClipboardResource(viewModel); // Change the glow of the window based on the monitor being active or not Application.Current.Resources["WindowGlowBrush"] = activate ? _glowBrush : (SolidColorBrush)Application.Current.Resources["FlatColorSunFlower"]; // Save the active settings _applicationService.IsClipboardMonitoring = activate; _applicationService.Save(); }
private void ExecuteSave() { _appSettingsService.Save(AppSettings); _projectSettingsService.Save(ProjectSettings); BackCommand.Execute(null); }
public SettingsWindow( ILoggerFactory loggerFactory, LogLevelSignal logLevelSignal, IAppSettingsService appSettingsService, CrossProcessSignal processSignal) { this.LoggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); if (appSettingsService == null) { throw new ArgumentNullException(nameof(appSettingsService)); } if (processSignal == null) { throw new ArgumentNullException(nameof(processSignal)); } this.Settings = appSettingsService.LoadOrCreate <SettingsModel>(); logLevelSignal.Update(this.Settings.LogLevel); this.LogLevels = Enum.GetValues(typeof(LogLevel)).Cast <LogLevel>().ToList(); this.SaveAndApplyConfigurationCommand = new DelegateCommand( _ => { this.Settings.SnmpPollers = this.SnmpMonitors.Pollers.ToList(); this.Settings.PerformanceCounterPollers = this.PerformanceCounterMonitors.Pollers.ToList(); appSettingsService.Save(this.Settings); logLevelSignal.Update(this.Settings.LogLevel); processSignal.Signal(); this.Close(); }); this.ExitCommand = new DelegateCommand(_ => this.Close()); this.InitializeComponent(); this.SnmpMonitors.Pollers = new ObservableCollection <SnmpPollerConfig>(this.Settings.SnmpPollers); this.PerformanceCounterMonitors.Pollers = new ObservableCollection <PerformanceCounterPollerConfig>(this.Settings.PerformanceCounterPollers); }