增加Esc退出窗口

This commit is contained in:
liufei
2021-12-20 09:39:27 +08:00
parent 3483bf88c2
commit e6a95c4668
19 changed files with 136 additions and 75 deletions

View File

@@ -3,6 +3,7 @@ using GeekDesk.Constant;
using GeekDesk.Control;
using GeekDesk.Control.UserControls.Config;
using GeekDesk.Control.Windows;
using GeekDesk.Interface;
using GeekDesk.Task;
using GeekDesk.Thread;
using GeekDesk.Util;
@@ -29,13 +30,10 @@ namespace GeekDesk
/// MainWindow.xaml 的交互逻辑
/// </summary>
///
public partial class MainWindow : Window
public partial class MainWindow : Window, IWindowCommon
{
//public IKeyboardMouseEvents m_GlobalHook = Hook.GlobalEvents();
public static AppData appData = CommonCode.GetAppDataByFile();
//public static ToDoInfoWindow toDoInfoWindow = (ToDoInfoWindow)ToDoInfoWindow.GetThis();
public static ToDoInfoWindow toDoInfoWindow;
public static int hotKeyId = -1;
public static int toDoHotKeyId = -1;
@@ -95,6 +93,7 @@ namespace GeekDesk
ShowApp();
}
//给任务栏图标一个名字
BarIcon.Text = Constants.MY_NAME;
//注册热键
@@ -108,36 +107,12 @@ namespace GeekDesk
}
//注册鼠标中键监听事件
//m_GlobalHook.MouseUpExt += M_GlobalHook_MouseUpExt;
MouseHookThread.MiddleHook();
//更新线程开启 检测更新
UpdateThread.Update();
}
/// <summary>
/// 鼠标中键呼出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//private void M_GlobalHook_MouseUpExt(object sender, System.Windows.Forms.MouseEventArgs e)
//{
// if (appData.AppConfig.MouseMiddleShow && e.Button == System.Windows.Forms.MouseButtons.Middle)
// {
// if (MotionControl.hotkeyFinished)
// {
// if (mainWindow.Visibility == Visibility.Collapsed || mainWindow.Opacity == 0)
// {
// ShowApp();
// }
// else
// {
// HideApp();
// }
// }
// }
//}
/// <summary>
/// 注册当前窗口的热键
/// </summary>
@@ -283,10 +258,6 @@ namespace GeekDesk
/// <param name="e"></param>
private void DragMove(object sender, MouseEventArgs e)
{
//if (e.LeftButton == MouseButtonState.Pressed)
//{
// this.DragMove();
//}
if (e.LeftButton == MouseButtonState.Pressed)
{
@@ -303,7 +274,6 @@ namespace GeekDesk
(When clicking the drag area, make the window follow) */
DragMove();
if (this.ResizeMode != windowMode)
{
this.ResizeMode = windowMode;
@@ -526,6 +496,15 @@ namespace GeekDesk
{
appData.AppConfig.ShowBarIcon = false;
}
public void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
HideApp();
}
}
}