晚安, 还在功能性开发

This commit is contained in:
Demo_Liu
2021-05-31 21:54:10 +08:00
parent 9a45899b47
commit 0a983a3a17
8 changed files with 86 additions and 8 deletions

View File

@@ -105,7 +105,7 @@
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel MouseLeftButtonDown="MenuClick" Tag="{Binding}">
<TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
<hc:TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
HorizontalAlignment="Left"
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}}"
FontSize="15"

View File

@@ -28,7 +28,7 @@
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="30,50,0,-102.337" Grid.ColumnSpan="4">
<CheckBox Content="显示时追随鼠标位置" IsChecked="{Binding FollowMouse}" Unchecked="CheckBox_Unchecked">
<CheckBox Content="显示时追随鼠标位置" IsChecked="{Binding FollowMouse}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
@@ -56,6 +56,14 @@
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="30,193,0,-180.337" Grid.ColumnSpan="4">
<TextBlock Text="当前热键:"/>
<hc:TextBox HorizontalAlignment="Left"
VerticalAlignment="Top"
IsReadOnly="True"
IsReadOnlyCaretVisible="True"
Width="80"
Text="{Binding HotkeyStr}"
KeyDown="HotKeyDown"
Margin="12.967,-7.38,-12.967,0"/>
</hc:UniformSpacingPanel>
</hc:SimplePanel>

View File

@@ -23,16 +23,40 @@ namespace GeekDesk.Control.UserControls
/// </summary>
public partial class MotionControl : UserControl
{
private static bool controlKeyDown = false;
private static AppConfig appConfig = MainWindow.appData.AppConfig;
public MotionControl()
{
InitializeComponent();
}
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
/// <summary>
/// 热键按下
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HotKeyDown(object sender, KeyEventArgs e)
{
}
if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control)
|| e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Windows)
|| e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Alt)
|| (e.Key >= Key.A && e.Key <= Key.Z))
{
if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control)
|| e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Windows)
|| e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Alt))
{
appConfig.HotkeyStr = "Ctrl + ";
} else if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control)
|| e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Windows)
|| e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Alt)
&& (e.Key >= Key.A && e.Key <= Key.Z))
{
appConfig.HotkeyStr += e.Key.ToString();
}
}
}
}
}

View File

@@ -53,6 +53,9 @@
<Reference Include="GalaSoft.MvvmLight.Platform, Version=5.4.1.0, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL">
<HintPath>packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference>
<Reference Include="GlobalHotKey, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\GlobalHotKey.1.1.0\lib\GlobalHotKey.dll</HintPath>
</Reference>
<Reference Include="HandyControl, Version=3.1.0.0, Culture=neutral, PublicKeyToken=45be8712787a1e5b, processorArchitecture=MSIL">
<HintPath>packages\HandyControl.3.1.0\lib\net452\HandyControl.dll</HintPath>
</Reference>

View File

@@ -3,6 +3,7 @@ using GeekDesk.Constant;
using GeekDesk.Control;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using GlobalHotKey;
using SharpShell.SharpContextMenu;
using System;
using System.Collections.ObjectModel;
@@ -53,7 +54,7 @@ namespace GeekDesk
this.Visibility = Visibility.Collapsed;
}
//加载完毕注册热键
Hotkey.Regist(this, HotkeyModifiers.MOD_CONTROL, Key.Y, ()=>
Hotkey.Regist(this, HotkeyModifiers.MOD_CONTROL | HotkeyModifiers.MOD_ALT, Key.Y, ()=>
{
if (this.Visibility == Visibility.Collapsed)
{

View File

@@ -82,7 +82,7 @@ namespace GeekDesk.Util
public delegate void HotKeyCallBackHanlder();
}
enum HotkeyModifiers
public enum HotkeyModifiers
{
MOD_ALT = 0x1,
MOD_CONTROL = 0x2,

View File

@@ -5,6 +5,7 @@ using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Imaging;
/// <summary>
@@ -36,8 +37,48 @@ namespace GeekDesk.ViewModel
private int pannelCornerRadius = 4; //面板圆角 默认4
[field: NonSerialized]
private ObservableCollection<IconInfo> selectedMenuIcons;
private string hotkeyStr;
private HotkeyModifiers hotkeyModifiers;
private Key hotkey;
#region GetSet
public Key Hotkey
{
get
{
return hotkey;
}
set
{
hotkey = value;
OnPropertyChanged("Hotkey");
}
}
public string HotkeyStr
{
get
{
return hotkeyStr;
}
set
{
hotkeyStr = value;
OnPropertyChanged("HotkeyStr");
}
}
public HotkeyModifiers HotkeyModifiers
{
get
{
return hotkeyModifiers;
}
set
{
hotkeyModifiers = value;
OnPropertyChanged("HotkeyModifiers");
}
}
public ObservableCollection<IconInfo> SelectedMenuIcons
{
get

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="2.0.6" targetFramework="net452" requireReinstallation="true" />
<package id="GlobalHotKey" version="1.1.0" targetFramework="net472" />
<package id="HandyControl" version="3.1.0" targetFramework="net452" requireReinstallation="true" />
<package id="MvvmLightLibs" version="5.4.1.1" targetFramework="net472" />
<package id="SharpShell" version="2.7.2" targetFramework="net472" />