public SettingsModel ReloadSettings()
 {
     SettingsModel settings = new SettingsModel();
     TextReader reader;
     string defaultPath = AppDomain.CurrentDomain.BaseDirectory + "\\cfg\\default.conf.json";
     string userPath = AppDomain.CurrentDomain.BaseDirectory + "\\cfg\\user.conf.json";
     string movedMdPath = AppDomain.CurrentDomain.BaseDirectory + "\\moved.md";
     string movedHostsPath = Path.Combine(
         Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
         ".psmoveapi\\moved_hosts.txt");
     if (File.Exists(userPath))
     {
         reader = new StreamReader(userPath);
         string fileContents = reader.ReadToEnd();
         settings = JsonConvert.DeserializeObject<SettingsModel>(fileContents);
         reader.Close();
     }
     else if (File.Exists(defaultPath))
     {
         reader = new StreamReader(defaultPath);
         string fileContents = reader.ReadToEnd();
         settings = JsonConvert.DeserializeObject<SettingsModel>(fileContents);
         reader.Close();
     }
     if (File.Exists(movedHostsPath))
     {
         settings.MovedHostsFile = File.ReadAllText(movedHostsPath);
         //string[] lines = File.ReadAllLines(movedHostsPath);
         //foreach (string line in lines)
         //{
         //    settings.MovedHostsFile += line + "&#10;";
         //}
     }
     if (File.Exists(movedMdPath))
     {
         settings.MovedHostsWaterMark = File.ReadAllText(movedMdPath);
     }
     return settings;
 }
        public SettingsViewModel(JsonSettingsService jsonSettingsService)
        {
            Header = "Settings";
            Settings = new SettingsModel();
            SettingsService = jsonSettingsService ?? new JsonSettingsService();

            // create accent color menu items for the demo
            AccentColors = ThemeManager.Accents
                                       .Select(a => new AccentColorMenuData
                                       {
                                           Name = a.Name,
                                           ColorBrush = a.Resources["AccentColorBrush"] as Brush })
                                       .ToList();

            // create metro theme color menu items for the demo
            AppThemes = ThemeManager.AppThemes
                                    .Select(a => new AppThemeMenuData
                                    {
                                        Name = a.Name,
                                        BorderColorBrush = a.Resources["BlackColorBrush"] as Brush,
                                        ColorBrush = a.Resources["WhiteColorBrush"] as Brush })
                                    .ToList();
            Settings = SettingsService.ReloadSettings();
        }
        public void SaveSettings(SettingsModel settings)
        {
            TextWriter writer = null;
            try
            {
                string json = JsonConvert.SerializeObject(settings, Formatting.Indented);
                writer = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\cfg\\user.conf.json", false);
                writer.Write(json);
            }
            finally
            {
                if (writer != null)
                    writer.Close();
            }

            File.WriteAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".psmoveapi\\moved_hosts.txt"),
                settings.MovedHostsFile);
        }