public Settings() { mainSettings = new MainSettings() { Jump = 10, Volume = 100, IsMute = false, AutoPlay = false, AutoPlayTime = 15, Rate = 1, AutoAudio = true, AutoSubtitle = true, HardwareAcceleration = true, SubtitleDisable = false }; }
public void Load() { if (!File.Exists(filePath)) { return; } try { using Stream fStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); mainSettings = (MainSettings)XmlFormatter.Deserialize(fStream); } catch (Exception ex) { try { File.Delete(filePath); Jump = 10; Volume = 100; IsMute = false; AutoPlay = false; AutoPlayTime = 15; Rate = 1; AutoAudio = true; AutoSubtitle = true; Acceleration = true; SubtitleDisable = false; using Stream fStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); XmlFormatter.Serialize(fStream, mainSettings); NeedsSaving = false; CMBox.Show("Error", "Couldn't load settings and file was reset, Error: " + ex.Message, Style.Error, Buttons.OK, ex.ToString()); } catch (Exception e) { CMBox.Show("Error", "Couldn't settings or reset recents, Error: " + e.Message, Style.Error, Buttons.OK, ex.ToString()); } } }