Exemplo n.º 1
0
 static Settings()
 {
     try
     {
         s_instance = Load(SettingsFile);
     }
     catch
     {
         s_instance = new Settings();
     }
 }
Exemplo n.º 2
0
        private static Settings Load(string a_settings_file)
        {
            if (!File.Exists(a_settings_file))
                return new Settings();

            var root = XDocument.Load(a_settings_file).Root;

            if (root.Name != XML_SETTINGS)
                throw new Exception();

            Settings settings = new Settings() 
            {
                Version = root.Attribute(XML_VERSION).Value,
                SeriesFilter = root.Element(XML_SERIESFILTER).Value,
                SeriesSplitterDistance = Int32.Parse(root.Element(XML_SERIESSPLITTERDISTANCE).Value),
                BookmarksSplitterDistance = Int32.Parse(root.Element(XML_BOOKMARKSSPLITTERDISTANCE).Value),
                FormState = FormState.Load(root.Element(XML_FORMSTATE)),
                PlaySoundWhenDownloaded = Boolean.Parse(root.Element(XML_PLAYSOUNDWHENDOWNLOADED).Value),
                MinimizeOnClose = Boolean.Parse(root.Element(XML_MINIMIZEONCLOSE).Value),
                ShowBaloonTips = Boolean.Parse(root.Element(XML_SHOWBALOONTIPS).Value),
                Autostart = Boolean.Parse(root.Element(XML_AUTOSTART).Value),
                CheckBookmarksPeriod = TimeSpan.Parse(root.Element(XML_CHECKBOOKMARKSPERIOD).Value),
                MangaSettings = MangaSettings.Load(root.Element(XML_MANGASETTINGS))
            };

            settings.FormState.Changed += () => settings.Save();
            settings.MangaSettings.Changed += () => settings.Save();

            return settings;
        }