/// <summary> /// 主程式關閉時保存設定 /// </summary> /// <param name="sender">委託</param> /// <param name="e">事件</param> private void Window_Closed(object sender, EventArgs e) { App.Set_rb_Answer_Eng = rb_Answer_Eng.IsChecked.ToString(); App.Set_rb_Order = rb_Order.IsChecked.ToString(); if (rb_fmt_xlsx.IsChecked == true) { App.Set_rb_FileCovertExt = ".xlxs"; } else if (rb_fmt_txt.IsChecked == true) { App.Set_rb_FileCovertExt = ".txt"; } else { App.Set_rb_FileCovertExt = ".db"; } App.Set_tb_Again_times = tb_Again_times.Text; App.Set_tb_pfclim = tb_pfclim.Text; App.Set_cb_AllowEnter = cb_AllowEnter.IsChecked.ToString(); App.Set_cb_pfclim = cb_pfclim.IsChecked.ToString(); // 保存設定 LoadSetting.SaveSetting(); // 清理暫存 if (Directory.Exists("cache")) { Directory.Delete("cache", true); } }
public MainWindow() { InitializeComponent(); WindowStartupLocation = WindowStartupLocation.CenterScreen; //居中顯示 LoadSetting.Init_Setting(); //讀取設定 tb_Again_times.Text = App.Set_tb_Again_times; tb_pfclim.Text = App.Set_tb_pfclim; if (App.Set_rb_FileCovertExt.Equals(".xlsx")) { rb_fmt_xlsx.IsChecked = true; } else if (App.Set_rb_FileCovertExt.Equals(".txt")) { rb_fmt_txt.IsChecked = true; } try { if (Convert.ToBoolean(App.Set_rb_Answer_Eng) != true) { rb_Answer_Cht.IsChecked = true; } if (Convert.ToBoolean(App.Set_rb_Order) != true) { rb_Random.IsChecked = true; } if (Convert.ToBoolean(App.Set_cb_AllowEnter) != true) { cb_AllowEnter.IsChecked = false; } if (Convert.ToBoolean(App.Set_cb_pfclim) != true) { cb_pfclim.IsChecked = false; } } catch { File.Delete(Path.Combine(App.Root, "UserSetting.ini")); System.Windows.MessageBox.Show("設定讀取失敗" + Environment.NewLine + "執行部分設定初始化...", "異常"); } WebServices.CheckVersion(App.CurrentVersion); }