/// <summary> /// 程序启动 /// </summary> /// <param name="e"></param> protected override void OnStartup(StartupEventArgs e) { #region 是否只能运行一个APP bool ret; mutex = new System.Threading.Mutex(true, "StikyNotesAPP", out ret); if (!ret) { MessageBox.Show("程序已经运行了"); Environment.Exit(0); } #endregion Logger.Log().Info("程序启动"); /// 将全局异常保存到文件目录下 Current.DispatcherUnhandledException += App_OnDispatcherUnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; //Messenger.Default.Register<SaveMessage>(this, SaveDataMessage); var systemtray = SystemTray.Instance; var programData = XMLHelper.DecodeXML <ProgramData>(ConstData.SaveSettingDataName); if (programData != null) { var windowsDatas = programData.Datas; ProgramData.Instance.IsWindowTopMost = programData.IsWindowTopMost; ProgramData.Instance.IsStartUpWithSystem = programData.IsStartUpWithSystem; ProgramData.Instance.CurrenTheme = programData.CurrenTheme; ProgramData.Instance.ShowAllHotKey = programData.ShowAllHotKey; ProgramData.Instance.IsAutoCheckUpdate = programData.IsAutoCheckUpdate; ThemeAssist.ChangeTheme(programData.CurrenTheme); //有创建过的窗口 if (windowsDatas.Count > 0) { for (int i = 0; i < windowsDatas.Count; i++) { OpenNewWindow(windowsDatas[i]); } } else//以前的窗口都被删掉了 { OpenNewWindow(); } } //没有创建过的窗口 else { OpenNewWindow(); } IsInited = false; TimerUtil = new TimerUtil(SaveDataAction); new Task(CheckUpdate).Start(); }
/// <summary> /// 程序启动 /// </summary> /// <param name="e"></param> protected override void OnStartup(StartupEventArgs e) { bool ret; mutex = new System.Threading.Mutex(true, "StikyNotesAPP", out ret); if (!ret) { MessageBox.Show("程序已经运行了"); Environment.Exit(0); } // base.OnStartup(e); Messenger.Default.Register <SaveMessage>(this, SaveDataMessage); var systemtray = SystemTray.Instance; var programData = XMLHelper.DecodeXML <ProgramData>(ConstData.SaveSettingDataName); if (programData != null) { var windowsDatas = programData.Datas; ProgramData.Instance.IsWindowTopMost = programData.IsWindowTopMost; ProgramData.Instance.IsStartUpWithSystem = programData.IsStartUpWithSystem; ProgramData.Instance.CurrenTheme = programData.CurrenTheme; ProgramData.Instance.ShowAllHotKey = programData.ShowAllHotKey; ThemeAssist.ChangeTheme(programData.CurrenTheme); //有创建过的窗口 if (windowsDatas.Count > 0) { for (int i = 0; i < windowsDatas.Count; i++) { OpenNewWindow(windowsDatas[i]); } } else//以前的窗口都被删掉了 { OpenNewWindow(); } } //没有创建过的窗口 else { OpenNewWindow(); } IsInited = false; TimerUtil = new TimerUtil(SaveDataAction); }
/// <summary> /// 选择主题发生改变 /// </summary> /// <param name="obj"></param> private void SelectionChangedMethod(SelectionChangedEventArgs e) { var content = e.AddedItems[0] as ComboBoxItem; switch (content.Content.ToString()) { case "橘黄色": ThemeAssist.ChangeTheme(Themes.Orange); break; case "蓝色": ThemeAssist.ChangeTheme(Themes.Blue); break; case "灰色": ThemeAssist.ChangeTheme(Themes.Gray); break; } }