Ver código fonte

增加Esc退出窗口

liufei 3 anos atrás
pai
commit
e6a95c4668

+ 1 - 1
App.config

@@ -28,7 +28,7 @@
     </assemblyBinding>
   </runtime>
   <appSettings>
-    <add key="Version" value="2.3.20" />
+    <add key="Version" value="2.4.10" />
     <add key="GitHubUrl" value="https://github.com/Demo-Liu/GeekDesk" />
     <add key="GiteeUrl" value="https://gitee.com/demo_liu/GeekDesk/tree/master" />
     <add key="GitHubUpdateUrl" value="https://demo-liu.github.io/GeekDesk/Update.json" />

+ 1 - 1
Constant/Constants.cs

@@ -11,7 +11,7 @@ namespace GeekDesk.Constant
         public static string APP_DIR = AppDomain.CurrentDomain.BaseDirectory.Trim();
 
         // 是否为开发模式
-        public static bool DEV = false;
+        public static bool DEV = true;
 
         public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk";
 

+ 5 - 4
Control/UserControls/PannelCard/LeftCardControl.xaml.cs

@@ -28,11 +28,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
             if (appData.AppConfig.SelectedMenuIndex >= appData.MenuList.Count || appData.AppConfig.SelectedMenuIndex == -1)
             {
                 appData.AppConfig.SelectedMenuIcons = appData.MenuList[0].IconList;
-            } else
+            }
+            else
             {
                 appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
             }
-
         }
 
         DelegateCommand<int[]> _swap;
@@ -207,8 +207,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
             //设置对应菜单的图标列表
             if (MenuListBox.SelectedIndex == -1)
             {
-                appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.MenuList.Count-1].IconList;
-            } else
+                appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.MenuList.Count - 1].IconList;
+            }
+            else
             {
                 appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList;
             }

+ 2 - 0
Control/Windows/ConfigWindow.xaml

@@ -15,6 +15,8 @@
            AllowsTransparency="True"
            Background="#00FFFFFF" ShowInTaskbar="False"
            BorderThickness="0"
+           Focusable="True"
+           KeyDown="OnKeyDown"
            >
 
     <Grid Margin="30">

+ 11 - 1
Control/Windows/ConfigWindow.xaml.cs

@@ -2,6 +2,7 @@
 using GeekDesk.Constant;
 using GeekDesk.Control.UserControls;
 using GeekDesk.Control.UserControls.Config;
+using GeekDesk.Interface;
 using GeekDesk.Util;
 using GeekDesk.ViewModel;
 using HandyControl.Controls;
@@ -15,7 +16,7 @@ namespace GeekDesk.Control.Windows
     /// <summary>
     /// ConfigDialog.xaml 的交互逻辑
     /// </summary>
-    public partial class ConfigWindow
+    public partial class ConfigWindow : IWindowCommon
     {
         private static readonly AboutControl about = new AboutControl();
         private static readonly ThemeControl theme = new ThemeControl();
@@ -87,6 +88,15 @@ namespace GeekDesk.Control.Windows
                 window = new ConfigWindow(appConfig, mainWindow);
             }
             window.Show();
+            Keyboard.Focus(window);
+        }
+
+        public void OnKeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.Key == Key.Escape)
+            {
+                this.Close();
+            }
         }
     }
 }

+ 24 - 20
Control/Windows/IconfontWindow.xaml

@@ -14,6 +14,8 @@
         AllowsTransparency="True"
         Background="Transparent" ShowInTaskbar="False"
         BorderThickness="0"
+        Focusable="True"
+        KeyDown="OnKeyDown"
         >
 
     <Window.Resources>
@@ -39,7 +41,7 @@
             <DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
                               RenderingBias="Quality" ShadowDepth="2"/>
         </Grid.Effect>
-        <Border MouseDown="DragMove" Style="{StaticResource BorderBG}">
+        <Border MouseDown="DragMove" Style="{StaticResource BorderBG}"  hc:Dialog.Token="IconUrlDialog">
             <!--<Border.Background>
                 --><!--<SolidColorBrush Color="AliceBlue" Opacity="0.9"/>--><!--
                 <LinearGradientBrush Opacity="0.97">
@@ -47,9 +49,10 @@
                     <GradientStop Color="#97D282" Offset="1"/>
                 </LinearGradientBrush>
             </Border.Background>-->
-            <Grid MouseDown="DragMove">
-                <TextBox x:Name="CheckSettingUrl" Visibility="Collapsed" Text="{Binding IsSettingUrl}" TextChanged="CheckSettingUrl_TextChanged"/>
-                <hc:TabControl x:Name="MyTabControl" 
+            <hc:DialogContainer>
+                <Grid MouseDown="DragMove">
+                    <TextBox x:Name="CheckSettingUrl" Visibility="Collapsed" Text="{Binding IsSettingUrl}" TextChanged="CheckSettingUrl_TextChanged"/>
+                    <hc:TabControl x:Name="MyTabControl" 
                                IsAnimationEnabled="True" 
                                SelectionChanged="TabControl_SelectionChanged" 
                                ShowContextMenu="True"  
@@ -58,24 +61,25 @@
                                Height="350" 
                                VerticalAlignment="Top"
                                Style="{StaticResource HcTabControl}">
-                    <hc:TabItem Tag="System"  IsSelected="True" Header="系统图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource SystemIcon}" Style="{StaticResource TabTitle}">
-                        <hc:SimplePanel>
-                            <uc:IconPannel x:Name="SystemIcon"/>
-                        </hc:SimplePanel>
-                    </hc:TabItem>
-                    <hc:TabItem Tag="Custom" Header="自定义图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CustomIcon}" Style="{StaticResource TabTitle}">
-                        <hc:SimplePanel>
-                            <uc:IconPannel x:Name="CustomIcon"/>
-                            <hc:LoadingCircle x:Name="LoadingEle"/>
-                        </hc:SimplePanel>
-                    </hc:TabItem>
-                </hc:TabControl>
+                        <hc:TabItem Tag="System"  IsSelected="True" Header="系统图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource SystemIcon}" Style="{StaticResource TabTitle}">
+                            <hc:SimplePanel>
+                                <uc:IconPannel x:Name="SystemIcon"/>
+                            </hc:SimplePanel>
+                        </hc:TabItem>
+                        <hc:TabItem Tag="Custom" Header="自定义图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CustomIcon}" Style="{StaticResource TabTitle}">
+                            <hc:SimplePanel>
+                                <uc:IconPannel x:Name="CustomIcon"/>
+                                <hc:LoadingCircle x:Name="LoadingEle"/>
+                            </hc:SimplePanel>
+                        </hc:TabItem>
+                    </hc:TabControl>
 
 
-                <Button Content="取消" Click="Close_Click" Margin="391,397.5,163,22.5"/>
-                <Button Content="自定义设置" Click="CustomButton_Click" IsEnabled="False" Name="CustomButton" Style="{StaticResource Btn1}" Margin="447,397.5,71,22.5"/>
-                <Button Content="确定" Click="Confirm_Click" Style="{StaticResource Btn1}" Margin="534,397.5,20,22.5" />
-            </Grid>
+                    <Button Content="取消" Click="Close_Click" Margin="391,397.5,163,22.5"/>
+                    <Button Content="自定义设置" Click="CustomButton_Click" IsEnabled="False" Name="CustomButton" Style="{StaticResource Btn1}" Margin="447,397.5,71,22.5"/>
+                    <Button Content="确定" Click="Confirm_Click" Style="{StaticResource Btn1}" Margin="534,397.5,20,22.5" />
+                </Grid>
+            </hc:DialogContainer>
         </Border>
     </Grid>
 

+ 11 - 2
Control/Windows/IconfontWindow.xaml.cs

@@ -1,4 +1,5 @@
 using GeekDesk.Control.Other;
+using GeekDesk.Interface;
 using GeekDesk.Util;
 using GeekDesk.ViewModel;
 
@@ -17,7 +18,7 @@ namespace GeekDesk.Control.Windows
     /// <summary>
     /// IconfontWindow.xaml 的交互逻辑
     /// </summary>
-    public partial class IconfontWindow : Window
+    public partial class IconfontWindow : Window, IWindowCommon
     {
         private static AppConfig appConfig = MainWindow.appData.AppConfig;
         private static MenuInfo menuInfo;
@@ -71,7 +72,7 @@ namespace GeekDesk.Control.Windows
                     {
                         LoadingEle.Visibility = Visibility.Visible;
                         CustomIcon.Visibility = Visibility.Collapsed;
-                        HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig));
+                        HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig), "IconUrlDialog");
                     } else
                     {
                         if (customIcons == null)
@@ -132,6 +133,7 @@ namespace GeekDesk.Control.Windows
                 window = new IconfontWindow(listInfo, menuInfo);
             }
             window.Show();
+            Keyboard.Focus(window);
             ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
         }
 
@@ -172,6 +174,13 @@ namespace GeekDesk.Control.Windows
             }
         }
 
+        public void OnKeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.Key == Key.Escape)
+            {
+                this.Close();
+            }
+        }
 
         public class IconfontViewModel : INotifyPropertyChanged
         {

+ 4 - 1
Control/Windows/ToDoInfoWindow.xaml

@@ -11,9 +11,12 @@
            Height="450" 
            Width="510" 
            WindowStyle="None"
+           Title=""
            AllowsTransparency="True"
            Background="Transparent" ShowInTaskbar="False"
-        >
+           Focusable="True"
+           KeyDown="OnKeyDown"
+            >
     <Window.Resources>
         <cvt:TodoTaskExecConvert x:Key="TodoTaskExecConvert"/>
     </Window.Resources>

+ 12 - 1
Control/Windows/ToDoInfoWindow.xaml.cs

@@ -1,4 +1,5 @@
 using GeekDesk.Constant;
+using GeekDesk.Interface;
 using GeekDesk.Util;
 using GeekDesk.ViewModel;
 using HandyControl.Controls;
@@ -22,7 +23,7 @@ namespace GeekDesk.Control.Windows
     /// <summary>
     /// BacklogInfoWindow.xaml 的交互逻辑
     /// </summary>
-    public partial class ToDoInfoWindow
+    public partial class ToDoInfoWindow : IWindowCommon
     {
 
         private static int windowType = -1;
@@ -207,6 +208,7 @@ namespace GeekDesk.Control.Windows
             {
                 window = new ToDoInfoWindow();
                 window.Show();
+                Keyboard.Focus(window);
             }
             window.Visibility = Visibility.Collapsed;
             windowType = NEW_TODO;
@@ -222,6 +224,7 @@ namespace GeekDesk.Control.Windows
             }
             windowType = DETAIL_TODO;
             window2.Show();
+            Keyboard.Focus(window2);
         }
 
         private void ExecType_Checked(object sender, RoutedEventArgs e)
@@ -239,5 +242,13 @@ namespace GeekDesk.Control.Windows
                     break;
             }
         }
+
+        public void OnKeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.Key == Key.Escape)
+            {
+                this.Close();
+            }
+        }
     }
 }

+ 2 - 0
Control/Windows/ToDoWindow.xaml

@@ -13,6 +13,8 @@
            WindowStyle="None"
            AllowsTransparency="True"
            Background="Transparent" ShowInTaskbar="False"
+           Focusable="True"
+           KeyDown="OnKeyDown"
         >
 
     <Grid Margin="50">

+ 10 - 2
Control/Windows/ToDoWindow.xaml.cs

@@ -1,4 +1,5 @@
 using GeekDesk.Control.UserControls.Backlog;
+using GeekDesk.Interface;
 using GeekDesk.ViewModel;
 using HandyControl.Controls;
 using System;
@@ -21,7 +22,7 @@ namespace GeekDesk.Control.Windows
     /// <summary>
     /// BacklogWindow.xaml 的交互逻辑
     /// </summary>
-    public partial class ToDoWindow
+    public partial class ToDoWindow : IWindowCommon
     {
         private static TodoControl backlog = new TodoControl();
         private AppData appData = MainWindow.appData;
@@ -94,8 +95,15 @@ namespace GeekDesk.Control.Windows
                 window = new ToDoWindow();
             }
             window.Show();
+            Keyboard.Focus(window);
         }
 
-        
+        public void OnKeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.Key == Key.Escape)
+            {
+                this.Close();
+            }
+        }
     }
 }

+ 4 - 1
Control/Windows/UpdateWindow.xaml

@@ -9,7 +9,10 @@
         Height="460" Width="610"
         WindowStyle="None"
         AllowsTransparency="True"
-        Background="Transparent" ShowInTaskbar="False">
+        Title=""
+        Background="Transparent" ShowInTaskbar="False"
+        Focusable="True"
+        KeyDown="OnKeyDown">
     <Grid Margin="20">
         <Grid.Effect>
             <DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"

+ 11 - 1
Control/Windows/UpdateWindow.xaml.cs

@@ -1,4 +1,5 @@
 using GeekDesk.Constant;
+using GeekDesk.Interface;
 using GeekDesk.Util;
 using GeekDesk.ViewModel;
 using Newtonsoft.Json.Linq;
@@ -23,7 +24,7 @@ namespace GeekDesk.Control.Windows
     /// <summary>
     /// UpdateWindow.xaml 的交互逻辑
     /// </summary>
-    public partial class UpdateWindow : Window
+    public partial class UpdateWindow : Window, IWindowCommon
     {
         private static AppConfig appConfig = MainWindow.appData.AppConfig;
         private static string githubUrl = "";
@@ -103,6 +104,15 @@ namespace GeekDesk.Control.Windows
                 window = new UpdateWindow(jo);
             }
             window.Show();
+            Keyboard.Focus(window);
+        }
+
+        public void OnKeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.Key == Key.Escape)
+            {
+                this.Close();
+            }
         }
     }
 }

+ 1 - 0
GeekDesk.csproj

@@ -189,6 +189,7 @@
     <Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
     <Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
     <Compile Include="Converts\HideTypeConvert.cs" />
+    <Compile Include="Interface\WindowCommon.cs" />
     <Compile Include="Task\ToDoTask.cs" />
     <Compile Include="Thread\MouseHookThread.cs" />
     <Compile Include="Thread\DispatcherBuild.cs" />

+ 15 - 0
Interface/WindowCommon.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
+
+namespace GeekDesk.Interface
+{
+    public interface IWindowCommon
+    {
+        void OnKeyDown(object sender, KeyEventArgs e);
+    }
+}

+ 5 - 2
MainWindow.xaml

@@ -9,7 +9,7 @@
         xmlns:cvt="clr-namespace:GeekDesk.Converts"
         xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
         x:Name="window"
-        xmlns:hc="https://handyorg.github.io/handycontrol" 
+        xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:AppData}"
         Title="GeekDesk" 
         d:DesignHeight="500" d:DesignWidth="700"
         WindowStyle="None"
@@ -19,6 +19,8 @@
         Opacity="0"
         Deactivated="Window_Deactivated"
         SizeChanged="Window_SizeChanged"
+        KeyDown="OnKeyDown"
+        Focusable="True"
         >
     <WindowChrome.WindowChrome>
         <WindowChrome CaptionHeight="0" ResizeBorderThickness="15"/>
@@ -113,7 +115,8 @@
                     </DockPanel>
 
 
-                    <uc:LeftCardControl  Grid.Row="1" Grid.Column="0"/>
+                    <uc:LeftCardControl Grid.Row="1" Grid.Column="0"/>
+                    
                     <!--分割线-->
                     <GridSplitter Opacity="0" Grid.Row="1" Grid.Column="0" Width="1"  VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
 

+ 12 - 33
MainWindow.xaml.cs

@@ -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();
+            }
+        }
     }
 
 

+ 2 - 2
Properties/AssemblyInfo.cs

@@ -49,5 +49,5 @@ using System.Windows;
 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
 //通过使用 "*",如下所示:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.3.2.0")]
-[assembly: AssemblyFileVersion("2.3.2.0")]
+[assembly: AssemblyVersion("2.4.1.0")]
+[assembly: AssemblyFileVersion("2.4.1.0")]

+ 3 - 3
Update.json

@@ -1,9 +1,9 @@
 {
 	"title": "版本更新",
-	"subTitle": "V2.3.20 正式版",
+	"subTitle": "V2.4.10",
 	"msgTitle": "本次更新内容如下",
-	"msg": "['一个小更新, 修复了一部分bug并增加了部分功能','修复无法修改菜单图标的bug','修复图标锯齿状bug','修复热键不支持Alt的bug','增加鼠标中键呼出功能','增加隐藏托盘图标功能','界面美化等','最后去给我点个star呗']",
+	"msg": "['所有窗口可Esc退出']",
 	"githubUrl": "https://github.com/Demo-Liu/GeekDesk/releases",
 	"giteeUrl": "https://gitee.com/demo_liu/GeekDesk/releases",
-	"version": "2.3.20"
+	"version": "2.4.10"
 }