public MainWindow() { try { LocalizationManager.Manager = new LocalizationManager { ResourceManager = GridViewResources.ResourceManager }; InitializeComponent(); t1.DataContext = callDuration; Settheme settheme1 = new Settheme(); StyleManager.SetTheme(this, GetMyTheme("Crystal")); settheme1.setTheme(settheme1.setLightOrDark("Crystal")); StyleManager.ApplicationTheme = GetMyTheme("Crystal"); timer.Elapsed += refreshTime; timer.AutoReset = true; //设置是执行一次(false)还是一直执行(true); timer.Enabled = true; //是否执行System.Timers.Timer.Elapsed事件; 数据库处理 sjkcl = new 数据库处理(); adminCodes = sjkcl.获取实况站点范围(0, 0, 0); callDuration.Text = $"{DateTime.Now} 启动呼和浩特市气象资料数据库"; XmlConfig util = new XmlConfig(Environment.CurrentDirectory + @"\config\基本信息.xml"); bool sfrk = true; bool znls = true; try { sfrk = Convert.ToBoolean(util.Read("SFRK")); sfrkbs = sfrk; znls = Convert.ToBoolean(util.Read("ZNSFRK")); znsfrkbs = znls; } catch { } switch1.IsChecked = sfrk; switch2.IsChecked = znls; switch1.Content = sfrk ? "是" : "否"; switch2.Content = znls ? "是" : "否"; } catch (Exception e) { callDuration.Text = $"{DateTime.Now} 启动失败:{e.Message}"; } }