public static void Save() { CloseLauncherAutomaticallyKey.SetValue(CloseLauncherAutomatically); ActiveVersionKey.SetValue(ActiveVersion); CurrentTabKey.SetValue(CurrentTab); SettingsContainer.SaveSettingsProfile(SettingsContainer.CurrentProfile, LauncherConfigPath); }
/// <summary> /// Saves the settings into the settings file. /// </summary> public static void Save() { // Special case for MRU: we always reload the latest version from the file. // Actually modifying and saving MRU is done in a specific class. var profileCopy = LoadProfileCopy(); var mruList = MostRecentlyUsedSessions.GetValue(profileCopy, true); MostRecentlyUsedSessions.SetValue(mruList); WriteFile(); }
private void SaveToSettings() { lock (SyncRoot) { // Update the current profile with the new values so we can properly save it. settingsKey.SetValue(mruList.Take(MaxMRUCount).ToList()); save.Invoke(); // Ensure we are properly synchronized with the file. LoadFromSettings(); } }
private void SaveToSettings(string xenkoVersion) { // We load a copy of the profile in case concurrent Game Studio instances are running. // Note that when this is called, the collection should be sync for the current version, // but not for other versions. var profileCopy = LoadLatestProfile(); var mruList = settingsKey.GetValue(profileCopy, true); mruList[xenkoVersion] = MostRecentlyUsedFiles.Where(x => x.Version.Equals(xenkoVersion)).Take(MaxMRUCount).ToList(); // Update the current profile with the new values so we can properly save it. settingsKey.SetValue(mruList); save?.Invoke(); // Ensure we are properly synchronized with the file. LoadFromSettings(); }
public void SetValue <T>(SettingsKey <T> key, T value) { key.SetValue(value, profile); }
public void AddDelayedNotification(SettingsKey <bool> confirmationSettingsKey, string message, string yesCaption, string noCaption, Action yesAction, Action noAction, SettingsKey <bool> yesNoSettingsKey) { if (confirmationSettingsKey == null) { throw new ArgumentNullException(nameof(confirmationSettingsKey)); } if (message == null) { throw new ArgumentNullException(nameof(message)); } if (yesCaption == null) { throw new ArgumentNullException(nameof(yesCaption)); } if (noCaption == null) { throw new ArgumentNullException(nameof(noCaption)); } // Prevent duplicate if (delayedNotifications.Any(t => ReferenceEquals(t.Item1, confirmationSettingsKey))) { return; } Action action = async() => { var yesNo = yesNoSettingsKey?.GetValue() ?? true; var ask = confirmationSettingsKey.GetValue(); if (ask) { var buttons = DialogHelper.CreateButtons(new[] { yesCaption, noCaption }, 1, 2); var result = await CheckedMessageBox(message, false, DialogHelper.DontAskAgain, buttons, MessageBoxImage.Question); // Close without clicking on a button if (result.Result == 0) { return; } yesNo = result.Result == 1; if (result.IsChecked == true && (yesNo || yesNoSettingsKey != null)) { confirmationSettingsKey.SetValue(false); yesNoSettingsKey?.SetValue(yesNo); Settings.EditorSettings.Save(); } } if (yesNo) { yesAction?.Invoke(); } else { noAction?.Invoke(); } }; var windows = Application.Current.Windows; if (windows.Count == 0 || windows.OfType <Window>().Any(w => w.IsActive)) { // Execute immediately Dispatcher.Invoke(action); return; } // Add a new question delayedNotifications.Enqueue(Tuple.Create((SettingsKey)confirmationSettingsKey, action)); }
private void SetValue(ref bool field, bool value, SettingsKey <bool> settingsKey, [CallerMemberName] string propertyName = null) { SetValue(ref field, value, propertyName); settingsKey.SetValue(value); }