public static void saveSettings(Settings settings) { if (!Directory.Exists(Settings.SaveDirPath) || !File.Exists(SettingsSavePath)) { Directory.CreateDirectory(Settings.SaveDirPath); } XmlSerializer serializer = new XmlSerializer(typeof(Settings)); using (XmlTextWriter writer = new XmlTextWriter(SettingsSavePath, Encoding.Unicode)) { writer.Formatting = Formatting.Indented; serializer.Serialize(writer, settings); } }
public static Settings tryLoad() { Settings settings = null; if(Directory.Exists(SaveDirPath) && File.Exists(SettingsSavePath)) { XmlSerializer serializer = new XmlSerializer(typeof(Settings)); using (XmlReader reader = new XmlTextReader(SettingsSavePath)) { settings = serializer.Deserialize(reader) as Settings; } if (settings.IntervalMinutes < 10) settings.IntervalMinutes = 10; } else settings = new Settings(); return settings; }
private void GUIMainWindow_Load(object sender, EventArgs e) { settings = Settings.tryLoad(); getter = new PikabuGetter(settings); getter.tryLoadComments(); table = new DataTable(); table.Columns.Add("Плюсы"); table.Columns.Add("Автор"); table.Columns.Add("Комментарий"); table.Columns.Add("Название поста"); commentsDataGridView.DataSource = table; resetTimer(); mainTimer.Start(); }
public GUISettings(Settings settings) { InitializeComponent(); this.settings = settings; }
public PikabuGetter(Settings settings) { this.comments = new List<PikabuComment>(); this.settings = settings; }