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

This commit is contained in:
liufei
2022-01-09 15:38:18 +08:00
parent ab13cff769
commit edacf3249c
3 changed files with 72 additions and 34 deletions

View File

@@ -41,7 +41,17 @@
</hc:UniformSpacingPanel> </hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4"> <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> <CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0"> <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/> <GradientStop Color="#FF9EA3A6"/>
@@ -51,7 +61,7 @@
</hc:UniformSpacingPanel> </hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4"> <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> <CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0"> <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/> <GradientStop Color="#FF9EA3A6"/>
@@ -61,7 +71,7 @@
</hc:UniformSpacingPanel> </hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4"> <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> <CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0"> <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/> <GradientStop Color="#FF9EA3A6"/>
@@ -69,7 +79,7 @@
</CheckBox.Background> </CheckBox.Background>
</CheckBox> </CheckBox>
</hc:UniformSpacingPanel> </hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4"> <hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<TextBlock Text="面板关闭方式" VerticalAlignment="Center"/> <TextBlock Text="面板关闭方式" VerticalAlignment="Center"/>
</hc:UniformSpacingPanel> </hc:UniformSpacingPanel>
@@ -102,8 +112,8 @@
/> />
</hc:UniformSpacingPanel> </hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4"> <hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<TextBlock Text="新建待办:" Width="55"/> <TextBlock Text="新建待办:" Width="55"/>
<hc:TextBox HorizontalAlignment="Left" <hc:TextBox HorizontalAlignment="Left"
Tag="ToDo" Tag="ToDo"
VerticalAlignment="Top" VerticalAlignment="Top"
IsReadOnly="True" IsReadOnly="True"
@@ -113,9 +123,9 @@
KeyDown="HotKeyDown" KeyDown="HotKeyDown"
KeyUp="HotKeyUp" KeyUp="HotKeyUp"
/> />
</hc:UniformSpacingPanel> </hc:UniformSpacingPanel>
</StackPanel> </StackPanel>
</Grid> </Grid>
</UserControl> </UserControl>

View File

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

View File

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