/// <summary> /// Obtain configuration from a file. If the file name is not supplied the the default /// path of Constants.Data_DIR\galnetmonitor.json is used /// </summary> public static GalnetConfiguration FromFile(string filename = null) { if (filename == null) { filename = Constants.DATA_DIR + @"\galnetmonitor.json"; } GalnetConfiguration configuration = new GalnetConfiguration(); if (File.Exists(filename)) { string data = Files.Read(filename); if (data != null) { try { configuration = JsonConvert.DeserializeObject <GalnetConfiguration>(data); } catch (Exception ex) { Logging.Debug("Failed to read Galnet monitor configuration", ex); } } } if (configuration == null) { configuration = new GalnetConfiguration(); } configuration.path = filename; return(configuration); }
private void galnetAlwaysOnUnchecked(object sender, RoutedEventArgs e) { GalnetConfiguration configuration = GalnetConfiguration.FromFile(); configuration.galnetAlwaysOn = galnetAlwaysOn.IsChecked.Value; configuration.ToFile(); galnetMonitor()?.Reload(); }
public ConfigurationWindow() { InitializeComponent(); monitor = ((GalnetMonitor)EDDI.Instance.ObtainMonitor("Galnet monitor")); GalnetConfiguration configuration = GalnetConfiguration.FromFile(); languageComboBox.SelectedValue = configuration.language; }
public ConfigurationWindow() { InitializeComponent(); GalnetConfiguration configuration = GalnetConfiguration.FromFile(); Dictionary <string, string> langs = galnetMonitor()?.GetGalnetLocales(); languageComboBox.ItemsSource = langs.Keys; languageComboBox.SelectedValue = configuration.language; galnetAlwaysOn.IsChecked = configuration.galnetAlwaysOn; }
public GalnetMonitor() { // Remove the old configuration file if it still exists if (File.Exists(Constants.DATA_DIR + @"\galnet")) { try { File.Delete(Constants.DATA_DIR + @"\galnet"); } catch { } } configuration = GalnetConfiguration.FromFile(); }
private void onLanguageChanged(object sender, SelectionChangedEventArgs e) { string language = (string)((ComboBox)e.Source).SelectedValue; GalnetConfiguration configuration = GalnetConfiguration.FromFile(); if (language != null && language != configuration.language) { // If the language changes we clear out the old articles GalnetSqLiteRepository.Instance.DeleteNews(); configuration.lastuuid = null; configuration.language = language; configuration.ToFile(); galnetMonitor()?.Reload(); } }
public void Reload() { configuration = GalnetConfiguration.FromFile(); }