diff --git a/App.config b/App.config index 4a166e8..faec5df 100644 --- a/App.config +++ b/App.config @@ -61,15 +61,16 @@ - + - + + diff --git a/App.xaml.cs b/App.xaml.cs index 1701231..4a63eea 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -1,8 +1,14 @@ using GeekDesk.Constant; +using GeekDesk.MyThread; using GeekDesk.Util; +using GeekDesk.ViewModel; +using Microsoft.Win32; using System; +using System.Diagnostics; using System.Windows; using System.Windows.Input; +using System.Windows.Interop; +using System.Windows.Media; using System.Windows.Threading; namespace GeekDesk @@ -20,10 +26,13 @@ namespace GeekDesk this.Startup += new StartupEventHandler(App_Startup); Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + SystemEvents.PowerModeChanged += OnPowerModeChanged; } + private void App_Startup(object sender, StartupEventArgs e) { + //RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly; //禁用硬件加速 mutex = new System.Threading.Mutex(true, Constants.MY_NAME, out bool ret); if (!ret) { @@ -40,6 +49,25 @@ namespace GeekDesk } } + + //电源监听 + private void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e) + { + switch (e.Mode) + { + case PowerModes.Resume: + // 系统从休眠状态唤醒 + LogUtil.WriteLog("System resumed from sleep."); + ProcessUtil.ReStartApp(); + break; + case PowerModes.Suspend: + // 系统进入休眠状态 + LogUtil.WriteLog("System is going to sleep."); + break; + } + } + + void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { e.Handled = true;//使用这一行代码告诉运行时,该异常被处理了,不再作为UnhandledException抛出了。 diff --git a/Constant/Constants.cs b/Constant/Constants.cs index 95e22be..513ddd5 100644 --- a/Constant/Constants.cs +++ b/Constant/Constants.cs @@ -22,11 +22,15 @@ namespace GeekDesk.Constant /// /// 备份文件路径 /// - public static string DATA_FILE_BAK_PATH = APP_DIR + "bak\\Data.bak"; //app备份数据文件路径 + public static string DATA_FILE_BAK_DIR_PATH = APP_DIR + "bak"; //app备份数据文件路径 + public static string DATA_FILE_TEMP_DIR_PATH = APP_DIR + "temp"; //app临时缓存文件路径 + + //public static string DATA_FILE_BAK_PATH = DATA_FILE_BAK_DIR_PATH + "\\Data.bak"; //app备份数据文件路径 + public static string PW_FILE_BAK_PATH = APP_DIR + "bak\\pw.txt"; //密码文件路径 - - public static string UUID_FILE_BAK_PATH = APP_DIR + "bak\\uuid.txt"; //密码文件路径 + + public static string UUID_FILE_BAK_PATH = APP_DIR + "bak\\uuid.txt"; //uuid文件路径 public static string LOG_FILE_PATH = APP_DIR + "logs\\log.log"; //日志文件 diff --git a/Constant/DictConst.cs b/Constant/DictConst.cs new file mode 100644 index 0000000..221600e --- /dev/null +++ b/Constant/DictConst.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GeekDesk.Constant +{ + public class DictConst + { + public static readonly Dictionary batchMenuHeaderDict = new Dictionary(); + static DictConst() { + batchMenuHeaderDict.Add(true, "取消批量操作"); + batchMenuHeaderDict.Add(false, "批量操作"); + } + } +} diff --git a/Control/Other/BGNmaeDialog.xaml b/Control/Other/BGNmaeDialog.xaml new file mode 100644 index 0000000..772ea71 --- /dev/null +++ b/Control/Other/BGNmaeDialog.xaml @@ -0,0 +1,34 @@ + + + + + + + +