public void Save() { bool debugFacilitiesRequiresRestart = !this.syncthingManager.DebugFacilities.SupportsRestartlessUpdate && !new HashSet <string>(this.syncthingManager.DebugFacilities.DebugFacilities.Where(x => x.IsEnabled).Select(x => x.Name)).SetEquals(this.SyncthingDebugFacilities.Where(x => x.IsEnabled).Select(x => x.Name)); this.configurationProvider.AtomicLoadAndSave(configuration => { foreach (var settingItem in this.settings) { settingItem.SaveValue(configuration); } configuration.Folders = this.FolderSettings.Select(x => new FolderConfiguration(x.FolderId, x.IsWatched, x.IsNotified)).ToList(); // The ConfigurationApplicator will propagate this to the DebugFacilitiesManager configuration.SyncthingDebugFacilities = this.SyncthingDebugFacilities.Where(x => x.IsEnabled).Select(x => x.Name).ToList(); }); if (this.autostartProvider.CanWrite) { var autostartConfig = new AutostartConfiguration() { AutoStart = this.StartOnLogon, StartMinimized = this.StartMinimized }; this.autostartProvider.SetAutoStart(autostartConfig); } if (this.settings.Any(x => x.HasChanged && x.RequiresSyncTrayzorRestart)) { var result = this.windowManager.ShowMessageBox( Resources.SettingsView_RestartSyncTrayzor_Message, Resources.SettingsView_RestartSyncTrayzor_Title, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { this.processStartProvider.StartDetached(this.assemblyProvider.Location); this.applicationState.Shutdown(); } } else if ((this.settings.Any(x => x.HasChanged && x.RequiresSyncthingRestart) || debugFacilitiesRequiresRestart) && this.syncthingManager.State == SyncthingState.Running) { var result = this.windowManager.ShowMessageBox( Resources.SettingsView_RestartSyncthing_Message, Resources.SettingsView_RestartSyncthing_Title, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { this.RestartSyncthing(); } } this.RequestClose(true); }
public void Save() { this.configurationProvider.AtomicLoadAndSave(configuration => { foreach (var settingItem in this.settings) { settingItem.SaveValue(configuration); } configuration.Folders = this.FolderSettings.Select(x => new FolderConfiguration(x.FolderName, x.IsWatched, x.IsNotified)).ToList(); }); if (this.autostartProvider.CanWrite) { var autostartConfig = new AutostartConfiguration() { AutoStart = this.StartOnLogon, StartMinimized = this.StartMinimized }; this.autostartProvider.SetAutoStart(autostartConfig); } if (this.settings.Any(x => x.HasChanged && x.RequiresSyncTrayzorRestart)) { var result = this.windowManager.ShowMessageBox( Resources.SettingsView_RestartSyncTrayzor_Message, Resources.SettingsView_RestartSyncTrayzor_Title, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { this.processStartProvider.StartDetached(this.assemblyProvider.Location); this.applicationState.Shutdown(); } } else if (this.settings.Any(x => x.HasChanged && x.RequiresSyncthingRestart) && this.syncThingManager.State == SyncThingState.Running) { var result = this.windowManager.ShowMessageBox( Resources.SettingsView_RestartSyncthing_Message, Resources.SettingsView_RestartSyncthing_Title, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { this.RestartSyncthing(); } } this.RequestClose(true); }
public void Save() { var configuration = this.configurationProvider.Load(); configuration.MinimizeToTray = this.MinimizeToTray; configuration.CloseToTray = this.CloseToTray; configuration.NotifyOfNewVersions = this.NotifyOfNewVersions; configuration.ObfuscateDeviceIDs = this.ObfuscateDeviceIDs; configuration.UseComputerCulture = this.UseComputerCulture; configuration.ShowTrayIconOnlyOnClose = this.ShowTrayIconOnlyOnClose; configuration.ShowSynchronizedBalloon = this.ShowSynchronizedBalloon; configuration.ShowDeviceConnectivityBalloons = this.ShowDeviceConnectivityBalloons; configuration.StartSyncthingAutomatically = this.StartSyncThingAutomatically; configuration.SyncthingRunLowPriority = this.SyncthingRunLowPriority; configuration.SyncthingAddress = this.SyncThingAddress; configuration.SyncthingApiKey = this.SyncThingApiKey; if (this.autostartProvider.CanWrite) { var autostartConfig = new AutostartConfiguration() { AutoStart = this.StartOnLogon, StartMinimized = this.StartMinimized }; this.autostartProvider.SetAutoStart(autostartConfig); } configuration.Folders = this.WatchedFolders.Select(x => new FolderConfiguration(x.Folder, x.IsSelected)).ToList(); configuration.SyncthingUseCustomHome = this.SyncthingUseCustomHome; EnvironmentalVariableCollection envVars; EnvironmentalVariablesParser.TryParse(this.SyncThingEnvironmentalVariables, out envVars); configuration.SyncthingEnvironmentalVariables = envVars; configuration.SyncthingDenyUpgrade = this.SyncthingDenyUpgrade; this.configurationProvider.Save(configuration); this.RequestClose(true); }