private void WaterS_Load(object sender, EventArgs e) { Application_Setting.ApplicationSetting setting = Application_Setting.ApplicationSetting.LoadSetting(); if (setting != null) { numericUpDown1.Value = setting.notiStatus.drinkTime; } }
public static void SaveSeting(ApplicationSetting setting) { string data = JsonConvert.SerializeObject(setting); if (!Directory.Exists("data")) { Directory.CreateDirectory("data"); } File.WriteAllText(Application.StartupPath + "/data/setting.json", data); }
private void loadALL() { works = Time_Management.Work.LoadJson(); if (works == null) { works = new List <Time_Management.Work>(); } setting = Application_Setting.ApplicationSetting.LoadSetting(); if (setting == null) { setting = new Application_Setting.ApplicationSetting(); } }
public static ApplicationSetting LoadSetting() { ApplicationSetting setting = null; if (!File.Exists(Application.StartupPath + "/data/setting.json")) { return(setting); } string data = File.ReadAllText(Application.StartupPath + "/data/setting.json"); setting = JsonConvert.DeserializeObject <ApplicationSetting>(data); return(setting); }
public SettingApp() { InitializeComponent(); setting = Application_Setting.ApplicationSetting.LoadSetting(); if (setting == null) { setting = new Application_Setting.ApplicationSetting(); } checkBox1.Checked = setting.notiStatus.BreakE; checkBox2.Checked = setting.notiStatus.taskE; checkBox3.Checked = setting.notiStatus.drinkE; checkBox4.Checked = setting.silenceMode; checkBox5.Checked = setting.isAutoStart; }
private void button1_Click(object sender, EventArgs e) { if (numericUpDown1.Value > 300) { MessageBox.Show("Thời gian vượt quá cho phép!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Information); } Application_Setting.ApplicationSetting setting = Application_Setting.ApplicationSetting.LoadSetting(); if (setting == null) { setting = new Application_Setting.ApplicationSetting(); } setting.notiStatus.drinkTime = int.Parse(numericUpDown1.Value.ToString()); Application_Setting.ApplicationSetting.SaveSeting(setting); MessageBox.Show("Thiết lập thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }