private void btnOK_Click(object sender, RoutedEventArgs e) { if (this.btnOK.Content.ToString() == "确定") { this.Close(); return; } Sys.AutoStartup((bool)this.chkAutoRun.IsChecked); Entity.App.MinToTray = (this.chkMinToTray.IsChecked == true); Entity.App.LockMinute = Convert.ToInt32(this.cboMinute.Text); _xml.SetXmlNodeValue("Configuration/LockMinute", this.cboMinute.Text); _xml.SetXmlNodeValue("Configuration/SaveLog", this.chkSaveLog.IsChecked == true ? "1" : "0"); Entity.App.SaveLog = this.chkSaveLog.IsChecked == true; try { string path = this.tbxBgImg.Text.Trim(); if (!System.IO.File.Exists(path) || (!path.ToLower().EndsWith(".jpg") && !path.ToLower().EndsWith(".png"))) { this.tbxBgImg.Text = ""; path = ""; } _xml.SetXmlNodeValue("Configuration/AppBgImg", path); path = this.tbxLockBgImg.Text.Trim(); if (!System.IO.File.Exists(path) || (!path.ToLower().EndsWith(".jpg") && !path.ToLower().EndsWith(".png"))) { this.tbxLockBgImg.Text = ""; path = ""; } _xml.SetXmlNodeValue("Configuration/LockBgImg", path); _xml.SetXmlNodeValue("Configuration/MinToTray", Entity.App.MinToTray ? "1" : "0"); _xml.Save(); //保存城市信息 this._area = (Entity.Area) this.chkCity.SelectedItem; if (this._area != null) { _balWeather.SaveCurrentArea(this._area); } MessageBox.Show("保存成功,重启后生效!", "提示", MessageBoxButton.OK, MessageBoxImage.Asterisk); } catch (Exception ex) { Log.SaveLog("Config btnOK_Click", ex.ToString()); MessageBox.Show("保存失败!", "警告", MessageBoxButton.OK, MessageBoxImage.Error); } }