public bool Load() { TextReader file = null; bool success = false; try { ResetToDefaults(); if (MyAPIGateway.Utilities.FileExistsInLocalStorage(FileName, typeof(Settings))) { file = MyAPIGateway.Utilities.ReadFileInLocalStorage(FileName, typeof(Settings)); ReadSettings(file); SettingsLoaded?.Invoke(); success = true; } } catch (Exception e) { Log.Error(e); } finally { file?.Dispose(); } Main.LocalToolDescription.RefreshToolDescription(); SettingsChanged?.Invoke(); return(success); }
public T Load <T>(string valueName) { try { if (registryKeyReadOnly == null) { registryKeyReadOnly = Registry.CurrentUser.OpenSubKey(registryPath); } if (registryKeyReadOnly != null) { object value = registryKeyReadOnly.GetValue(valueName, null); SettingsLoaded?.Invoke(this, registryKeyReadOnly); if (typeof(T) == typeof(bool)) { return((T)Convert.ChangeType((int)value > 0, typeof(T))); } else { return((T)value); } } return(default(T)); } catch (SecurityException exception) { Debug.WriteLine(exception); RegistryAccessFailed?.Invoke(this, registryKeyReadOnly); return(default(T)); } catch (Exception exception) { Debug.WriteLine(exception); return(default(T)); } }
private async System.Threading.Tasks.Task loadSettings() { this.IsBusy = true; try { if (CellPhoneCarriers.Count < 1) { var carriers = await DataService.GetItemsAsync <CellPhoneCarrier>("cellPhoneCarriers"); carriers.Data.ForEach(d => this.CellPhoneCarriers.Add(d)); } User = await DataService.GetItemAsync <User>("mySettings"); User.CellPhoneCarrier = CellPhoneCarriers.FirstOrDefault(c => c.CellPhoneCarrierIdValue == User.CellPhoneCarrierIdValue); OnPropertyChanged("User"); SettingsLoaded?.Invoke(this, new EventArgs()); } catch (Exception ex) { IsBusy = false; ExceptionHelper.ShowException(ex); } finally { IsBusy = false; } }
public void LoadSettings() { if (File.Exists(FILE_SETTINGS_CURRENT)) { try { loadingSettings = true; XmlDocument doc = new XmlDocument(); FileExtensions.CreateDirectoriesForFile(FILE_SETTINGS_CURRENT); doc.Load(FILE_SETTINGS_CURRENT); XmlNode root = doc.DocumentElement; if (root.LocalName != ROOT_TAG) { return; } foreach (XmlNode node in root.ChildNodes) { deserializeSetting(node); } SettingsLoaded?.Invoke(); } finally { loadingSettings = false; } } else { SaveSettings(); SettingsLoaded?.Invoke(); } }
private void ApplySettingsProcedure(PdfCreatorSettings settings) { _settingsManager.ApplyAndSaveSettings(settings); _settingsManager.LoadPdfCreatorSettings(); //Load settings to ensure default profile _settingsManager.SaveCurrentSettings(); //Save settings again to synch registry with current settings SettingsLoaded?.Invoke(this, new SettingsEventArgs(_settingsProvider.Settings)); }
public static bool Load() { if (!File.Exists(ConfigPath)) { Settings = new Configuration { Ranks = Rank.GetDefaultRanks() }; Logger.Log(LogType.Info, "New config file generated"); if (Save()) { return(true); } Logger.Log(LogType.Warning, "Failed to save new config file"); return(false); } try { Settings = JsonConvert.DeserializeObject <Configuration>(File.ReadAllText(ConfigPath)); SettingsLoaded?.Invoke(); return(Save()); } catch (Exception e) { Logger.Log(LogType.Error, $"Failed to load config file: {e.Message}"); Logger.Log(LogType.Debug, $"Stack Trace: {e.StackTrace}"); Settings = new Configuration(); Settings.Ranks = Rank.GetDefaultRanks(); return(false); } }
protected override void OnApply(PageApplyEventArgs e) { if (e.ApplyBehavior == ApplyKind.Apply) { // save the changes SaveSettingsToStorage(); SettingsLoaded?.Invoke(this, EventArgs.Empty); } base.OnApply(e); }
public static void Load() { try { var json = FileUtils.GetJSON(Terraria3D.Instance.DisplayName); var settings = JsonConvert.DeserializeObject <SettingsData>(json); settings.Apply(Terraria3D.Instance); SettingsLoaded?.Invoke(settings); } // If not settings file is found, no sweat. Don't do anything. catch (FileNotFoundException) { } catch (DirectoryNotFoundException) { } catch { Terraria3D.Instance.Scene.CameraDriver.ResetCameraPosition(); Main.NewText(string.Format("{0}: Could not load settings from last session.", Terraria3D.Instance.DisplayName)); } }
private void OnSettingsLoaded(EventArgs args) { SettingsLoaded?.Invoke(this, args); }
void Start() { SettingsLoaded?.Invoke(); SettingsChanged?.Invoke(); }
private void SettingsLoadedHandler(object sender, SettingsLoadedEventArgs e) { SettingsLoaded?.Invoke(sender, e); }
private void OnSettingsLoaded() { SettingsLoaded?.Invoke(); }
protected virtual void OnSettingsLoaded(EventArgs e) { SettingsLoaded?.Invoke(this, e); }