public static void Load() { if (File.Exists(SaveFile)) { string text; try { text = File.ReadAllText(SaveFile); } catch (Exception e) { MessageBox.Show(LocalizationUtils.GetString("savedata_cant_read", "Can't read profiles file!") + "\n" + e.Message, LocalizationUtils.GetString("error", "Error")); return; } try { Profiles = JsonConvert.DeserializeObject <ProfilesData>(text); } catch (Exception e) { MessageBox.Show(LocalizationUtils.GetString("savedata_cant_parse", "Can't parse profiles file!") + "\n" + e.Message, LocalizationUtils.GetString("error", "Error")); return; } } }
public static void Save() { try { File.WriteAllText(SaveFile, JsonConvert.SerializeObject(Profiles, Formatting.Indented)); } catch (Exception e) { MessageBox.Show(LocalizationUtils.GetString("savedata_cant_write", "Can't write profiles file!") + "\n" + e.Message, LocalizationUtils.GetString("error", "Error")); } }
private void btn_remove_profile_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show(string.Format(LocalizationUtils.GetString("mainform_confirm_remove_text", "Do you really want to remove profile {0}?"), (string)cb_profiles.SelectedItem), LocalizationUtils.GetString("mainform_confirm_remove_title", "Please confirm..."), MessageBoxButton.YesNo) == MessageBoxResult.Yes) { SaveData.Profiles.RemoveProfile((string)cb_profiles.SelectedItem); UpdateProfilesList(); UpdateCards(); } }
public MainWindow() { InitializeComponent(); HeroesData.Load(); SaveData.Load(); //SaveData.Save(); if (HeroesData.Heroes.Count != 0) { LoadHeroesList(); } else { MessageBox.Show(LocalizationUtils.GetString("mainform_heroes_json_error", "Heroes.json not found or corrupted.\nTry to reinstall this program."), LocalizationUtils.GetString("error", "Error") ); } UpdateProfilesList(); SortHeroCards(); UpdateLocale(); SettingsData.Settings.OnLocaleChanged += Settings_OnLocaleChanged; if (SettingsData.Settings.MainWindowTop != null) { Top = (int)SettingsData.Settings.MainWindowTop; } if (SettingsData.Settings.MainWindowTop != null) { Left = (int)SettingsData.Settings.MainWindowLeft; } if (SettingsData.Settings.MainWindowWidth != null) { Width = (int)SettingsData.Settings.MainWindowWidth; } if (SettingsData.Settings.MainWindowHeight != null) { Height = (int)SettingsData.Settings.MainWindowHeight; } WindowState = SettingsData.Settings.MainWindowMaximized ? WindowState.Maximized : WindowState.Normal; }
public void UpdateLocale() { btn_add_profile.Content = LocalizationUtils.GetString("mainform_add_profile", "Add"); btn_remove_profile.Content = LocalizationUtils.GetString("mainform_remove_profile", "Remove"); l_about_app.Content = LocalizationUtils.GetString("mainform_about_this_app", "About this app"); }
public void UpdateLocale() { Title = LocalizationUtils.GetString("selectlang_title", "Select Language"); btn_accept.Content = LocalizationUtils.GetString("apply", "Apply"); cb_show_only_available.Content = LocalizationUtils.GetString("selectlang_show_only", "Show only available locales"); }
public void UpdateLocale() { Title = LocalizationUtils.GetString("add_profile_title", "Add New Profile"); l_profile_name.Content = LocalizationUtils.GetString("add_profile_label", "New profile name:"); btn_ok.Content = LocalizationUtils.GetString("add_profile_button", "Add Profile"); }