private void Mainform_Load(object sender, EventArgs e) { _settings = Preferences.Load(); cbSource.Items.Add(Keys.XButton1.ToString()); cbSource.Items.Add(Keys.XButton2.ToString()); FillWithKeys(cbTarget); RefreshListView(-1); Mouse.MouseButtonInputChanged += MouseButtonOnMouseButtonInputChanged; Mouse.HookMouse(); _watcher.ProcessStarted += WatcherOnProcessStarted; _watcher.ProcessFinished += WatcherOnProcessFinished; _watcher.Hook(); }
public static SettingEntries Load() { SettingEntries settings = new SettingEntries(); if (!File.Exists(Constants.SettingsFile)) { return(settings); } XmlSerializer serial = new XmlSerializer(settings.GetType()); settings = (SettingEntries)serial.Deserialize(new StreamReader(Constants.SettingsFile)); return(settings); }
public static bool Write(SettingEntries settings) { bool result = false; try { XmlSerializer serial = new XmlSerializer(settings.GetType()); serial.Serialize(new StreamWriter(Constants.SettingsFile), settings); result = true; } catch (IOException) { // TODO log or whatever } catch (Exception) { // TODO: Same } return(result); }