瀏覽代碼

增加双击打开 修复重复进程导致不能关闭程序

liufei 3 年之前
父節點
當前提交
edacf3249c
共有 3 個文件被更改,包括 72 次插入34 次删除
  1. 19 9
      Control/UserControls/Config/MotionControl.xaml
  2. 24 19
      Control/UserControls/Config/MotionControl.xaml.cs
  3. 29 6
      ViewModel/AppConfig.cs

+ 19 - 9
Control/UserControls/Config/MotionControl.xaml

@@ -41,7 +41,17 @@
             </hc:UniformSpacingPanel>
 
             <hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
-                <CheckBox  Content="鼠标中间呼出" Checked="MouseMiddle_Changed" Unchecked="MouseMiddle_Changed" IsChecked="{Binding MouseMiddleShow}">
+                <CheckBox  Content="鼠标中间呼出" Click="MouseMiddle_Changed" IsChecked="{Binding MouseMiddleShow}">
+                    <CheckBox.Background>
+                        <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
+                            <GradientStop Color="#FF9EA3A6"/>
+                        </LinearGradientBrush>
+                    </CheckBox.Background>
+                </CheckBox>
+            </hc:UniformSpacingPanel>
+
+            <hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0"  Grid.ColumnSpan="4">
+                <CheckBox  Content="双击启动" IsChecked="{Binding DoubleOpen}">
                     <CheckBox.Background>
                         <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
                             <GradientStop Color="#FF9EA3A6"/>
@@ -51,7 +61,7 @@
             </hc:UniformSpacingPanel>
 
             <hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
-                <CheckBox  Content="贴边隐藏" IsChecked="{Binding MarginHide}" Checked="MarginHide_Changed" Unchecked="MarginHide_Changed">
+                <CheckBox  Content="贴边隐藏" IsChecked="{Binding MarginHide}" Click="MarginHide_Changed">
                     <CheckBox.Background>
                         <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
                             <GradientStop Color="#FF9EA3A6"/>
@@ -61,7 +71,7 @@
             </hc:UniformSpacingPanel>
 
             <hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
-                <CheckBox  Content="主窗口动画效果" IsChecked="{Binding AppAnimation}" Checked="Animation_Checked">
+                <CheckBox  Content="主窗口动画效果" IsChecked="{Binding AppAnimation}" Click="Animation_Checked">
                     <CheckBox.Background>
                         <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
                             <GradientStop Color="#FF9EA3A6"/>
@@ -69,7 +79,7 @@
                     </CheckBox.Background>
                 </CheckBox>
             </hc:UniformSpacingPanel>
-            
+
             <hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
                 <TextBlock Text="面板关闭方式" VerticalAlignment="Center"/>
             </hc:UniformSpacingPanel>
@@ -102,8 +112,8 @@
                         />
             </hc:UniformSpacingPanel>
             <hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
-            <TextBlock Text="新建待办:"  Width="55"/>
-            <hc:TextBox HorizontalAlignment="Left" 
+                <TextBlock Text="新建待办:"  Width="55"/>
+                <hc:TextBox HorizontalAlignment="Left" 
                         Tag="ToDo"
                         VerticalAlignment="Top" 
                         IsReadOnly="True" 
@@ -113,9 +123,9 @@
                         KeyDown="HotKeyDown"
                         KeyUp="HotKeyUp"
                         />
-        </hc:UniformSpacingPanel>
+            </hc:UniformSpacingPanel>
         </StackPanel>
     </Grid>
-   
-   
+
+
 </UserControl>

+ 24 - 19
Control/UserControls/Config/MotionControl.xaml.cs

@@ -62,7 +62,7 @@ namespace GeekDesk.Control.UserControls.Config
                 main = true;
             }
 
-            if (prevKeyTemp == Key.None || prevKeyTemp!=downKey)
+            if (prevKeyTemp == Key.None || prevKeyTemp != downKey)
             {
                 if (hotkeyFinished)
                 {
@@ -71,7 +71,8 @@ namespace GeekDesk.Control.UserControls.Config
                         appConfig.Hotkey = 0;
                         appConfig.HotkeyStr = "";
                         appConfig.HotkeyModifiers = 0;
-                    } else
+                    }
+                    else
                     {
                         appConfig.ToDoHotkey = 0;
                         appConfig.ToDoHotkeyStr = "";
@@ -80,7 +81,7 @@ namespace GeekDesk.Control.UserControls.Config
                     hotkeyFinished = false;
                 }
                 //首次按下按键
-                if ((main && (appConfig.HotkeyStr == null || appConfig.HotkeyStr.Length == 0)) 
+                if ((main && (appConfig.HotkeyStr == null || appConfig.HotkeyStr.Length == 0))
                     || (!main && (appConfig.ToDoHotkeyStr == null || appConfig.ToDoHotkeyStr.Length == 0)))
                 {
                     if (CheckModifierKeys(downKey))
@@ -90,7 +91,8 @@ namespace GeekDesk.Control.UserControls.Config
                         {
                             appConfig.HotkeyStr = GetKeyName(downKey);
                             appConfig.HotkeyModifiers = GetModifierKeys(downKey);
-                        } else
+                        }
+                        else
                         {
                             appConfig.ToDoHotkeyStr = GetKeyName(downKey);
                             appConfig.ToDoHotkeyModifiers = GetModifierKeys(downKey);
@@ -111,7 +113,8 @@ namespace GeekDesk.Control.UserControls.Config
                         {
                             appConfig.Hotkey = downKey;
                             appConfig.HotkeyStr += downKey.ToString();
-                        } else
+                        }
+                        else
                         {
                             appConfig.ToDoHotkey = downKey;
                             appConfig.ToDoHotkeyStr += downKey.ToString();
@@ -125,12 +128,13 @@ namespace GeekDesk.Control.UserControls.Config
                         {
                             appConfig.HotkeyStr += GetKeyName(downKey);
                             appConfig.HotkeyModifiers |= GetModifierKeys(downKey);
-                        } else
+                        }
+                        else
                         {
                             appConfig.ToDoHotkeyStr += GetKeyName(downKey);
                             appConfig.ToDoHotkeyModifiers |= GetModifierKeys(downKey);
                         }
-                        
+
                         prevKeyTemp = downKey;
                         keysTemp.Add(e);
                     }
@@ -143,7 +147,8 @@ namespace GeekDesk.Control.UserControls.Config
             if (key == Key.LeftCtrl || key == Key.RightCtrl)
             {
                 return "Ctrl + ";
-            } else if (key == Key.LWin || key == Key.RWin)
+            }
+            else if (key == Key.LWin || key == Key.RWin)
             {
                 return "Win + ";
             }
@@ -187,7 +192,7 @@ namespace GeekDesk.Control.UserControls.Config
 
 
         [MethodImpl(MethodImplOptions.Synchronized)]
-        private  void HotKeyUp(object sender, KeyEventArgs e)
+        private void HotKeyUp(object sender, KeyEventArgs e)
         {
             string tag = (sender as TextBox).Tag.ToString();
             bool main = false;
@@ -195,7 +200,7 @@ namespace GeekDesk.Control.UserControls.Config
             {
                 main = true;
             }
-            lock(this)
+            lock (this)
             {
                 bool allKeyUp = true;
                 //判断所有键是否都松开
@@ -221,7 +226,8 @@ namespace GeekDesk.Control.UserControls.Config
                             GlobalHotKey.Dispose(MainWindow.hotKeyId);
                         }
                         MainWindow.RegisterHotKey(false);
-                    } else
+                    }
+                    else
                     {
                         if (MainWindow.toDoHotKeyId != -1)
                         {
@@ -231,7 +237,7 @@ namespace GeekDesk.Control.UserControls.Config
                         MainWindow.RegisterCreateToDoHotKey(false);
                     }
 
-                    
+
                 }
             }
         }
@@ -253,13 +259,11 @@ namespace GeekDesk.Control.UserControls.Config
         {
             if (appConfig.MarginHide)
             {
-                MainWindow.hide.TimerSet();
-            } else
+                MarginHide.StartHide();
+            }
+            else
             {
-                if (MainWindow.hide.timer != null)
-                {
-                    MainWindow.hide.TimerStop();
-                }
+                MarginHide.StopHide();
             }
         }
 
@@ -284,7 +288,8 @@ namespace GeekDesk.Control.UserControls.Config
             if (appConfig.MouseMiddleShow)
             {
                 MouseHookThread.MiddleHook();
-            } else
+            }
+            else
             {
                 MouseHookThread.Dispose();
             }

+ 29 - 6
ViewModel/AppConfig.cs

@@ -1,6 +1,7 @@
 
 using GeekDesk.Constant;
 using GeekDesk.Util;
+using Newtonsoft.Json;
 using System;
 using System.Collections.ObjectModel;
 using System.ComponentModel;
@@ -70,7 +71,22 @@ namespace GeekDesk.ViewModel
 
         private bool showBarIcon = true; //显示托盘图标  默认显示
 
+        private bool doubleOpen = false; //双击打开项目  默认关闭
+
         #region GetSet
+        public bool DoubleOpen
+        {
+            get
+            {
+                return doubleOpen;
+            }
+            set
+            {
+                doubleOpen = value;
+                OnPropertyChanged("DoubleOpen");
+            }
+        }
+
         public bool ShowBarIcon
         {
             get
@@ -105,18 +121,19 @@ namespace GeekDesk.ViewModel
                 if (imageWidth == 0)
                 {
                     return (int)CommonEnum.IMAGE_WIDTH;
-                } else
+                }
+                else
                 {
                     return imageWidth;
                 }
-                
+
             }
             set
             {
                 imageWidth = value;
                 //同时设置高度
                 ImageHeight = value;
-                
+
 
                 //计算 容器宽度因子
                 double i = ((double)imageWidth - (double)CommonEnum.IMAGE_WIDTH) / 5d;
@@ -126,7 +143,7 @@ namespace GeekDesk.ViewModel
                 {
                     i /= 10d;
                 }
-                
+
                 if (i > 0d)
                 {
                     s -= i;
@@ -380,7 +397,8 @@ namespace GeekDesk.ViewModel
                 if (blurEffect)
                 {
                     BlurValue = 100;
-                } else
+                }
+                else
                 {
                     BlurValue = 0;
                 }
@@ -552,7 +570,8 @@ namespace GeekDesk.ViewModel
                     bacImgName = "系统默认";
                     //Image image = ImageUtil.ByteArrayToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
                     return ImageUtil.ByteArrToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
-                } else
+                }
+                else
                 {
                     return ImageUtil.ByteArrToImage(ImageByteArr);
                 }
@@ -707,5 +726,9 @@ namespace GeekDesk.ViewModel
 
         #endregion
 
+        public override String ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
     }
 }