Пример #1
0
 public SettingsViewModel()
 {
     _settings = MouseSettings.ReadSettings() ?? new MouseSettings();
 }
Пример #2
0
 /// <summary>
 /// Чтение файлов с языками
 /// </summary>
 private static void ReadLanguages(MouseSettings ms)
 {
     string cult;
     foreach (var item in Directory.GetFiles("Languages", "lang.*.xaml")) {
         cult = item.Substring(item.IndexOf('.') + 1);
         cult = cult.Substring(0, cult.LastIndexOf('.'));
         ms.Languages.Add(new CultureInfo(cult));
     }
 }
Пример #3
0
 /// <summary>
 /// Чтение файла с настройками
 /// </summary>
 public static MouseSettings ReadSettings()
 {
     MouseSettings ms = null;
     if (File.Exists(SETTINGS_FILENAME)) {
         using (TextReader tr = new StreamReader(SETTINGS_FILENAME)) {
             XmlSerializer xs = new XmlSerializer(typeof(MouseSettings));
             ms = (MouseSettings)xs.Deserialize(tr);
             ms.CheckRegistry();
             if (ms.AutoStart) {
                 Messenger.Default.Send(new NotificationMessage<MouseSettings>(ms, string.Empty));
             }
         }
     }
     else ms = new MouseSettings();
     ms.Languages = new List<CultureInfo>();
     ReadLanguages(ms);
     if (ms.SelectedLanguageName == null) {
         ms.SelectedLanguageName = "en-US";
     }
     ms.SelectedLanguage = ms.Languages.Find(l => l.Name == ms.SelectedLanguageName);
     return ms;
 }
Пример #4
0
 public static void Save(MouseSettings ms)
 {
     using (TextWriter tw = new StreamWriter(SETTINGS_FILENAME)) {
         XmlSerializer xs = new XmlSerializer(ms.GetType());
         xs.Serialize(tw, ms);
     }
 }