Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee47443c34 | ||
|
|
ad2556a216 | ||
|
|
7589736751 | ||
|
|
de57b8d78d | ||
|
|
d9b0a4de89 | ||
|
|
d5e0dc98db | ||
|
|
e82af431b5 | ||
|
|
7360412c97 | ||
|
|
3fa3a42bb3 | ||
|
|
904e9a2999 | ||
|
|
39bb8e0c67 | ||
|
|
01350dff43 | ||
|
|
8efab6bdee | ||
|
|
cbaeb71a0c | ||
|
|
b8a6c9b91d | ||
|
|
001d807bb3 | ||
|
|
93e70e4525 | ||
|
|
240008ce2c | ||
|
|
6cfa9b1361 | ||
|
|
8f043ffd05 | ||
|
|
6e58afcdea | ||
|
|
896dc26f11 | ||
|
|
d44cc90100 | ||
|
|
da7588273e | ||
|
|
c7ef24a5b1 | ||
|
|
6b6372847c | ||
|
|
3995084776 | ||
|
|
7d061abadc | ||
|
|
9d174ed2fc | ||
|
|
444697b457 | ||
|
|
2ecad2fea2 | ||
|
|
e46d64193b | ||
|
|
e42f2c3c73 | ||
|
|
0aa7969e4a | ||
|
|
1a88194d26 | ||
|
|
b47dd0fbf7 | ||
|
|
50cebd48ce | ||
|
|
4c5c88769f | ||
|
|
2fc38fdb5f | ||
|
|
c310fd441f | ||
|
|
302e8bff8b | ||
|
|
12ac544e42 | ||
|
|
d72ea7a43a | ||
|
|
f868eb77b6 | ||
|
|
efb8c537d3 | ||
|
|
f56991410b | ||
|
|
9cbbd6cf45 | ||
|
|
524b134d16 | ||
|
|
5c17348312 |
17
App.config
17
App.config
@@ -2,9 +2,16 @@
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="SystemIcons" type="System.Configuration.DictionarySectionHandler" />
|
||||
<section name="ShowSecondsSettings" type="System.Configuration.DictionarySectionHandler" />
|
||||
<section name="SystemBGs" type="System.Collections.ObjectModel.ObservableCollection" />
|
||||
<section name="GradientBGParam" type="GeekDesk.ViewModel.GradientBGParam" />
|
||||
</configSections>
|
||||
<ShowSecondsSettings>
|
||||
<add key="Version" value="1.0.01" />
|
||||
<add key="LProportion" value="0.82" />
|
||||
<add key="TProportion" value="0.03" />
|
||||
<add key="DelayTime" value="1500" />
|
||||
</ShowSecondsSettings>
|
||||
<SystemIcons>
|
||||
<add key="Calculator" value="计算器" />
|
||||
<add key="Computer" value="此电脑" />
|
||||
@@ -26,6 +33,7 @@
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<probing privatePath="lib" />
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="CommonServiceLocator" publicKeyToken="489b6accfaf20ef0" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.6.0" newVersion="2.0.6.0" />
|
||||
@@ -46,17 +54,22 @@
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.1.1.0" newVersion="2.1.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<appSettings>
|
||||
<add key="Version" value="2.4.15" />
|
||||
<add key="Version" value="2.5.13" />
|
||||
<add key="GitHubUrl" value="https://github.com/BookerLiu/GeekDesk" />
|
||||
<add key="GiteeUrl" value="https://gitee.com/BookerLiu/GeekDesk/tree/master" />
|
||||
<add key="GitHubUpdateUrl" value="https://raw.githubusercontent.com/BookerLiu/GeekDesk/master/Update.json" />
|
||||
<add key="GiteeUpdateUrl" value="https://gitee.com/BookerLiu/GeekDesk/raw/master/Update.json" />
|
||||
<!--<add key="GiteeUpdateUrl" value="file:///C:/Users/Fei/Desktop/GeekDesk/Update.json" />-->
|
||||
<!--<add key="GiteeUpdateUrl" value="file:///D:/WorkSpace/workspace-VS/GeekDesk/Update.json" />-->
|
||||
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
||||
<add key="CustomIconTeachUrl" value="https://mp.weixin.qq.com/s/LxoHAekho9HBVl4FRw_Law" />
|
||||
<add key="ShowPublicWeChat" value="Y" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<membership defaultProvider="ClientAuthenticationMembershipProvider">
|
||||
|
||||
2
App.xaml
2
App.xaml
@@ -13,6 +13,8 @@
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
|
||||
<ResourceDictionary Source="/GeekDesk;component/Resource/Dictionary/CommonStyle.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/XamlFlair.WPF;component/DefaultAnimations.xaml"/>
|
||||
<ResourceDictionary Source="/GeekDesk;component/Resource/Dictionary/XamlFlairSettings.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace GeekDesk
|
||||
|
||||
private void App_Startup(object sender, StartupEventArgs e)
|
||||
{
|
||||
|
||||
mutex = new System.Threading.Mutex(true, Constants.MY_NAME, out bool ret);
|
||||
if (!ret)
|
||||
{
|
||||
@@ -32,6 +31,10 @@ namespace GeekDesk
|
||||
mutex = new System.Threading.Mutex(true, Constants.MY_NAME, out ret);
|
||||
if (!ret)
|
||||
{
|
||||
MessageUtil.SendMsgByWName(
|
||||
"GeekDesk_Main_" + Constants.MY_UUID,
|
||||
"ShowApp"
|
||||
);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,14 +13,28 @@ namespace GeekDesk.Constant
|
||||
|
||||
public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk";
|
||||
|
||||
public static string MY_UUID = "8400A17AEEF7C029";
|
||||
/// <summary>
|
||||
/// app数据文件路径
|
||||
/// </summary>
|
||||
public static string DATA_FILE_PATH = APP_DIR + "Data"; //app数据文件路径
|
||||
|
||||
public static string LOG_FILE_PATH = APP_DIR + "Log.log";
|
||||
/// <summary>
|
||||
/// 备份文件路径
|
||||
/// </summary>
|
||||
public static string DATA_FILE_BAK_PATH = APP_DIR + "bak\\Data.bak"; //app备份数据文件路径
|
||||
|
||||
public static string PW_FILE_BAK_PATH = APP_DIR + "bak\\pw.txt"; //密码文件路径
|
||||
|
||||
public static string LOG_FILE_PATH = APP_DIR + "logs\\log.log"; //日志文件
|
||||
|
||||
public static string ERROR_FILE_PATH = APP_DIR + "logs\\error.log"; // 错误日志
|
||||
|
||||
/// <summary>
|
||||
/// 插件文件夹
|
||||
/// </summary>
|
||||
public static string PLUGINS_PATH = APP_DIR + "plugins\\";
|
||||
|
||||
public static string ERROR_FILE_PATH = APP_DIR + "Error.log";
|
||||
|
||||
public static int SHADOW_WIDTH = 20;
|
||||
|
||||
|
||||
16
Constant/PasswordType.cs
Normal file
16
Constant/PasswordType.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Constant
|
||||
{
|
||||
public enum PasswordType
|
||||
{
|
||||
INPUT = 0, //键入密码
|
||||
CREATE = 1, //新建密码
|
||||
ALTER = 2, //修改密码
|
||||
CANCEL = 3, //取消密码
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,43 @@
|
||||
public static bool LOCK_APP_PANEL = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否弹出了菜单密码框
|
||||
/// </summary>
|
||||
public static bool SHOW_MENU_PASSWORDBOX = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否弹出了右键菜单
|
||||
/// </summary>
|
||||
public static bool SHOW_RIGHT_BTN_MENU = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否点击了面板功能按钮
|
||||
/// </summary>
|
||||
public static bool APP_BTN_IS_DOWN = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否正在编辑菜单
|
||||
/// </summary>
|
||||
public static bool IS_MENU_EDIT = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 图标card 鼠标滚轮是否正在工作
|
||||
/// 用来控制popup的显示 否则低性能机器会造成卡顿
|
||||
/// </summary>
|
||||
public static bool ICONLIST_MOUSE_WHEEL = false;
|
||||
/// <summary>
|
||||
/// 控制多少毫秒后 关闭(ICONLIST_MOUSE_WHEEL)鼠标滚轮运行状态
|
||||
/// </summary>
|
||||
public static int MOUSE_WHEEL_WAIT_MS = 100;
|
||||
/// <summary>
|
||||
/// 与关闭popup 配合使用, 避免线程结束后不显示popup
|
||||
/// </summary>
|
||||
public static bool MOUSE_ENTER_ICON = false;
|
||||
/// <summary>
|
||||
/// 控制每次刷新搜索结果 鼠标移动后显示popup
|
||||
/// </summary>
|
||||
public static int MOUSE_MOVE_COUNT = 0;
|
||||
}
|
||||
}
|
||||
|
||||
15
Constant/WidthTypeEnum.cs
Normal file
15
Constant/WidthTypeEnum.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Constant
|
||||
{
|
||||
public enum WidthTypeEnum
|
||||
{
|
||||
LEFT_CARD = 0, //左侧托盘宽度
|
||||
RIGHT_CARD = 1, //右侧托盘宽度
|
||||
RIGHT_CARD_HALF = 2 //右侧托盘宽度的一半
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ namespace GeekDesk.Control.Other
|
||||
}
|
||||
ToDoTask.activityBacklog[info].Close(); //关闭桌面通知
|
||||
ToDoTask.activityBacklog.Remove(info);//激活任务删除
|
||||
CommonCode.SaveAppData(appData);
|
||||
CommonCode.SaveAppData(appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
|
||||
|
||||
|
||||
54
Control/Other/GlobalMsgNotification.xaml
Normal file
54
Control/Other/GlobalMsgNotification.xaml
Normal file
@@ -0,0 +1,54 @@
|
||||
<Border x:Class="GeekDesk.Control.Other.GlobalMsgNotification"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
BorderThickness="0"
|
||||
Style="{StaticResource BorderBG}"
|
||||
Margin="15"
|
||||
BorderBrush="{DynamicResource BorderBrush}"
|
||||
Width="320"
|
||||
Height="400">
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="AliceBlue" Opacity="0.96"/>
|
||||
</Border.Background>
|
||||
<Grid>
|
||||
|
||||
<StackPanel>
|
||||
<Image Source="/Resource/Image/BacklogImg.png" Width="260" Margin="0,20,0,0"/>
|
||||
<hc:Card Width="260" Height="220" BorderThickness="0" Effect="{DynamicResource EffectShadow2}" Margin="0,20,0,0">
|
||||
|
||||
<Border CornerRadius="4,4,0,0" Height="160" Padding="10,0,10,0">
|
||||
<ScrollViewer>
|
||||
<TextBlock TextOptions.TextFormattingMode="Display"
|
||||
TextOptions.TextHintingMode="Animated"
|
||||
UseLayoutRounding="True"
|
||||
TextWrapping="Wrap"
|
||||
FontStyle="Normal"
|
||||
FontSize="15"
|
||||
LineHeight="22"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Text="{Binding Msg}"/>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
|
||||
|
||||
<!--<hc:Card.Footer>
|
||||
<StackPanel Margin="10" Width="160">
|
||||
|
||||
<TextBlock TextWrapping="NoWrap" FontSize="20" Style="{DynamicResource TextBlockLargeBold}" TextTrimming="CharacterEllipsis"
|
||||
Text="{Binding Title}"
|
||||
HorizontalAlignment="Left"/>
|
||||
|
||||
|
||||
<TextBlock TextWrapping="NoWrap" Style="{DynamicResource TextBlockDefault}" TextTrimming="CharacterEllipsis"
|
||||
Margin="0,6,0,0"
|
||||
HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
||||
</hc:Card.Footer>-->
|
||||
</hc:Card>
|
||||
</StackPanel>
|
||||
|
||||
<Button Click="Close_Click" Content="朕已阅" Margin="10,0,10,20" Width="298" VerticalAlignment="Bottom"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
61
Control/Other/GlobalMsgNotification.xaml.cs
Normal file
61
Control/Other/GlobalMsgNotification.xaml.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Task;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Controls;
|
||||
using Quartz;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace GeekDesk.Control.Other
|
||||
{
|
||||
/// <summary>
|
||||
/// BacklogNotificatin.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class GlobalMsgNotification
|
||||
{
|
||||
|
||||
public Notification ntf;
|
||||
public GlobalMsgNotification(DialogMsg msg)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = msg;
|
||||
}
|
||||
|
||||
|
||||
public class DialogMsg
|
||||
{
|
||||
public string msg;
|
||||
public string title;
|
||||
|
||||
public string Msg
|
||||
{
|
||||
get
|
||||
{
|
||||
return msg;
|
||||
}
|
||||
set
|
||||
{
|
||||
msg = value;
|
||||
}
|
||||
}
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
return title;
|
||||
}
|
||||
set
|
||||
{
|
||||
title = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ntf.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
CornerRadius="4"
|
||||
Width="350"
|
||||
Height="450"
|
||||
@@ -10,29 +11,39 @@
|
||||
<Border.Resources>
|
||||
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
|
||||
<Setter Property="Width" Value="75"/>
|
||||
<Setter Property="TextAlignment" Value="Center"/>
|
||||
<Setter Property="TextAlignment" Value="Left"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="Margin" Value="0,8,0,0"/>
|
||||
<Setter Property="Margin" Value="5,8,0,0"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
</Style>
|
||||
<cvt:StringAppendConvert x:Key="StringAppendConvert"/>
|
||||
</Border.Resources>
|
||||
<hc:SimplePanel Margin="10" VerticalAlignment="Center">
|
||||
<StackPanel>
|
||||
<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top"/>
|
||||
<hc:UniformSpacingPanel Spacing="10">
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,15,0,0">
|
||||
<TextBlock Text="名称:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBox x:Name="IconName" Text="{Binding Name, Mode=OneWay}" Width="230" FontSize="14"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,15,0,0">
|
||||
<TextBlock Text="相对路径:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBlock Text="{Binding RelativePath, Mode=OneWay}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,8,0,0"
|
||||
Width="230"
|
||||
FontSize="14"
|
||||
TextTrimming="WordEllipsis"
|
||||
hc:Poptip.Placement="Bottom"
|
||||
hc:Poptip.Content="{Binding RelativePath, Mode=OneWay, Converter={StaticResource StringAppendConvert}, ConverterParameter='\{\}\\\n(同盘符下才会建立相对路径)'}"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,15,0,0">
|
||||
<TextBlock Text="图标:" Style="{StaticResource LeftTB}"/>
|
||||
<Image x:Name="IconImg" Source="{Binding BitmapImage, Mode=OneWay}" RenderOptions.BitmapScalingMode="HighQuality" Width="60" Height="60"/>
|
||||
<Button Content="修改" Click="EditImage"/>
|
||||
<Button Content="重置" Click="ReStoreImage"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
<hc:UniformSpacingPanel Spacing="10">
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="4,15,0,0">
|
||||
<CheckBox x:Name="IconIsAdmin" Content="始终以管理员方式启动" IsChecked="{Binding AdminStartUp, Mode=OneWay}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
@@ -41,12 +52,11 @@
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
<hc:UniformSpacingPanel Spacing="10">
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,15,0,0">
|
||||
<TextBlock Text="启动参数:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBox x:Name="StartArg" Text="{Binding StartArg, Mode=OneWay}" Width="230" Height="100" TextWrapping="Wrap" FontSize="14"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<hc:UniformSpacingPanel Margin="0,25,0,0" Spacing="10" Grid.ColumnSpan="4">
|
||||
<Button Content="保存" Style="{StaticResource Btn1}" Click="SaveProperty" Margin="265,10,0,0"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
@@ -38,7 +39,7 @@ namespace GeekDesk.Control.Other
|
||||
info.Name = IconName.Text;
|
||||
info.AdminStartUp = IconIsAdmin.IsChecked.Value;
|
||||
info.StartArg = StartArg.Text;
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
dialog.Close();
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ namespace GeekDesk.Control.Other
|
||||
{
|
||||
IconInfo info = this.DataContext as IconInfo;
|
||||
info.BitmapImage = ImageUtil.ByteArrToImage(info.DefaultImage);
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -72,7 +73,7 @@ namespace GeekDesk.Control.Other
|
||||
{
|
||||
IconInfo info = this.DataContext as IconInfo;
|
||||
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
}
|
||||
catch (Exception e1)
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace GeekDesk.Control.Other
|
||||
{
|
||||
MainWindow.appData.MenuList[MainWindow.appData.AppConfig.SelectedMenuIndex].IconList.Add(info);
|
||||
}
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
dialog.Close();
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace GeekDesk.Control.Other
|
||||
{
|
||||
IconInfo info = this.DataContext as IconInfo;
|
||||
info.BitmapImage = ImageUtil.ByteArrToImage(info.DefaultImage);
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -86,7 +86,7 @@ namespace GeekDesk.Control.Other
|
||||
{
|
||||
IconInfo info = this.DataContext as IconInfo;
|
||||
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
75
Control/Other/PasswordDialog.xaml
Normal file
75
Control/Other/PasswordDialog.xaml
Normal file
@@ -0,0 +1,75 @@
|
||||
<Border x:Class="GeekDesk.Control.Other.PasswordDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
|
||||
CornerRadius="6"
|
||||
Width="300"
|
||||
Height="150"
|
||||
BorderThickness="0"
|
||||
>
|
||||
<Border.Resources>
|
||||
<Style x:Key="PassBox" TargetType="PasswordBox" BasedOn="{StaticResource PasswordBoxBaseStyle}">
|
||||
<Setter Property="Height" Value="40"/>
|
||||
<Setter Property="Width" Value="40"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="FontSize" Value="18"/>
|
||||
<Setter Property="Focusable" Value="True"/>
|
||||
<Setter Property="MaxLength" Value="1"/>
|
||||
<EventSetter Event="PasswordChanged" Handler="PasswordBox_PasswordChanged"/>
|
||||
<EventSetter Event="PreviewKeyDown" Handler="PasswordBox_KeyDown"/>
|
||||
</Style>
|
||||
<Style x:Key="NextTB" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="#408CCB"/>
|
||||
<Setter Property="TextDecorations" Value="Underline"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="Red"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Resources>
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="White" Opacity="0.7"/>
|
||||
</Border.Background>
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<hc:UniformSpacingPanel Spacing="10" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<TextBlock x:Name="Title" Text="请输入密码"
|
||||
FontSize="15"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<Grid Height="65" x:Name="PasswordGrid" Visibility="Visible" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndGrowHorizontally}, Event=Visibility}">
|
||||
<TextBlock x:Name="HintMsg"
|
||||
Visibility="Hidden"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Center"
|
||||
Width="250"
|
||||
TextAlignment="Center"
|
||||
Margin="0,3,0,0"
|
||||
Text="提示:"
|
||||
hc:Poptip.Content="{Binding ElementName=HintMsg, Path=Text}"
|
||||
Foreground="Gray"/>
|
||||
<hc:UniformSpacingPanel Margin="0,20,0,0" Spacing="10" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<PasswordBox x:Name="P1" Tag="P1" Style="{StaticResource PassBox}"/>
|
||||
<PasswordBox x:Name="P2" Tag="P2" Style="{StaticResource PassBox}"/>
|
||||
<PasswordBox x:Name="P3" Tag="P3" Style="{StaticResource PassBox}"/>
|
||||
<PasswordBox x:Name="P4" Tag="P4" Style="{StaticResource PassBox}"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<TextBlock HorizontalAlignment="Right"
|
||||
x:Name="ErrorMsg"
|
||||
Margin="0,65,37,-65"
|
||||
Foreground="Red"
|
||||
Text="密码输入错误"
|
||||
Visibility="Visible"/>
|
||||
</Grid>
|
||||
<Grid Height="65" x:Name="HintGrid" Visibility="Collapsed" Margin="0,20,0,0" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, Event=Visibility}">
|
||||
<hc:UniformSpacingPanel Spacing="10" VerticalAlignment="Top" HorizontalAlignment="Center">
|
||||
<hc:TextBox x:Name="HintBox" TextAlignment="Left" Width="220"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="202,35,0,0" VerticalAlignment="Top" HorizontalAlignment="Left">
|
||||
<TextBlock Text="跳过" MouseLeftButtonDown="NextTB_MouseLeftButtonDown" Style="{StaticResource NextTB}"/>
|
||||
<TextBlock Text="完成" MouseLeftButtonDown="DoneTB_MouseLeftButtonDown" Style="{StaticResource NextTB}"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
280
Control/Other/PasswordDialog.xaml.cs
Normal file
280
Control/Other/PasswordDialog.xaml.cs
Normal file
@@ -0,0 +1,280 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace GeekDesk.Control.Other
|
||||
{
|
||||
/// <summary>
|
||||
/// TextDialog.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class PasswordDialog
|
||||
{
|
||||
private AppData appData = MainWindow.appData;
|
||||
|
||||
public PasswordType type;
|
||||
public MenuInfo menuInfo;
|
||||
public int count = 0;
|
||||
private string tempPassword = null;
|
||||
private PasswordType tempType;
|
||||
public PasswordDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PasswordBox pb = sender as PasswordBox;
|
||||
if (!string.IsNullOrEmpty(pb.Password))
|
||||
{
|
||||
char c = pb.Password.ToCharArray()[0];
|
||||
if (c > '9' || c < '0')
|
||||
{
|
||||
pb.Password = "";
|
||||
return;
|
||||
}
|
||||
}
|
||||
string tag = pb.Tag.ToString();
|
||||
switch (tag)
|
||||
{
|
||||
case "P1":
|
||||
if (!string.IsNullOrEmpty(pb.Password))
|
||||
{
|
||||
P2.Focus();
|
||||
}
|
||||
break;
|
||||
case "P2":
|
||||
if (!string.IsNullOrEmpty(pb.Password))
|
||||
{
|
||||
P3.Focus();
|
||||
}
|
||||
break;
|
||||
case "P3":
|
||||
if (!string.IsNullOrEmpty(pb.Password))
|
||||
{
|
||||
P4.Focus();
|
||||
}
|
||||
break;
|
||||
case "P4":
|
||||
if (string.IsNullOrEmpty(pb.Password))
|
||||
{
|
||||
P3.Focus();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(P1.Password)
|
||||
&& !string.IsNullOrEmpty(P2.Password)
|
||||
&& !string.IsNullOrEmpty(P3.Password)
|
||||
&& !string.IsNullOrEmpty(P4.Password))
|
||||
{
|
||||
string pw = P1.Password
|
||||
+ P2.Password
|
||||
+ P3.Password
|
||||
+ P4.Password;
|
||||
pw = MD5Util.CreateMD5(pw);
|
||||
if (type == PasswordType.INPUT || type == PasswordType.CANCEL)
|
||||
{
|
||||
if (pw.Equals(appData.AppConfig.MenuPassword))
|
||||
{
|
||||
//隐藏弹框
|
||||
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Collapsed;
|
||||
//赋值
|
||||
MainWindow.appData.AppConfig.SelectedMenuIcons
|
||||
= appData.MenuList[
|
||||
MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex
|
||||
].IconList;
|
||||
//显示数据托盘
|
||||
MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Visible;
|
||||
//取消加密操作
|
||||
if (type == PasswordType.CANCEL)
|
||||
{
|
||||
menuInfo.IsEncrypt = false;
|
||||
}
|
||||
} else
|
||||
{
|
||||
//密码比对不一致
|
||||
ErrorMsg.Text = "密码输入错误";
|
||||
ErrorMsg.Visibility = Visibility.Visible;
|
||||
if (!string.IsNullOrEmpty(appData.AppConfig.PasswordHint))
|
||||
{
|
||||
//显示提示信息
|
||||
HintMsg.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
} else if (type == PasswordType.CREATE)
|
||||
{
|
||||
//创建密码
|
||||
if (count == 0)
|
||||
{
|
||||
count++;
|
||||
tempPassword = pw;
|
||||
Title.Text = "再次输入密码";
|
||||
ClearVal();
|
||||
SetFocus(0);
|
||||
} else
|
||||
{
|
||||
if (tempPassword.Equals(pw))
|
||||
{
|
||||
//两次密码设置一致 显示提示输入框
|
||||
Title.Text = "填写密码提示";
|
||||
PasswordGrid.Visibility = Visibility.Collapsed;
|
||||
HintGrid.Visibility = Visibility.Visible;
|
||||
HintBox.Focus();
|
||||
} else
|
||||
{
|
||||
ErrorMsg.Text = "两次密码输入不一致";
|
||||
ErrorMsg.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
} else if (type == PasswordType.ALTER)
|
||||
{
|
||||
//修改密码
|
||||
if (appData.AppConfig.MenuPassword.Equals(pw))
|
||||
{
|
||||
tempType = type;
|
||||
type = PasswordType.CREATE;
|
||||
Title.Text = "设置新密码";
|
||||
ClearVal();
|
||||
SetFocus(0);
|
||||
} else
|
||||
{
|
||||
//密码比对不一致
|
||||
ErrorMsg.Text = "密码输入错误";
|
||||
ErrorMsg.Visibility = Visibility.Visible;
|
||||
HintMsg.Text = MainWindow.appData.AppConfig.PasswordHint;
|
||||
HintMsg.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
//密码未输入完全 隐藏错误信息
|
||||
if (ErrorMsg.IsVisible)
|
||||
{
|
||||
ErrorMsg.Visibility = Visibility.Hidden;
|
||||
HintMsg.Visibility = Visibility.Hidden;
|
||||
HintMsg.Visibility = Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFocus(int time = 100)
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(time);
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(P1.Password))
|
||||
{
|
||||
P1.Focus();
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(P2.Password))
|
||||
{
|
||||
P2.Focus();
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(P3.Password))
|
||||
{
|
||||
P3.Focus();
|
||||
return;
|
||||
}
|
||||
P4.Focus();
|
||||
});
|
||||
}).Start();
|
||||
}
|
||||
|
||||
public void ClearVal()
|
||||
{
|
||||
P1.Clear();
|
||||
P2.Clear();
|
||||
P3.Clear();
|
||||
P4.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 跳过设置密码提示
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void NextTB_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
appData.AppConfig.PasswordHint = "";
|
||||
DonePassword();
|
||||
}
|
||||
|
||||
private void DoneTB_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
string hint = HintBox.Text.Trim();
|
||||
appData.AppConfig.PasswordHint = hint;
|
||||
DonePassword();
|
||||
}
|
||||
|
||||
private void DonePassword()
|
||||
{
|
||||
appData.AppConfig.MenuPassword = tempPassword;
|
||||
CommonCode.SavePassword(tempPassword);
|
||||
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Collapsed;
|
||||
PasswordGrid.Visibility = Visibility.Visible;
|
||||
HintGrid.Visibility = Visibility.Collapsed;
|
||||
if (tempType == PasswordType.ALTER)
|
||||
{
|
||||
HandyControl.Controls.Growl.Success("密码修改成功!", "MainWindowGrowl");
|
||||
} else
|
||||
{
|
||||
menuInfo.IsEncrypt = true;
|
||||
HandyControl.Controls.Growl.Success(menuInfo.MenuName + " 已加密!", "MainWindowGrowl");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PasswordBox_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Back)
|
||||
{
|
||||
if (P2.IsKeyboardFocused)
|
||||
{
|
||||
if (string.IsNullOrEmpty(P2.Password))
|
||||
{
|
||||
P1.Password = "";
|
||||
} else
|
||||
{
|
||||
P2.Password = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (P3.IsKeyboardFocused)
|
||||
{
|
||||
if (string.IsNullOrEmpty(P3.Password))
|
||||
{
|
||||
P2.Password = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
P3.Password = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (P4.IsKeyboardFocused)
|
||||
{
|
||||
if (string.IsNullOrEmpty(P4.Password))
|
||||
{
|
||||
P3.Password = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
P4.Password = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
SetFocus(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
|
||||
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
@@ -16,7 +17,11 @@
|
||||
<Grid MouseDown="DragMove">
|
||||
<hc:SimplePanel Margin="20,50,20,20" >
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Top">
|
||||
<Image Source="/Resource/Image/About.png" Width="400" Height="100"/>
|
||||
<Image Source="/Resource/Image/About.png"
|
||||
Width="400"
|
||||
Height="100"
|
||||
xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndContract}, Delay=250}"
|
||||
/>
|
||||
<TextBlock x:Name="AppInfo" TextAlignment="Center" Text="Copyright © 2021 GeekDesk V"/>
|
||||
<hc:UniformSpacingPanel Spacing="5" HorizontalAlignment="Center" Margin="10,10,0,0" VerticalAlignment="Center">
|
||||
<hc:Shield Subject=".net" Status=">=4.72" Margin="0,0,10,0" Color="#1182c3"/>
|
||||
@@ -27,18 +32,21 @@
|
||||
MouseLeave="SC_MouseLeave"
|
||||
Command="hc:ControlCommands.OpenLink"
|
||||
CommandParameter="https://github.com/BookerLiu/GeekDesk"
|
||||
Margin="0,0,10,0" Color="#24292F"/>
|
||||
Margin="0,0,10,0" Color="#24292F"
|
||||
/>
|
||||
|
||||
<hc:Shield Subject="Gitee" Visibility="Visible" Status="Star"
|
||||
MouseEnter="SC_MouseEnter"
|
||||
MouseLeave="SC_MouseLeave"
|
||||
Command="hc:ControlCommands.OpenLink"
|
||||
CommandParameter="https://gitee.com/BookerLiu/GeekDesk"
|
||||
Margin="0,0,10,0" Color="#C71D23"/>
|
||||
Margin="0,0,10,0" Color="#C71D23"
|
||||
/>
|
||||
|
||||
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" HorizontalAlignment="Center" Margin="0,5,0,0">
|
||||
<hc:Shield Subject="公众号" Visibility="Visible" Status="抓几个娃" Margin="0,0,5,0" Color="#04913B">
|
||||
<hc:Shield x:Name="PublicWeChatPanel" Subject="公众号" Visibility="Visible" Status="抓几个娃" Margin="0,0,5,0" Color="#04913B">
|
||||
<hc:Poptip.Instance>
|
||||
<hc:Poptip PlacementType="Top">
|
||||
<hc:Poptip.Content>
|
||||
|
||||
@@ -16,6 +16,15 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
InitializeComponent();
|
||||
AppInfo.Text += ConfigurationManager.AppSettings["Version"];
|
||||
string showPublicWeChat = ConfigurationManager.AppSettings["ShowPublicWeChat"];
|
||||
if ("Y".Equals(showPublicWeChat))
|
||||
{
|
||||
PublicWeChatPanel.Visibility = Visibility.Visible;
|
||||
} else
|
||||
{
|
||||
PublicWeChatPanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
PublicWeChat.Source = ImageUtil.Base64ToBitmapImage(Constants.PUBLIC_WE_CHAT_IMG_BASE64);
|
||||
WeChatCode.Source = ImageUtil.Base64ToBitmapImage(Constants.WE_CHAT_CODE_IMG_BASE64);
|
||||
ZFBCode.Source = ImageUtil.Base64ToBitmapImage(Constants.ZFB_CODE_IMG_BASE64);
|
||||
|
||||
@@ -84,15 +84,7 @@
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="主窗口动画效果" IsChecked="{Binding AppAnimation}" Click="Animation_Checked">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="面板关闭方式" VerticalAlignment="Center"/>
|
||||
|
||||
@@ -35,8 +35,6 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
/// <param name="e"></param>
|
||||
private void HotKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
Console.WriteLine("downKey:" + e.Key.ToString());
|
||||
|
||||
lock (this)
|
||||
{
|
||||
HotKeyType hkType = (HotKeyType)(sender as TextBox).Tag;
|
||||
@@ -50,8 +48,6 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
if (!CheckIsEnable(hkType)) return;
|
||||
|
||||
|
||||
Console.WriteLine("prevKeyTemp:" + prevKeyTemp.ToString());
|
||||
|
||||
if (prevKeyTemp == Key.None || prevKeyTemp != downKey)
|
||||
{
|
||||
if (hotkeyFinished)
|
||||
@@ -101,7 +97,6 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
appConfig.ColorPickerHotkeyModifiers = GetModifierKeys(downKey);
|
||||
break;
|
||||
}
|
||||
Console.WriteLine("进入设置" + downKey.ToString());
|
||||
prevKeyTemp = downKey;
|
||||
keysTemp.Add(e);
|
||||
}
|
||||
@@ -119,7 +114,10 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
KeyUtil.KeyProp keyProp = new KeyUtil.KeyProp();
|
||||
KeyUtil.KeyToChar(downKey, ref keyProp, true);
|
||||
string downKeyStr = keyProp.character.ToString();
|
||||
//string downKeyStr = "";
|
||||
if (keyProp.character == '\x00')
|
||||
{
|
||||
downKeyStr = downKey.ToString();
|
||||
}
|
||||
switch (hkType)
|
||||
{
|
||||
case HotKeyType.Main:
|
||||
@@ -308,15 +306,6 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
}
|
||||
}
|
||||
|
||||
private void Animation_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed)
|
||||
{
|
||||
MainWindow.mainWindow.Visibility = Visibility.Visible;
|
||||
// 执行一下动画 防止太过突兀
|
||||
MainWindow.FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -326,14 +315,17 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
/// <param name="e"></param>
|
||||
private void MouseMiddle_Changed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (appConfig.MouseMiddleShow)
|
||||
{
|
||||
MouseHookThread.MiddleHook();
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (appConfig.MouseMiddleShow)
|
||||
//{
|
||||
// MouseHookThread.MiddleHook();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// MouseHookThread.DisposeMiddle();
|
||||
//}
|
||||
|
||||
MouseHookThread.Dispose();
|
||||
}
|
||||
MouseHookThread.Hook();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -350,7 +342,8 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
if (true == appConfig.EnableAppHotKey)
|
||||
{
|
||||
MainWindow.RegisterHotKey(false);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MainWindow.hotKeyId != -1)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
|
||||
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:AppConfig}"
|
||||
mc:Ignorable="d"
|
||||
Background="Transparent"
|
||||
d:DesignHeight="400" d:DesignWidth="500"
|
||||
@@ -41,6 +41,20 @@
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<TextBlock Text="插件" Margin="0,20,0,0"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,6,0,0">
|
||||
<CheckBox Content="时钟显秒" Click="ShowSeconds_Click" IsChecked="{Binding SecondsWindow}"
|
||||
hc:Poptip.HitMode="None"
|
||||
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
|
||||
hc:Poptip.Content="仅Win11有效"
|
||||
hc:Poptip.Placement="TopLeft">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<TextBlock Text="排序方式" Margin="0,25,0,0"/>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,8,0,0">
|
||||
@@ -93,6 +107,16 @@
|
||||
Foreground="Black"
|
||||
IsChecked="{Binding UpdateType, Mode=TwoWay, Converter={StaticResource UpdateTypeConvert}, ConverterParameter=2}"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<TextBlock Text="其它" Margin="0,25,0,0"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,8,0,0">
|
||||
<Button Content="备份数据"
|
||||
hc:Poptip.Content="当数据文件损坏时, 以便能够恢复部分数据 (损坏时将有操作提示)"
|
||||
hc:Poptip.Placement="TopLeft"
|
||||
hc:Poptip.Offset="10"
|
||||
Style="{StaticResource Btn1}"
|
||||
Click="BakDataFile"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
</hc:SimplePanel>
|
||||
</Grid>
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.MyThread;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using ShowSeconds;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Management;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
@@ -107,5 +113,80 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
CountLowSort.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
private void BakDataFile(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CommonCode.BakAppData();
|
||||
}
|
||||
|
||||
private void ShowSeconds_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (MainWindow.appData.AppConfig.SecondsWindow == true)
|
||||
{
|
||||
//StartSecondsWindow();
|
||||
SecondsWindow.ShowWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
SecondsWindow.CloseWindow();
|
||||
//StopSecondsWindow();
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopSecondsWindow()
|
||||
{
|
||||
if (MessageUtil.CheckWindowIsRuning("ShowSeconds_Main_" + Constants.MY_UUID))
|
||||
{
|
||||
MessageUtil.SendMsgByWName(
|
||||
"ShowSeconds_Main_" + Constants.MY_UUID,
|
||||
"Shutdown"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static void StartSecondsWindow()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var objOS = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem"))
|
||||
{
|
||||
foreach (ManagementObject objMgmt in objOS.Get())
|
||||
{
|
||||
if (objMgmt.Properties["Caption"].Value != null)
|
||||
{
|
||||
string caption = objMgmt.Properties["Caption"].Value.ToString(); ;
|
||||
LogUtil.WriteLog("获取的系统版本号为:" + caption);
|
||||
if (caption.Contains("Windows 11"))
|
||||
{
|
||||
//找到ShowSeconds插件
|
||||
FileInfo fi = FileUtil.GetFileByNameWithDir("ShowSeconds.exe", Constants.PLUGINS_PATH);
|
||||
if (fi == null)
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Show("未安装程序插件:ShowSeconds");
|
||||
}
|
||||
else
|
||||
{
|
||||
//检查是否在运行
|
||||
if (!MessageUtil.CheckWindowIsRuning("ShowSeconds_Main_" + Constants.MY_UUID))
|
||||
{
|
||||
using (Process p = new Process())
|
||||
{
|
||||
p.StartInfo.FileName = fi.FullName;
|
||||
p.StartInfo.WorkingDirectory = fi.FullName.Substring(0, fi.FullName.LastIndexOf("\\"));
|
||||
p.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { }
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,24 @@
|
||||
<hc:Divider LineStrokeDashArray="3,3" Margin="0,0,0,0" Height="20" LineStroke="Black" Grid.ColumnSpan="1"/>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="5,-10,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="主窗口动画" IsChecked="{Binding AppAnimation}" Click="Animation_Checked">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="5,10,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="列表展开动画" IsChecked="{Binding ItemSpradeAnimation}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="5,10,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox x:Name="BarIcon" Content="显示托盘图标" IsChecked="{Binding ShowBarIcon}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
@@ -120,7 +138,7 @@
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="5,5,0,0" Grid.ColumnSpan="4">
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="5,10,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="显示主面板Logo" IsChecked="{Binding TitleLogoVisible, Mode=TwoWay, Converter={StaticResource Visibility2BooleanConverter}}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
@@ -149,7 +167,7 @@
|
||||
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="背景图片不透明度" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="背景不透明度" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding BgOpacity}"
|
||||
@@ -164,7 +182,7 @@
|
||||
</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"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
@@ -177,7 +195,7 @@
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
</hc:UniformSpacingPanel>-->
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="主面板圆角大小" VerticalAlignment="Center"/>
|
||||
|
||||
@@ -157,5 +157,16 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
GradientBGDialog gbg = new GradientBGDialog();
|
||||
gbg.dialog = HandyControl.Controls.Dialog.Show(gbg, "ConfigWindowDialog");
|
||||
}
|
||||
|
||||
|
||||
private void Animation_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed)
|
||||
{
|
||||
appConfig.IsShow = true;
|
||||
}
|
||||
appConfig.IsShow = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
xmlns:cst="clr-namespace:GeekDesk.Constant"
|
||||
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
@@ -18,11 +19,18 @@
|
||||
<Setter Property="Margin" Value="0,0,0,1"/>
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Opacity="0"/>
|
||||
<SolidColorBrush Color="Black" Opacity="0.01"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="AllowDrop" Value="True"/>
|
||||
<EventSetter Event="Drop" Handler="Menu_Drop"/>
|
||||
<EventSetter Event="PreviewDragEnter" Handler="Menu_PreviewDragEnter"/>
|
||||
<EventSetter Event="PreviewDragLeave" Handler="Menu_PreviewDragLeave"/>
|
||||
<EventSetter Event="MouseLeave" Handler="Menu_MouseLeave"/>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<EventSetter Event="MouseEnter" Handler="Menu_MouseEnter"/>
|
||||
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListBoxItem_MouseDown"/>
|
||||
<EventSetter Event="PreviewMouseRightButtonDown" Handler="ListBoxItem_PreviewMouseRightButtonDown"/>
|
||||
<!--<EventSetter Event="Unselected" Handler="Lbi_Unselected"/>-->
|
||||
<Style.Triggers>
|
||||
<MultiTrigger>
|
||||
@@ -45,7 +53,11 @@
|
||||
</BeginStoryboard>
|
||||
</MultiTrigger.ExitActions>
|
||||
<MultiTrigger.Setters>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="Black" Opacity="0.01"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</MultiTrigger.Setters>
|
||||
</MultiTrigger>
|
||||
@@ -66,22 +78,55 @@
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</Trigger>-->
|
||||
<Trigger Property="IsMouseOver" Value="False">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Background" Value="#00FFFFFF"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</Trigger>
|
||||
|
||||
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="MyPoptipStyle" TargetType="Border">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
||||
<Setter Property="CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
|
||||
<Setter Property="Padding" Value="{StaticResource DefaultControlPadding}"/>
|
||||
<!--<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="hc:Poptip">
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>-->
|
||||
</Style>
|
||||
|
||||
<cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
|
||||
<cvt:OpcityConvert x:Key="OpcityConvert"/>
|
||||
<cvt:StringAppendConvert x:Key="StringAppendConvert"/>
|
||||
</UserControl.Resources>
|
||||
<Grid Background="Transparent">
|
||||
<Popup Name="MyPoptip" FlowDirection="LeftToRight"
|
||||
PopupAnimation="None" Placement="Mouse" IsOpen="False"
|
||||
AllowsTransparency="True"
|
||||
>
|
||||
<Grid Background="Transparent">
|
||||
<Border Style="{StaticResource MyPoptipStyle}">
|
||||
<TextBlock Name="MyPoptipContent" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" Text="Test" FontSize="14"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Popup>
|
||||
|
||||
<!--左侧栏-->
|
||||
<hc:Card x:Name="MyCard"
|
||||
BorderThickness="1"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
Margin="5,0,0,5"
|
||||
MouseDown="MyCard_MouseDown"
|
||||
PreviewMouseRightButtonDown="MyCard_PreviewMouseRightButtonDown"
|
||||
>
|
||||
<hc:Card.Background>
|
||||
<SolidColorBrush Color="#FFFFFFFF" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
|
||||
@@ -94,8 +139,10 @@
|
||||
<hc:Card.ContextMenu>
|
||||
<ContextMenu Width="200">
|
||||
<MenuItem Header="新建菜单" Click="CreateMenu"/>
|
||||
<MenuItem x:Name="AlterPW1" Header="修改密码" Click="AlterPassword"/>
|
||||
</ContextMenu>
|
||||
</hc:Card.ContextMenu>
|
||||
|
||||
<WrapPanel Orientation="Horizontal">
|
||||
<ListBox x:Name="MenuListBox"
|
||||
Padding="2,3,0,2"
|
||||
@@ -106,11 +153,14 @@
|
||||
VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
SelectionChanged="Menu_SelectionChanged"
|
||||
PreviewMouseWheel="Menu_MouseWheel"
|
||||
PreviewMouseRightButtonDown="MyCard_PreviewMouseRightButtonDown"
|
||||
>
|
||||
<ListBox.Resources>
|
||||
<ContextMenu x:Key="MenuDialog" Width="200">
|
||||
<MenuItem Header="新建菜单" Click="CreateMenu"/>
|
||||
<MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
|
||||
<MenuItem Header="加密此列表" Click="EncryptMenu" Tag="{Binding}"/>
|
||||
<MenuItem x:Name="AlterPW2" Header="修改密码" Click="AlterPassword"/>
|
||||
<MenuItem Header="修改图标" Click="EditMenuGeometry" Tag="{Binding}"/>
|
||||
<MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
|
||||
</ContextMenu>
|
||||
@@ -133,7 +183,7 @@
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Tag="{Binding}" MouseDown="ListBoxItem_MouseDown">
|
||||
<StackPanel Tag="{Binding}">
|
||||
<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}, ConverterParameter=35}"
|
||||
@@ -172,4 +222,5 @@
|
||||
</ListBox>
|
||||
</WrapPanel>
|
||||
</hc:Card>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,5 +1,6 @@
|
||||
using DraggAnimatedPanelExample;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Other;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
@@ -24,9 +25,6 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
private SolidColorBrush bac = new SolidColorBrush(Color.FromRgb(236, 236, 236));
|
||||
|
||||
|
||||
//是否正在修改菜单
|
||||
private static bool IS_EDIT = false;
|
||||
|
||||
public LeftCardControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -162,6 +160,8 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
|
||||
private void Lbi_Selected(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
ListBoxItem lbi = sender as ListBoxItem;
|
||||
|
||||
@@ -171,6 +171,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
lbi.Background = bac;
|
||||
lbi.Foreground = fontColor;
|
||||
}
|
||||
catch { }
|
||||
|
||||
}
|
||||
|
||||
private void Lbi_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
@@ -205,9 +208,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
/// <param name="e"></param>
|
||||
private void RenameMenu(object sender, RoutedEventArgs e)
|
||||
{
|
||||
RunTimeStatus.IS_MENU_EDIT = true;
|
||||
MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
|
||||
menuInfo.MenuEdit = (int)Visibility.Visible;
|
||||
IS_EDIT = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -275,7 +278,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
menuInfo.MenuName = text;
|
||||
menuInfo.MenuEdit = Visibility.Collapsed;
|
||||
}
|
||||
IS_EDIT = false;
|
||||
RunTimeStatus.IS_MENU_EDIT = false;
|
||||
//为了解决无法修改菜单的问题
|
||||
MainWindow.mainWindow.SearchBox.Focus();
|
||||
MenuListBox.SelectedIndex = menuSelectIndexTemp;
|
||||
}
|
||||
}
|
||||
@@ -309,6 +314,14 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
|
||||
private void Menu_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (RunTimeStatus.IS_MENU_EDIT) return;
|
||||
|
||||
if (appData.AppConfig.ItemSpradeAnimation)
|
||||
{
|
||||
//是否启用列表展开动画
|
||||
MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
//设置对应菜单的图标列表
|
||||
if (MenuListBox.SelectedIndex == -1)
|
||||
{
|
||||
@@ -316,9 +329,23 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
else
|
||||
{
|
||||
if (appData.MenuList[MenuListBox.SelectedIndex].IsEncrypt)
|
||||
{
|
||||
appData.AppConfig.SelectedMenuIcons = null;
|
||||
RunTimeStatus.SHOW_MENU_PASSWORDBOX = true;
|
||||
MainWindow.mainWindow.RightCard.PDDialog.Title.Text = "输入密码";
|
||||
MainWindow.mainWindow.RightCard.PDDialog.type = PasswordType.INPUT;
|
||||
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Collapsed;
|
||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList;
|
||||
}
|
||||
}
|
||||
MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Visible;
|
||||
//App.DoEvents();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -328,7 +355,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
/// <param name="e"></param>
|
||||
private void Menu_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (appData.AppConfig.HoverMenu && !IS_EDIT)
|
||||
if (appData.AppConfig.HoverMenu && !RunTimeStatus.IS_MENU_EDIT)
|
||||
{
|
||||
Thread t = new Thread(() =>
|
||||
{
|
||||
@@ -359,8 +386,31 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
MainWindow.mainWindow.HidedSearchBox();
|
||||
}
|
||||
|
||||
ListBoxItem lbi = sender as ListBoxItem;
|
||||
MenuInfo mi = lbi.DataContext as MenuInfo;
|
||||
int index = MenuListBox.Items.IndexOf(mi);
|
||||
MenuListBox.SelectedIndex = index;
|
||||
}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 点击菜单后 隐藏搜索框
|
||||
///// </summary>
|
||||
///// <param name="sender"></param>
|
||||
///// <param name="e"></param>
|
||||
//private void ListBoxItemPanel_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
//{
|
||||
// if (RunTimeStatus.SEARCH_BOX_SHOW)
|
||||
// {
|
||||
// MainWindow.mainWindow.HidedSearchBox();
|
||||
// }
|
||||
// MenuInfo mi = (sender as StackPanel).Tag as MenuInfo;
|
||||
// int index = MenuListBox.Items.IndexOf(mi);
|
||||
// MenuListBox.SelectedIndex = index;
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏搜索框
|
||||
/// </summary>
|
||||
@@ -376,18 +426,29 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
|
||||
private void Menu_MouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (RunTimeStatus.IS_MENU_EDIT) return;
|
||||
|
||||
ScrollViewer scrollViewer = ScrollUtil.FindSimpleVisualChild<ScrollViewer>(MenuListBox);
|
||||
if (e.Delta < 0)
|
||||
{
|
||||
//判断是否到了最底部
|
||||
if (ScrollUtil.IsBootomScrollView(scrollViewer))
|
||||
{
|
||||
int index = MenuListBox.SelectedIndex;
|
||||
if (index < MenuListBox.Items.Count - 1)
|
||||
{
|
||||
index++;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
MenuListBox.SelectedIndex = index;
|
||||
} else if (e.Delta > 0)
|
||||
}
|
||||
}
|
||||
else if (e.Delta > 0)
|
||||
{
|
||||
if (ScrollUtil.IsTopScrollView(scrollViewer))
|
||||
{
|
||||
int index = MenuListBox.SelectedIndex;
|
||||
if (index > 0)
|
||||
@@ -401,5 +462,142 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
MenuListBox.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
//滚动到选中项
|
||||
MenuListBox.ScrollIntoView(MenuListBox.SelectedItem);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void Menu_PreviewDragLeave(object sender, DragEventArgs e)
|
||||
{
|
||||
MyPoptip.IsOpen = false;
|
||||
}
|
||||
|
||||
private void Menu_PreviewDragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
MenuInfo mi = (sender as ListBoxItem).DataContext as MenuInfo;
|
||||
MyPoptipContent.Text = "移动至:" + mi.MenuName;
|
||||
MyPoptip.VerticalOffset = 30;
|
||||
MyPoptip.IsOpen = true;
|
||||
}
|
||||
|
||||
private void Menu_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
MyPoptip.IsOpen = false;
|
||||
}
|
||||
|
||||
private void Menu_Drop(object sender, DragEventArgs e)
|
||||
{
|
||||
MyPoptip.IsOpen = false;
|
||||
|
||||
MenuInfo mi = (sender as ListBoxItem).DataContext as MenuInfo;
|
||||
IconInfo iconInfo = (IconInfo)e.Data.GetData(typeof(IconInfo));
|
||||
|
||||
appData.MenuList[MenuListBox.SelectedIndex].IconList.Remove(iconInfo);
|
||||
appData.MenuList[MenuListBox.Items.IndexOf(mi)].IconList.Add(iconInfo);
|
||||
}
|
||||
|
||||
private void EncryptMenu(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
|
||||
if (menuInfo.IsEncrypt)
|
||||
{
|
||||
MainWindow.mainWindow.RightCard.PDDialog.menuInfo = menuInfo;
|
||||
MainWindow.mainWindow.RightCard.PDDialog.Title.Text = "输入密码";
|
||||
MainWindow.mainWindow.RightCard.PDDialog.type = PasswordType.CANCEL;
|
||||
RunTimeStatus.SHOW_MENU_PASSWORDBOX = true;
|
||||
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Visible;
|
||||
//单独设置焦点
|
||||
MainWindow.mainWindow.RightCard.PDDialog.SetFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(appData.AppConfig.MenuPassword))
|
||||
{
|
||||
MainWindow.mainWindow.RightCard.PDDialog.menuInfo = menuInfo;
|
||||
MainWindow.mainWindow.RightCard.PDDialog.Title.Text = "设置新密码";
|
||||
MainWindow.mainWindow.RightCard.PDDialog.type = PasswordType.CREATE;
|
||||
RunTimeStatus.SHOW_MENU_PASSWORDBOX = true;
|
||||
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
menuInfo.IsEncrypt = true;
|
||||
HandyControl.Controls.Growl.Success(menuInfo.MenuName + " 已加密!", "MainWindowGrowl");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AlterPassword(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MainWindow.mainWindow.RightCard.PDDialog.Title.Text = "输入旧密码";
|
||||
MainWindow.mainWindow.RightCard.PDDialog.type = PasswordType.ALTER;
|
||||
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Visible;
|
||||
//单独设置焦点
|
||||
MainWindow.mainWindow.RightCard.PDDialog.SetFocus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右键点击进行处理
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MyCard_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
RunTimeStatus.SHOW_RIGHT_BTN_MENU = true;
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(50);
|
||||
RunTimeStatus.SHOW_RIGHT_BTN_MENU = false;
|
||||
}).Start();
|
||||
|
||||
//在没有设置密码的情况下不弹出修改密码菜单
|
||||
if (string.IsNullOrEmpty(appData.AppConfig.MenuPassword))
|
||||
{
|
||||
AlterPW1.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
AlterPW1.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
private void ListBoxItem_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ListBoxItem lbi = sender as ListBoxItem;
|
||||
MenuInfo info = lbi.DataContext as MenuInfo;
|
||||
|
||||
ItemCollection ics = lbi.ContextMenu.Items;
|
||||
|
||||
foreach (object obj in ics)
|
||||
{
|
||||
MenuItem mi = (MenuItem)obj;
|
||||
if (mi.Header.Equals("修改密码"))
|
||||
{
|
||||
if (string.IsNullOrEmpty(appData.AppConfig.MenuPassword))
|
||||
{
|
||||
mi.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
mi.Visibility = Visibility.Visible;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (mi.Header.Equals("加密此列表") || mi.Header.Equals("取消加密此列表"))
|
||||
{
|
||||
if (info.IsEncrypt)
|
||||
{
|
||||
mi.Header = "取消加密此列表";
|
||||
}
|
||||
else
|
||||
{
|
||||
mi.Header = "加密此列表";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
xmlns:temp="clr-namespace:GeekDesk.ViewModel.Temp"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
xmlns:cst="clr-namespace:GeekDesk.Constant"
|
||||
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
|
||||
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
|
||||
xmlns:ot="clr-namespace:GeekDesk.Control.Other"
|
||||
xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:AppData}"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
>
|
||||
@@ -19,15 +23,6 @@
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>-->
|
||||
|
||||
<Storyboard x:Key="Custom1Transition" x:Shared="False">
|
||||
<DoubleAnimation From="50" To="0" Duration="0:0:0.4" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
|
||||
<DoubleAnimation.EasingFunction>
|
||||
<ElasticEase Oscillations="1"/>
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
</Storyboard>
|
||||
|
||||
<Style x:Key="ImageStyle" TargetType="Image">
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageWidth, Mode=OneWay}"/>
|
||||
<Setter Property="Height" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"/>
|
||||
@@ -46,12 +41,85 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SearchListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
||||
<Border>
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="MyPoptipStyle" TargetType="Border">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
||||
<Setter Property="CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
|
||||
<Setter Property="Padding" Value="{StaticResource DefaultControlPadding}"/>
|
||||
<!--<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="hc:Poptip">
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>-->
|
||||
</Style>
|
||||
|
||||
<Storyboard x:Key="Custom1Transition1" x:Shared="False">
|
||||
<DoubleAnimation From="50" To="0" Duration="0:0:0.4" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
|
||||
<DoubleAnimation.EasingFunction>
|
||||
<ElasticEase Oscillations="1"/>
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="Custom2Transition2" x:Shared="False">
|
||||
<DoubleAnimation From="10" To="0" Duration="0:0:0.4" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
|
||||
<DoubleAnimation.EasingFunction>
|
||||
<ElasticEase Oscillations="1"/>
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
</Storyboard>
|
||||
|
||||
<Storyboard x:Key="Custom3Transition3" x:Shared="False">
|
||||
<DoubleAnimation From=".8" To="1" Duration="0:0:0.4">
|
||||
<DoubleAnimation.EasingFunction>
|
||||
<ElasticEase Oscillations="1"/>
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
</Storyboard>
|
||||
|
||||
<cvt:OpcityConvert x:Key="OpcityConvert"/>
|
||||
<cvt:SearchResWidth x:Key="SearchResWidth"/>
|
||||
<cvt:GetWidthByWWConvert x:Key="GetWidthByWWConvert"/>
|
||||
<temp:SearchIconList x:Key="SearchIconList"/>
|
||||
</UserControl.Resources>
|
||||
<!--右侧栏-->
|
||||
<Grid>
|
||||
<Popup Name="MyPoptip" FlowDirection="LeftToRight"
|
||||
PopupAnimation="None" Placement="Mouse"
|
||||
IsOpen="False"
|
||||
AllowsTransparency="True"
|
||||
>
|
||||
<Grid Background="Transparent">
|
||||
<Border Style="{StaticResource MyPoptipStyle}">
|
||||
<TextBlock Name="MyPoptipContent" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Left" Text="Test" FontSize="13"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Popup>
|
||||
|
||||
<hc:Card AllowDrop="True"
|
||||
x:Name="WrapCard"
|
||||
Visibility="Visible"
|
||||
@@ -59,7 +127,10 @@
|
||||
BorderThickness="1"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
Margin="5,0,5,5" Grid.ColumnSpan="2"
|
||||
PreviewMouseRightButtonDown="WrapCard_PreviewMouseRightButtonDown">
|
||||
PreviewMouseRightButtonDown="WrapCard_PreviewMouseRightButtonDown"
|
||||
hc:Dialog.Token="RightWrapCardDialog"
|
||||
MouseWheel="IconListBox_MouseWheel"
|
||||
>
|
||||
<hc:Card.Background>
|
||||
<SolidColorBrush Color="AliceBlue" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
|
||||
</hc:Card.Background>
|
||||
@@ -73,26 +144,62 @@
|
||||
<MenuItem x:Name="CardLockCM" Header="锁定主面板" Click="LockAppPanel"/>
|
||||
</ContextMenu>
|
||||
</hc:Card.ContextMenu>
|
||||
<hc:DialogContainer>
|
||||
<Grid>
|
||||
<StackPanel Panel.ZIndex="1" Margin="0,-10,-300,0" hc:Growl.GrowlParent="True" hc:Growl.Token="MainWindowGrowl"/>
|
||||
<WrapPanel Orientation="Horizontal" VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
<ot:PasswordDialog xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndGrowHorizontally}, Event=Visibility, Duration=50, Delay=0}"
|
||||
x:Name="PDDialog"
|
||||
Panel.ZIndex="99"
|
||||
IsVisibleChanged="PDDialog_IsVisibleChanged"
|
||||
Margin="0,-100,0,0"/>
|
||||
<StackPanel Panel.ZIndex="1" Margin="0,-10,-0,0"/>
|
||||
|
||||
<WrapPanel Orientation="Horizontal"
|
||||
Margin="10"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
>
|
||||
<ListBox x:Name="IconListBox" ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=OneWay}"
|
||||
<UniformGrid x:Name="WrapUFG" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndGrowHorizontally}, Event=Visibility}">
|
||||
<!--<hc:TransitioningContentControl TransitionStoryboard="{StaticResource Custom3Transition3}">-->
|
||||
<ListBox x:Name="IconListBox"
|
||||
ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=OneWay}"
|
||||
BorderThickness="0"
|
||||
Padding="0,10,0,0"
|
||||
ScrollViewer.CanContentScroll ="False"
|
||||
>
|
||||
<ListBox.Template>
|
||||
<ControlTemplate TargetType="ListBox">
|
||||
<hc:ScrollViewer x:Name="WrapScroll"
|
||||
Orientation="Vertical"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
IsInertiaEnabled="True"
|
||||
CanContentScroll="True"
|
||||
PreviewMouseWheel="IconListBox_MouseWheel"
|
||||
>
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderBrush}">
|
||||
<ItemsPresenter/>
|
||||
|
||||
</Border>
|
||||
</hc:ScrollViewer>
|
||||
</ControlTemplate>
|
||||
</ListBox.Template>
|
||||
<ListBox.Background>
|
||||
<SolidColorBrush Opacity="0"/>
|
||||
<SolidColorBrush Color="#00FFFFFF" />
|
||||
</ListBox.Background>
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<DraggAnimatedPanel:DraggAnimatedPanel Background="#00FFFFFF"
|
||||
<!--<DraggAnimatedPanel:DraggAnimatedPanel Background="#00FFFFFF"
|
||||
ItemsWidth="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelWidth, Mode=OneWay}"
|
||||
ItemsHeight="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelHeight, Mode=OneWay}"
|
||||
HorizontalAlignment="Center"
|
||||
SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
|
||||
SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>-->
|
||||
|
||||
<WrapPanel Background="#00FFFFFF"
|
||||
Width="{Binding AppConfig.WindowWidth, Mode=OneWay,
|
||||
Converter={StaticResource GetWidthByWWConvert},
|
||||
ConverterParameter={x:Static cst:WidthTypeEnum.RIGHT_CARD}}"
|
||||
/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
@@ -116,15 +223,15 @@
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
||||
<hc:SimpleStackPanel Tag="{Binding}"
|
||||
Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelHeight, Mode=OneWay}"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelWidth, Mode=OneWay}"
|
||||
HorizontalAlignment="Center"
|
||||
hc:Poptip.Content="{Binding Content}"
|
||||
hc:Poptip.Placement="BottomLeft"
|
||||
Background="#00FFFFFF"
|
||||
MouseEnter="StackPanel_MouseEnter"
|
||||
MouseLeave="StackPanel_MouseLeave"
|
||||
MouseEnter="MenuIcon_MouseEnter"
|
||||
MouseLeave="MenuIcon_MouseLeave"
|
||||
MouseMove="MenuIcon_MouseMove"
|
||||
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
|
||||
>
|
||||
@@ -150,10 +257,12 @@
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<!--</hc:TransitioningContentControl>-->
|
||||
</UniformGrid>
|
||||
</WrapPanel>
|
||||
|
||||
</Grid>
|
||||
</hc:DialogContainer>
|
||||
</hc:Card>
|
||||
|
||||
<hc:Card x:Name="VerticalCard"
|
||||
@@ -172,17 +281,35 @@
|
||||
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
|
||||
</hc:Card.BorderBrush>
|
||||
<Grid>
|
||||
<StackPanel Panel.ZIndex="1" Margin="0,-10,-300,0" hc:Growl.GrowlParent="True" hc:Growl.Token="MainWindowGrowl"/>
|
||||
<WrapPanel Orientation="Horizontal" VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
Margin="10"
|
||||
>
|
||||
<UniformGrid x:Name="VerticalUFG">
|
||||
<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">
|
||||
<UniformGrid x:Name="VerticalUFG" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, OffsetY= -10, Event=Visibility}">
|
||||
<!--<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">-->
|
||||
<ListBox ItemsSource="{Binding Source={StaticResource SearchIconList},Path=IconList}"
|
||||
BorderThickness="0"
|
||||
Padding="0,10,0,0"
|
||||
x:Name="SearchListBox"
|
||||
SelectionChanged="SearchListBox_SelectionChanged"
|
||||
>
|
||||
<ListBox.Template>
|
||||
<ControlTemplate TargetType="ListBox">
|
||||
<hc:ScrollViewer Orientation="Vertical"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
IsInertiaEnabled="True"
|
||||
CanContentScroll="True"
|
||||
PreviewMouseWheel="VerticalIconList_PreviewMouseWheel"
|
||||
>
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderBrush}">
|
||||
<ItemsPresenter/>
|
||||
</Border>
|
||||
</hc:ScrollViewer>
|
||||
</ControlTemplate>
|
||||
</ListBox.Template>
|
||||
|
||||
<ListBox.Background>
|
||||
<SolidColorBrush Opacity="0"/>
|
||||
</ListBox.Background>
|
||||
@@ -199,7 +326,7 @@
|
||||
</ListBox.Resources>
|
||||
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MyListBoxItemStyle}">
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource SearchListBoxItemStyle}">
|
||||
<Setter Property="ContextMenu" Value="{StaticResource IconDialog}"/>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
@@ -207,25 +334,47 @@
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Background="#00FFFFFF"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.MenuCardWidth, Mode=OneWay, Converter={StaticResource SearchResWidth}, ConverterParameter=1}"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.WindowWidth, Mode=OneWay,
|
||||
Converter={StaticResource GetWidthByWWConvert},
|
||||
ConverterParameter={x:Static cst:WidthTypeEnum.RIGHT_CARD}}"
|
||||
/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border CornerRadius="8">
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem }}}"
|
||||
Value="True">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="White" Opacity="0.68"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<WrapPanel Tag="{Binding}"
|
||||
Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.MenuCardWidth, Mode=OneWay, Converter={StaticResource SearchResWidth}, ConverterParameter=2}"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.WindowWidth, Mode=OneWay,
|
||||
Converter={StaticResource GetWidthByWWConvert},
|
||||
ConverterParameter={x:Static cst:WidthTypeEnum.RIGHT_CARD_HALF}}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
hc:Poptip.HitMode="None"
|
||||
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
|
||||
hc:Poptip.Content="{Binding Content}"
|
||||
hc:Poptip.Placement="BottomLeft"
|
||||
Background="#00FFFFFF"
|
||||
MouseEnter="SearchIcon_MouseEnter"
|
||||
MouseLeave="SearchIcon_MouseLeave"
|
||||
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
|
||||
Margin="25,20,0,0"
|
||||
MouseMove="SearchIcon_MouseMove"
|
||||
Margin="25,10,0,10"
|
||||
>
|
||||
<Image Style="{StaticResource ImageStyle}" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<TextBlock
|
||||
@@ -239,11 +388,12 @@
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
||||
Text="{Binding Name}"/>
|
||||
</WrapPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
</hc:TransitioningContentControl>
|
||||
<!--</hc:TransitioningContentControl>-->
|
||||
</UniformGrid>
|
||||
</WrapPanel>
|
||||
|
||||
|
||||
@@ -9,10 +9,12 @@ using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Threading;
|
||||
|
||||
@@ -25,68 +27,76 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
private AppData appData = MainWindow.appData;
|
||||
|
||||
private volatile static bool DROP_ICON = false;
|
||||
private Thread dropCheckThread = null;
|
||||
ListBoxDragDropManager<IconInfo> dragMgr;
|
||||
|
||||
//private Thread dropCheckThread = null;
|
||||
|
||||
public RightCardControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Loaded += RightCardControl_Loaded;
|
||||
|
||||
}
|
||||
|
||||
private void RightCardControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.dragMgr = new ListBoxDragDropManager<IconInfo>(this.IconListBox);
|
||||
}
|
||||
|
||||
|
||||
#region 图标拖动
|
||||
DelegateCommand<int[]> _swap;
|
||||
public DelegateCommand<int[]> SwapCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_swap == null)
|
||||
_swap = new DelegateCommand<int[]>(
|
||||
(indexes) =>
|
||||
{
|
||||
DROP_ICON = true;
|
||||
if (appData.AppConfig.IconSortType != SortType.CUSTOM
|
||||
&& (dropCheckThread == null || !dropCheckThread.IsAlive))
|
||||
{
|
||||
dropCheckThread = new Thread(() =>
|
||||
{
|
||||
do
|
||||
{
|
||||
DROP_ICON = false;
|
||||
Thread.Sleep(1000);
|
||||
} while (DROP_ICON);
|
||||
//#region 图标拖动
|
||||
//DelegateCommand<int[]> _swap;
|
||||
//public DelegateCommand<int[]> SwapCommand
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (_swap == null)
|
||||
// _swap = new DelegateCommand<int[]>(
|
||||
// (indexes) =>
|
||||
// {
|
||||
// DROP_ICON = true;
|
||||
// if (appData.AppConfig.IconSortType != SortType.CUSTOM
|
||||
// && (dropCheckThread == null || !dropCheckThread.IsAlive))
|
||||
// {
|
||||
// dropCheckThread = new Thread(() =>
|
||||
// {
|
||||
// do
|
||||
// {
|
||||
// DROP_ICON = false;
|
||||
// Thread.Sleep(1000);
|
||||
// } while (DROP_ICON);
|
||||
|
||||
MainWindow.appData.AppConfig.IconSortType = SortType.CUSTOM;
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed
|
||||
|| MainWindow.mainWindow.Opacity != 1)
|
||||
{
|
||||
Growl.WarningGlobal("已将图标排序规则重置为自定义!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("已将图标排序规则重置为自定义!", "MainWindowGrowl");
|
||||
}
|
||||
});
|
||||
});
|
||||
dropCheckThread.Start();
|
||||
}
|
||||
int fromS = indexes[0];
|
||||
int to = indexes[1];
|
||||
ObservableCollection<IconInfo> iconList = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
|
||||
var elementSource = iconList[to];
|
||||
var dragged = iconList[fromS];
|
||||
// MainWindow.appData.AppConfig.IconSortType = SortType.CUSTOM;
|
||||
// App.Current.Dispatcher.Invoke(() =>
|
||||
// {
|
||||
// if (MainWindow.mainWindow.Visibility == Visibility.Collapsed
|
||||
// || MainWindow.mainWindow.Opacity != 1)
|
||||
// {
|
||||
// Growl.WarningGlobal("已将图标排序规则重置为自定义!");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Growl.Warning("已将图标排序规则重置为自定义!", "MainWindowGrowl");
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// dropCheckThread.Start();
|
||||
// }
|
||||
// int fromS = indexes[0];
|
||||
// int to = indexes[1];
|
||||
// ObservableCollection<IconInfo> iconList = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
|
||||
// var elementSource = iconList[to];
|
||||
// var dragged = iconList[fromS];
|
||||
|
||||
iconList.Remove(dragged);
|
||||
iconList.Insert(to, dragged);
|
||||
}
|
||||
);
|
||||
return _swap;
|
||||
}
|
||||
}
|
||||
// iconList.Remove(dragged);
|
||||
// iconList.Insert(to, dragged);
|
||||
// }
|
||||
// );
|
||||
// return _swap;
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion 图标拖动
|
||||
//#endregion 图标拖动
|
||||
|
||||
|
||||
|
||||
@@ -163,7 +173,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
StartIconApp(icon, IconStartType.SHOW_IN_EXPLORE);
|
||||
}
|
||||
|
||||
private void StartIconApp(IconInfo icon, IconStartType type)
|
||||
private void StartIconApp(IconInfo icon, IconStartType type, bool useRelativePath = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -177,19 +187,38 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
else
|
||||
{
|
||||
p.StartInfo.FileName = icon.Path;
|
||||
string path;
|
||||
if (useRelativePath)
|
||||
{
|
||||
string fullPath = Path.Combine(Constants.APP_DIR, icon.RelativePath);
|
||||
path = Path.GetFullPath(fullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = icon.Path;
|
||||
}
|
||||
p.StartInfo.FileName = path;
|
||||
if (!StringUtil.IsEmpty(startArg))
|
||||
{
|
||||
p.StartInfo.Arguments = startArg;
|
||||
}
|
||||
if (icon.IconType == IconType.OTHER)
|
||||
{
|
||||
if (!File.Exists(icon.Path) && !Directory.Exists(icon.Path))
|
||||
if (!File.Exists(path) && !Directory.Exists(path))
|
||||
{
|
||||
//如果没有使用相对路径 那么使用相对路径启动一次
|
||||
if (!useRelativePath)
|
||||
{
|
||||
StartIconApp(icon, type, true);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
|
||||
return;
|
||||
}
|
||||
p.StartInfo.WorkingDirectory = icon.Path.Substring(0, icon.Path.LastIndexOf("\\"));
|
||||
}
|
||||
p.StartInfo.WorkingDirectory = path.Substring(0, path.LastIndexOf("\\"));
|
||||
switch (type)
|
||||
{
|
||||
case IconStartType.ADMIN_STARTUP:
|
||||
@@ -257,6 +286,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
}
|
||||
p.Start();
|
||||
if (useRelativePath)
|
||||
{
|
||||
//如果使用相对路径启动成功 那么重新设置程序绝对路径
|
||||
icon.Path = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
icon.Count++;
|
||||
@@ -269,10 +303,17 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(不支持的启动方式)!");
|
||||
if (!useRelativePath)
|
||||
{
|
||||
StartIconApp(icon, type, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(可能为不支持的启动方式)!");
|
||||
LogUtil.WriteErrorLog(e, "程序启动失败:path=" + icon.Path + ",type=" + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -368,7 +409,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
MainWindow.appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Add(iconInfo);
|
||||
}
|
||||
CommonCode.SortIconList();
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -405,47 +446,64 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
case IconType.URL:
|
||||
IconInfoUrlDialog urlDialog = new IconInfoUrlDialog(info);
|
||||
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "IconInfoDialog");
|
||||
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "MainWindowDialog");
|
||||
break;
|
||||
default:
|
||||
IconInfoDialog dialog = new IconInfoDialog(info);
|
||||
dialog.dialog = HandyControl.Controls.Dialog.Show(dialog, "IconInfoDialog");
|
||||
dialog.dialog = HandyControl.Controls.Dialog.Show(dialog, "MainWindowDialog");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void StackPanel_MouseEnter(object sender, MouseEventArgs e)
|
||||
private void MenuIcon_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
RunTimeStatus.MOUSE_ENTER_ICON = true;
|
||||
if (!RunTimeStatus.ICONLIST_MOUSE_WHEEL)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
IconInfo info = (sender as Panel).Tag as IconInfo;
|
||||
MyPoptipContent.Text = info.Content;
|
||||
MyPoptip.VerticalOffset = 30;
|
||||
Thread.Sleep(50);
|
||||
if (!RunTimeStatus.ICONLIST_MOUSE_WHEEL)
|
||||
{
|
||||
MyPoptip.IsOpen = true;
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
double width = appData.AppConfig.ImageWidth;
|
||||
double height = appData.AppConfig.ImageHeight;
|
||||
width += width * 0.15;
|
||||
height += height * 0.15;
|
||||
Thread t = new Thread(() =>
|
||||
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
ImgStoryBoard(sender, (int)width, (int)height, 1, true);
|
||||
}));
|
||||
});
|
||||
t.IsBackground = true;
|
||||
t.Start();
|
||||
|
||||
}
|
||||
|
||||
private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
|
||||
private void MenuIcon_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
RunTimeStatus.MOUSE_ENTER_ICON = false;
|
||||
MyPoptip.IsOpen = false;
|
||||
|
||||
Thread t = new Thread(() =>
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
ImgStoryBoard(sender, appData.AppConfig.ImageWidth, appData.AppConfig.ImageHeight, 260);
|
||||
}));
|
||||
});
|
||||
t.IsBackground = true;
|
||||
t.Start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -636,7 +694,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
private void AddUrlIcon(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IconInfoUrlDialog urlDialog = new IconInfoUrlDialog();
|
||||
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "IconInfoDialog");
|
||||
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "MainWindowDialog");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -711,10 +769,282 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
if (RunTimeStatus.LOCK_APP_PANEL)
|
||||
{
|
||||
CardLockCM.Header = "解锁主面板";
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
CardLockCM.Header = "锁定主面板";
|
||||
}
|
||||
}
|
||||
|
||||
public void SearchListBoxIndexAdd()
|
||||
{
|
||||
//控制移动后 鼠标即使在图标上也不显示popup
|
||||
RunTimeStatus.MOUSE_MOVE_COUNT = 0;
|
||||
MyPoptip.IsOpen = false;
|
||||
|
||||
if (SearchListBox.Items.Count > 0)
|
||||
{
|
||||
if (SearchListBox.SelectedIndex < SearchListBox.Items.Count - 1)
|
||||
{
|
||||
SearchListBox.SelectedIndex += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SearchListBoxIndexSub()
|
||||
{
|
||||
//控制移动后 鼠标即使在图标上也不显示popup
|
||||
RunTimeStatus.MOUSE_MOVE_COUNT = 0;
|
||||
MyPoptip.IsOpen = false;
|
||||
|
||||
if (SearchListBox.Items.Count > 0)
|
||||
{
|
||||
if (SearchListBox.SelectedIndex > 0)
|
||||
{
|
||||
SearchListBox.SelectedIndex -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StartupSelectionItem()
|
||||
{
|
||||
if (SearchListBox.SelectedItem != null)
|
||||
{
|
||||
IconInfo icon = SearchListBox.SelectedItem as IconInfo;
|
||||
if (icon.AdminStartUp)
|
||||
{
|
||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
SearchListBox.ScrollIntoView(SearchListBox.SelectedItem);
|
||||
}
|
||||
|
||||
private void PDDialog_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (PDDialog.Visibility == Visibility.Visible)
|
||||
{
|
||||
RunTimeStatus.SHOW_MENU_PASSWORDBOX = true;
|
||||
PDDialog.ClearVal();
|
||||
PDDialog.ErrorMsg.Visibility = Visibility.Collapsed;
|
||||
PDDialog.PasswordGrid.Visibility = Visibility.Visible;
|
||||
PDDialog.HintGrid.Visibility = Visibility.Collapsed;
|
||||
PDDialog.count = 0;
|
||||
PDDialog.SetFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
RunTimeStatus.SHOW_MENU_PASSWORDBOX = false;
|
||||
PDDialog.ClearVal();
|
||||
MainWindow.mainWindow.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单结果icon 列表鼠标滚轮预处理时间
|
||||
/// 主要使用自定义popup解决卡顿问题解决卡顿问题
|
||||
/// 以及滚动条收尾切换菜单
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void IconListBox_MouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
|
||||
//控制在滚动时不显示popup 否则会在低GPU性能机器上造成卡顿
|
||||
MyPoptip.IsOpen = false;
|
||||
if (RunTimeStatus.ICONLIST_MOUSE_WHEEL)
|
||||
{
|
||||
RunTimeStatus.MOUSE_WHEEL_WAIT_MS = 500;
|
||||
}
|
||||
else
|
||||
{
|
||||
RunTimeStatus.ICONLIST_MOUSE_WHEEL = true;
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
while (RunTimeStatus.MOUSE_WHEEL_WAIT_MS > 0)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
RunTimeStatus.MOUSE_WHEEL_WAIT_MS -= 1;
|
||||
}
|
||||
if (RunTimeStatus.MOUSE_ENTER_ICON)
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
MyPoptip.IsOpen = true;
|
||||
}));
|
||||
}
|
||||
RunTimeStatus.MOUSE_WHEEL_WAIT_MS = 100;
|
||||
RunTimeStatus.ICONLIST_MOUSE_WHEEL = false;
|
||||
}).Start();
|
||||
}
|
||||
|
||||
//修改菜单时不切换菜单
|
||||
if (RunTimeStatus.IS_MENU_EDIT) return;
|
||||
|
||||
|
||||
//切换菜单
|
||||
System.Windows.Controls.ScrollViewer scrollViewer = sender as System.Windows.Controls.ScrollViewer;
|
||||
if (scrollViewer == null)
|
||||
{
|
||||
//在card 上获取的事件
|
||||
scrollViewer = ScrollUtil.FindSimpleVisualChild<System.Windows.Controls.ScrollViewer>(IconListBox);
|
||||
}
|
||||
if (e.Delta < 0)
|
||||
{
|
||||
int index = MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex;
|
||||
if (ScrollUtil.IsBootomScrollView(scrollViewer))
|
||||
{
|
||||
if (index < MainWindow.mainWindow.LeftCard.MenuListBox.Items.Count - 1)
|
||||
{
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex = index;
|
||||
scrollViewer.ScrollToVerticalOffset(0);
|
||||
}
|
||||
}
|
||||
else if (e.Delta > 0)
|
||||
{
|
||||
if (ScrollUtil.IsTopScrollView(scrollViewer))
|
||||
{
|
||||
int index = MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex;
|
||||
if (index > 0)
|
||||
{
|
||||
index--;
|
||||
}
|
||||
else
|
||||
{
|
||||
index = MainWindow.mainWindow.LeftCard.MenuListBox.Items.Count - 1;
|
||||
}
|
||||
MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex = index;
|
||||
scrollViewer.ScrollToVerticalOffset(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜索结果icon 列表鼠标滚轮预处理时间
|
||||
/// 主要使用自定义popup解决卡顿问题解决卡顿问题
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void VerticalIconList_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
//控制在滚动时不显示popup 否则会在低GPU性能机器上造成卡顿
|
||||
MyPoptip.IsOpen = false;
|
||||
if (RunTimeStatus.ICONLIST_MOUSE_WHEEL)
|
||||
{
|
||||
RunTimeStatus.MOUSE_WHEEL_WAIT_MS = 500;
|
||||
}
|
||||
else
|
||||
{
|
||||
RunTimeStatus.ICONLIST_MOUSE_WHEEL = true;
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
while (RunTimeStatus.MOUSE_WHEEL_WAIT_MS > 0)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
RunTimeStatus.MOUSE_WHEEL_WAIT_MS -= 1;
|
||||
}
|
||||
if (RunTimeStatus.MOUSE_ENTER_ICON)
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
MyPoptip.IsOpen = true;
|
||||
}));
|
||||
}
|
||||
RunTimeStatus.MOUSE_WHEEL_WAIT_MS = 100;
|
||||
RunTimeStatus.ICONLIST_MOUSE_WHEEL = false;
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询结果 ICON 鼠标进入事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SearchIcon_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
||||
//显示popup
|
||||
RunTimeStatus.MOUSE_ENTER_ICON = true;
|
||||
if (!RunTimeStatus.ICONLIST_MOUSE_WHEEL)
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
IconInfo info = (sender as Panel).Tag as IconInfo;
|
||||
MyPoptipContent.Text = info.Content;
|
||||
MyPoptip.VerticalOffset = 30;
|
||||
Thread.Sleep(100);
|
||||
if (!RunTimeStatus.ICONLIST_MOUSE_WHEEL && RunTimeStatus.MOUSE_MOVE_COUNT > 1)
|
||||
{
|
||||
MyPoptip.IsOpen = true;
|
||||
}
|
||||
}));
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询结果ICON鼠标离开事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SearchIcon_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
RunTimeStatus.MOUSE_ENTER_ICON = false;
|
||||
MyPoptip.IsOpen = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询结果ICON鼠标移动事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SearchIcon_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
//控制首次刷新搜索结果后, 鼠标首次移动后显示popup
|
||||
RunTimeStatus.MOUSE_MOVE_COUNT++;
|
||||
|
||||
//防止移动后不刷新popup content
|
||||
IconInfo info = (sender as Panel).Tag as IconInfo;
|
||||
MyPoptipContent.Text = info.Content;
|
||||
MyPoptip.VerticalOffset = 30;
|
||||
|
||||
if (RunTimeStatus.MOUSE_MOVE_COUNT > 1 && !RunTimeStatus.ICONLIST_MOUSE_WHEEL)
|
||||
{
|
||||
MyPoptip.IsOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// menu结果ICON鼠标移动事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MenuIcon_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
//防止移动后不刷新popup content
|
||||
IconInfo info = (sender as Panel).Tag as IconInfo;
|
||||
MyPoptipContent.Text = info.Content;
|
||||
MyPoptip.VerticalOffset = 30;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace GeekDesk.Control.UserControls.SystemItem
|
||||
iconInfo = CommonCode.GetIconInfoByPath(thisInfo.LnkPath_NoWrite);
|
||||
}
|
||||
menuInfo.IconList.Add(iconInfo);
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:ToDoInfo}"
|
||||
mc:Ignorable="d"
|
||||
xmlns:cst="clr-namespace:GeekDesk.Converts"
|
||||
Background="Transparent"
|
||||
>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Controls;
|
||||
@@ -42,7 +43,7 @@ namespace GeekDesk.Control.UserControls.Backlog
|
||||
{
|
||||
MainWindow.appData.HiToDoList.Remove(info);
|
||||
}
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
return true;
|
||||
}, "DeleteConfirm");
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
|
||||
xmlns:local="clr-namespace:GeekDesk"
|
||||
Title="Setting"
|
||||
mc:Ignorable="d"
|
||||
@@ -109,14 +110,14 @@
|
||||
</hc:SideMenu>
|
||||
</hc:Card>
|
||||
<hc:ScrollViewer Grid.Row="0" Grid.Column="1" BorderThickness="0" Margin="0,5,1,5">
|
||||
<UniformGrid x:Name="UFG">
|
||||
<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">
|
||||
<UniformGrid x:Name="UFG" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, Event=Visibility, Delay=0}">
|
||||
<!--<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">-->
|
||||
<hc:Card x:Name="RightCard" BorderThickness="0" MouseDown="DragMove">
|
||||
<hc:Card.Background>
|
||||
<SolidColorBrush Opacity="0"/>
|
||||
</hc:Card.Background>
|
||||
</hc:Card>
|
||||
</hc:TransitioningContentControl>
|
||||
<!--</hc:TransitioningContentControl>-->
|
||||
</UniformGrid>
|
||||
</hc:ScrollViewer>
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace GeekDesk.Control.Windows
|
||||
RightCard.Content = about;
|
||||
this.Topmost = true;
|
||||
this.mainWindow = mainWindow;
|
||||
UFG.Visibility = Visibility.Collapsed;
|
||||
UFG.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -81,15 +81,25 @@ namespace GeekDesk.Control.Windows
|
||||
if (window == null || !window.Activate())
|
||||
{
|
||||
window = new GlobalColorPickerWindow();
|
||||
window.Opacity = 0;
|
||||
App.DoEvents();
|
||||
window.Show();
|
||||
}
|
||||
window.Hide();
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(200);
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
GlobalColorPickerWindow thisWindow = (GlobalColorPickerWindow)window;
|
||||
if (thisWindow.colorPickerWindow == null || !thisWindow.colorPickerWindow.Activate())
|
||||
{
|
||||
thisWindow.colorPickerWindow = new PixelColorPickerWindow(thisWindow.MyColorPicker);
|
||||
}
|
||||
thisWindow.colorPickerWindow.Show();
|
||||
});
|
||||
}).Start();
|
||||
|
||||
}
|
||||
|
||||
public static void Show()
|
||||
@@ -98,6 +108,7 @@ namespace GeekDesk.Control.Windows
|
||||
{
|
||||
window = new GlobalColorPickerWindow();
|
||||
}
|
||||
window.Opacity = 1;
|
||||
window.Show();
|
||||
Keyboard.Focus(window);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace GeekDesk.Control.Windows
|
||||
}
|
||||
window.Show();
|
||||
Keyboard.Focus(window);
|
||||
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
|
||||
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
private void CustomButton_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
Background="Black"
|
||||
PreviewMouseMove="Window_PreviewMouseMove"
|
||||
MouseLeftButtonDown="Window_MouseLeftButtonDown"
|
||||
MouseRightButtonDown="Window_MouseRightButtonDown"
|
||||
MouseWheel="Window_MouseWheel"
|
||||
>
|
||||
<Window.Resources>
|
||||
|
||||
@@ -7,10 +7,14 @@ using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Cursors = System.Windows.Input.Cursors;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
|
||||
namespace GeekDesk.Control.Windows
|
||||
{
|
||||
@@ -28,10 +32,19 @@ namespace GeekDesk.Control.Windows
|
||||
|
||||
private readonly ColorPicker colorPicker;
|
||||
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll")]
|
||||
private static extern bool SetProcessDPIAware();
|
||||
|
||||
public PixelColorPickerWindow(ColorPicker colorPicker)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.colorPicker = colorPicker;
|
||||
|
||||
try
|
||||
{
|
||||
SetProcessDPIAware();
|
||||
}
|
||||
catch (Exception e) { }
|
||||
ColorPickerWindow_Init();
|
||||
}
|
||||
|
||||
@@ -50,9 +63,12 @@ namespace GeekDesk.Control.Windows
|
||||
DesktopBG.Height = this.Height;
|
||||
this.Topmost = true;
|
||||
|
||||
//获取缩放比例
|
||||
double scale = ScreenUtil.GetScreenScalingFactor();
|
||||
|
||||
bgBitmap = new System.Drawing.Bitmap(
|
||||
(int)SystemParameters.VirtualScreenWidth,
|
||||
(int)SystemParameters.VirtualScreenHeight,
|
||||
(int)(Width * scale),
|
||||
(int)(Height * scale),
|
||||
System.Drawing.Imaging.PixelFormat.Format32bppArgb
|
||||
);
|
||||
|
||||
@@ -72,6 +88,7 @@ namespace GeekDesk.Control.Windows
|
||||
Int32Rect.Empty,
|
||||
BitmapSizeOptions.FromEmptyOptions()
|
||||
);
|
||||
|
||||
DesktopBG.Source = bs;
|
||||
VisualBrush b = (VisualBrush)PixelBG.Fill;
|
||||
b.Visual = DesktopBG;
|
||||
@@ -191,5 +208,17 @@ namespace GeekDesk.Control.Windows
|
||||
SetPixelAbout(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右键按下
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Window_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Mouse.OverrideCursor = null;
|
||||
GlobalColorPickerWindow.ShowOrHide();
|
||||
//关闭
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ namespace GeekDesk.Control.Windows
|
||||
}
|
||||
window.Show();
|
||||
Keyboard.Focus(window);
|
||||
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
|
||||
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace GeekDesk.Control.Windows
|
||||
Growl.SuccessGlobal("设置待办任务成功, 系统将在 " + minutes + " 分钟后提醒您!");
|
||||
}
|
||||
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace GeekDesk.Control.Windows
|
||||
InitializeComponent();
|
||||
RightCard.Content = backlog;
|
||||
backlog.BacklogList.ItemsSource = appData.ToDoList;
|
||||
backlog.type = ToDoType.NEW;
|
||||
this.Topmost = true;
|
||||
if (backlog.BacklogList.Items.Count > 0)
|
||||
{
|
||||
@@ -68,7 +69,8 @@ namespace GeekDesk.Control.Windows
|
||||
{
|
||||
backlog.NoData.Visibility = Visibility.Collapsed;
|
||||
backlog.BacklogList.Visibility = Visibility.Visible;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
backlog.NoData.Visibility = Visibility.Visible;
|
||||
backlog.BacklogList.Visibility = Visibility.Collapsed;
|
||||
@@ -109,9 +111,7 @@ namespace GeekDesk.Control.Windows
|
||||
|
||||
|
||||
private static System.Windows.Window window = null;
|
||||
#pragma warning disable CS0108 // “ToDoWindow.Show()”隐藏继承的成员“Window.Show()”。如果是有意隐藏,请使用关键字 new。
|
||||
public static void Show()
|
||||
#pragma warning restore CS0108 // “ToDoWindow.Show()”隐藏继承的成员“Window.Show()”。如果是有意隐藏,请使用关键字 new。
|
||||
{
|
||||
if (window == null || !window.Activate())
|
||||
{
|
||||
|
||||
40
Converts/GetWidthByWWConvert.cs
Normal file
40
Converts/GetWidthByWWConvert.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.ViewModel;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace GeekDesk.Converts
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据主窗口width 和传入类型 获取其它宽度
|
||||
/// </summary>
|
||||
class GetWidthByWWConvert : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
WidthTypeEnum type = (WidthTypeEnum)parameter;
|
||||
|
||||
AppConfig config = MainWindow.appData.AppConfig;
|
||||
|
||||
if (WidthTypeEnum.LEFT_CARD == type)
|
||||
{
|
||||
return config.MenuCardWidth;
|
||||
}
|
||||
else if (WidthTypeEnum.RIGHT_CARD == type)
|
||||
{
|
||||
return config.WindowWidth - config.MenuCardWidth;
|
||||
} else if (WidthTypeEnum.RIGHT_CARD_HALF == type)
|
||||
{
|
||||
return (config.WindowWidth - config.MenuCardWidth) / 2;
|
||||
}
|
||||
|
||||
return config.WindowWidth;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,21 @@ namespace GeekDesk.Converts
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
int val = int.Parse(value.ToString());
|
||||
var param = 0;
|
||||
if (parameter != null)
|
||||
{
|
||||
param = int.Parse(parameter.ToString());
|
||||
}
|
||||
if (val + param > 0)
|
||||
{
|
||||
val += param;
|
||||
}
|
||||
return new CornerRadius(val);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
Converts/ReverseBoolConvert.cs
Normal file
22
Converts/ReverseBoolConvert.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace GeekDesk.Converts
|
||||
{
|
||||
internal class ReverseBoolConvert : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null) return null;
|
||||
bool val = (bool)value;
|
||||
return !val;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,10 @@ namespace GeekDesk.Converts
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null) return null;
|
||||
if (value == null)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
if (parameter == null)
|
||||
{
|
||||
return value.ToString();
|
||||
@@ -16,7 +19,14 @@ namespace GeekDesk.Converts
|
||||
else
|
||||
{
|
||||
string val = value.ToString();
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
return parameter.ToString()
|
||||
.Replace("\\n", "")
|
||||
.Replace("{}", "");
|
||||
}
|
||||
string param = parameter.ToString();
|
||||
param = param.Replace("\\n", "\n");
|
||||
return param.Replace("{}", val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace DraggAnimatedPanel
|
||||
#endregion
|
||||
static DraggAnimatedPanel()
|
||||
{
|
||||
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(DraggAnimatedPanel), new FrameworkPropertyMetadata(typeof(DraggAnimatedPanel)));
|
||||
}
|
||||
|
||||
|
||||
104
GeekDesk.csproj
104
GeekDesk.csproj
@@ -1,5 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props" Condition="Exists('packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props')" />
|
||||
<Import Project="packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props" Condition="Exists('packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props')" />
|
||||
<Import Project="packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props" Condition="Exists('packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -15,6 +18,9 @@
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
@@ -27,7 +33,6 @@
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
@@ -52,6 +57,8 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>GeekDesk.App</StartupObject>
|
||||
@@ -60,7 +67,7 @@
|
||||
<SignManifests>false</SignManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Taskbar.ico</ApplicationIcon>
|
||||
<ApplicationIcon>Logo.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetZone>LocalIntranet</TargetZone>
|
||||
@@ -68,6 +75,9 @@
|
||||
<PropertyGroup>
|
||||
<GenerateManifests>false</GenerateManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="CommonServiceLocator, Version=2.0.6.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
|
||||
<HintPath>packages\CommonServiceLocator.2.0.6\lib\net45\CommonServiceLocator.dll</HintPath>
|
||||
@@ -106,6 +116,7 @@
|
||||
<Reference Include="System.Drawing.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Drawing.Common.6.0.0-preview.6.21352.12\lib\net461\System.Drawing.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -113,12 +124,19 @@
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Reactive, Version=5.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Reactive.5.0.0\lib\net472\System.Reactive.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Remoting" />
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Windows" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@@ -132,6 +150,9 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="XamlFlair.WPF, Version=1.2.13.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\XamlFlair.WPF.1.2.13\lib\net472\XamlFlair.WPF.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
@@ -146,12 +167,17 @@
|
||||
<Compile Include="Constant\IconType.cs" />
|
||||
<Compile Include="Constant\CommonEnum.cs" />
|
||||
<Compile Include="Constant\IconStartType.cs" />
|
||||
<Compile Include="Constant\PasswordType.cs" />
|
||||
<Compile Include="Constant\RunTimeStatus.cs" />
|
||||
<Compile Include="Constant\SearchType.cs" />
|
||||
<Compile Include="Constant\SortType.cs" />
|
||||
<Compile Include="Constant\TodoTaskExecType.cs" />
|
||||
<Compile Include="Constant\BGStyle.cs" />
|
||||
<Compile Include="Constant\UpdateType.cs" />
|
||||
<Compile Include="Constant\WidthTypeEnum.cs" />
|
||||
<Compile Include="Control\Other\GlobalMsgNotification.xaml.cs">
|
||||
<DependentUpon>GlobalMsgNotification.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Control\Other\BacklogNotificatin.xaml.cs">
|
||||
<DependentUpon>BacklogNotificatin.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -161,6 +187,9 @@
|
||||
<Compile Include="Control\Other\GradientBGDialog.xaml.cs">
|
||||
<DependentUpon>GradientBGDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Control\Other\PasswordDialog.xaml.cs">
|
||||
<DependentUpon>PasswordDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Control\Other\MyColorPickerDialog.xaml.cs">
|
||||
<DependentUpon>MyColorPickerDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -223,6 +252,7 @@
|
||||
</Compile>
|
||||
<Compile Include="Converts\CountGreZero2BoolConvert.cs" />
|
||||
<Compile Include="Converts\Count2VisibleConvert.cs" />
|
||||
<Compile Include="Converts\GetWidthByWWConvert.cs" />
|
||||
<Compile Include="Converts\SearchTypeConvert.cs" />
|
||||
<Compile Include="Converts\StringAppendConvert.cs" />
|
||||
<Compile Include="Converts\DoubleToGridLength.cs" />
|
||||
@@ -234,34 +264,58 @@
|
||||
<Compile Include="Converts\OpcityConvert.cs" />
|
||||
<Compile Include="Converts\BGStyleConvert.cs" />
|
||||
<Compile Include="Converts\UpdateTypeConvert.cs" />
|
||||
<Compile Include="Converts\ReverseBoolConvert.cs" />
|
||||
<Compile Include="Converts\Visibility2BooleanConverter.cs" />
|
||||
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
|
||||
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
|
||||
<Compile Include="Converts\HideTypeConvert.cs" />
|
||||
<Compile Include="Interface\IWindowCommon.cs" />
|
||||
<Compile Include="MyThread\RelativePathThread.cs" />
|
||||
<Compile Include="Plugins\ShowSeconds\Common\Constants.cs" />
|
||||
<Compile Include="Plugins\ShowSeconds\SecondsWindow.xaml.cs">
|
||||
<DependentUpon>SecondsWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Plugins\ShowSeconds\ViewModel\SecondsDataContext.cs" />
|
||||
<Compile Include="Task\ShowSecondTask.cs" />
|
||||
<Compile Include="Task\ToDoTask.cs" />
|
||||
<Compile Include="MyThread\MouseHookThread.cs" />
|
||||
<Compile Include="MyThread\DispatcherBuild.cs" />
|
||||
<Compile Include="MyThread\UpdateThread.cs" />
|
||||
<Compile Include="Util\AeroGlassHelper.cs" />
|
||||
<Compile Include="Util\BGSettingUtil.cs" />
|
||||
<Compile Include="Util\BlurGlassUtil.cs" />
|
||||
<Compile Include="Util\ColorUtil.cs" />
|
||||
<Compile Include="Util\DefaultIcons.cs" />
|
||||
<Compile Include="Util\DragAdorner.cs" />
|
||||
<Compile Include="Util\GlobalHotKey.cs" />
|
||||
<Compile Include="Util\CommonCode.cs" />
|
||||
<Compile Include="Util\FileIcon.cs" />
|
||||
<Compile Include="Util\FileUtil.cs" />
|
||||
<Compile Include="Util\HideWindowUtil.cs" />
|
||||
<Compile Include="Util\IconHelper.cs" />
|
||||
<Compile Include="Util\IconUtil.cs" />
|
||||
<Compile Include="Util\KeyUtil.cs" />
|
||||
<Compile Include="Util\ListBoxDragDropManager.cs" />
|
||||
<Compile Include="Util\LogUtil.cs" />
|
||||
<Compile Include="Util\MarginHide.cs" />
|
||||
<Compile Include="Util\HttpUtil.cs" />
|
||||
<Compile Include="Util\ImageUtil.cs" />
|
||||
<Compile Include="Converts\MenuWidthConvert.cs" />
|
||||
<Compile Include="Util\MD5Util.cs" />
|
||||
<Compile Include="Util\MessageUtil.cs" />
|
||||
<Compile Include="Util\MouseHook.cs" />
|
||||
<Compile Include="Util\MouseUtil.cs" />
|
||||
<Compile Include="Util\NativeMethods.cs" />
|
||||
<Compile Include="Util\RegisterUtil.cs" />
|
||||
<Compile Include="Util\RelayCommand.cs" />
|
||||
<Compile Include="Util\ScreenUtil.cs" />
|
||||
<Compile Include="Util\ScrollUtil.cs" />
|
||||
<Compile Include="Util\ShellContextMenu.cs" />
|
||||
<Compile Include="Util\ShowWindowFollowMouse.cs" />
|
||||
<Compile Include="Util\StringUtil.cs" />
|
||||
<Compile Include="Util\SvgToGeometry.cs" />
|
||||
<Compile Include="Util\UserActivityHook.cs" />
|
||||
<Compile Include="Util\WindowsThumbnailProvider.cs" />
|
||||
<Compile Include="ViewModel\AppConfig.cs" />
|
||||
<Compile Include="ViewModel\AppData.cs" />
|
||||
<Compile Include="ViewModel\GradientBGParam.cs" />
|
||||
@@ -272,6 +326,10 @@
|
||||
<Compile Include="ViewModel\IconfontInfo.cs" />
|
||||
<Compile Include="ViewModel\IconInfo.cs" />
|
||||
<Compile Include="ViewModel\MenuInfo.cs" />
|
||||
<Page Include="Control\Other\GlobalMsgNotification.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Control\Other\BacklogNotificatin.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -284,6 +342,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Control\Other\PasswordDialog.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Control\Other\MyColorPickerDialog.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -376,6 +438,10 @@
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="Plugins\ShowSeconds\SecondsWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Resource\Dictionary\Geometry.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -384,6 +450,11 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Resource\Dictionary\XamlFlairSettings.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
@@ -404,6 +475,7 @@
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<Resource Include="Resource\Iconfont\iconfont.json" />
|
||||
<None Include="app.manifest" />
|
||||
<None Include="Properties\app.manifest" />
|
||||
<None Include="Update.json" />
|
||||
<None Include="packages.config" />
|
||||
@@ -472,10 +544,36 @@
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Logo.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties update_1json__JsonSchema="https://typedoc.org/schema.json" />
|
||||
<UserProperties update_1json__JsonSchema="https://beaujs.com/schema.json" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props'))" />
|
||||
<Error Condition="!Exists('packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets'))" />
|
||||
<Error Condition="!Exists('packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props'))" />
|
||||
<Error Condition="!Exists('packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets'))" />
|
||||
<Error Condition="!Exists('packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props'))" />
|
||||
<Error Condition="!Exists('packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets'))" />
|
||||
</Target>
|
||||
<Import Project="packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets" Condition="Exists('packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets')" />
|
||||
<Import Project="packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets" Condition="Exists('packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets')" />
|
||||
<Import Project="packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets" Condition="Exists('packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets')" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>; Move all assemblies and related files to lib folder
|
||||
ROBOCOPY "$(TargetDir) " "$(TargetDir)lib\ " /XF Data *.exe *.config *.manifest /XD lib logs bak /E /IS /MOVE
|
||||
if %25errorlevel%25 leq 4 exit 0 else exit %25errorlevel%25</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -5,30 +5,31 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
|
||||
xmlns:cn="clr-namespace:GeekDesk.Constant"
|
||||
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
|
||||
xmlns:local="clr-namespace:GeekDesk"
|
||||
mc:Ignorable="d"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
x:Name="AppWindow"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:AppData}"
|
||||
Title="GeekDesk"
|
||||
Title="GeekDesk_Main_8400A17AEEF7C029"
|
||||
MinWidth="600"
|
||||
MinHeight="400"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
ShowInTaskbar="False"
|
||||
Opacity="0"
|
||||
Opacity="1"
|
||||
Deactivated="AppWindow_Deactivated"
|
||||
SizeChanged="Window_SizeChanged"
|
||||
KeyDown="OnKeyDown"
|
||||
PreviewKeyDown="OnKeyDown"
|
||||
Focusable="True"
|
||||
MouseDown="MainWindow_MouseDown"
|
||||
MouseEnter="MainWindow_MouseEnter"
|
||||
GotFocus="Window_GotFocus"
|
||||
Loaded="Window_Loaded"
|
||||
>
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="0" ResizeBorderThickness="15"/>
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<Window.Resources>
|
||||
<RoutedUICommand x:Key="SearchHotKeyDown" Text="SearchHotKeyDown"/>
|
||||
|
||||
@@ -36,37 +37,38 @@
|
||||
<cvt:OpcityConvert x:Key="OpcityConvert"/>
|
||||
<cvt:IntToCornerRadius x:Key="IntToCornerRadius"/>
|
||||
<cvt:DoubleToGridLength x:Key="DoubleToGridLength"/>
|
||||
<Style x:Key="BorderBacStyle" TargetType="Border">
|
||||
|
||||
</Style>
|
||||
|
||||
<cvt:ReverseBoolConvert x:Key="ReverseBoolConvert"/>
|
||||
</Window.Resources>
|
||||
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="0" CornerRadius="30" ResizeBorderThickness="15"/>
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<Window.InputBindings>
|
||||
<KeyBinding Gesture="Ctrl+F" Key="F" Command="{StaticResource SearchHotKeyDown}"/>
|
||||
</Window.InputBindings>
|
||||
<Window.CommandBindings>
|
||||
<CommandBinding Command="{StaticResource SearchHotKeyDown}" CanExecute="SearchHotKeyDown"/>
|
||||
<!--<CommandBinding Command="ChangeImgBG" Executed="ChangeImgBG_Executed" CanExecute="ChangeImgBG_CanExecute" />-->
|
||||
|
||||
</Window.CommandBindings>
|
||||
|
||||
<Window.Effect>
|
||||
<!--Opacity="{Binding AppConfig.PannelOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"-->
|
||||
<Border Margin="20" CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}"
|
||||
BorderThickness="0"
|
||||
Focusable="True"
|
||||
x:Name="BGBorder"
|
||||
hc:Dialog.Token="MainWindowDialog"
|
||||
xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndGrowHorizontally}, Event=None}"
|
||||
xf:Animations.PrimaryBinding="{Binding AppConfig.IsShow, Mode=OneWay}"
|
||||
xf:Animations.Secondary="{xf:Animate BasedOn={StaticResource FadeOut}, Event=None}"
|
||||
xf:Animations.SecondaryBinding="{Binding AppConfig.IsShow, Mode=OneWay, Converter={StaticResource ReverseBoolConvert}}"
|
||||
xf:Animations.SecondaryCompletionCommand="{Binding HideCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
|
||||
xf:Animations.AllowOpacityReset="False"
|
||||
>
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
|
||||
RenderingBias="Quality" ShadowDepth="2"/>
|
||||
</Window.Effect>
|
||||
<Border Margin="20" CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}" BorderThickness="0"
|
||||
Background="AliceBlue"
|
||||
Opacity="{Binding AppConfig.PannelOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"
|
||||
hc:Dialog.Token="IconInfoDialog"
|
||||
Focusable="True"
|
||||
>
|
||||
</Border.Effect>
|
||||
<hc:DialogContainer Focusable="True">
|
||||
<!-- -1是为了解决圆角白线的问题-->
|
||||
<Border x:Name="BGBorder"
|
||||
CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}"
|
||||
BorderThickness="0"
|
||||
Margin="-1"
|
||||
>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40" MouseMove="DragMove"></RowDefinition>
|
||||
@@ -77,15 +79,16 @@
|
||||
<ColumnDefinition x:Name="RightColumn" Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!--获取焦点用-->
|
||||
<TextBox x:Name="EmptyTextBox" Width="0"/>
|
||||
<CheckBox x:Name="ShowBox" Visibility="Hidden" Panel.ZIndex="2"/>
|
||||
<CheckBox x:Name="HideBox" Visibility="Hidden" Panel.ZIndex="2"/>
|
||||
|
||||
<StackPanel HorizontalAlignment="Right" Panel.ZIndex="99" hc:Growl.GrowlParent="False" hc:Growl.Token="MainWindowGrowl" Grid.Column="1" Grid.Row="1"/>
|
||||
|
||||
<DockPanel Grid.Row="0" Grid.Column="0" MouseMove="DragMove">
|
||||
<DockPanel.Background>
|
||||
<SolidColorBrush Opacity="0.01"/>
|
||||
</DockPanel.Background>
|
||||
<Image Visibility="{Binding AppConfig.TitleLogoVisible}" Source="/Resource/Image/TitleLogo.png" Margin="10,0,0,0" Width="94" Height="30" HorizontalAlignment="Left"/>
|
||||
<Image Visibility="{Binding AppConfig.TitleLogoVisible}" Source="/Resource/Image/TitleLogo.png" RenderOptions.BitmapScalingMode="HighQuality" Margin="10,0,0,0" Width="200" Height="30" HorizontalAlignment="Left"/>
|
||||
</DockPanel>
|
||||
|
||||
<DockPanel Grid.Row="0" Grid.Column="2" MouseMove="DragMove">
|
||||
@@ -101,6 +104,7 @@
|
||||
HorizontalAlignment="Right"
|
||||
Click="ConfigButtonClick"
|
||||
Initialized="SettingButton_Initialized"
|
||||
PreviewMouseLeftButtonDown="AppButton_PreviewMouseLeftButtonDown"
|
||||
x:Name="SettingButton"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
>
|
||||
@@ -118,14 +122,14 @@
|
||||
hc:IconElement.Width="18"
|
||||
HorizontalAlignment="Right"
|
||||
Click="CloseButtonClick"
|
||||
PreviewMouseLeftButtonDown="AppButton_PreviewMouseLeftButtonDown"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
</DockPanel>
|
||||
|
||||
|
||||
<uc:LeftCardControl Grid.Row="1" Grid.Column="0"/>
|
||||
<uc:LeftCardControl x:Name="LeftCard" Grid.Row="1" Grid.Column="0"/>
|
||||
|
||||
<!--分割线-->
|
||||
<GridSplitter Opacity="0" Grid.Row="1" Grid.Column="0" Width="1" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
|
||||
@@ -141,15 +145,14 @@
|
||||
TextChanged="SearchBox_TextChanged"
|
||||
/>
|
||||
|
||||
<uc:RightCardControl x:Name="RightCard" Grid.Row="1" Grid.Column="1"/>
|
||||
|
||||
<hc:NotifyIcon Icon="/Taskbar.ico" Click="NotifyIcon_Click" x:Name="BarIcon"
|
||||
MouseRightButtonDown="BarIcon_MouseRightButtonDown"
|
||||
<hc:NotifyIcon Icon="/Logo.ico" Click="NotifyIcon_Click" x:Name="BarIcon"
|
||||
Visibility="{Binding AppConfig.ShowBarIcon, Mode=TwoWay, Converter={StaticResource Boolean2VisibilityConverter}}">
|
||||
<hc:NotifyIcon.ContextMenu>
|
||||
<ContextMenu Width="130" x:Name="TaskbarContextMenu">
|
||||
<MenuItem Header="打开面板" Click="ShowApp"/>
|
||||
<MenuItem Header="拾色器" Click="ColorPicker"/>
|
||||
<MenuItem Header="备份" Click="BakDataFile"/>
|
||||
<MenuItem Header="隐藏图标" Click="CloseBarIcon"/>
|
||||
<MenuItem Header="待办" Click="BacklogMenuClick"/>
|
||||
<MenuItem Header="程序目录" Click="OpenThisDir"/>
|
||||
@@ -158,11 +161,12 @@
|
||||
<MenuItem Header="退出" Click="ExitApp"/>
|
||||
</ContextMenu>
|
||||
</hc:NotifyIcon.ContextMenu>
|
||||
|
||||
</hc:NotifyIcon>
|
||||
|
||||
<uc:RightCardControl x:Name="RightCard" Grid.Row="1" Grid.Column="1"/>
|
||||
|
||||
<StackPanel hc:Growl.GrowlParent="True" VerticalAlignment="Top" Margin="0,10,10,0"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</hc:DialogContainer>
|
||||
</Border>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.UserControls.Config;
|
||||
using GeekDesk.Control.UserControls.PannelCard;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Interface;
|
||||
using GeekDesk.MyThread;
|
||||
@@ -7,7 +8,9 @@ using GeekDesk.Task;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using GeekDesk.ViewModel.Temp;
|
||||
using Microsoft.Win32;
|
||||
using NPinyin;
|
||||
using ShowSeconds;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
@@ -15,6 +18,7 @@ using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Threading;
|
||||
using static GeekDesk.Util.ShowWindowFollowMouse;
|
||||
@@ -36,14 +40,18 @@ namespace GeekDesk
|
||||
public static MainWindow mainWindow;
|
||||
public MainWindow()
|
||||
{
|
||||
//加载数据
|
||||
LoadData();
|
||||
InitializeComponent();
|
||||
mainWindow = this;
|
||||
this.Topmost = true;
|
||||
this.Loaded += Window_Loaded;
|
||||
this.SizeChanged += MainWindow_Resize;
|
||||
ToDoTask.BackLogCheck();
|
||||
|
||||
//用于其他类访问
|
||||
mainWindow = this;
|
||||
|
||||
//置于顶层
|
||||
this.Topmost = true;
|
||||
|
||||
//执行待办提醒
|
||||
ToDoTask.BackLogCheck();
|
||||
|
||||
////实例化隐藏 Hide类,进行时间timer设置
|
||||
MarginHide.ReadyHide(this);
|
||||
@@ -51,11 +59,14 @@ namespace GeekDesk
|
||||
{
|
||||
MarginHide.StartHide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 显示搜索框
|
||||
/// 搜索快捷键按下
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
@@ -67,6 +78,9 @@ namespace GeekDesk
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示搜索框
|
||||
/// </summary>
|
||||
private void ShowSearchBox()
|
||||
{
|
||||
RunTimeStatus.SEARCH_BOX_SHOW = true;
|
||||
@@ -93,6 +107,11 @@ namespace GeekDesk
|
||||
|
||||
if (!RunTimeStatus.SEARCH_BOX_SHOW) ShowSearchBox();
|
||||
|
||||
//刷新搜索后 鼠标移动次数置为0
|
||||
RunTimeStatus.MOUSE_MOVE_COUNT = 0;
|
||||
//隐藏popup
|
||||
RightCard.MyPoptip.IsOpen = false;
|
||||
|
||||
string inputText = SearchBox.Text.ToLower();
|
||||
RightCard.VerticalUFG.Visibility = Visibility.Collapsed;
|
||||
if (!string.IsNullOrEmpty(inputText))
|
||||
@@ -116,9 +135,16 @@ namespace GeekDesk
|
||||
{
|
||||
SearchIconList.IconList.Clear();
|
||||
}
|
||||
if (RightCard.SearchListBox.Items.Count > 0)
|
||||
{
|
||||
RightCard.SearchListBox.SelectedIndex = 0;
|
||||
}
|
||||
RightCard.VerticalUFG.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏搜索框
|
||||
/// </summary>
|
||||
public void HidedSearchBox()
|
||||
{
|
||||
RunTimeStatus.SEARCH_BOX_SHOW = false;
|
||||
@@ -148,7 +174,6 @@ namespace GeekDesk
|
||||
this.Height = appData.AppConfig.WindowHeight;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 窗口加载完毕 执行方法
|
||||
/// </summary>
|
||||
@@ -158,21 +183,13 @@ namespace GeekDesk
|
||||
{
|
||||
BGSettingUtil.BGSetting();
|
||||
if (!appData.AppConfig.StartedShowPanel)
|
||||
{
|
||||
if (appData.AppConfig.AppAnimation)
|
||||
{
|
||||
this.Opacity = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowApp();
|
||||
}
|
||||
|
||||
//给任务栏图标一个名字
|
||||
BarIcon.Text = Constants.MY_NAME;
|
||||
|
||||
@@ -197,14 +214,29 @@ namespace GeekDesk
|
||||
RegisterUtil.SetSelfStarting(appData.AppConfig.SelfStartUp, Constants.MY_NAME);
|
||||
}
|
||||
|
||||
//注册鼠标中键监听事件
|
||||
//注册鼠标监听事件
|
||||
if (appData.AppConfig.MouseMiddleShow)
|
||||
{
|
||||
MouseHookThread.MiddleHook();
|
||||
MouseHookThread.Hook();
|
||||
}
|
||||
|
||||
//显秒插件
|
||||
if (appData.AppConfig.SecondsWindow == true)
|
||||
{
|
||||
SecondsWindow.ShowWindow();
|
||||
}
|
||||
|
||||
|
||||
//更新线程开启 检测更新
|
||||
UpdateThread.Update();
|
||||
|
||||
//建立相对路径
|
||||
RelativePathThread.MakeRelativePath();
|
||||
|
||||
//毛玻璃 暂时未解决阴影问题
|
||||
//BlurGlassUtil.EnableBlur(this);
|
||||
|
||||
MessageUtil.ChangeWindowMessageFilter(MessageUtil.WM_COPYDATA, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -234,7 +266,8 @@ namespace GeekDesk
|
||||
{
|
||||
HandyControl.Controls.Growl.Success("GeekDesk快捷键注册成功(" + appData.AppConfig.HotkeyStr + ")!", "HotKeyGrowl");
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -329,21 +362,6 @@ namespace GeekDesk
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重置窗体大小 写入缓存
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void MainWindow_Resize(object sender, System.EventArgs e)
|
||||
{
|
||||
if (this.DataContext != null)
|
||||
{
|
||||
AppData appData = this.DataContext as AppData;
|
||||
appData.AppConfig.WindowWidth = this.Width;
|
||||
appData.AppConfig.WindowHeight = this.Height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -422,8 +440,6 @@ namespace GeekDesk
|
||||
// return;
|
||||
//}
|
||||
|
||||
MainWindow.mainWindow.Activate();
|
||||
|
||||
if (MarginHide.ON_HIDE)
|
||||
{
|
||||
//修改贴边隐藏状态为未隐藏
|
||||
@@ -437,35 +453,71 @@ namespace GeekDesk
|
||||
|
||||
if (appData.AppConfig.FollowMouse)
|
||||
{
|
||||
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0, false);
|
||||
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0);
|
||||
}
|
||||
|
||||
FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
|
||||
MainWindow.mainWindow.Activate();
|
||||
mainWindow.Show();
|
||||
//mainWindow.Visibility = Visibility.Visible;
|
||||
if (appData.AppConfig.AppAnimation)
|
||||
{
|
||||
appData.AppConfig.IsShow = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
appData.AppConfig.IsShow = null;
|
||||
//防止永远不显示界面
|
||||
if (mainWindow.Opacity < 1)
|
||||
{
|
||||
mainWindow.Opacity = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
|
||||
|
||||
Keyboard.Focus(mainWindow);
|
||||
if (RunTimeStatus.SHOW_MENU_PASSWORDBOX)
|
||||
{
|
||||
mainWindow.RightCard.PDDialog.SetFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
Keyboard.Focus(mainWindow.SearchBox);
|
||||
}
|
||||
}
|
||||
|
||||
public static void HideApp()
|
||||
{
|
||||
if (!MarginHide.IS_HIDE)
|
||||
if (appData.AppConfig.AppAnimation)
|
||||
{
|
||||
appData.AppConfig.IsShow = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
appData.AppConfig.IsShow = null;
|
||||
HideAppVis();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void HideAppVis()
|
||||
{
|
||||
//关闭锁定
|
||||
RunTimeStatus.LOCK_APP_PANEL = false;
|
||||
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
||||
{
|
||||
mainWindow.HidedSearchBox();
|
||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
||||
}
|
||||
else
|
||||
{
|
||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowApp();
|
||||
}
|
||||
mainWindow.Visibility = Visibility.Collapsed;
|
||||
//if (!MarginHide.IS_HIDE)
|
||||
//{
|
||||
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// ShowApp();
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -631,7 +683,7 @@ namespace GeekDesk
|
||||
/// <param name="e"></param>
|
||||
private void ExitApp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (appData.AppConfig.MouseMiddleShow)
|
||||
if (appData.AppConfig.MouseMiddleShow || appData.AppConfig.SecondsWindow == true)
|
||||
{
|
||||
MouseHookThread.Dispose();
|
||||
}
|
||||
@@ -644,7 +696,7 @@ namespace GeekDesk
|
||||
/// <param name="e"></param>
|
||||
private void ReStartApp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (appData.AppConfig.MouseMiddleShow)
|
||||
if (appData.AppConfig.MouseMiddleShow || appData.AppConfig.SecondsWindow == true)
|
||||
{
|
||||
MouseHookThread.Dispose();
|
||||
}
|
||||
@@ -676,16 +728,26 @@ namespace GeekDesk
|
||||
{
|
||||
HideApp();
|
||||
}
|
||||
//else if (
|
||||
// appData.AppConfig.SearchType == SearchType.KEY_DOWN &&
|
||||
// (
|
||||
// (e.Key >= Key.D0 && e.Key <= Key.Z)
|
||||
// || (e.Key >= Key.NumPad0 && e.Key < Key.NumPad9)
|
||||
// )
|
||||
// )
|
||||
//{
|
||||
// ShowSearchBox();
|
||||
//}
|
||||
|
||||
if (RunTimeStatus.SEARCH_BOX_SHOW && (e.Key == Key.Up
|
||||
|| e.Key == Key.Down
|
||||
|| e.Key == Key.Tab
|
||||
|| e.Key == Key.Enter
|
||||
))
|
||||
{
|
||||
if (e.Key == Key.Down || e.Key == Key.Tab)
|
||||
{
|
||||
RightCard.SearchListBoxIndexAdd();
|
||||
}
|
||||
else if (e.Key == Key.Up)
|
||||
{
|
||||
RightCard.SearchListBoxIndexSub();
|
||||
}
|
||||
else if (e.Key == Key.Enter)
|
||||
{
|
||||
RightCard.StartupSelectionItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -718,29 +780,111 @@ namespace GeekDesk
|
||||
/// <param name="e"></param>
|
||||
private void ColorPicker(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TaskbarContextMenu.Visibility = Visibility.Collapsed;
|
||||
App.DoEvents();
|
||||
TaskbarContextMenu.IsOpen = false;
|
||||
GlobalColorPickerWindow.CreateNoShow();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 防止点击拾色器后无法显示菜单的问题
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BarIcon_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
TaskbarContextMenu.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void Window_GotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 如果没有在修改菜单 并且不是右键点击了面板
|
||||
if (!RunTimeStatus.IS_MENU_EDIT
|
||||
&& !RunTimeStatus.SHOW_RIGHT_BTN_MENU
|
||||
&& !RunTimeStatus.APP_BTN_IS_DOWN)
|
||||
{
|
||||
if (RunTimeStatus.SHOW_MENU_PASSWORDBOX)
|
||||
{
|
||||
//必须在其它文本框没有工作的时候才给密码框焦点
|
||||
RightCard.PDDialog.SetFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
//必须在其它文本框没有工作的时候才给搜索框焦点
|
||||
Keyboard.Focus(SearchBox);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void AppWindow_Deactivated(object sender, EventArgs e)
|
||||
{
|
||||
AppWindowLostFocus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 备份数据文件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
[Obsolete]
|
||||
private void BakDataFile(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Thread t = new Thread(() =>
|
||||
{
|
||||
CommonCode.BakAppData();
|
||||
});
|
||||
t.ApartmentState = ApartmentState.STA;
|
||||
t.Start();
|
||||
}
|
||||
|
||||
private void AppButton_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
//点击了面板
|
||||
RunTimeStatus.APP_BTN_IS_DOWN = true;
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(50);
|
||||
RunTimeStatus.APP_BTN_IS_DOWN = false;
|
||||
}).Start();
|
||||
}
|
||||
|
||||
|
||||
private ICommand _hideCommand;
|
||||
public ICommand HideCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_hideCommand == null)
|
||||
{
|
||||
_hideCommand = new RelayCommand(
|
||||
p =>
|
||||
{
|
||||
return true;
|
||||
},
|
||||
p =>
|
||||
{
|
||||
HideAppVis();
|
||||
});
|
||||
}
|
||||
return _hideCommand;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
{
|
||||
base.OnSourceInitialized(e);
|
||||
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
|
||||
if (hwndSource != null)
|
||||
{
|
||||
IntPtr handle = hwndSource.Handle;
|
||||
hwndSource.AddHook(new HwndSourceHook(WndProc));
|
||||
}
|
||||
}
|
||||
|
||||
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
if (msg == MessageUtil.WM_COPYDATA)
|
||||
{
|
||||
MessageUtil.CopyDataStruct cds = (MessageUtil.CopyDataStruct)System.Runtime.InteropServices.Marshal.PtrToStructure(lParam, typeof(MessageUtil.CopyDataStruct));
|
||||
if ("ShowApp".Equals(cds.msg))
|
||||
{
|
||||
ShowApp();
|
||||
}
|
||||
}
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# BookerLiu
|
||||
diff a/MainWindow.xaml b/MainWindow.xaml (rejected hunks)
|
||||
@@ -20,6 +20,7 @@
|
||||
SizeChanged="Window_SizeChanged"
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using GeekDesk.Control.UserControls.Config;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Gma.System.MouseKeyHook;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
@@ -9,28 +13,38 @@ namespace GeekDesk.MyThread
|
||||
{
|
||||
public class MouseHookThread
|
||||
{
|
||||
private static AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
private static IKeyboardMouseEvents m_GlobalHook = Hook.GlobalEvents();
|
||||
private static Dispatcher dispatcher;
|
||||
private static readonly AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
public static Dispatcher dispatcher;
|
||||
private static UserActivityHook hook;
|
||||
|
||||
|
||||
|
||||
public static void MiddleHook()
|
||||
public static void Hook()
|
||||
{
|
||||
//使用dispatcher来单独监听UI线程 防止程序卡顿
|
||||
dispatcher = DispatcherBuild.Build();
|
||||
m_GlobalHook = Hook.GlobalEvents();
|
||||
dispatcher.BeginInvoke((Action)(() =>
|
||||
dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
|
||||
{
|
||||
m_GlobalHook.MouseUpExt += M_GlobalHook_MouseUpExt;
|
||||
hook = new UserActivityHook();
|
||||
|
||||
if (appConfig.MouseMiddleShow)
|
||||
{
|
||||
hook.OnMouseWheelUp += OnMouseWheelUp;
|
||||
}
|
||||
|
||||
hook.Start(true, false);
|
||||
}));
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
private static void OnMouseLeftDown(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
m_GlobalHook.MouseUpExt -= M_GlobalHook_MouseUpExt;
|
||||
m_GlobalHook.Dispose();
|
||||
dispatcher.InvokeShutdown();
|
||||
}
|
||||
|
||||
private static void OnMouseLeftUp(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private static void OnMouseWheelUp(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
MouseWheelShowApp(sender, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -38,13 +52,12 @@ namespace GeekDesk.MyThread
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private static void M_GlobalHook_MouseUpExt(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
private static void MouseWheelShowApp(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if (appConfig.MouseMiddleShow && e.Button == System.Windows.Forms.MouseButtons.Middle)
|
||||
//中键打开App
|
||||
if (appConfig.MouseMiddleShow && MotionControl.hotkeyFinished)
|
||||
{
|
||||
if (MotionControl.hotkeyFinished)
|
||||
{
|
||||
App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
|
||||
App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
|
||||
{
|
||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed || MainWindow.mainWindow.Opacity == 0)
|
||||
{
|
||||
@@ -57,7 +70,38 @@ namespace GeekDesk.MyThread
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (hook != null)
|
||||
{
|
||||
if (hook.MouseWheelUpEnable())
|
||||
{
|
||||
hook.OnMouseWheelUp -= OnMouseWheelUp;
|
||||
}
|
||||
if (hook.MouseLeftDownEnable())
|
||||
{
|
||||
hook.OnMouseLeftDown -= OnMouseLeftDown;
|
||||
}
|
||||
if (hook.MouseLeftUpEnable())
|
||||
{
|
||||
hook.OnMouseLeftUp -= OnMouseLeftUp;
|
||||
}
|
||||
hook.Stop();
|
||||
dispatcher.InvokeShutdown();
|
||||
hook = null;
|
||||
dispatcher = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogUtil.WriteErrorLog(ex, "关闭hook出错");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
47
MyThread/RelativePathThread.cs
Normal file
47
MyThread/RelativePathThread.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace GeekDesk.MyThread
|
||||
{
|
||||
public class RelativePathThread
|
||||
{
|
||||
public static void MakeRelativePath()
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ObservableCollection<MenuInfo> menuList = MainWindow.appData.MenuList;
|
||||
|
||||
string myExePath = Constants.APP_DIR + "GeekDesk.exe";
|
||||
foreach (MenuInfo mi in menuList)
|
||||
{
|
||||
ObservableCollection<IconInfo> iconList = mi.IconList;
|
||||
foreach (IconInfo icon in iconList)
|
||||
{
|
||||
if (icon == null) continue;
|
||||
string relativePath = FileUtil.MakeRelativePath(myExePath, icon.Path);
|
||||
if (File.Exists(icon.Path)
|
||||
&& !string.IsNullOrEmpty(relativePath)
|
||||
&& !relativePath.Equals(icon.Path))
|
||||
{
|
||||
icon.RelativePath_NoWrite = relativePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_BAK_PATH);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogUtil.WriteErrorLog(ex, "init相对路径出错!");
|
||||
}
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Plugins/ShowSeconds/Common/Constants.cs
Normal file
39
Plugins/ShowSeconds/Common/Constants.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ShowSeconds.Common
|
||||
{
|
||||
public class Constants
|
||||
{
|
||||
public readonly static string MY_UUID = "8400A17AEEF7C029";
|
||||
|
||||
//dark theam
|
||||
public readonly static System.Windows.Media.SolidColorBrush darkBG
|
||||
= new System.Windows.Media.SolidColorBrush
|
||||
{
|
||||
Color = System.Windows.Media.Color.FromRgb(46, 50, 54),
|
||||
Opacity = 0.8
|
||||
};
|
||||
public readonly static System.Windows.Media.SolidColorBrush darkFont
|
||||
= new System.Windows.Media.SolidColorBrush
|
||||
{
|
||||
Color = System.Windows.Media.Color.FromRgb(255, 255, 255)
|
||||
};
|
||||
|
||||
//light theam
|
||||
public readonly static System.Windows.Media.SolidColorBrush lightBG
|
||||
= new System.Windows.Media.SolidColorBrush
|
||||
{
|
||||
Color = System.Windows.Media.Color.FromRgb(236, 244, 251),
|
||||
Opacity = 1
|
||||
};
|
||||
public readonly static System.Windows.Media.SolidColorBrush lightFont
|
||||
= new System.Windows.Media.SolidColorBrush
|
||||
{
|
||||
Color = System.Windows.Media.Color.FromRgb(65, 63, 61),
|
||||
};
|
||||
}
|
||||
}
|
||||
32
Plugins/ShowSeconds/SecondsWindow.xaml
Normal file
32
Plugins/ShowSeconds/SecondsWindow.xaml
Normal file
@@ -0,0 +1,32 @@
|
||||
<Window x:Class="ShowSeconds.SecondsWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
|
||||
Height="90"
|
||||
Width="160"
|
||||
WindowStyle="None"
|
||||
Title=""
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent" ShowInTaskbar="False"
|
||||
Focusable="True"
|
||||
Loaded="Window_Loaded"
|
||||
>
|
||||
|
||||
<Grid Margin="20">
|
||||
<Grid.Effect>
|
||||
<DropShadowEffect BlurRadius="20" Direction="-90" Color="Gray"
|
||||
RenderingBias="Quality" ShadowDepth="2"/>
|
||||
</Grid.Effect>
|
||||
<Border x:Name="BGBorder" CornerRadius="8" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndSlideFromRight}, Event=Visibility, Delay=0}">
|
||||
<TextBlock x:Name="SecondsText" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="25"
|
||||
FontWeight="Bold"
|
||||
Foreground="White"
|
||||
Text="{Binding Seconds}"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
312
Plugins/ShowSeconds/SecondsWindow.xaml.cs
Normal file
312
Plugins/ShowSeconds/SecondsWindow.xaml.cs
Normal file
@@ -0,0 +1,312 @@
|
||||
using GeekDesk.Util;
|
||||
using Gma.System.MouseKeyHook;
|
||||
using ShowSeconds.Common;
|
||||
using GeekDesk.Util;
|
||||
using ShowSeconds.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using GeekDesk.MyThread;
|
||||
using GeekDesk;
|
||||
using System.Collections;
|
||||
|
||||
namespace ShowSeconds
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class SecondsWindow : Window
|
||||
{
|
||||
|
||||
private System.Drawing.Color beforeColor;
|
||||
private System.Drawing.Color topBeforeColor;
|
||||
|
||||
private bool expandClock = true; //是否展开时钟
|
||||
private System.Windows.Forms.Timer timer;
|
||||
|
||||
private static double lProportion = 0.82;
|
||||
private static double tProportion = 0.03;
|
||||
private static int sleepTime = 1000;
|
||||
public SecondsWindow()
|
||||
{
|
||||
SecondsDataContext dc = new SecondsDataContext
|
||||
{
|
||||
Seconds = (DateTime.Now.Hour).ToString() + ":" +
|
||||
FormatMS(DateTime.Now.Minute) + ":" +
|
||||
FormatMS(DateTime.Now.Second)
|
||||
};
|
||||
InitializeComponent();
|
||||
SolidColorBrush scb = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 47, 52, 44))
|
||||
{
|
||||
Opacity = 0.8
|
||||
};
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Hashtable settings = (Hashtable)ConfigurationManager.GetSection("ShowSecondsSettings");
|
||||
|
||||
lProportion = Convert.ToDouble(settings["LProportion"]);
|
||||
tProportion = Convert.ToDouble(settings["TProportion"]);
|
||||
sleepTime = Convert.ToInt32(settings["DelayTime"]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lProportion = 0.82;
|
||||
tProportion = 0.03;
|
||||
sleepTime = 1000;
|
||||
}
|
||||
|
||||
BGBorder.Background = scb;
|
||||
this.DataContext = dc;
|
||||
this.Topmost = true;
|
||||
BGBorder.Visibility = Visibility.Collapsed;
|
||||
this.Show();
|
||||
}
|
||||
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
timer = new System.Windows.Forms.Timer();
|
||||
timer.Interval = 1000;
|
||||
timer.Tick += Timer_Tick;
|
||||
|
||||
Dispatcher secondsDP = DispatcherBuild.Build();
|
||||
IKeyboardMouseEvents secondsHook = Hook.GlobalEvents();
|
||||
secondsDP.Invoke((Action)(() =>
|
||||
{
|
||||
secondsHook.MouseDownExt += SecondsBakColorFun;
|
||||
secondsHook.MouseUpExt += SecondsHookSetFuc;
|
||||
}));
|
||||
|
||||
HideWindowUtil.HideAltTab(this);
|
||||
}
|
||||
|
||||
private void Timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
string str = (DateTime.Now.Hour).ToString() + ":" +
|
||||
FormatMS(DateTime.Now.Minute) + ":" +
|
||||
FormatMS(DateTime.Now.Second);
|
||||
SecondsDataContext dc = this.DataContext as SecondsDataContext;
|
||||
dc.Seconds = str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static string FormatMS(int ms)
|
||||
{
|
||||
if (ms < 10)
|
||||
{
|
||||
return "0" + ms;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ms.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void SecondsHookSetFuc(object sender, MouseEventExtArgs e)
|
||||
{
|
||||
if (e.Button == System.Windows.Forms.MouseButtons.Left)
|
||||
{
|
||||
if (ScreenUtil.IsPrimaryFullScreen()) return;
|
||||
|
||||
App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
|
||||
{
|
||||
int x = e.X;
|
||||
int y = e.Y;
|
||||
double w = 1920;
|
||||
double h = 1080;
|
||||
double width = SystemParameters.PrimaryScreenWidth;
|
||||
double height = SystemParameters.PrimaryScreenHeight;
|
||||
if (x > 1843 / w * width
|
||||
&& x < 1907 / w * width
|
||||
&& y > 1037 / h * height
|
||||
&& y < 1074 / h * height)
|
||||
{
|
||||
|
||||
System.Drawing.Color c;
|
||||
int count = sleepTime;
|
||||
do
|
||||
{
|
||||
c = GetBottomBeforeColor();
|
||||
if (c.A != beforeColor.A
|
||||
|| c.R != beforeColor.R
|
||||
|| c.G != beforeColor.G
|
||||
|| c.B != beforeColor.B)
|
||||
{
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(50);
|
||||
count -= 50;
|
||||
} while (count > 0);
|
||||
|
||||
if (c.A != beforeColor.A
|
||||
|| c.R != beforeColor.R
|
||||
|| c.G != beforeColor.G
|
||||
|| c.B != beforeColor.B)
|
||||
{
|
||||
//判断是否展开时钟
|
||||
System.Drawing.Color ct = GetTopBeforeColor();
|
||||
if (ct.A != topBeforeColor.A
|
||||
|| ct.R != topBeforeColor.R
|
||||
|| ct.G != topBeforeColor.G
|
||||
|| ct.B != topBeforeColor.B)
|
||||
{
|
||||
expandClock = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
expandClock = false;
|
||||
}
|
||||
|
||||
if (!BGBorder.IsVisible)
|
||||
{
|
||||
|
||||
System.Drawing.Color theamColor = GetColor(1919, 1079);
|
||||
if (CalculateLight(theamColor) > 255 / 2)
|
||||
{
|
||||
//light
|
||||
BGBorder.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(theamColor.A, theamColor.R, theamColor.G, theamColor.B));
|
||||
SecondsText.Foreground = Constants.lightFont;
|
||||
}
|
||||
else
|
||||
{
|
||||
// dark
|
||||
//BGBorder.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(theamColor.A, theamColor.R, theamColor.G, theamColor.B));
|
||||
BGBorder.Background = Constants.darkBG;
|
||||
SecondsText.Foreground = Constants.darkFont;
|
||||
}
|
||||
|
||||
SecondsDataContext dc = this.DataContext as SecondsDataContext;
|
||||
dc.Seconds = (DateTime.Now.Hour).ToString() + ":" +
|
||||
FormatMS(DateTime.Now.Minute) + ":" +
|
||||
FormatMS(DateTime.Now.Second);
|
||||
|
||||
int sx = (int)(SystemParameters.PrimaryScreenWidth * lProportion);
|
||||
int sMarginBottom = (int)(SystemParameters.WorkArea.Height * tProportion);
|
||||
Left = sx - Width;
|
||||
Top = SystemParameters.WorkArea.Height - Height;
|
||||
BGBorder.Visibility = Visibility.Visible;
|
||||
timer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
BGBorder.Visibility= Visibility.Collapsed;
|
||||
timer.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (true)
|
||||
{
|
||||
if ((expandClock && (x < 1574 / w * width
|
||||
|| x > 1906 / w * width
|
||||
|| y < 598 / h * height
|
||||
|| y > 1020 / h * height)
|
||||
)
|
||||
|| !expandClock && (x < 1574 / w * width
|
||||
|| x > 1906 / w * width
|
||||
|| y < 950 / h * height
|
||||
|| y > 1020 / h * height)
|
||||
)
|
||||
{
|
||||
BGBorder.Visibility = Visibility.Collapsed;
|
||||
timer.Stop();
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static System.Windows.Window window = null;
|
||||
public static void ShowWindow()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (window == null || !window.Activate())
|
||||
{
|
||||
window = new SecondsWindow();
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, "打开显秒窗口异常!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void CloseWindow()
|
||||
{
|
||||
try
|
||||
{
|
||||
window.Close();
|
||||
} catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, "关闭显秒窗口异常!");
|
||||
}
|
||||
}
|
||||
|
||||
private void SecondsBakColorFun(object sender, MouseEventExtArgs e)
|
||||
{
|
||||
if (e.Button == System.Windows.Forms.MouseButtons.Left)
|
||||
{
|
||||
beforeColor = GetBottomBeforeColor();
|
||||
topBeforeColor = GetTopBeforeColor();
|
||||
}
|
||||
}
|
||||
|
||||
private static System.Drawing.Color GetBottomBeforeColor()
|
||||
{
|
||||
return GetColor(1760, 985);
|
||||
}
|
||||
|
||||
private static System.Drawing.Color GetTopBeforeColor()
|
||||
{
|
||||
return GetColor(1751, 693);
|
||||
}
|
||||
|
||||
private static System.Drawing.Color GetColor(int w2, int h2)
|
||||
{
|
||||
double w = 1920;
|
||||
double h = 1080;
|
||||
double width = SystemParameters.PrimaryScreenWidth;
|
||||
double height = SystemParameters.PrimaryScreenHeight;
|
||||
System.Drawing.Point p = new System.Drawing.Point((int)(w2 / w * width), (int)(h2 / h * height));
|
||||
return ScreenUtil.GetColorAt(p);
|
||||
}
|
||||
|
||||
|
||||
private static int CalculateLight(System.Drawing.Color color)
|
||||
{
|
||||
int[] colorArr = new int[] { color.R, color.G, color.B };
|
||||
|
||||
int max = 0;
|
||||
int min = 255;
|
||||
foreach (int i in colorArr)
|
||||
{
|
||||
max = Math.Max(max, i);
|
||||
min = Math.Min(min, i);
|
||||
}
|
||||
int avg = (max + min) / 2;
|
||||
return avg;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
25
Plugins/ShowSeconds/ViewModel/SecondsDataContext.cs
Normal file
25
Plugins/ShowSeconds/ViewModel/SecondsDataContext.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
|
||||
namespace ShowSeconds.ViewModel
|
||||
{
|
||||
public class SecondsDataContext : INotifyPropertyChanged
|
||||
{
|
||||
private string seconds;
|
||||
public string Seconds
|
||||
{
|
||||
set
|
||||
{
|
||||
seconds = value;
|
||||
OnPropertyChanged("Seconds");
|
||||
}
|
||||
get { return seconds; }
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,5 +49,5 @@ using System.Windows;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.4.1.5")]
|
||||
[assembly: AssemblyFileVersion("2.4.1.5")]
|
||||
[assembly: AssemblyVersion("2.5.1.3")]
|
||||
[assembly: AssemblyFileVersion("2.5.1.3")]
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
|
||||
|
||||
### GitHub
|
||||
[https://github.com/Demo-Liu/GeekDesk](https://github.com/Demo-Liu/GeekDesk)
|
||||
[https://github.com/BookerLiu/GeekDesk](https://github.com/BookerLiu/GeekDesk)
|
||||
### 码云
|
||||
[https://gitee.com/demo_liu/GeekDesk](https://gitee.com/demo_liu/GeekDesk)
|
||||
[https://gitee.com/BookerLiu/GeekDesk](https://gitee.com/BookerLiu/GeekDesk)
|
||||
|
||||
<img src="https://z3.ax1x.com/2021/07/20/WYdfmR.jpg" alt="WYdfmR.jpg" border="0" width="400px"/>
|
||||
|
||||
|
||||
7
Resource/Dictionary/XamlFlairSettings.xaml
Normal file
7
Resource/Dictionary/XamlFlairSettings.xaml
Normal file
@@ -0,0 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF">
|
||||
<!--组合动画-->
|
||||
|
||||
|
||||
</ResourceDictionary>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 101 KiB |
31
Task/ShowSecondTask.cs
Normal file
31
Task/ShowSecondTask.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Task
|
||||
{
|
||||
internal class ShowSecondTask
|
||||
{
|
||||
|
||||
public static void SHowSecond()
|
||||
{
|
||||
System.Timers.Timer timer = new System.Timers.Timer
|
||||
{
|
||||
Enabled = true,
|
||||
Interval = 5000
|
||||
};
|
||||
timer.Start();
|
||||
timer.Elapsed += Timer_Elapsed;
|
||||
}
|
||||
|
||||
private static void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
Process[] pcArr = Process.GetProcessesByName("ShellExperienceHost.exe");
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace GeekDesk.Task
|
||||
}
|
||||
}
|
||||
}
|
||||
ClearMemory();
|
||||
//ClearMemory();
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"title": "GeekDesk版本更新",
|
||||
"subTitle": "V2.4.15",
|
||||
"subTitle": "V2.5.13",
|
||||
"msgTitle": "本次更新内容如下",
|
||||
"msg": "['PS:又一次的更新, 虽然还有很多需求没有完成, 但仍然耗费了我大量的精力, 没有点Star的兄弟萌, 求个免费Star(GitHub国内某些用户可能进不去), 再给我一点更新的动力!','增加纯色/渐变色背景','增加/优化拾色器功能','增加主面板Logo开关','优化待办任务,现在待办任务快捷键不再是新建待办窗口','增加鼠标滚轮切换菜单功能(需要鼠标指针在菜单栏)','优化搜索功能,增加 快捷键搜索/按键即搜 可选操作','优化贴边隐藏动画, 纵享丝滑了属于是兄弟萌', '其它已知问题修复']",
|
||||
"githubUrl": "https://github.com/Demo-Liu/GeekDesk/releases",
|
||||
"msg": "['求Star,求Star', '集成Win11显秒插件', '崩溃问题修复', '现在在右侧栏(快捷图标区域)也可以鼠标滚轮切换菜单了', '缩放屏幕截图问题修复(感谢@1062406901提的PR)', '更改一下Logo', '其它已知问题修复']",
|
||||
"githubUrl": "https://github.com/BookerLiu/GeekDesk/releases",
|
||||
"giteeUrl": "https://gitee.com/BookerLiu/GeekDesk/releases",
|
||||
"version": "2.4.15"
|
||||
"version": "2.5.13"
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace GeekDesk.Util
|
||||
else
|
||||
{
|
||||
LinearGradientBrush lgb = new LinearGradientBrush();
|
||||
|
||||
lgb.Opacity = (double)(Math.Round((decimal)(appConfig.BgOpacity / 100.00), 2));
|
||||
GradientStop gs = new GradientStop
|
||||
{
|
||||
Color = (Color)ColorConverter.ConvertFromString(appConfig.GradientBGParam.Color1),
|
||||
|
||||
77
Util/BlurGlassUtil.cs
Normal file
77
Util/BlurGlassUtil.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class BlurGlassUtil
|
||||
{
|
||||
internal enum AccentState
|
||||
{
|
||||
ACCENT_DISABLED = 1,
|
||||
ACCENT_ENABLE_GRADIENT = 0,
|
||||
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
|
||||
ACCENT_ENABLE_BLURBEHIND = 3,
|
||||
ACCENT_INVALID_STATE = 4
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct AccentPolicy
|
||||
{
|
||||
public AccentState AccentState;
|
||||
public int AccentFlags;
|
||||
public int GradientColor;
|
||||
public int AnimationId;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct WindowCompositionAttributeData
|
||||
{
|
||||
public WindowCompositionAttribute Attribute;
|
||||
public IntPtr Data;
|
||||
public int SizeOfData;
|
||||
}
|
||||
|
||||
internal enum WindowCompositionAttribute
|
||||
{
|
||||
// ...
|
||||
WCA_ACCENT_POLICY = 19
|
||||
// ...
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
|
||||
|
||||
|
||||
public static void EnableBlur(Window window)
|
||||
{
|
||||
WindowInteropHelper windowHelper = new WindowInteropHelper(window);
|
||||
|
||||
AccentPolicy accent = new AccentPolicy
|
||||
{
|
||||
AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND
|
||||
};
|
||||
|
||||
int accentStructSize = Marshal.SizeOf(accent);
|
||||
|
||||
IntPtr accentPtr = Marshal.AllocHGlobal(accentStructSize);
|
||||
Marshal.StructureToPtr(accent, accentPtr, false);
|
||||
|
||||
WindowCompositionAttributeData data = new WindowCompositionAttributeData
|
||||
{
|
||||
Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
|
||||
SizeOfData = accentStructSize,
|
||||
Data = accentPtr
|
||||
};
|
||||
|
||||
SetWindowCompositionAttribute(windowHelper.Handle, ref data);
|
||||
|
||||
Marshal.FreeHGlobal(accentPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Other;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Data;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -8,6 +12,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
using static GeekDesk.Control.Other.GlobalMsgNotification;
|
||||
|
||||
/// <summary>
|
||||
/// 提取一些代码
|
||||
@@ -28,10 +33,11 @@ namespace GeekDesk.Util
|
||||
{
|
||||
using (FileStream fs = File.Create(Constants.DATA_FILE_PATH)) { }
|
||||
appData = new AppData();
|
||||
SaveAppData(appData);
|
||||
|
||||
SaveAppData(appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
using (FileStream fs = new FileStream(Constants.DATA_FILE_PATH, FileMode.Open))
|
||||
{
|
||||
@@ -39,42 +45,106 @@ namespace GeekDesk.Util
|
||||
appData = bf.Deserialize(fs) as AppData;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (File.Exists(Constants.DATA_FILE_BAK_PATH))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (FileStream fs = new FileStream(Constants.DATA_FILE_BAK_PATH, FileMode.Open))
|
||||
{
|
||||
BinaryFormatter bf = new BinaryFormatter();
|
||||
appData = bf.Deserialize(fs) as AppData;
|
||||
}
|
||||
|
||||
DialogMsg msg = new DialogMsg();
|
||||
msg.msg = "不幸的是, GeekDesk当前的数据文件已经损坏, " +
|
||||
"现在已经启用系统自动备份的数据\n\n" +
|
||||
"如果你有较新的备份, " +
|
||||
"请退出GeekDesk, " +
|
||||
"将备份文件重命名为:Data, " +
|
||||
"然后将Data覆盖到GeekDesk的根目录即可\n\n" +
|
||||
"系统上次备份时间: \n" + appData.AppConfig.SysBakTime +
|
||||
"\n\n如果当前数据就是你想要的数据, 那么请不用管它";
|
||||
GlobalMsgNotification gm = new GlobalMsgNotification(msg);
|
||||
HandyControl.Controls.Notification ntf = HandyControl.Controls.Notification.Show(gm, ShowAnimation.Fade, true);
|
||||
gm.ntf = ntf;
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("不幸的是, GeekDesk当前的数据文件已经损坏\n如果你有备份, 请将备份文件重命名为:Data 然后将Data覆盖到GeekDesk的根目录即可!");
|
||||
Application.Current.Shutdown();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("不幸的是, GeekDesk当前的数据文件已经损坏\n如果你有备份, 请将备份文件重命名为:Data 然后将Data覆盖到GeekDesk的根目录即可!");
|
||||
Application.Current.Shutdown();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return appData;
|
||||
}
|
||||
|
||||
private readonly static object _MyLock = new object();
|
||||
/// <summary>
|
||||
/// 保存app 数据
|
||||
/// </summary>
|
||||
/// <param name="appData"></param>
|
||||
public static void SaveAppData(AppData appData)
|
||||
public static void SaveAppData(AppData appData, string filePath)
|
||||
{
|
||||
using (FileStream fs = new FileStream(Constants.DATA_FILE_PATH, FileMode.Create))
|
||||
lock (_MyLock)
|
||||
{
|
||||
if (filePath.Equals(Constants.DATA_FILE_BAK_PATH))
|
||||
{
|
||||
appData.AppConfig.SysBakTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
if (!Directory.Exists(filePath.Substring(0, filePath.LastIndexOf("\\"))))
|
||||
{
|
||||
Directory.CreateDirectory(filePath.Substring(0, filePath.LastIndexOf("\\")));
|
||||
}
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
BinaryFormatter bf = new BinaryFormatter();
|
||||
bf.Serialize(fs, appData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断当前屏幕(鼠标最后活动屏幕)是否有全屏化应用
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool IsPrimaryFullScreen()
|
||||
{
|
||||
RECT rect = new RECT();
|
||||
GetWindowRect(new HandleRef(null, GetForegroundWindow()), ref rect);
|
||||
|
||||
int windowHeight = rect.bottom - rect.top;
|
||||
int screenHeight = (int)SystemParameters.PrimaryScreenHeight;
|
||||
|
||||
if (windowHeight >= screenHeight)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
public static void SavePassword(string password)
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(Constants.PW_FILE_BAK_PATH))
|
||||
{
|
||||
sw.Write(password);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void BakAppData()
|
||||
{
|
||||
|
||||
SaveFileDialog sfd = new SaveFileDialog
|
||||
{
|
||||
Title = "备份文件",
|
||||
Filter = "bak文件(*.bak)|*.bak",
|
||||
FileName = "Data-GD-" + DateTime.Now.ToString("yyMMdd") + ".bak",
|
||||
};
|
||||
if (sfd.ShowDialog() == true)
|
||||
{
|
||||
using (FileStream fs = new FileStream(sfd.FileName, FileMode.Create))
|
||||
{
|
||||
BinaryFormatter bf = new BinaryFormatter();
|
||||
bf.Serialize(fs, MainWindow.appData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据路径获取文件图标等信息
|
||||
@@ -92,7 +162,7 @@ namespace GeekDesk.Util
|
||||
// ext = System.IO.Path.GetExtension(path).ToLower();
|
||||
//}
|
||||
|
||||
string iconPath = null;
|
||||
string iconPath;
|
||||
//if (".lnk".Equals(ext))
|
||||
//{
|
||||
|
||||
@@ -111,16 +181,21 @@ namespace GeekDesk.Util
|
||||
BitmapImage bi = ImageUtil.GetBitmapIconByPath(iconPath);
|
||||
IconInfo iconInfo = new IconInfo
|
||||
{
|
||||
Path = path,
|
||||
LnkPath = tempPath,
|
||||
BitmapImage = bi,
|
||||
StartArg = FileUtil.GetArgByLnk(tempPath)
|
||||
Path_NoWrite = path,
|
||||
LnkPath_NoWrite = tempPath,
|
||||
BitmapImage_NoWrite = bi,
|
||||
StartArg_NoWrite = FileUtil.GetArgByLnk(tempPath)
|
||||
};
|
||||
iconInfo.DefaultImage = iconInfo.ImageByteArr;
|
||||
iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(tempPath);
|
||||
iconInfo.DefaultImage_NoWrite = iconInfo.ImageByteArr;
|
||||
iconInfo.Name_NoWrite = System.IO.Path.GetFileNameWithoutExtension(tempPath);
|
||||
if (StringUtil.IsEmpty(iconInfo.Name))
|
||||
{
|
||||
iconInfo.Name = path;
|
||||
iconInfo.Name_NoWrite = path;
|
||||
}
|
||||
string relativePath = FileUtil.MakeRelativePath(Constants.APP_DIR + "GeekDesk.exe", iconInfo.Path);
|
||||
if (!string.IsNullOrEmpty(relativePath) && !relativePath.Equals(iconInfo.Path))
|
||||
{
|
||||
iconInfo.RelativePath_NoWrite = relativePath;
|
||||
}
|
||||
return iconInfo;
|
||||
}
|
||||
@@ -171,20 +246,6 @@ namespace GeekDesk.Util
|
||||
}
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct RECT
|
||||
{
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool GetWindowRect(HandleRef hWnd, [In, Out] ref RECT rect);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetForegroundWindow();
|
||||
|
||||
|
||||
|
||||
|
||||
175
Util/DragAdorner.cs
Normal file
175
Util/DragAdorner.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
// Copyright (C) Josh Smith - January 2007
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
/// <summary>
|
||||
/// Renders a visual which can follow the mouse cursor,
|
||||
/// such as during a drag-and-drop operation.
|
||||
/// </summary>
|
||||
public class DragAdorner : Adorner
|
||||
{
|
||||
#region Data
|
||||
|
||||
private Rectangle child = null;
|
||||
private double offsetLeft = 0;
|
||||
private double offsetTop = 0;
|
||||
|
||||
#endregion // Data
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of DragVisualAdorner.
|
||||
/// </summary>
|
||||
/// <param name="adornedElement">The element being adorned.</param>
|
||||
/// <param name="size">The size of the adorner.</param>
|
||||
/// <param name="brush">A brush to with which to paint the adorner.</param>
|
||||
public DragAdorner( UIElement adornedElement, Size size, Brush brush )
|
||||
: base( adornedElement )
|
||||
{
|
||||
Rectangle rect = new Rectangle();
|
||||
rect.Fill = brush;
|
||||
rect.Width = size.Width;
|
||||
rect.Height = size.Height;
|
||||
rect.IsHitTestVisible = false;
|
||||
this.child = rect;
|
||||
}
|
||||
|
||||
#endregion // Constructor
|
||||
|
||||
#region Public Interface
|
||||
|
||||
#region GetDesiredTransform
|
||||
|
||||
/// <summary>
|
||||
/// Override.
|
||||
/// </summary>
|
||||
/// <param name="transform"></param>
|
||||
/// <returns></returns>
|
||||
public override GeneralTransform GetDesiredTransform( GeneralTransform transform )
|
||||
{
|
||||
GeneralTransformGroup result = new GeneralTransformGroup();
|
||||
result.Children.Add( base.GetDesiredTransform( transform ) );
|
||||
result.Children.Add( new TranslateTransform( this.offsetLeft, this.offsetTop ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion // GetDesiredTransform
|
||||
|
||||
#region OffsetLeft
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the horizontal offset of the adorner.
|
||||
/// </summary>
|
||||
public double OffsetLeft
|
||||
{
|
||||
get { return this.offsetLeft; }
|
||||
set
|
||||
{
|
||||
this.offsetLeft = value;
|
||||
UpdateLocation();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // OffsetLeft
|
||||
|
||||
#region SetOffsets
|
||||
|
||||
/// <summary>
|
||||
/// Updates the location of the adorner in one atomic operation.
|
||||
/// </summary>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="top"></param>
|
||||
public void SetOffsets( double left, double top )
|
||||
{
|
||||
this.offsetLeft = left;
|
||||
this.offsetTop = top;
|
||||
this.UpdateLocation();
|
||||
}
|
||||
|
||||
#endregion // SetOffsets
|
||||
|
||||
#region OffsetTop
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the vertical offset of the adorner.
|
||||
/// </summary>
|
||||
public double OffsetTop
|
||||
{
|
||||
get { return this.offsetTop; }
|
||||
set
|
||||
{
|
||||
this.offsetTop = value;
|
||||
UpdateLocation();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // OffsetTop
|
||||
|
||||
#endregion // Public Interface
|
||||
|
||||
#region Protected Overrides
|
||||
|
||||
/// <summary>
|
||||
/// Override.
|
||||
/// </summary>
|
||||
/// <param name="constraint"></param>
|
||||
/// <returns></returns>
|
||||
protected override Size MeasureOverride( Size constraint )
|
||||
{
|
||||
this.child.Measure( constraint );
|
||||
return this.child.DesiredSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override.
|
||||
/// </summary>
|
||||
/// <param name="finalSize"></param>
|
||||
/// <returns></returns>
|
||||
protected override Size ArrangeOverride( Size finalSize )
|
||||
{
|
||||
this.child.Arrange( new Rect( finalSize ) );
|
||||
return finalSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override.
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
protected override Visual GetVisualChild( int index )
|
||||
{
|
||||
return this.child;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override. Always returns 1.
|
||||
/// </summary>
|
||||
protected override int VisualChildrenCount
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
#endregion // Protected Overrides
|
||||
|
||||
#region Private Helpers
|
||||
|
||||
private void UpdateLocation()
|
||||
{
|
||||
AdornerLayer adornerLayer = this.Parent as AdornerLayer;
|
||||
if( adornerLayer != null )
|
||||
adornerLayer.Update( this.AdornedElement );
|
||||
}
|
||||
|
||||
#endregion // Private Helpers
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
@@ -10,16 +11,31 @@ namespace GeekDesk.Util
|
||||
{
|
||||
public class FileIcon
|
||||
{
|
||||
|
||||
private static List<string> GetBlurExts()
|
||||
static List<string> blurExtsList;
|
||||
static List<int[]> pixelList;
|
||||
static FileIcon() {
|
||||
blurExtsList = new List<string>
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
list.Add(".exe");
|
||||
list.Add(".cer");
|
||||
list.Add(".lnk");
|
||||
return list;
|
||||
".exe",
|
||||
".cer",
|
||||
".lnk",
|
||||
".chm"
|
||||
};
|
||||
pixelList = new List<int[]>
|
||||
{
|
||||
new int[]{ 256 / 4, 256 / 4 },
|
||||
new int[]{ 256 / 2, 256 / 4 },
|
||||
new int[]{ 256 / 4 * 3, 256 / 4 },
|
||||
new int[]{ 256 / 4, 256 / 2 },
|
||||
new int[]{ 256 / 4, 256 / 4 * 3 },
|
||||
new int[]{ 256 / 4 * 3, 256 / 2 },
|
||||
new int[]{ 256 / 4 * 3, 256 / 4 * 3 },
|
||||
new int[]{ 256 / 2, 256 / 4 * 3 },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
public static extern int PrivateExtractIcons(
|
||||
string lpszFile, //文件名可以是exe,dll,ico,cur,ani,bmp
|
||||
@@ -53,7 +69,7 @@ namespace GeekDesk.Util
|
||||
ip = hIcons[0];
|
||||
ico = Icon.FromHandle(ip);
|
||||
}
|
||||
else if (GetBlurExts().Contains(ext))
|
||||
else if (blurExtsList.Contains(ext))
|
||||
{
|
||||
ico = Icon.ExtractAssociatedIcon(filePath);
|
||||
}
|
||||
@@ -61,7 +77,13 @@ namespace GeekDesk.Util
|
||||
{
|
||||
ip = GetJumboIcon(GetIconIndex(filePath));
|
||||
ico = Icon.FromHandle(ip);
|
||||
if (CheckIsSmallIco(ico.ToBitmap()))
|
||||
{
|
||||
ico = Icon.ExtractAssociatedIcon(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Bitmap bmp = ico.ToBitmap();
|
||||
MemoryStream strm = new MemoryStream();
|
||||
@@ -73,6 +95,7 @@ namespace GeekDesk.Util
|
||||
myEncoderParameters.Param[0] = myEncoderParameter;
|
||||
|
||||
bmp.Save(strm, myImageCodecInfo, myEncoderParameters);
|
||||
|
||||
BitmapImage bmpImage = new BitmapImage();
|
||||
bmpImage.BeginInit();
|
||||
strm.Seek(0, SeekOrigin.Begin);
|
||||
@@ -82,6 +105,7 @@ namespace GeekDesk.Util
|
||||
{
|
||||
Shell32.DestroyIcon(ip);
|
||||
}
|
||||
DeleteObject(bmp.GetHbitmap());
|
||||
return bmpImage.Clone();
|
||||
}
|
||||
|
||||
@@ -98,6 +122,30 @@ namespace GeekDesk.Util
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool CheckIsSmallIco(Bitmap bm)
|
||||
{
|
||||
Color color;
|
||||
int count = 0;
|
||||
foreach (int[] arr in pixelList)
|
||||
{
|
||||
color = bm.GetPixel(arr[0], arr[1]);
|
||||
if (color.A == 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
DeleteObject(bm.GetHbitmap());
|
||||
if (count >= 6)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
|
||||
public static extern bool DeleteObject(IntPtr onj);
|
||||
|
||||
|
||||
|
||||
public static int GetIconIndex(string pszFile)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using IWshRuntimeLibrary;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -156,5 +157,48 @@ namespace GeekDesk.Util
|
||||
}
|
||||
}
|
||||
|
||||
public static string MakeRelativePath(string fromPath, string toPath)
|
||||
{
|
||||
string relativePath = null;
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(toPath) || string.IsNullOrEmpty(fromPath)) return null;
|
||||
Uri file = new Uri(@toPath);
|
||||
// Must end in a slash to indicate folder
|
||||
Uri folder = new Uri(@fromPath);
|
||||
relativePath =
|
||||
Uri.UnescapeDataString(
|
||||
folder.MakeRelativeUri(file)
|
||||
.ToString()
|
||||
.Replace('/', Path.DirectorySeparatorChar)
|
||||
);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogUtil.WriteErrorLog(ex, "建立相对路径出错:fromPath:" + fromPath + ",toPath:" + toPath);
|
||||
}
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
|
||||
public static FileInfo GetFileByNameWithDir(string name, string dir)
|
||||
{
|
||||
DirectoryInfo d = new DirectoryInfo(dir);
|
||||
FileInfo[] files = d.GetFiles();//文件
|
||||
foreach (FileInfo fi in files)
|
||||
{
|
||||
if (fi.Name.Equals(name))
|
||||
{
|
||||
return fi;
|
||||
}
|
||||
}
|
||||
DirectoryInfo[] directs = d.GetDirectories();
|
||||
foreach (DirectoryInfo direct in directs)
|
||||
{
|
||||
return GetFileByNameWithDir(name, direct.FullName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
227
Util/HideWindowUtil.cs
Normal file
227
Util/HideWindowUtil.cs
Normal file
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class HideWindowUtil
|
||||
{
|
||||
|
||||
public enum GetWindowLongFields
|
||||
{
|
||||
// ...
|
||||
GWL_EXSTYLE = (-20),
|
||||
// ...
|
||||
}
|
||||
|
||||
public static void HideAltTab(Window window)
|
||||
{
|
||||
try
|
||||
{
|
||||
WindowInteropHelper wndHelper = new WindowInteropHelper(window);
|
||||
int exStyle = (int)HideWindowUtil.GetWindowLong(wndHelper.Handle, (int)HideWindowUtil.GetWindowLongFields.GWL_EXSTYLE);
|
||||
exStyle |= (int)HideWindowUtil.ExtendedWindowStyles.WS_EX_TOOLWINDOW;
|
||||
HideWindowUtil.SetWindowLong(wndHelper.Handle, (int)HideWindowUtil.GetWindowLongFields.GWL_EXSTYLE, (IntPtr)exStyle);
|
||||
} catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
public static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
|
||||
{
|
||||
int error = 0;
|
||||
IntPtr result = IntPtr.Zero;
|
||||
// Win32 SetWindowLong doesn't clear error on success
|
||||
SetLastError(0);
|
||||
|
||||
if (IntPtr.Size == 4)
|
||||
{
|
||||
// use SetWindowLong
|
||||
Int32 tempResult = IntSetWindowLong(hWnd, nIndex, IntPtrToInt32(dwNewLong));
|
||||
error = Marshal.GetLastWin32Error();
|
||||
result = new IntPtr(tempResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
// use SetWindowLongPtr
|
||||
result = IntSetWindowLongPtr(hWnd, nIndex, dwNewLong);
|
||||
error = Marshal.GetLastWin32Error();
|
||||
}
|
||||
|
||||
if ((result == IntPtr.Zero) && (error != 0))
|
||||
{
|
||||
throw new System.ComponentModel.Win32Exception(error);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", SetLastError = true)]
|
||||
private static extern IntPtr IntSetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowLong", SetLastError = true)]
|
||||
private static extern Int32 IntSetWindowLong(IntPtr hWnd, int nIndex, Int32 dwNewLong);
|
||||
|
||||
private static int IntPtrToInt32(IntPtr intPtr)
|
||||
{
|
||||
return unchecked((int)intPtr.ToInt64());
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", EntryPoint = "SetLastError")]
|
||||
public static extern void SetLastError(int dwErrorCode);
|
||||
/// <summary>
|
||||
/// 扩展的窗口风格
|
||||
/// </summary>
|
||||
/// 代码:[Extended Window Styles (Windows)](https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx )
|
||||
/// code from [Extended Window Styles (Windows)](https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx )
|
||||
[Flags]
|
||||
public enum ExtendedWindowStyles : long
|
||||
{
|
||||
/// <summary>
|
||||
/// The window accepts drag-drop files
|
||||
/// </summary>
|
||||
WS_EX_ACCEPTFILES = 0x00000010L,
|
||||
|
||||
/// <summary>
|
||||
/// Forces a top-level window onto the taskbar when the window is visible
|
||||
/// </summary>
|
||||
WS_EX_APPWINDOW = 0x00040000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window has a border with a sunken edge.
|
||||
/// </summary>
|
||||
WS_EX_CLIENTEDGE = 0x00000200L,
|
||||
|
||||
/// <summary>
|
||||
/// Paints all descendants of a window in bottom-to-top painting order using double-buffering. For more information, see Remarks. This cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.Windows 2000: This style is not supported.
|
||||
/// </summary>
|
||||
WS_EX_COMPOSITED = 0x02000000L,
|
||||
|
||||
/// <summary>
|
||||
/// The title bar of the window includes a question mark. When the user clicks the question mark, the cursor changes to a question mark with a pointer. If the user then clicks a child window, the child receives a WM_HELP message. The child window should pass the message to the parent window procedure, which should call the WinHelp function using the HELP_WM_HELP command. The Help application displays a pop-up window that typically contains help for the child window.WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles.
|
||||
/// </summary>
|
||||
WS_EX_CONTEXTHELP = 0x00000400L,
|
||||
|
||||
/// <summary>
|
||||
/// The window itself contains child windows that should take part in dialog box navigation. If this style is specified, the dialog manager recurses into children of this window when performing navigation operations such as handling the TAB key, an arrow key, or a keyboard mnemonic.
|
||||
/// </summary>
|
||||
WS_EX_CONTROLPARENT = 0x00010000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the dwStyle parameter.
|
||||
/// </summary>
|
||||
WS_EX_DLGMODALFRAME = 0x00000001L,
|
||||
|
||||
/// <summary>
|
||||
/// The window is a layered window. This style cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.Windows 8: The WS_EX_LAYERED style is supported for top-level windows and child windows. Previous Windows versions support WS_EX_LAYERED only for top-level windows.
|
||||
/// </summary>
|
||||
WS_EX_LAYERED = 0x00080000,
|
||||
|
||||
/// <summary>
|
||||
/// If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the horizontal origin of the window is on the right edge. Increasing horizontal values advance to the left.
|
||||
/// </summary>
|
||||
WS_EX_LAYOUTRTL = 0x00400000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window has generic left-aligned properties. This is the default.
|
||||
/// </summary>
|
||||
WS_EX_LEFT = 0x00000000L,
|
||||
|
||||
/// <summary>
|
||||
/// If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the vertical scroll bar (if present) is to the left of the client area. For other languages, the style is ignored.
|
||||
/// </summary>
|
||||
WS_EX_LEFTSCROLLBAR = 0x00004000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window text is displayed using left-to-right reading-order properties. This is the default.
|
||||
/// </summary>
|
||||
WS_EX_LTRREADING = 0x00000000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window is a MDI child window.
|
||||
/// </summary>
|
||||
WS_EX_MDICHILD = 0x00000040L,
|
||||
|
||||
/// <summary>
|
||||
/// A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window.To activate the window, use the SetActiveWindow or SetForegroundWindow function.The window does not appear on the taskbar by default. To force the window to appear on the taskbar, use the WS_EX_APPWINDOW style.
|
||||
/// </summary>
|
||||
WS_EX_NOACTIVATE = 0x08000000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window does not pass its window layout to its child windows.
|
||||
/// </summary>
|
||||
WS_EX_NOINHERITLAYOUT = 0x00100000L,
|
||||
|
||||
/// <summary>
|
||||
/// The child window created with this style does not send the WM_PARENTNOTIFY message to its parent window when it is created or destroyed.
|
||||
/// </summary>
|
||||
WS_EX_NOPARENTNOTIFY = 0x00000004L,
|
||||
|
||||
/// <summary>
|
||||
/// The window does not render to a redirection surface. This is for windows that do not have visible content or that use mechanisms other than surfaces to provide their visual.
|
||||
/// </summary>
|
||||
WS_EX_NOREDIRECTIONBITMAP = 0x00200000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window is an overlapped window.
|
||||
/// </summary>
|
||||
WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE),
|
||||
|
||||
/// <summary>
|
||||
/// The window is palette window, which is a modeless dialog box that presents an array of commands.
|
||||
/// </summary>
|
||||
WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST),
|
||||
|
||||
/// <summary>
|
||||
/// The window has generic "right-aligned" properties. This depends on the window class. This style has an effect only if the shell language is Hebrew, Arabic, or another language that supports reading-order alignment; otherwise, the style is ignored.Using the WS_EX_RIGHT style for static or edit controls has the same effect as using the SS_RIGHT or ES_RIGHT style, respectively. Using this style with button controls has the same effect as using BS_RIGHT and BS_RIGHTBUTTON styles.
|
||||
/// </summary>
|
||||
WS_EX_RIGHT = 0x00001000L,
|
||||
|
||||
/// <summary>
|
||||
/// The vertical scroll bar (if present) is to the right of the client area. This is the default.
|
||||
/// </summary>
|
||||
WS_EX_RIGHTSCROLLBAR = 0x00000000L,
|
||||
|
||||
/// <summary>
|
||||
/// If the shell language is Hebrew, Arabic, or another language that supports reading-order alignment, the window text is displayed using right-to-left reading-order properties. For other languages, the style is ignored.
|
||||
/// </summary>
|
||||
WS_EX_RTLREADING = 0x00002000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window has a three-dimensional border style intended to be used for items that do not accept user input.
|
||||
/// </summary>
|
||||
WS_EX_STATICEDGE = 0x00020000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window is intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by right-clicking or by typing ALT+SPACE.
|
||||
/// </summary>
|
||||
WS_EX_TOOLWINDOW = 0x00000080L,
|
||||
|
||||
/// <summary>
|
||||
/// The window should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use the SetWindowPos function.
|
||||
/// </summary>
|
||||
WS_EX_TOPMOST = 0x00000008L,
|
||||
|
||||
/// <summary>
|
||||
/// The window should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted.To achieve transparency without these restrictions, use the SetWindowRgn function.
|
||||
/// </summary>
|
||||
WS_EX_TRANSPARENT = 0x00000020L,
|
||||
|
||||
/// <summary>
|
||||
/// The window has a border with a raised edge
|
||||
/// </summary>
|
||||
WS_EX_WINDOWEDGE = 0x00000100L
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
893
Util/ListBoxDragDropManager.cs
Normal file
893
Util/ListBoxDragDropManager.cs
Normal file
@@ -0,0 +1,893 @@
|
||||
// Copyright (C) Josh Smith - January 2007
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Input;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.Constant;
|
||||
using HandyControl.Controls;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
#region ListBoxDragDropManager
|
||||
|
||||
/// <summary>
|
||||
/// Manages the dragging and dropping of ListBoxItems in a ListBox.
|
||||
/// The ItemType type parameter indicates the type of the objects in
|
||||
/// the ListBox's items source. The ListBox's ItemsSource must be
|
||||
/// set to an instance of ObservableCollection of ItemType, or an
|
||||
/// Exception will be thrown.
|
||||
/// </summary>
|
||||
/// <typeparam name="ItemType">The type of the ListBox's items.</typeparam>
|
||||
public class ListBoxDragDropManager<ItemType> where ItemType : class
|
||||
{
|
||||
#region Data
|
||||
|
||||
bool canInitiateDrag;
|
||||
DragAdorner dragAdorner;
|
||||
double dragAdornerOpacity;
|
||||
int indexToSelect;
|
||||
bool isDragInProgress;
|
||||
ItemType itemUnderDragCursor;
|
||||
ListBox listBox;
|
||||
Point ptMouseDown;
|
||||
bool showDragAdorner;
|
||||
|
||||
#endregion // Data
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ListBoxDragManager.
|
||||
/// </summary>
|
||||
public ListBoxDragDropManager()
|
||||
{
|
||||
this.canInitiateDrag = false;
|
||||
this.dragAdornerOpacity = 0.7;
|
||||
this.indexToSelect = -1;
|
||||
this.showDragAdorner = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ListBoxDragManager.
|
||||
/// </summary>
|
||||
/// <param name="listBox"></param>
|
||||
public ListBoxDragDropManager( ListBox listBox )
|
||||
: this()
|
||||
{
|
||||
this.ListBox = listBox;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ListBoxDragManager.
|
||||
/// </summary>
|
||||
/// <param name="listBox"></param>
|
||||
/// <param name="dragAdornerOpacity"></param>
|
||||
public ListBoxDragDropManager( ListBox listBox, double dragAdornerOpacity )
|
||||
: this( listBox )
|
||||
{
|
||||
this.DragAdornerOpacity = dragAdornerOpacity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ListBoxDragManager.
|
||||
/// </summary>
|
||||
/// <param name="listBox"></param>
|
||||
/// <param name="showDragAdorner"></param>
|
||||
public ListBoxDragDropManager( ListBox listBox, bool showDragAdorner )
|
||||
: this( listBox )
|
||||
{
|
||||
this.ShowDragAdorner = showDragAdorner;
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
#region Public Interface
|
||||
|
||||
#region DragAdornerOpacity
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the opacity of the drag adorner. This property has no
|
||||
/// effect if ShowDragAdorner is false. The default value is 0.7
|
||||
/// </summary>
|
||||
public double DragAdornerOpacity
|
||||
{
|
||||
get { return this.dragAdornerOpacity; }
|
||||
set
|
||||
{
|
||||
if( this.IsDragInProgress )
|
||||
throw new InvalidOperationException( "Cannot set the DragAdornerOpacity property during a drag operation." );
|
||||
|
||||
if( value < 0.0 || value > 1.0 )
|
||||
throw new ArgumentOutOfRangeException( "DragAdornerOpacity", value, "Must be between 0 and 1." );
|
||||
|
||||
this.dragAdornerOpacity = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // DragAdornerOpacity
|
||||
|
||||
#region IsDragInProgress
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if there is currently a drag operation being managed.
|
||||
/// </summary>
|
||||
public bool IsDragInProgress
|
||||
{
|
||||
get { return this.isDragInProgress; }
|
||||
private set { this.isDragInProgress = value; }
|
||||
}
|
||||
|
||||
#endregion // IsDragInProgress
|
||||
|
||||
#region ListBox
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the ListBox whose dragging is managed. This property
|
||||
/// can be set to null, to prevent drag management from occuring. If
|
||||
/// the ListBox's AllowDrop property is false, it will be set to true.
|
||||
/// </summary>
|
||||
public ListBox ListBox
|
||||
{
|
||||
get { return listBox; }
|
||||
set
|
||||
{
|
||||
if( this.IsDragInProgress )
|
||||
throw new InvalidOperationException( "Cannot set the ListBox property during a drag operation." );
|
||||
|
||||
if( this.listBox != null )
|
||||
{
|
||||
#region Unhook Events
|
||||
|
||||
this.listBox.PreviewMouseLeftButtonDown -= LIstBox_PreviewMouseLeftButtonDown;
|
||||
this.listBox.PreviewMouseMove -= LIstBox_PreviewMouseMove;
|
||||
this.listBox.DragOver -= LIstBox_DragOver;
|
||||
this.listBox.DragLeave -= LIstBox_DragLeave;
|
||||
this.listBox.DragEnter -= LIstBox_DragEnter;
|
||||
this.listBox.Drop -= LIstBox_Drop;
|
||||
|
||||
#endregion // Unhook Events
|
||||
}
|
||||
|
||||
this.listBox = value;
|
||||
|
||||
if( this.listBox != null )
|
||||
{
|
||||
if( !this.listBox.AllowDrop )
|
||||
this.listBox.AllowDrop = true;
|
||||
|
||||
#region Hook Events
|
||||
|
||||
this.listBox.PreviewMouseLeftButtonDown += LIstBox_PreviewMouseLeftButtonDown;
|
||||
this.listBox.PreviewMouseMove += LIstBox_PreviewMouseMove;
|
||||
this.listBox.DragOver += LIstBox_DragOver;
|
||||
this.listBox.DragLeave += LIstBox_DragLeave;
|
||||
this.listBox.DragEnter += LIstBox_DragEnter;
|
||||
this.listBox.Drop += LIstBox_Drop;
|
||||
|
||||
#endregion // Hook Events
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // ListBox
|
||||
|
||||
#region ProcessDrop [event]
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a drop occurs. By default the dropped item will be moved
|
||||
/// to the target index. Handle this event if relocating the dropped item
|
||||
/// requires custom behavior. Note, if this event is handled the default
|
||||
/// item dropping logic will not occur.
|
||||
/// </summary>
|
||||
public event EventHandler<ProcessDropEventArgs<ItemType>> ProcessDrop;
|
||||
|
||||
#endregion // ProcessDrop [event]
|
||||
|
||||
#region ShowDragAdorner
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets whether a visual representation of the ListBoxItem being dragged
|
||||
/// follows the mouse cursor during a drag operation. The default value is true.
|
||||
/// </summary>
|
||||
public bool ShowDragAdorner
|
||||
{
|
||||
get { return this.showDragAdorner; }
|
||||
set
|
||||
{
|
||||
if( this.IsDragInProgress )
|
||||
throw new InvalidOperationException( "Cannot set the ShowDragAdorner property during a drag operation." );
|
||||
|
||||
this.showDragAdorner = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // ShowDragAdorner
|
||||
|
||||
#endregion // Public Interface
|
||||
|
||||
#region Event Handling Methods
|
||||
|
||||
#region LIstBox_PreviewMouseLeftButtonDown
|
||||
|
||||
void LIstBox_PreviewMouseLeftButtonDown( object sender, MouseButtonEventArgs e )
|
||||
{
|
||||
if( this.IsMouseOverScrollbar )
|
||||
{
|
||||
// 4/13/2007 - Set the flag to false when cursor is over scrollbar.
|
||||
this.canInitiateDrag = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int index = this.IndexUnderDragCursor;
|
||||
this.canInitiateDrag = index > -1;
|
||||
|
||||
if( this.canInitiateDrag )
|
||||
{
|
||||
// Remember the location and index of the ListBoxItem the user clicked on for later.
|
||||
this.ptMouseDown = MouseUtil.GetMousePosition();
|
||||
//this.ptMouseDown = MouseUtil.GetMousePosition( this.listBox );
|
||||
this.indexToSelect = index;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ptMouseDown = new Point( -10000, -10000 );
|
||||
this.indexToSelect = -1;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // LIstBox_PreviewMouseLeftButtonDown
|
||||
|
||||
#region LIstBox_PreviewMouseMove
|
||||
|
||||
void LIstBox_PreviewMouseMove( object sender, MouseEventArgs e )
|
||||
{
|
||||
if( !this.CanStartDragOperation )
|
||||
return;
|
||||
|
||||
// Select the item the user clicked on.
|
||||
if( this.listBox.SelectedIndex != this.indexToSelect )
|
||||
this.listBox.SelectedIndex = this.indexToSelect;
|
||||
|
||||
// If the item at the selected index is null, there's nothing
|
||||
// we can do, so just return;
|
||||
if( this.listBox.SelectedItem == null )
|
||||
return;
|
||||
|
||||
ListBoxItem itemToDrag = this.GetListBoxItem( this.listBox.SelectedIndex );
|
||||
if( itemToDrag == null )
|
||||
return;
|
||||
|
||||
AdornerLayer adornerLayer = this.ShowDragAdornerResolved ? this.InitializeAdornerLayer( itemToDrag ) : null;
|
||||
|
||||
this.InitializeDragOperation( itemToDrag );
|
||||
this.PerformDragOperation();
|
||||
this.FinishDragOperation( itemToDrag, adornerLayer );
|
||||
}
|
||||
|
||||
#endregion // LIstBox_PreviewMouseMove
|
||||
|
||||
#region LIstBox_DragOver
|
||||
|
||||
void LIstBox_DragOver( object sender, DragEventArgs e )
|
||||
{
|
||||
e.Effects = DragDropEffects.Move;
|
||||
|
||||
if ( this.ShowDragAdornerResolved )
|
||||
this.UpdateDragAdornerLocation();
|
||||
|
||||
// Update the item which is known to be currently under the drag cursor.
|
||||
int index = this.IndexUnderDragCursor;
|
||||
this.ItemUnderDragCursor = index < 0 ? null : this.ListBox.Items[index] as ItemType;
|
||||
}
|
||||
|
||||
#endregion // LIstBox_DragOver
|
||||
|
||||
#region LIstBox_DragLeave
|
||||
|
||||
void LIstBox_DragLeave( object sender, DragEventArgs e )
|
||||
{
|
||||
if( !this.IsMouseOver( this.listBox ) )
|
||||
{
|
||||
if( this.ItemUnderDragCursor != null )
|
||||
this.ItemUnderDragCursor = null;
|
||||
|
||||
if( this.dragAdorner != null )
|
||||
this.dragAdorner.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // LIstBox_DragLeave
|
||||
|
||||
#region LIstBox_DragEnter
|
||||
|
||||
void LIstBox_DragEnter( object sender, DragEventArgs e )
|
||||
{
|
||||
if( this.dragAdorner != null && this.dragAdorner.Visibility != Visibility.Visible )
|
||||
{
|
||||
// Update the location of the adorner and then show it.
|
||||
this.UpdateDragAdornerLocation();
|
||||
this.dragAdorner.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // LIstBox_DragEnter
|
||||
|
||||
#region LIstBox_Drop
|
||||
|
||||
void LIstBox_Drop( object sender, DragEventArgs e )
|
||||
{
|
||||
if( this.ItemUnderDragCursor != null )
|
||||
this.ItemUnderDragCursor = null;
|
||||
|
||||
e.Effects = DragDropEffects.None;
|
||||
|
||||
if( !e.Data.GetDataPresent( typeof( ItemType ) ) )
|
||||
return;
|
||||
|
||||
// Get the data object which was dropped.
|
||||
ItemType data = e.Data.GetData( typeof( ItemType ) ) as ItemType;
|
||||
if( data == null )
|
||||
return;
|
||||
|
||||
// Get the ObservableCollection<ItemType> which contains the dropped data object.
|
||||
ObservableCollection<ItemType> itemsSource = this.listBox.ItemsSource as ObservableCollection<ItemType>;
|
||||
if( itemsSource == null )
|
||||
throw new Exception(
|
||||
"A ListBox managed by ListBoxDragManager must have its ItemsSource set to an ObservableCollection<ItemType>." );
|
||||
|
||||
int oldIndex = itemsSource.IndexOf( data );
|
||||
int newIndex = this.IndexUnderDragCursor;
|
||||
|
||||
if( newIndex < 0 )
|
||||
{
|
||||
// The drag started somewhere else, and our ListBox is empty
|
||||
// so make the new item the first in the list.
|
||||
if( itemsSource.Count == 0 )
|
||||
newIndex = 0;
|
||||
|
||||
// The drag started somewhere else, but our ListBox has items
|
||||
// so make the new item the last in the list.
|
||||
else if( oldIndex < 0 )
|
||||
newIndex = itemsSource.Count;
|
||||
|
||||
// The user is trying to drop an item from our ListBox into
|
||||
// our ListBox, but the mouse is not over an item, so don't
|
||||
// let them drop it.
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
// Dropping an item back onto itself is not considered an actual 'drop'.
|
||||
if( oldIndex == newIndex )
|
||||
return;
|
||||
|
||||
if( this.ProcessDrop != null )
|
||||
{
|
||||
// Let the client code process the drop.
|
||||
ProcessDropEventArgs<ItemType> args = new ProcessDropEventArgs<ItemType>( itemsSource, data, oldIndex, newIndex, e.AllowedEffects );
|
||||
this.ProcessDrop( this, args );
|
||||
e.Effects = args.Effects;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Move the dragged data object from it's original index to the
|
||||
// new index (according to where the mouse cursor is). If it was
|
||||
// not previously in the ListBox, then insert the item.
|
||||
if( oldIndex > -1 )
|
||||
{
|
||||
// <20>ⲿҵ<E2B2BF><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
itemsSource.Move(oldIndex, newIndex);
|
||||
if (MainWindow.appData.AppConfig.IconSortType != SortType.CUSTOM)
|
||||
{
|
||||
MainWindow.appData.AppConfig.IconSortType = SortType.CUSTOM;
|
||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed
|
||||
|| MainWindow.mainWindow.Opacity != 1)
|
||||
{
|
||||
Growl.WarningGlobal("<22>ѽ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("<22>ѽ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>!", "MainWindowGrowl");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itemsSource.Insert(newIndex, data);
|
||||
}
|
||||
|
||||
// Set the Effects property so that the call to DoDragDrop will return 'Move'.
|
||||
e.Effects = DragDropEffects.Move;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // LIstBox_Drop
|
||||
|
||||
#endregion // Event Handling Methods
|
||||
|
||||
#region Private Helpers
|
||||
|
||||
#region CanStartDragOperation
|
||||
|
||||
bool CanStartDragOperation
|
||||
{
|
||||
get
|
||||
{
|
||||
if( Mouse.LeftButton != MouseButtonState.Pressed )
|
||||
return false;
|
||||
|
||||
if( !this.canInitiateDrag )
|
||||
return false;
|
||||
|
||||
if( this.indexToSelect == -1 )
|
||||
return false;
|
||||
|
||||
if( !this.HasCursorLeftDragThreshold )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // CanStartDragOperation
|
||||
|
||||
#region FinishDragOperation
|
||||
|
||||
void FinishDragOperation( ListBoxItem draggedItem, AdornerLayer adornerLayer )
|
||||
{
|
||||
// Let the ListBoxItem know that it is not being dragged anymore.
|
||||
ListBoxItemDragState.SetIsBeingDragged( draggedItem, false );
|
||||
|
||||
this.IsDragInProgress = false;
|
||||
|
||||
if( this.ItemUnderDragCursor != null )
|
||||
this.ItemUnderDragCursor = null;
|
||||
|
||||
// Remove the drag adorner from the adorner layer.
|
||||
if( adornerLayer != null )
|
||||
{
|
||||
adornerLayer.Remove( this.dragAdorner );
|
||||
this.dragAdorner = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // FinishDragOperation
|
||||
|
||||
#region GetListBoxItem
|
||||
|
||||
ListBoxItem GetListBoxItem( int index )
|
||||
{
|
||||
if( this.listBox.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated )
|
||||
return null;
|
||||
|
||||
return this.listBox.ItemContainerGenerator.ContainerFromIndex( index ) as ListBoxItem;
|
||||
}
|
||||
|
||||
ListBoxItem GetListBoxItem( ItemType dataItem )
|
||||
{
|
||||
if( this.listBox.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated )
|
||||
return null;
|
||||
|
||||
return this.listBox.ItemContainerGenerator.ContainerFromItem( dataItem ) as ListBoxItem;
|
||||
}
|
||||
|
||||
#endregion // GetListBoxItem
|
||||
|
||||
#region HasCursorLeftDragThreshold
|
||||
|
||||
bool HasCursorLeftDragThreshold
|
||||
{
|
||||
get
|
||||
{
|
||||
if( this.indexToSelect < 0 )
|
||||
return false;
|
||||
|
||||
ListBoxItem item = this.GetListBoxItem( this.indexToSelect );
|
||||
if (item == null) return false;
|
||||
Rect bounds = VisualTreeHelper.GetDescendantBounds( item );
|
||||
Point ptInItem = this.listBox.TranslatePoint( this.ptMouseDown, item );
|
||||
|
||||
// In case the cursor is at the very top or bottom of the ListBoxItem
|
||||
// we want to make the vertical threshold very small so that dragging
|
||||
// over an adjacent item does not select it.
|
||||
double topOffset = Math.Abs( ptInItem.Y );
|
||||
double btmOffset = Math.Abs( bounds.Height - ptInItem.Y );
|
||||
double vertOffset = Math.Min( topOffset, btmOffset );
|
||||
|
||||
double width = SystemParameters.MinimumHorizontalDragDistance * 2;
|
||||
double height = Math.Min( SystemParameters.MinimumVerticalDragDistance, vertOffset ) * 2;
|
||||
Size szThreshold = new Size( width, height );
|
||||
|
||||
Rect rect = new Rect( this.ptMouseDown, szThreshold );
|
||||
rect.Offset( szThreshold.Width / -2, szThreshold.Height / -2 );
|
||||
//Point ptInListBox = MouseUtil.GetMousePosition(this.listBox);
|
||||
Point ptInListBox = MouseUtil.GetMousePosition();
|
||||
return !rect.Contains( ptInListBox );
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // HasCursorLeftDragThreshold
|
||||
|
||||
#region IndexUnderDragCursor
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of the ListBoxItem underneath the
|
||||
/// drag cursor, or -1 if the cursor is not over an item.
|
||||
/// </summary>
|
||||
int IndexUnderDragCursor
|
||||
{
|
||||
get
|
||||
{
|
||||
int index = -1;
|
||||
for( int i = 0; i < this.listBox.Items.Count; ++i )
|
||||
{
|
||||
ListBoxItem item = this.GetListBoxItem( i );
|
||||
if( this.IsMouseOver( item ) )
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // IndexUnderDragCursor
|
||||
|
||||
#region InitializeAdornerLayer
|
||||
|
||||
AdornerLayer InitializeAdornerLayer( ListBoxItem itemToDrag )
|
||||
{
|
||||
// Create a brush which will paint the ListBoxItem onto
|
||||
// a visual in the adorner layer.
|
||||
VisualBrush brush = new VisualBrush( itemToDrag );
|
||||
|
||||
// Create an element which displays the source item while it is dragged.
|
||||
this.dragAdorner = new DragAdorner( this.listBox, itemToDrag.RenderSize, brush );
|
||||
|
||||
// Set the drag adorner's opacity.
|
||||
this.dragAdorner.Opacity = this.DragAdornerOpacity;
|
||||
|
||||
AdornerLayer layer = AdornerLayer.GetAdornerLayer( this.listBox );
|
||||
layer.Add( dragAdorner );
|
||||
|
||||
// Save the location of the cursor when the left mouse button was pressed.
|
||||
this.ptMouseDown = MouseUtil.GetMousePosition(this.listBox);
|
||||
//this.ptMouseDown = MouseUtil.GetMousePosition();
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
#endregion // InitializeAdornerLayer
|
||||
|
||||
#region InitializeDragOperation
|
||||
|
||||
void InitializeDragOperation( ListBoxItem itemToDrag )
|
||||
{
|
||||
// Set some flags used during the drag operation.
|
||||
this.IsDragInProgress = true;
|
||||
this.canInitiateDrag = false;
|
||||
|
||||
// Let the ListBoxItem know that it is being dragged.
|
||||
ListBoxItemDragState.SetIsBeingDragged( itemToDrag, true );
|
||||
}
|
||||
|
||||
#endregion // InitializeDragOperation
|
||||
|
||||
#region IsMouseOver
|
||||
|
||||
bool IsMouseOver( Visual target )
|
||||
{
|
||||
// We need to use MouseUtil to figure out the cursor
|
||||
// coordinates because, during a drag-drop operation, the WPF
|
||||
// mechanisms for getting the coordinates behave strangely.
|
||||
|
||||
Rect bounds = VisualTreeHelper.GetDescendantBounds( target );
|
||||
Point mousePos = MouseUtil.GetMousePosition( target );
|
||||
return bounds.Contains( mousePos );
|
||||
}
|
||||
|
||||
#endregion // IsMouseOver
|
||||
|
||||
#region IsMouseOverScrollbar
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the mouse cursor is over a scrollbar in the ListBox.
|
||||
/// </summary>
|
||||
bool IsMouseOverScrollbar
|
||||
{
|
||||
get
|
||||
{
|
||||
Point ptMouse = MouseUtil.GetMousePosition( this.listBox );
|
||||
HitTestResult res = VisualTreeHelper.HitTest( this.listBox, ptMouse );
|
||||
if( res == null )
|
||||
return false;
|
||||
|
||||
DependencyObject depObj = res.VisualHit;
|
||||
while( depObj != null )
|
||||
{
|
||||
if( depObj is ScrollBar )
|
||||
return true;
|
||||
|
||||
// VisualTreeHelper works with objects of type Visual or Visual3D.
|
||||
// If the current object is not derived from Visual or Visual3D,
|
||||
// then use the LogicalTreeHelper to find the parent element.
|
||||
if( depObj is Visual || depObj is System.Windows.Media.Media3D.Visual3D )
|
||||
depObj = VisualTreeHelper.GetParent( depObj );
|
||||
else
|
||||
depObj = LogicalTreeHelper.GetParent( depObj );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // IsMouseOverScrollbar
|
||||
|
||||
#region ItemUnderDragCursor
|
||||
|
||||
ItemType ItemUnderDragCursor
|
||||
{
|
||||
get { return this.itemUnderDragCursor; }
|
||||
set
|
||||
{
|
||||
if( this.itemUnderDragCursor == value )
|
||||
return;
|
||||
|
||||
// The first pass handles the previous item under the cursor.
|
||||
// The second pass handles the new one.
|
||||
for( int i = 0; i < 2; ++i )
|
||||
{
|
||||
if( i == 1 )
|
||||
this.itemUnderDragCursor = value;
|
||||
|
||||
if( this.itemUnderDragCursor != null )
|
||||
{
|
||||
ListBoxItem listBoxItem = this.GetListBoxItem( this.itemUnderDragCursor );
|
||||
if( listBoxItem != null )
|
||||
ListBoxItemDragState.SetIsUnderDragCursor( listBoxItem, i == 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // ItemUnderDragCursor
|
||||
|
||||
#region PerformDragOperation
|
||||
|
||||
void PerformDragOperation()
|
||||
{
|
||||
ItemType selectedItem = this.listBox.SelectedItem as ItemType;
|
||||
DragDropEffects allowedEffects = DragDropEffects.Move | DragDropEffects.Move | DragDropEffects.Link;
|
||||
if( DragDrop.DoDragDrop( this.listBox, selectedItem, allowedEffects ) != DragDropEffects.None )
|
||||
{
|
||||
// The item was dropped into a new location,
|
||||
// so make it the new selected item.
|
||||
this.listBox.SelectedItem = selectedItem;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // PerformDragOperation
|
||||
|
||||
#region ShowDragAdornerResolved
|
||||
|
||||
bool ShowDragAdornerResolved
|
||||
{
|
||||
get { return this.ShowDragAdorner && this.DragAdornerOpacity > 0.0; }
|
||||
}
|
||||
|
||||
#endregion // ShowDragAdornerResolved
|
||||
|
||||
#region UpdateDragAdornerLocation
|
||||
|
||||
void UpdateDragAdornerLocation()
|
||||
{
|
||||
if( this.dragAdorner != null )
|
||||
{
|
||||
//Point ptCursor = MouseUtil.GetMousePosition(this.ListBox);
|
||||
|
||||
|
||||
Point ptCursor = MouseUtil.GetMousePosition(this.ListBox);
|
||||
|
||||
//double left = ptCursor.X - this.ptMouseDown.X;
|
||||
//double left2 = ptCursor.X;
|
||||
|
||||
ListBoxItem itemBeingDragged = this.GetListBoxItem(this.indexToSelect);
|
||||
|
||||
// 4/13/2007 - Made the top offset relative to the item being dragged.
|
||||
Point itemLoc = itemBeingDragged.TranslatePoint( new Point( 0, 0 ), this.ListBox );
|
||||
double top = itemLoc.Y + ptCursor.Y - this.ptMouseDown.Y;
|
||||
double left = itemLoc.X + ptCursor.X - this.ptMouseDown.X;
|
||||
|
||||
this.dragAdorner.SetOffsets(left, top );
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // UpdateDragAdornerLocation
|
||||
|
||||
#endregion // Private Helpers
|
||||
}
|
||||
|
||||
#endregion // ListBoxDragDropManager
|
||||
|
||||
#region ListBoxItemDragState
|
||||
|
||||
/// <summary>
|
||||
/// Exposes attached properties used in conjunction with the ListBoxDragDropManager class.
|
||||
/// Those properties can be used to allow triggers to modify the appearance of ListBoxItems
|
||||
/// in a ListBox during a drag-drop operation.
|
||||
/// </summary>
|
||||
public static class ListBoxItemDragState
|
||||
{
|
||||
#region IsBeingDragged
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the ListBoxItemDragState's IsBeingDragged attached property.
|
||||
/// This field is read-only.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsBeingDraggedProperty =
|
||||
DependencyProperty.RegisterAttached(
|
||||
"IsBeingDragged",
|
||||
typeof( bool ),
|
||||
typeof( ListBoxItemDragState ),
|
||||
new UIPropertyMetadata( false ) );
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified ListBoxItem is being dragged, else false.
|
||||
/// </summary>
|
||||
/// <param name="item">The ListBoxItem to check.</param>
|
||||
public static bool GetIsBeingDragged( ListBoxItem item )
|
||||
{
|
||||
return (bool)item.GetValue( IsBeingDraggedProperty );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the IsBeingDragged attached property for the specified ListBoxItem.
|
||||
/// </summary>
|
||||
/// <param name="item">The ListBoxItem to set the property on.</param>
|
||||
/// <param name="value">Pass true if the element is being dragged, else false.</param>
|
||||
internal static void SetIsBeingDragged( ListBoxItem item, bool value )
|
||||
{
|
||||
item.SetValue( IsBeingDraggedProperty, value );
|
||||
}
|
||||
|
||||
#endregion // IsBeingDragged
|
||||
|
||||
#region IsUnderDragCursor
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the ListBoxItemDragState's IsUnderDragCursor attached property.
|
||||
/// This field is read-only.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsUnderDragCursorProperty =
|
||||
DependencyProperty.RegisterAttached(
|
||||
"IsUnderDragCursor",
|
||||
typeof( bool ),
|
||||
typeof( ListBoxItemDragState ),
|
||||
new UIPropertyMetadata( false ) );
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified ListBoxItem is currently underneath the cursor
|
||||
/// during a drag-drop operation, else false.
|
||||
/// </summary>
|
||||
/// <param name="item">The ListBoxItem to check.</param>
|
||||
public static bool GetIsUnderDragCursor( ListBoxItem item )
|
||||
{
|
||||
return (bool)item.GetValue( IsUnderDragCursorProperty );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the IsUnderDragCursor attached property for the specified ListBoxItem.
|
||||
/// </summary>
|
||||
/// <param name="item">The ListBoxItem to set the property on.</param>
|
||||
/// <param name="value">Pass true if the element is underneath the drag cursor, else false.</param>
|
||||
internal static void SetIsUnderDragCursor( ListBoxItem item, bool value )
|
||||
{
|
||||
item.SetValue( IsUnderDragCursorProperty, value );
|
||||
}
|
||||
|
||||
#endregion // IsUnderDragCursor
|
||||
}
|
||||
|
||||
#endregion // ListBoxItemDragState
|
||||
|
||||
#region ProcessDropEventArgs
|
||||
|
||||
/// <summary>
|
||||
/// Event arguments used by the ListBoxDragDropManager.ProcessDrop event.
|
||||
/// </summary>
|
||||
/// <typeparam name="ItemType">The type of data object being dropped.</typeparam>
|
||||
public class ProcessDropEventArgs<ItemType> : EventArgs where ItemType : class
|
||||
{
|
||||
#region Data
|
||||
|
||||
ObservableCollection<ItemType> itemsSource;
|
||||
ItemType dataItem;
|
||||
int oldIndex;
|
||||
int newIndex;
|
||||
DragDropEffects allowedEffects = DragDropEffects.None;
|
||||
DragDropEffects effects = DragDropEffects.None;
|
||||
|
||||
#endregion // Data
|
||||
|
||||
#region Constructor
|
||||
|
||||
internal ProcessDropEventArgs(
|
||||
ObservableCollection<ItemType> itemsSource,
|
||||
ItemType dataItem,
|
||||
int oldIndex,
|
||||
int newIndex,
|
||||
DragDropEffects allowedEffects )
|
||||
{
|
||||
this.itemsSource = itemsSource;
|
||||
this.dataItem = dataItem;
|
||||
this.oldIndex = oldIndex;
|
||||
this.newIndex = newIndex;
|
||||
this.allowedEffects = allowedEffects;
|
||||
}
|
||||
|
||||
#endregion // Constructor
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// The items source of the ListBox where the drop occurred.
|
||||
/// </summary>
|
||||
public ObservableCollection<ItemType> ItemsSource
|
||||
{
|
||||
get { return this.itemsSource; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The data object which was dropped.
|
||||
/// </summary>
|
||||
public ItemType DataItem
|
||||
{
|
||||
get { return this.dataItem; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The current index of the data item being dropped, in the ItemsSource collection.
|
||||
/// </summary>
|
||||
public int OldIndex
|
||||
{
|
||||
get { return this.oldIndex; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The target index of the data item being dropped, in the ItemsSource collection.
|
||||
/// </summary>
|
||||
public int NewIndex
|
||||
{
|
||||
get { return this.newIndex; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The drag drop effects allowed to be performed.
|
||||
/// </summary>
|
||||
public DragDropEffects AllowedEffects
|
||||
{
|
||||
get { return allowedEffects; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The drag drop effect(s) performed on the dropped item.
|
||||
/// </summary>
|
||||
public DragDropEffects Effects
|
||||
{
|
||||
get { return effects; }
|
||||
set { effects = value; }
|
||||
}
|
||||
|
||||
#endregion // Public Properties
|
||||
}
|
||||
|
||||
#endregion // ProcessDropEventArgs
|
||||
}
|
||||
@@ -12,7 +12,10 @@ namespace GeekDesk.Util
|
||||
try
|
||||
{
|
||||
Exception ex = exception as Exception;
|
||||
|
||||
if (!Directory.Exists(Constants.ERROR_FILE_PATH.Substring(0, Constants.ERROR_FILE_PATH.LastIndexOf("\\"))))
|
||||
{
|
||||
Directory.CreateDirectory(Constants.ERROR_FILE_PATH.Substring(0, Constants.ERROR_FILE_PATH.LastIndexOf("\\")));
|
||||
}
|
||||
using (FileStream fs = File.Open(Constants.ERROR_FILE_PATH, FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
{
|
||||
fs.Seek(0, SeekOrigin.End);
|
||||
@@ -58,6 +61,10 @@ namespace GeekDesk.Util
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(Constants.LOG_FILE_PATH.Substring(0, Constants.LOG_FILE_PATH.LastIndexOf("\\"))))
|
||||
{
|
||||
Directory.CreateDirectory(Constants.LOG_FILE_PATH.Substring(0, Constants.LOG_FILE_PATH.LastIndexOf("\\")));
|
||||
}
|
||||
using (FileStream fs = File.Open(Constants.LOG_FILE_PATH, FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
{
|
||||
fs.Seek(0, SeekOrigin.End);
|
||||
|
||||
32
Util/MD5Util.cs
Normal file
32
Util/MD5Util.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
internal class MD5Util
|
||||
{
|
||||
|
||||
public static string CreateMD5(string input)
|
||||
{
|
||||
// Use input string to calculate MD5 hash
|
||||
using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
|
||||
{
|
||||
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
|
||||
byte[] hashBytes = md5.ComputeHash(inputBytes);
|
||||
|
||||
//return Convert.ToHexString(hashBytes); // .NET 5 +
|
||||
|
||||
//Convert the byte array to hexadecimal string prior to.NET 5
|
||||
StringBuilder sb = new System.Text.StringBuilder();
|
||||
for (int i = 0; i < hashBytes.Length; i++)
|
||||
{
|
||||
sb.Append(hashBytes[i].ToString("X2"));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,8 @@ namespace GeekDesk.Util
|
||||
{
|
||||
private static Window window;//定义使用该方法的窗体
|
||||
|
||||
private static readonly int hideTime = 50;
|
||||
private static readonly int showTime = 30;
|
||||
private static readonly int hideTime = 65;
|
||||
private static readonly int showTime = 15;
|
||||
|
||||
private static int animalTime;
|
||||
|
||||
@@ -77,8 +77,7 @@ namespace GeekDesk.Util
|
||||
#region 窗体贴边隐藏功能
|
||||
private static void HideWindow(object o, EventArgs e)
|
||||
{
|
||||
if (window.Visibility != Visibility.Visible
|
||||
|| RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW
|
||||
if (RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW
|
||||
|| RunTimeStatus.LOCK_APP_PANEL) return;
|
||||
|
||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||
@@ -98,7 +97,7 @@ namespace GeekDesk.Util
|
||||
|
||||
//鼠标不在窗口上
|
||||
if ((mouseX < windowLeft || mouseX > windowLeft + windowWidth
|
||||
|| mouseY < windowTop || mouseY > windowTop + windowHeight) && !IS_HIDE)
|
||||
|| mouseY < windowTop || mouseY > windowTop + windowHeight) && !IS_HIDE && window.Visibility == Visibility.Visible)
|
||||
{
|
||||
//上方隐藏条件
|
||||
if (windowTop <= screenTop)
|
||||
@@ -126,8 +125,9 @@ namespace GeekDesk.Util
|
||||
}
|
||||
}
|
||||
else if (mouseX >= windowLeft && mouseX <= windowLeft + windowWidth
|
||||
&& mouseY >= windowTop && mouseY <= windowTop + windowHeight && IS_HIDE)
|
||||
&& mouseY >= windowTop && mouseY <= windowTop + windowHeight && IS_HIDE && window.Visibility != Visibility.Visible)
|
||||
{
|
||||
window.Show();
|
||||
//上方显示
|
||||
if (windowTop <= screenTop - showMarginWidth)
|
||||
{
|
||||
@@ -189,6 +189,7 @@ namespace GeekDesk.Util
|
||||
double windowTop = window.Top;
|
||||
double windowLeft = window.Left;
|
||||
|
||||
window.Visibility = Visibility.Visible;
|
||||
//左侧显示
|
||||
if (windowLeft <= screenLeft - showMarginWidth)
|
||||
{
|
||||
@@ -226,17 +227,30 @@ namespace GeekDesk.Util
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
double abs = Math.Abs(Math.Abs(to) - Math.Abs(from));
|
||||
double subLen = abs / hideTime;
|
||||
|
||||
if ((int)hideType <= 3)
|
||||
switch (hideType)
|
||||
{
|
||||
case HideType.LEFT_SHOW:
|
||||
to -= 20;
|
||||
break;
|
||||
case HideType.RIGHT_SHOW:
|
||||
to += 20;
|
||||
break;
|
||||
case HideType.TOP_SHOW:
|
||||
to -= 20;
|
||||
break;
|
||||
}
|
||||
|
||||
double abs = Math.Abs(Math.Abs(to) - Math.Abs(from));
|
||||
|
||||
if (hideType <= HideType.RIGHT_SHOW)
|
||||
{
|
||||
animalTime = showTime;
|
||||
} else
|
||||
{
|
||||
animalTime = hideTime;
|
||||
}
|
||||
|
||||
double subLen = abs / animalTime;
|
||||
int count = 0;
|
||||
while (count < animalTime)
|
||||
{
|
||||
@@ -267,81 +281,20 @@ namespace GeekDesk.Util
|
||||
|
||||
switch (hideType)
|
||||
{
|
||||
case HideType.LEFT_HIDE:
|
||||
window.Left = to;
|
||||
break;
|
||||
case HideType.LEFT_SHOW:
|
||||
window.Left = to - 20;
|
||||
break;
|
||||
case HideType.RIGHT_HIDE:
|
||||
window.Left = to;
|
||||
break;
|
||||
case HideType.RIGHT_SHOW:
|
||||
window.Left = to + 20;
|
||||
break;
|
||||
case HideType.TOP_HIDE:
|
||||
window.Top = to;
|
||||
break;
|
||||
case HideType.TOP_SHOW:
|
||||
window.Top = to - 20;
|
||||
window.Top = to;
|
||||
break;
|
||||
default:
|
||||
window.Left = to;
|
||||
break;
|
||||
}
|
||||
//double toTemp = to;
|
||||
//double leftT = 0;
|
||||
//double topT = 0;
|
||||
//switch (hideType)
|
||||
//{
|
||||
// case HideType.LEFT_HIDE:
|
||||
// to += leftT;
|
||||
// break;
|
||||
// case HideType.LEFT_SHOW:
|
||||
// to -= leftT;
|
||||
// break;
|
||||
// case HideType.RIGHT_HIDE:
|
||||
// to -= leftT;
|
||||
// break;
|
||||
// case HideType.RIGHT_SHOW:
|
||||
// to += leftT;
|
||||
// break;
|
||||
// case HideType.TOP_HIDE:
|
||||
// to += topT;
|
||||
// break;
|
||||
// case HideType.TOP_SHOW:
|
||||
// to -= topT;
|
||||
// break;
|
||||
//}
|
||||
//DoubleAnimation da = new DoubleAnimation
|
||||
//{
|
||||
// From = from,
|
||||
// To = to,
|
||||
// Duration = new Duration(TimeSpan.FromMilliseconds(hideTime))
|
||||
//};
|
||||
//// 如果是显示 则贴屏幕侧不显示阴影
|
||||
//bool isShow = false;
|
||||
//int shadowWidthTemp = Constants.SHADOW_WIDTH;
|
||||
//if (hideType <= HideType.RIGHT_SHOW)
|
||||
//{
|
||||
// isShow = true;
|
||||
// if (hideType == HideType.RIGHT_SHOW)
|
||||
// {
|
||||
// shadowWidthTemp = -shadowWidthTemp;
|
||||
// }
|
||||
//}
|
||||
//da.Completed += (s, e) =>
|
||||
//{
|
||||
// if ("Top".Equals(property.Name))
|
||||
// {
|
||||
// window.Top = isShow ? toTemp - shadowWidthTemp : toTemp;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// window.Left = isShow ? toTemp - shadowWidthTemp : toTemp;
|
||||
// }
|
||||
// window.BeginAnimation(property, null);
|
||||
//};
|
||||
|
||||
//Timeline.SetDesiredFrameRate(da, 60);
|
||||
//window.BeginAnimation(property, da);
|
||||
if (hideType > HideType.RIGHT_SHOW)
|
||||
{
|
||||
window.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
});
|
||||
}).Start();
|
||||
|
||||
|
||||
131
Util/MessageUtil.cs
Normal file
131
Util/MessageUtil.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class MessageUtil
|
||||
{
|
||||
|
||||
public const int WM_COPYDATA = 0x004A;
|
||||
public static bool SendMsgByPName(string processName, string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process[] processArr = Process.GetProcessesByName(processName);
|
||||
if (processArr != null && processArr.Length > 0)
|
||||
{
|
||||
foreach (Process process in processArr)
|
||||
{
|
||||
IntPtr windowHandle = process.MainWindowHandle;
|
||||
// 发送消息
|
||||
CopyDataStruct cds = new CopyDataStruct(IntPtr.Zero, msg);
|
||||
SendMessage(
|
||||
windowHandle,
|
||||
WM_COPYDATA,
|
||||
0, ref cds);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, processName + "P发送消息失败!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SendMsgByWName(string windowName, string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
IntPtr hwnd = FindWindow(null, windowName);
|
||||
if (hwnd != IntPtr.Zero)
|
||||
{
|
||||
// 发送消息
|
||||
CopyDataStruct cds = new CopyDataStruct(IntPtr.Zero, msg);
|
||||
SendMessage(
|
||||
hwnd,
|
||||
WM_COPYDATA,
|
||||
0, ref cds);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, windowName + "W发送消息失败!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool CheckProcessIsRuning(string processName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process[] processArr = Process.GetProcessesByName(processName);
|
||||
return (processArr != null && processArr.Length > 0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, processName + "检查进程名失败!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckWindowIsRuning(string windowName)
|
||||
{
|
||||
try
|
||||
{
|
||||
IntPtr hwnd = FindWindow(null, windowName);
|
||||
return (hwnd != IntPtr.Zero);
|
||||
} catch(Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[DllImport("User32.dll", EntryPoint = "FindWindow")]
|
||||
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
|
||||
[DllImport("User32.dll", EntryPoint = "SendMessage")]
|
||||
private static extern int SendMessage(
|
||||
IntPtr hWnd, //目标窗体句柄
|
||||
int Msg, //WM_COPYDATA
|
||||
int wParam, //自定义数值
|
||||
ref CopyDataStruct lParam //传递消息的结构体,
|
||||
);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct CopyDataStruct
|
||||
{
|
||||
public CopyDataStruct(IntPtr custom, string msg)
|
||||
{
|
||||
this.custom = custom;
|
||||
this.msg = msg;
|
||||
this.msgLength = msg.Length + 1;
|
||||
}
|
||||
public IntPtr custom;//用户定义数据
|
||||
public int msgLength;//字符串长度
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string msg;//字符串
|
||||
}
|
||||
|
||||
|
||||
[DllImport("user32")]
|
||||
public static extern bool ChangeWindowMessageFilter(uint msg, int flags);
|
||||
|
||||
}
|
||||
}
|
||||
156
Util/MouseHook.cs
Normal file
156
Util/MouseHook.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class MouseHook
|
||||
{
|
||||
|
||||
private Point point;
|
||||
private Point Point
|
||||
{
|
||||
get { return point; }
|
||||
set
|
||||
{
|
||||
if (point != value)
|
||||
{
|
||||
point = value;
|
||||
if (MouseMoveEvent != null)
|
||||
{
|
||||
var e = new MouseEventArgs(MouseButtons.None, 0, point.X, point.Y, 0);
|
||||
MouseMoveEvent(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private int hHook;
|
||||
private const int WM_MOUSEMOVE = 0x200;
|
||||
private const int WM_LBUTTONDOWN = 0x201;
|
||||
private const int WM_RBUTTONDOWN = 0x204;
|
||||
private const int WM_MBUTTONDOWN = 0x207;
|
||||
private const int WM_LBUTTONUP = 0x202;
|
||||
private const int WM_RBUTTONUP = 0x205;
|
||||
private const int WM_MBUTTONUP = 0x208;
|
||||
private const int WM_LBUTTONDBLCLK = 0x203;
|
||||
private const int WM_RBUTTONDBLCLK = 0x206;
|
||||
private const int WM_MBUTTONDBLCLK = 0x209;
|
||||
public const int WH_MOUSE_LL = 14;
|
||||
public Win32Api.HookProc hProc;
|
||||
public MouseHook()
|
||||
{
|
||||
this.Point = new Point();
|
||||
}
|
||||
public int SetHook()
|
||||
{
|
||||
hProc = new Win32Api.HookProc(MouseHookProc);
|
||||
hHook = Win32Api.SetWindowsHookEx(WH_MOUSE_LL, hProc, IntPtr.Zero, 0);
|
||||
return hHook;
|
||||
}
|
||||
public void UnHook()
|
||||
{
|
||||
Win32Api.UnhookWindowsHookEx(hHook);
|
||||
}
|
||||
private int MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
Win32Api.MouseHookStruct MyMouseHookStruct = (Win32Api.MouseHookStruct)Marshal.PtrToStructure(lParam, typeof(Win32Api.MouseHookStruct));
|
||||
if (nCode < 0)
|
||||
{
|
||||
return Win32Api.CallNextHookEx(hHook, nCode, wParam, lParam);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MouseClickEvent != null)
|
||||
{
|
||||
MouseButtons button = MouseButtons.None;
|
||||
int clickCount = 0;
|
||||
switch ((Int32)wParam)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
button = MouseButtons.Left;
|
||||
clickCount = 1;
|
||||
MouseDownEvent(this, new MouseEventArgs(button, clickCount, point.X, point.Y, 0));
|
||||
break;
|
||||
case WM_RBUTTONDOWN:
|
||||
button = MouseButtons.Right;
|
||||
clickCount = 1;
|
||||
MouseDownEvent(this, new MouseEventArgs(button, clickCount, point.X, point.Y, 0));
|
||||
break;
|
||||
case WM_MBUTTONDOWN:
|
||||
button = MouseButtons.Middle;
|
||||
clickCount = 1;
|
||||
MouseDownEvent(this, new MouseEventArgs(button, clickCount, point.X, point.Y, 0));
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
button = MouseButtons.Left;
|
||||
clickCount = 1;
|
||||
MouseUpEvent(this, new MouseEventArgs(button, clickCount, point.X, point.Y, 0));
|
||||
break;
|
||||
case WM_RBUTTONUP:
|
||||
button = MouseButtons.Right;
|
||||
clickCount = 1;
|
||||
MouseUpEvent(this, new MouseEventArgs(button, clickCount, point.X, point.Y, 0));
|
||||
break;
|
||||
case WM_MBUTTONUP:
|
||||
button = MouseButtons.Middle;
|
||||
clickCount = 1;
|
||||
MouseUpEvent(this, new MouseEventArgs(button, clickCount, point.X, point.Y, 0));
|
||||
break;
|
||||
}
|
||||
|
||||
var e = new MouseEventArgs(button, clickCount, point.X, point.Y, 0);
|
||||
MouseClickEvent(this, e);
|
||||
}
|
||||
this.Point = new Point(MyMouseHookStruct.pt.x, MyMouseHookStruct.pt.y);
|
||||
return Win32Api.CallNextHookEx(hHook, nCode, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void MouseMoveHandler(object sender, MouseEventArgs e);
|
||||
public event MouseMoveHandler MouseMoveEvent;
|
||||
|
||||
public delegate void MouseClickHandler(object sender, MouseEventArgs e);
|
||||
public event MouseClickHandler MouseClickEvent;
|
||||
|
||||
public delegate void MouseDownHandler(object sender, MouseEventArgs e);
|
||||
public event MouseDownHandler MouseDownEvent;
|
||||
|
||||
public delegate void MouseUpHandler(object sender, MouseEventArgs e);
|
||||
public event MouseUpHandler MouseUpEvent;
|
||||
|
||||
|
||||
public class Win32Api
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class POINT
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class MouseHookStruct
|
||||
{
|
||||
public POINT pt;
|
||||
public int hwnd;
|
||||
public int wHitTestCode;
|
||||
public int dwExtraInfo;
|
||||
}
|
||||
public delegate int HookProc(int nCode, IntPtr wParam, IntPtr lParam);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern bool UnhookWindowsHookEx(int idHook);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int CallNextHookEx(int idHook, int nCode, IntPtr wParam, IntPtr lParam);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
@@ -27,5 +28,27 @@ namespace GeekDesk.Util
|
||||
GetCursorPos(ref w32Mouse);
|
||||
return new Point(w32Mouse.X, w32Mouse.Y);
|
||||
}
|
||||
|
||||
|
||||
public static Point GetMousePosition(Visual relativeTo)
|
||||
{
|
||||
Win32Point mouse = new Win32Point();
|
||||
GetCursorPos(ref mouse);
|
||||
|
||||
// Using PointFromScreen instead of Dan Crevier's code (commented out below)
|
||||
// is a bug fix created by William J. Roberts. Read his comments about the fix
|
||||
// here: http://www.codeproject.com/useritems/ListViewDragDropManager.asp?msg=1911611#xx1911611xx
|
||||
return relativeTo.PointFromScreen(new Point((double)mouse.X, (double)mouse.Y));
|
||||
|
||||
#region Commented Out
|
||||
//System.Windows.Interop.HwndSource presentationSource =
|
||||
// (System.Windows.Interop.HwndSource)PresentationSource.FromVisual( relativeTo );
|
||||
//ScreenToClient( presentationSource.Handle, ref mouse );
|
||||
//GeneralTransform transform = relativeTo.TransformToAncestor( presentationSource.RootVisual );
|
||||
//Point offset = transform.Transform( new Point( 0, 0 ) );
|
||||
//return new Point( mouse.X - offset.X, mouse.Y - offset.Y );
|
||||
#endregion // Commented Out
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
37
Util/RelayCommand.cs
Normal file
37
Util/RelayCommand.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
private readonly Predicate<object> _canExecute;
|
||||
private readonly Action<object> _execute;
|
||||
|
||||
public RelayCommand(Predicate<object> canExecute, Action<object> execute)
|
||||
{
|
||||
_canExecute = canExecute;
|
||||
_execute = execute;
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add => CommandManager.RequerySuggested += value;
|
||||
remove => CommandManager.RequerySuggested -= value;
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return _canExecute(parameter);
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
_execute(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
156
Util/ScreenUtil.cs
Normal file
156
Util/ScreenUtil.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class ScreenUtil
|
||||
{
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool GetCursorPos(ref System.Drawing.Point lpPoint);
|
||||
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
|
||||
public static extern int BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct RECT
|
||||
{
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
}
|
||||
|
||||
//取得前台窗口句柄函数
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetForegroundWindow();
|
||||
//取得桌面窗口句柄函数
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetDesktopWindow();
|
||||
//取得Shell窗口句柄函数
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetShellWindow();
|
||||
//取得窗口大小函数
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern int GetWindowRect(IntPtr hwnd, out RECT rc);
|
||||
//获取窗口标题
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
private static extern int GetWindowText(
|
||||
IntPtr hWnd,//窗口句柄
|
||||
StringBuilder lpString,//标题
|
||||
int nMaxCount //最大值
|
||||
);
|
||||
|
||||
//获取类的名字
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int GetClassName(
|
||||
IntPtr hWnd,//句柄
|
||||
StringBuilder lpString, //类名
|
||||
int nMaxCount); //最大值
|
||||
|
||||
/// <summary>
|
||||
/// 判断当前屏幕(鼠标最后活动屏幕)是否有全屏化应用
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool IsPrimaryFullScreen()
|
||||
{
|
||||
|
||||
//桌面窗口句柄
|
||||
IntPtr desktopHandle; //Window handle for the desktop
|
||||
//Shell窗口句柄
|
||||
IntPtr shellHandle; //Window handle for the shell 因为桌面窗口和Shell窗口也是全屏,要排除在其他全屏程序之外。 //取得桌面和Shell窗口句柄
|
||||
desktopHandle = GetDesktopWindow();
|
||||
shellHandle = GetShellWindow(); //取得前台窗口句柄并判断是否全屏
|
||||
bool runningFullScreen = false;
|
||||
RECT appBounds;
|
||||
Rectangle screenBounds;
|
||||
IntPtr hWnd;
|
||||
//取得前台窗口
|
||||
hWnd = GetForegroundWindow();
|
||||
|
||||
StringBuilder sb = new StringBuilder(256);
|
||||
try
|
||||
{
|
||||
GetClassName(hWnd, sb, sb.Capacity);
|
||||
}
|
||||
catch { }
|
||||
if (sb.ToString().ToLower().Equals("workerw")) return false;
|
||||
if (hWnd != null && !hWnd.Equals(IntPtr.Zero))
|
||||
{
|
||||
//判断是否桌面或shell
|
||||
if (!(hWnd.Equals(desktopHandle) || hWnd.Equals(shellHandle)))
|
||||
{
|
||||
//取得窗口大小
|
||||
GetWindowRect(hWnd, out appBounds);
|
||||
//判断是否全屏
|
||||
screenBounds = Screen.FromHandle(hWnd).Bounds;
|
||||
if ((appBounds.bottom - appBounds.top) == screenBounds.Height
|
||||
&& (appBounds.right - appBounds.left) == screenBounds.Width)
|
||||
runningFullScreen = true;
|
||||
}
|
||||
}
|
||||
return runningFullScreen;
|
||||
}
|
||||
|
||||
|
||||
public static Color GetColorAt(System.Drawing.Point location)
|
||||
{
|
||||
Bitmap screenPixel = new Bitmap(1, 1, PixelFormat.Format32bppArgb);
|
||||
|
||||
using (Graphics gdest = Graphics.FromImage(screenPixel))
|
||||
{
|
||||
using (Graphics gsrc = Graphics.FromHwnd(IntPtr.Zero))
|
||||
{
|
||||
IntPtr hSrcDC = gsrc.GetHdc();
|
||||
IntPtr hDC = gdest.GetHdc();
|
||||
int retval = BitBlt(hDC, 0, 0, 1, 1, hSrcDC, location.X, location.Y, (int)CopyPixelOperation.SourceCopy);
|
||||
gdest.ReleaseHdc();
|
||||
gsrc.ReleaseHdc();
|
||||
}
|
||||
}
|
||||
|
||||
return screenPixel.GetPixel(0, 0);
|
||||
}
|
||||
|
||||
|
||||
[DllImport("gdi32")]
|
||||
static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
|
||||
|
||||
public const int HORZRES = 8;
|
||||
public const int VERTRES = 10;
|
||||
public const int DESKTOPVERTRES = 117;
|
||||
public const int DESKTOPHORZRES = 118;
|
||||
/// <summary>
|
||||
/// 获取屏幕缩放比例
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static double GetScreenScalingFactor()
|
||||
{
|
||||
try
|
||||
{
|
||||
var g = Graphics.FromHwnd(IntPtr.Zero);
|
||||
IntPtr desktop = g.GetHdc();
|
||||
var physicalScreenHeight = GetDeviceCaps(desktop, (int)DESKTOPVERTRES);
|
||||
|
||||
var screenScalingFactor =
|
||||
(double)physicalScreenHeight / SystemParameters.PrimaryScreenHeight;
|
||||
//SystemParameters.PrimaryScreenHeight;
|
||||
|
||||
return screenScalingFactor;
|
||||
} catch (Exception e)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
75
Util/ScrollUtil.cs
Normal file
75
Util/ScrollUtil.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class ScrollUtil
|
||||
{
|
||||
|
||||
public static bool IsBootomScrollView(ScrollViewer view)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool isBottom = false;
|
||||
double dVer = view.VerticalOffset;
|
||||
double vViewport = view.ViewportHeight;
|
||||
double eextent = view.ExtentHeight;
|
||||
if (dVer + vViewport >= eextent)
|
||||
{
|
||||
isBottom = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isBottom = false;
|
||||
}
|
||||
return isBottom;
|
||||
} catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static bool IsTopScrollView(ScrollViewer view)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (int)view.VerticalOffset == 0;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static T FindSimpleVisualChild<T>(DependencyObject element) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
while (element != null)
|
||||
{
|
||||
|
||||
if (element is T)
|
||||
return element as T;
|
||||
if (VisualTreeHelper.GetChildrenCount(element) > 0)
|
||||
{
|
||||
element = VisualTreeHelper.GetChild(element, 0);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace GeekDesk.Util
|
||||
/// <summary>
|
||||
/// 随鼠标位置显示面板
|
||||
/// </summary>
|
||||
public static void Show(Window window, MousePosition position, double widthOffset = 0, double heightOffset = 0, bool visibility = true)
|
||||
public static void Show(Window window, MousePosition position, double widthOffset = 0, double heightOffset = 0)
|
||||
{
|
||||
//获取鼠标位置
|
||||
System.Windows.Point p = MouseUtil.GetMousePosition();
|
||||
@@ -101,11 +101,6 @@ namespace GeekDesk.Util
|
||||
{
|
||||
window.Top = p.Y - afterHeight;
|
||||
}
|
||||
if (visibility)
|
||||
{
|
||||
window.Opacity = 0;
|
||||
window.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
837
Util/UserActivityHook.cs
Normal file
837
Util/UserActivityHook.cs
Normal file
@@ -0,0 +1,837 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
/// <summary>
|
||||
/// This class allows you to tap keyboard and mouse and / or to detect their activity even when an
|
||||
/// application runes in background or does not have any user interface at all. This class raises
|
||||
/// common .NET events with KeyEventArgs and MouseEventArgs so you can easily retrive any information you need.
|
||||
/// </summary>
|
||||
public class UserActivityHook
|
||||
{
|
||||
#region Windows structure definitions
|
||||
|
||||
/// <summary>
|
||||
/// The POINT structure defines the x- and y- coordinates of a point.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/rectangl_0tiq.asp
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private class POINT
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the x-coordinate of the point.
|
||||
/// </summary>
|
||||
public int x;
|
||||
/// <summary>
|
||||
/// Specifies the y-coordinate of the point.
|
||||
/// </summary>
|
||||
public int y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The MOUSEHOOKSTRUCT structure contains information about a mouse event passed to a WH_MOUSE hook procedure, MouseProc.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookstructures/cwpstruct.asp
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private class MouseHookStruct
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies a POINT structure that contains the x- and y-coordinates of the cursor, in screen coordinates.
|
||||
/// </summary>
|
||||
public POINT pt;
|
||||
/// <summary>
|
||||
/// Handle to the window that will receive the mouse message corresponding to the mouse event.
|
||||
/// </summary>
|
||||
public int hwnd;
|
||||
/// <summary>
|
||||
/// Specifies the hit-test value. For a list of hit-test values, see the description of the WM_NCHITTEST message.
|
||||
/// </summary>
|
||||
public int wHitTestCode;
|
||||
/// <summary>
|
||||
/// Specifies extra information associated with the message.
|
||||
/// </summary>
|
||||
public int dwExtraInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The MSLLHOOKSTRUCT structure contains information about a low-level keyboard input event.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private class MouseLLHookStruct
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies a POINT structure that contains the x- and y-coordinates of the cursor, in screen coordinates.
|
||||
/// </summary>
|
||||
public POINT pt;
|
||||
/// <summary>
|
||||
/// If the message is WM_MOUSEWHEEL, the high-order word of this member is the wheel delta.
|
||||
/// The low-order word is reserved. A positive value indicates that the wheel was rotated forward,
|
||||
/// away from the user; a negative value indicates that the wheel was rotated backward, toward the user.
|
||||
/// One wheel click is defined as WHEEL_DELTA, which is 120.
|
||||
///If the message is WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP,
|
||||
/// or WM_NCXBUTTONDBLCLK, the high-order word specifies which X button was pressed or released,
|
||||
/// and the low-order word is reserved. This value can be one or more of the following values. Otherwise, mouseData is not used.
|
||||
///XBUTTON1
|
||||
///The first X button was pressed or released.
|
||||
///XBUTTON2
|
||||
///The second X button was pressed or released.
|
||||
/// </summary>
|
||||
public int mouseData;
|
||||
/// <summary>
|
||||
/// Specifies the event-injected flag. An application can use the following value to test the mouse flags. Value Purpose
|
||||
///LLMHF_INJECTED Test the event-injected flag.
|
||||
///0
|
||||
///Specifies whether the event was injected. The value is 1 if the event was injected; otherwise, it is 0.
|
||||
///1-15
|
||||
///Reserved.
|
||||
/// </summary>
|
||||
public int flags;
|
||||
/// <summary>
|
||||
/// Specifies the time stamp for this message.
|
||||
/// </summary>
|
||||
public int time;
|
||||
/// <summary>
|
||||
/// Specifies extra information associated with the message.
|
||||
/// </summary>
|
||||
public int dwExtraInfo;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The KBDLLHOOKSTRUCT structure contains information about a low-level keyboard input event.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookstructures/cwpstruct.asp
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private class KeyboardHookStruct
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies a virtual-key code. The code must be a value in the range 1 to 254.
|
||||
/// </summary>
|
||||
public int vkCode;
|
||||
/// <summary>
|
||||
/// Specifies a hardware scan code for the key.
|
||||
/// </summary>
|
||||
public int scanCode;
|
||||
/// <summary>
|
||||
/// Specifies the extended-key flag, event-injected flag, context code, and transition-state flag.
|
||||
/// </summary>
|
||||
public int flags;
|
||||
/// <summary>
|
||||
/// Specifies the time stamp for this message.
|
||||
/// </summary>
|
||||
public int time;
|
||||
/// <summary>
|
||||
/// Specifies extra information associated with the message.
|
||||
/// </summary>
|
||||
public int dwExtraInfo;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Windows function imports
|
||||
/// <summary>
|
||||
/// The SetWindowsHookEx function installs an application-defined hook procedure into a hook chain.
|
||||
/// You would install a hook procedure to monitor the system for certain types of events. These events
|
||||
/// are associated either with a specific thread or with all threads in the same desktop as the calling thread.
|
||||
/// </summary>
|
||||
/// <param name="idHook">
|
||||
/// [in] Specifies the type of hook procedure to be installed. This parameter can be one of the following values.
|
||||
/// </param>
|
||||
/// <param name="lpfn">
|
||||
/// [in] Pointer to the hook procedure. If the dwThreadId parameter is zero or specifies the identifier of a
|
||||
/// thread created by a different process, the lpfn parameter must point to a hook procedure in a dynamic-link
|
||||
/// library (DLL). Otherwise, lpfn can point to a hook procedure in the code associated with the current process.
|
||||
/// </param>
|
||||
/// <param name="hMod">
|
||||
/// [in] Handle to the DLL containing the hook procedure pointed to by the lpfn parameter.
|
||||
/// The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by
|
||||
/// the current process and if the hook procedure is within the code associated with the current process.
|
||||
/// </param>
|
||||
/// <param name="dwThreadId">
|
||||
/// [in] Specifies the identifier of the thread with which the hook procedure is to be associated.
|
||||
/// If this parameter is zero, the hook procedure is associated with all existing threads running in the
|
||||
/// same desktop as the calling thread.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// If the function succeeds, the return value is the handle to the hook procedure.
|
||||
/// If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/setwindowshookex.asp
|
||||
/// </remarks>
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto,
|
||||
CallingConvention = CallingConvention.StdCall, SetLastError = true)]
|
||||
private static extern int SetWindowsHookEx(
|
||||
int idHook,
|
||||
HookProc lpfn,
|
||||
IntPtr hMod,
|
||||
int dwThreadId);
|
||||
|
||||
/// <summary>
|
||||
/// The UnhookWindowsHookEx function removes a hook procedure installed in a hook chain by the SetWindowsHookEx function.
|
||||
/// </summary>
|
||||
/// <param name="idHook">
|
||||
/// [in] Handle to the hook to be removed. This parameter is a hook handle obtained by a previous call to SetWindowsHookEx.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// If the function succeeds, the return value is nonzero.
|
||||
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/setwindowshookex.asp
|
||||
/// </remarks>
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto,
|
||||
CallingConvention = CallingConvention.StdCall, SetLastError = true)]
|
||||
private static extern int UnhookWindowsHookEx(int idHook);
|
||||
|
||||
/// <summary>
|
||||
/// The CallNextHookEx function passes the hook information to the next hook procedure in the current hook chain.
|
||||
/// A hook procedure can call this function either before or after processing the hook information.
|
||||
/// </summary>
|
||||
/// <param name="idHook">Ignored.</param>
|
||||
/// <param name="nCode">
|
||||
/// [in] Specifies the hook code passed to the current hook procedure.
|
||||
/// The next hook procedure uses this code to determine how to process the hook information.
|
||||
/// </param>
|
||||
/// <param name="wParam">
|
||||
/// [in] Specifies the wParam value passed to the current hook procedure.
|
||||
/// The meaning of this parameter depends on the type of hook associated with the current hook chain.
|
||||
/// </param>
|
||||
/// <param name="lParam">
|
||||
/// [in] Specifies the lParam value passed to the current hook procedure.
|
||||
/// The meaning of this parameter depends on the type of hook associated with the current hook chain.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// This value is returned by the next hook procedure in the chain.
|
||||
/// The current hook procedure must also return this value. The meaning of the return value depends on the hook type.
|
||||
/// For more information, see the descriptions of the individual hook procedures.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/setwindowshookex.asp
|
||||
/// </remarks>
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto,
|
||||
CallingConvention = CallingConvention.StdCall)]
|
||||
private static extern int CallNextHookEx(
|
||||
int idHook,
|
||||
int nCode,
|
||||
int wParam,
|
||||
IntPtr lParam);
|
||||
|
||||
/// <summary>
|
||||
/// The CallWndProc hook procedure is an application-defined or library-defined callback
|
||||
/// function used with the SetWindowsHookEx function. The HOOKPROC type defines a pointer
|
||||
/// to this callback function. CallWndProc is a placeholder for the application-defined
|
||||
/// or library-defined function name.
|
||||
/// </summary>
|
||||
/// <param name="nCode">
|
||||
/// [in] Specifies whether the hook procedure must process the message.
|
||||
/// If nCode is HC_ACTION, the hook procedure must process the message.
|
||||
/// If nCode is less than zero, the hook procedure must pass the message to the
|
||||
/// CallNextHookEx function without further processing and must return the
|
||||
/// value returned by CallNextHookEx.
|
||||
/// </param>
|
||||
/// <param name="wParam">
|
||||
/// [in] Specifies whether the message was sent by the current thread.
|
||||
/// If the message was sent by the current thread, it is nonzero; otherwise, it is zero.
|
||||
/// </param>
|
||||
/// <param name="lParam">
|
||||
/// [in] Pointer to a CWPSTRUCT structure that contains details about the message.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx.
|
||||
/// If nCode is greater than or equal to zero, it is highly recommended that you call CallNextHookEx
|
||||
/// and return the value it returns; otherwise, other applications that have installed WH_CALLWNDPROC
|
||||
/// hooks will not receive hook notifications and may behave incorrectly as a result. If the hook
|
||||
/// procedure does not call CallNextHookEx, the return value should be zero.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/callwndproc.asp
|
||||
/// </remarks>
|
||||
private delegate int HookProc(int nCode, int wParam, IntPtr lParam);
|
||||
|
||||
/// <summary>
|
||||
/// The ToAscii function translates the specified virtual-key code and keyboard
|
||||
/// state to the corresponding character or characters. The function translates the code
|
||||
/// using the input language and physical keyboard layout identified by the keyboard layout handle.
|
||||
/// </summary>
|
||||
/// <param name="uVirtKey">
|
||||
/// [in] Specifies the virtual-key code to be translated.
|
||||
/// </param>
|
||||
/// <param name="uScanCode">
|
||||
/// [in] Specifies the hardware scan code of the key to be translated.
|
||||
/// The high-order bit of this value is set if the key is up (not pressed).
|
||||
/// </param>
|
||||
/// <param name="lpbKeyState">
|
||||
/// [in] Pointer to a 256-byte array that contains the current keyboard state.
|
||||
/// Each element (byte) in the array contains the state of one key.
|
||||
/// If the high-order bit of a byte is set, the key is down (pressed).
|
||||
/// The low bit, if set, indicates that the key is toggled on. In this function,
|
||||
/// only the toggle bit of the CAPS LOCK key is relevant. The toggle state
|
||||
/// of the NUM LOCK and SCROLL LOCK keys is ignored.
|
||||
/// </param>
|
||||
/// <param name="lpwTransKey">
|
||||
/// [out] Pointer to the buffer that receives the translated character or characters.
|
||||
/// </param>
|
||||
/// <param name="fuState">
|
||||
/// [in] Specifies whether a menu is active. This parameter must be 1 if a menu is active, or 0 otherwise.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// If the specified key is a dead key, the return value is negative. Otherwise, it is one of the following values.
|
||||
/// Value Meaning
|
||||
/// 0 The specified virtual key has no translation for the current state of the keyboard.
|
||||
/// 1 One character was copied to the buffer.
|
||||
/// 2 Two characters were copied to the buffer. This usually happens when a dead-key character
|
||||
/// (accent or diacritic) stored in the keyboard layout cannot be composed with the specified
|
||||
/// virtual key to form a single character.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/toascii.asp
|
||||
/// </remarks>
|
||||
[DllImport("user32")]
|
||||
private static extern int ToAscii(
|
||||
int uVirtKey,
|
||||
int uScanCode,
|
||||
byte[] lpbKeyState,
|
||||
byte[] lpwTransKey,
|
||||
int fuState);
|
||||
|
||||
/// <summary>
|
||||
/// The GetKeyboardState function copies the status of the 256 virtual keys to the
|
||||
/// specified buffer.
|
||||
/// </summary>
|
||||
/// <param name="pbKeyState">
|
||||
/// [in] Pointer to a 256-byte array that contains keyboard key states.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// If the function succeeds, the return value is nonzero.
|
||||
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/toascii.asp
|
||||
/// </remarks>
|
||||
[DllImport("user32")]
|
||||
private static extern int GetKeyboardState(byte[] pbKeyState);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
||||
private static extern short GetKeyState(int vKey);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Windows constants
|
||||
|
||||
//values from Winuser.h in Microsoft SDK.
|
||||
/// <summary>
|
||||
/// Windows NT/2000/XP: Installs a hook procedure that monitors low-level mouse input events.
|
||||
/// </summary>
|
||||
private const int WH_MOUSE_LL = 14;
|
||||
/// <summary>
|
||||
/// Windows NT/2000/XP: Installs a hook procedure that monitors low-level keyboard input events.
|
||||
/// </summary>
|
||||
private const int WH_KEYBOARD_LL = 13;
|
||||
|
||||
/// <summary>
|
||||
/// Installs a hook procedure that monitors mouse messages. For more information, see the MouseProc hook procedure.
|
||||
/// </summary>
|
||||
private const int WH_MOUSE = 7;
|
||||
/// <summary>
|
||||
/// Installs a hook procedure that monitors keystroke messages. For more information, see the KeyboardProc hook procedure.
|
||||
/// </summary>
|
||||
private const int WH_KEYBOARD = 2;
|
||||
|
||||
/// <summary>
|
||||
/// The WM_MOUSEMOVE message is posted to a window when the cursor moves.
|
||||
/// </summary>
|
||||
private const int WM_MOUSEMOVE = 0x200;
|
||||
/// <summary>
|
||||
/// The WM_LBUTTONDOWN message is posted when the user presses the left mouse button
|
||||
/// </summary>
|
||||
private const int WM_LBUTTONDOWN = 0x201;
|
||||
/// <summary>
|
||||
/// The WM_RBUTTONDOWN message is posted when the user presses the right mouse button
|
||||
/// </summary>
|
||||
private const int WM_RBUTTONDOWN = 0x204;
|
||||
/// <summary>
|
||||
/// The WM_MBUTTONDOWN message is posted when the user presses the middle mouse button
|
||||
/// </summary>
|
||||
private const int WM_MBUTTONDOWN = 0x207;
|
||||
/// <summary>
|
||||
/// The WM_LBUTTONUP message is posted when the user releases the left mouse button
|
||||
/// </summary>
|
||||
private const int WM_LBUTTONUP = 0x202;
|
||||
/// <summary>
|
||||
/// The WM_RBUTTONUP message is posted when the user releases the right mouse button
|
||||
/// </summary>
|
||||
private const int WM_RBUTTONUP = 0x205;
|
||||
/// <summary>
|
||||
/// The WM_MBUTTONUP message is posted when the user releases the middle mouse button
|
||||
/// </summary>
|
||||
private const int WM_MBUTTONUP = 0x208;
|
||||
/// <summary>
|
||||
/// The WM_LBUTTONDBLCLK message is posted when the user double-clicks the left mouse button
|
||||
/// </summary>
|
||||
private const int WM_LBUTTONDBLCLK = 0x203;
|
||||
/// <summary>
|
||||
/// The WM_RBUTTONDBLCLK message is posted when the user double-clicks the right mouse button
|
||||
/// </summary>
|
||||
private const int WM_RBUTTONDBLCLK = 0x206;
|
||||
/// <summary>
|
||||
/// The WM_RBUTTONDOWN message is posted when the user presses the right mouse button
|
||||
/// </summary>
|
||||
private const int WM_MBUTTONDBLCLK = 0x209;
|
||||
/// <summary>
|
||||
/// The WM_MOUSEWHEEL message is posted when the user presses the mouse wheel.
|
||||
/// </summary>
|
||||
private const int WM_MOUSEWHEEL = 0x020A;
|
||||
|
||||
/// <summary>
|
||||
/// The WM_KEYDOWN message is posted to the window with the keyboard focus when a nonsystem
|
||||
/// key is pressed. A nonsystem key is a key that is pressed when the ALT key is not pressed.
|
||||
/// </summary>
|
||||
private const int WM_KEYDOWN = 0x100;
|
||||
/// <summary>
|
||||
/// The WM_KEYUP message is posted to the window with the keyboard focus when a nonsystem
|
||||
/// key is released. A nonsystem key is a key that is pressed when the ALT key is not pressed,
|
||||
/// or a keyboard key that is pressed when a window has the keyboard focus.
|
||||
/// </summary>
|
||||
private const int WM_KEYUP = 0x101;
|
||||
/// <summary>
|
||||
/// The WM_SYSKEYDOWN message is posted to the window with the keyboard focus when the user
|
||||
/// presses the F10 key (which activates the menu bar) or holds down the ALT key and then
|
||||
/// presses another key. It also occurs when no window currently has the keyboard focus;
|
||||
/// in this case, the WM_SYSKEYDOWN message is sent to the active window. The window that
|
||||
/// receives the message can distinguish between these two contexts by checking the context
|
||||
/// code in the lParam parameter.
|
||||
/// </summary>
|
||||
private const int WM_SYSKEYDOWN = 0x104;
|
||||
/// <summary>
|
||||
/// The WM_SYSKEYUP message is posted to the window with the keyboard focus when the user
|
||||
/// releases a key that was pressed while the ALT key was held down. It also occurs when no
|
||||
/// window currently has the keyboard focus; in this case, the WM_SYSKEYUP message is sent
|
||||
/// to the active window. The window that receives the message can distinguish between
|
||||
/// these two contexts by checking the context code in the lParam parameter.
|
||||
/// </summary>
|
||||
private const int WM_SYSKEYUP = 0x105;
|
||||
|
||||
private const byte VK_SHIFT = 0x10;
|
||||
private const byte VK_CAPITAL = 0x14;
|
||||
private const byte VK_NUMLOCK = 0x90;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of UserActivityHook object and sets mouse and keyboard hooks.
|
||||
/// </summary>
|
||||
/// <exception cref="Win32Exception">Any windows problem.</exception>
|
||||
public UserActivityHook()
|
||||
{
|
||||
Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of UserActivityHook object and installs both or one of mouse and/or keyboard hooks and starts rasing events
|
||||
/// </summary>
|
||||
/// <param name="InstallMouseHook"><b>true</b> if mouse events must be monitored</param>
|
||||
/// <param name="InstallKeyboardHook"><b>true</b> if keyboard events must be monitored</param>
|
||||
/// <exception cref="Win32Exception">Any windows problem.</exception>
|
||||
/// <remarks>
|
||||
/// To create an instance without installing hooks call new UserActivityHook(false, false)
|
||||
/// </remarks>
|
||||
public UserActivityHook(bool InstallMouseHook, bool InstallKeyboardHook)
|
||||
{
|
||||
Start(InstallMouseHook, InstallKeyboardHook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Destruction.
|
||||
/// </summary>
|
||||
~UserActivityHook()
|
||||
{
|
||||
//uninstall hooks and do not throw exceptions
|
||||
Stop(true, true, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the user moves the mouse, presses any mouse button or scrolls the wheel
|
||||
/// </summary>
|
||||
///
|
||||
public bool EnableMouse = false;
|
||||
|
||||
|
||||
public event MouseEventHandler OnMouseLeftDown;
|
||||
|
||||
public event MouseEventHandler OnMouseLeftUp;
|
||||
|
||||
public event MouseEventHandler OnMouseWheelDown;
|
||||
|
||||
public event MouseEventHandler OnMouseWheelUp;
|
||||
|
||||
public bool MouseLeftDownEnable()
|
||||
{
|
||||
return OnMouseLeftDown != null;
|
||||
}
|
||||
public bool MouseLeftUpEnable()
|
||||
{
|
||||
return OnMouseLeftUp != null;
|
||||
}
|
||||
public bool MouseWheelDownEnable()
|
||||
{
|
||||
return OnMouseWheelDown != null;
|
||||
}
|
||||
public bool MouseWheelUpEnable()
|
||||
{
|
||||
return OnMouseWheelUp != null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Occurs when the user presses a key
|
||||
/// </summary>
|
||||
public event KeyEventHandler KeyDown;
|
||||
/// <summary>
|
||||
/// Occurs when the user presses and releases
|
||||
/// </summary>
|
||||
public event KeyPressEventHandler KeyPress;
|
||||
/// <summary>
|
||||
/// Occurs when the user releases a key
|
||||
/// </summary>
|
||||
public event KeyEventHandler KeyUp;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Stores the handle to the mouse hook procedure.
|
||||
/// </summary>
|
||||
private int hMouseHook = 0;
|
||||
/// <summary>
|
||||
/// Stores the handle to the keyboard hook procedure.
|
||||
/// </summary>
|
||||
private int hKeyboardHook = 0;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Declare MouseHookProcedure as HookProc type.
|
||||
/// </summary>
|
||||
private static HookProc MouseHookProcedure;
|
||||
/// <summary>
|
||||
/// Declare KeyboardHookProcedure as HookProc type.
|
||||
/// </summary>
|
||||
private static HookProc KeyboardHookProcedure;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Installs both mouse and keyboard hooks and starts rasing events
|
||||
/// </summary>
|
||||
/// <exception cref="Win32Exception">Any windows problem.</exception>
|
||||
public void Start()
|
||||
{
|
||||
this.Start(true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Installs both or one of mouse and/or keyboard hooks and starts rasing events
|
||||
/// </summary>
|
||||
/// <param name="InstallMouseHook"><b>true</b> if mouse events must be monitored</param>
|
||||
/// <param name="InstallKeyboardHook"><b>true</b> if keyboard events must be monitored</param>
|
||||
/// <exception cref="Win32Exception">Any windows problem.</exception>
|
||||
public void Start(bool InstallMouseHook, bool InstallKeyboardHook)
|
||||
{
|
||||
this.EnableMouse = InstallMouseHook;
|
||||
// install Mouse hook only if it is not installed and must be installed
|
||||
if (hMouseHook == 0 && EnableMouse)
|
||||
{
|
||||
// Create an instance of HookProc.
|
||||
MouseHookProcedure = new HookProc(MouseHookProc);
|
||||
//install hook
|
||||
hMouseHook = SetWindowsHookEx(
|
||||
WH_MOUSE_LL,
|
||||
MouseHookProcedure,
|
||||
Marshal.GetHINSTANCE(
|
||||
Assembly.GetExecutingAssembly().GetModules()[0]),
|
||||
0);
|
||||
//If SetWindowsHookEx fails.
|
||||
if (hMouseHook == 0)
|
||||
{
|
||||
//Returns the error code returned by the last unmanaged function called using platform invoke that has the DllImportAttribute.SetLastError flag set.
|
||||
int errorCode = Marshal.GetLastWin32Error();
|
||||
//do cleanup
|
||||
Stop(true, false, false);
|
||||
//Initializes and throws a new instance of the Win32Exception class with the specified error.
|
||||
throw new Win32Exception(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
// install Keyboard hook only if it is not installed and must be installed
|
||||
if (hKeyboardHook == 0 && InstallKeyboardHook)
|
||||
{
|
||||
// Create an instance of HookProc.
|
||||
KeyboardHookProcedure = new HookProc(KeyboardHookProc);
|
||||
//install hook
|
||||
hKeyboardHook = SetWindowsHookEx(
|
||||
WH_KEYBOARD_LL,
|
||||
KeyboardHookProcedure,
|
||||
Marshal.GetHINSTANCE(
|
||||
Assembly.GetExecutingAssembly().GetModules()[0]),
|
||||
0);
|
||||
//If SetWindowsHookEx fails.
|
||||
if (hKeyboardHook == 0)
|
||||
{
|
||||
//Returns the error code returned by the last unmanaged function called using platform invoke that has the DllImportAttribute.SetLastError flag set.
|
||||
int errorCode = Marshal.GetLastWin32Error();
|
||||
//do cleanup
|
||||
Stop(false, true, false);
|
||||
//Initializes and throws a new instance of the Win32Exception class with the specified error.
|
||||
throw new Win32Exception(errorCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops monitoring both mouse and keyboard events and rasing events.
|
||||
/// </summary>
|
||||
/// <exception cref="Win32Exception">Any windows problem.</exception>
|
||||
public void Stop()
|
||||
{
|
||||
this.Stop(true, true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops monitoring both or one of mouse and/or keyboard events and rasing events.
|
||||
/// </summary>
|
||||
/// <param name="UninstallMouseHook"><b>true</b> if mouse hook must be uninstalled</param>
|
||||
/// <param name="UninstallKeyboardHook"><b>true</b> if keyboard hook must be uninstalled</param>
|
||||
/// <param name="ThrowExceptions"><b>true</b> if exceptions which occured during uninstalling must be thrown</param>
|
||||
/// <exception cref="Win32Exception">Any windows problem.</exception>
|
||||
public void Stop(bool UninstallMouseHook, bool UninstallKeyboardHook, bool ThrowExceptions)
|
||||
{
|
||||
//if mouse hook set and must be uninstalled
|
||||
if (hMouseHook != 0 && UninstallMouseHook)
|
||||
{
|
||||
//uninstall hook
|
||||
int retMouse = UnhookWindowsHookEx(hMouseHook);
|
||||
//reset invalid handle
|
||||
hMouseHook = 0;
|
||||
//if failed and exception must be thrown
|
||||
if (retMouse == 0 && ThrowExceptions)
|
||||
{
|
||||
//Returns the error code returned by the last unmanaged function called using platform invoke that has the DllImportAttribute.SetLastError flag set.
|
||||
int errorCode = Marshal.GetLastWin32Error();
|
||||
//Initializes and throws a new instance of the Win32Exception class with the specified error.
|
||||
throw new Win32Exception(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
//if keyboard hook set and must be uninstalled
|
||||
if (hKeyboardHook != 0 && UninstallKeyboardHook)
|
||||
{
|
||||
//uninstall hook
|
||||
int retKeyboard = UnhookWindowsHookEx(hKeyboardHook);
|
||||
//reset invalid handle
|
||||
hKeyboardHook = 0;
|
||||
//if failed and exception must be thrown
|
||||
if (retKeyboard == 0 && ThrowExceptions)
|
||||
{
|
||||
//Returns the error code returned by the last unmanaged function called using platform invoke that has the DllImportAttribute.SetLastError flag set.
|
||||
int errorCode = Marshal.GetLastWin32Error();
|
||||
//Initializes and throws a new instance of the Win32Exception class with the specified error.
|
||||
throw new Win32Exception(errorCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A callback function which will be called every time a mouse activity detected.
|
||||
/// </summary>
|
||||
/// <param name="nCode">
|
||||
/// [in] Specifies whether the hook procedure must process the message.
|
||||
/// If nCode is HC_ACTION, the hook procedure must process the message.
|
||||
/// If nCode is less than zero, the hook procedure must pass the message to the
|
||||
/// CallNextHookEx function without further processing and must return the
|
||||
/// value returned by CallNextHookEx.
|
||||
/// </param>
|
||||
/// <param name="wParam">
|
||||
/// [in] Specifies whether the message was sent by the current thread.
|
||||
/// If the message was sent by the current thread, it is nonzero; otherwise, it is zero.
|
||||
/// </param>
|
||||
/// <param name="lParam">
|
||||
/// [in] Pointer to a CWPSTRUCT structure that contains details about the message.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx.
|
||||
/// If nCode is greater than or equal to zero, it is highly recommended that you call CallNextHookEx
|
||||
/// and return the value it returns; otherwise, other applications that have installed WH_CALLWNDPROC
|
||||
/// hooks will not receive hook notifications and may behave incorrectly as a result. If the hook
|
||||
/// procedure does not call CallNextHookEx, the return value should be zero.
|
||||
/// </returns>
|
||||
private int MouseHookProc(int nCode, int wParam, IntPtr lParam)
|
||||
{
|
||||
// if ok and someone listens to our events
|
||||
if ((nCode >= 0) && EnableMouse)
|
||||
{
|
||||
//Marshall the data from callback.
|
||||
MouseLLHookStruct mouseHookStruct = (MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct));
|
||||
|
||||
//detect button clicked
|
||||
MouseButtons button = MouseButtons.None;
|
||||
short mouseDelta = 0;
|
||||
switch (wParam)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_LBUTTONUP:
|
||||
button = MouseButtons.Left;
|
||||
|
||||
break;
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_RBUTTONUP:
|
||||
//case WM_RBUTTONUP:
|
||||
//case WM_RBUTTONDBLCLK:
|
||||
button = MouseButtons.Right;
|
||||
break;
|
||||
case WM_MOUSEWHEEL:
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_MBUTTONUP:
|
||||
button = MouseButtons.Middle;
|
||||
//If the message is WM_MOUSEWHEEL, the high-order word of mouseData member is the wheel delta.
|
||||
//One wheel click is defined as WHEEL_DELTA, which is 120.
|
||||
//(value >> 16) & 0xffff; retrieves the high-order word from the given 32-bit value
|
||||
mouseDelta = (short)((mouseHookStruct.mouseData >> 16) & 0xffff);
|
||||
|
||||
//TODO: X BUTTONS (I havent them so was unable to test)
|
||||
//If the message is WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP,
|
||||
//or WM_NCXBUTTONDBLCLK, the high-order word specifies which X button was pressed or released,
|
||||
//and the low-order word is reserved. This value can be one or more of the following values.
|
||||
//Otherwise, mouseData is not used.
|
||||
break;
|
||||
}
|
||||
|
||||
//double clicks
|
||||
int clickCount = 0;
|
||||
if (button != MouseButtons.None)
|
||||
if (wParam == WM_LBUTTONDBLCLK || wParam == WM_RBUTTONDBLCLK) clickCount = 2;
|
||||
else clickCount = 1;
|
||||
|
||||
//generate event
|
||||
MouseEventArgs e = new MouseEventArgs(
|
||||
button,
|
||||
clickCount,
|
||||
mouseHookStruct.pt.x,
|
||||
mouseHookStruct.pt.y,
|
||||
mouseDelta);
|
||||
//raise it
|
||||
switch (wParam)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
this.OnMouseLeftDown?.Invoke(this, e);
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
this.OnMouseLeftUp?.Invoke(this, e);
|
||||
break;
|
||||
case WM_RBUTTONDOWN:
|
||||
break;
|
||||
case WM_RBUTTONUP:
|
||||
break;
|
||||
case WM_MOUSEWHEEL:
|
||||
break;
|
||||
case WM_MBUTTONDOWN:
|
||||
this.OnMouseWheelDown?.Invoke(this, e);
|
||||
break;
|
||||
case WM_MBUTTONUP:
|
||||
this.OnMouseWheelUp?.Invoke(this, e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//call next hook
|
||||
return CallNextHookEx(hMouseHook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A callback function which will be called every time a keyboard activity detected.
|
||||
/// </summary>
|
||||
/// <param name="nCode">
|
||||
/// [in] Specifies whether the hook procedure must process the message.
|
||||
/// If nCode is HC_ACTION, the hook procedure must process the message.
|
||||
/// If nCode is less than zero, the hook procedure must pass the message to the
|
||||
/// CallNextHookEx function without further processing and must return the
|
||||
/// value returned by CallNextHookEx.
|
||||
/// </param>
|
||||
/// <param name="wParam">
|
||||
/// [in] Specifies whether the message was sent by the current thread.
|
||||
/// If the message was sent by the current thread, it is nonzero; otherwise, it is zero.
|
||||
/// </param>
|
||||
/// <param name="lParam">
|
||||
/// [in] Pointer to a CWPSTRUCT structure that contains details about the message.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx.
|
||||
/// If nCode is greater than or equal to zero, it is highly recommended that you call CallNextHookEx
|
||||
/// and return the value it returns; otherwise, other applications that have installed WH_CALLWNDPROC
|
||||
/// hooks will not receive hook notifications and may behave incorrectly as a result. If the hook
|
||||
/// procedure does not call CallNextHookEx, the return value should be zero.
|
||||
/// </returns>
|
||||
private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)
|
||||
{
|
||||
//indicates if any of underlaing events set e.Handled flag
|
||||
bool handled = false;
|
||||
//it was ok and someone listens to events
|
||||
if ((nCode >= 0) && (KeyDown != null || KeyUp != null || KeyPress != null))
|
||||
{
|
||||
//read structure KeyboardHookStruct at lParam
|
||||
KeyboardHookStruct MyKeyboardHookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));
|
||||
//raise KeyDown
|
||||
if (KeyDown != null && (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN))
|
||||
{
|
||||
Keys keyData = (Keys)MyKeyboardHookStruct.vkCode;
|
||||
KeyEventArgs e = new KeyEventArgs(keyData);
|
||||
KeyDown(this, e);
|
||||
handled = handled || e.Handled;
|
||||
}
|
||||
|
||||
// raise KeyPress
|
||||
if (KeyPress != null && wParam == WM_KEYDOWN)
|
||||
{
|
||||
bool isDownShift = ((GetKeyState(VK_SHIFT) & 0x80) == 0x80 ? true : false);
|
||||
bool isDownCapslock = (GetKeyState(VK_CAPITAL) != 0 ? true : false);
|
||||
|
||||
byte[] keyState = new byte[256];
|
||||
GetKeyboardState(keyState);
|
||||
byte[] inBuffer = new byte[2];
|
||||
if (ToAscii(MyKeyboardHookStruct.vkCode,
|
||||
MyKeyboardHookStruct.scanCode,
|
||||
keyState,
|
||||
inBuffer,
|
||||
MyKeyboardHookStruct.flags) == 1)
|
||||
{
|
||||
char key = (char)inBuffer[0];
|
||||
if ((isDownCapslock ^ isDownShift) && Char.IsLetter(key)) key = Char.ToUpper(key);
|
||||
KeyPressEventArgs e = new KeyPressEventArgs(key);
|
||||
KeyPress(this, e);
|
||||
handled = handled || e.Handled;
|
||||
}
|
||||
}
|
||||
|
||||
// raise KeyUp
|
||||
if (KeyUp != null && (wParam == WM_KEYUP || wParam == WM_SYSKEYUP))
|
||||
{
|
||||
Keys keyData = (Keys)MyKeyboardHookStruct.vkCode;
|
||||
KeyEventArgs e = new KeyEventArgs(keyData);
|
||||
KeyUp(this, e);
|
||||
handled = handled || e.Handled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//if event handled in application do not handoff to other listeners
|
||||
if (handled)
|
||||
return 1;
|
||||
else
|
||||
return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,9 +93,97 @@ namespace GeekDesk.ViewModel
|
||||
|
||||
private SearchType searchType;
|
||||
|
||||
private string sysBakTime; //系统自动备份时间
|
||||
|
||||
private string menuPassword; //锁菜单密码
|
||||
|
||||
private string passwordHint; //密码提示
|
||||
|
||||
private bool? isShow;
|
||||
|
||||
private bool itemSpradeAnimation; //列表展开动画
|
||||
|
||||
private bool? secondsWindow; //秒数窗口 默认打开
|
||||
|
||||
#region GetSet
|
||||
|
||||
public bool? SecondsWindow
|
||||
{
|
||||
get
|
||||
{
|
||||
if (secondsWindow == null) secondsWindow = true;
|
||||
return secondsWindow;
|
||||
}
|
||||
set
|
||||
{
|
||||
secondsWindow = value;
|
||||
OnPropertyChanged("SecondsWindow");
|
||||
}
|
||||
}
|
||||
|
||||
public bool ItemSpradeAnimation
|
||||
{
|
||||
get
|
||||
{
|
||||
return itemSpradeAnimation;
|
||||
}
|
||||
set
|
||||
{
|
||||
itemSpradeAnimation = value;
|
||||
OnPropertyChanged("ItemSpradeAnimation");
|
||||
}
|
||||
}
|
||||
|
||||
public bool? IsShow
|
||||
{
|
||||
get
|
||||
{
|
||||
return isShow;
|
||||
}
|
||||
set
|
||||
{
|
||||
isShow = value;
|
||||
OnPropertyChanged("IsShow");
|
||||
}
|
||||
}
|
||||
|
||||
public string PasswordHint
|
||||
{
|
||||
get
|
||||
{
|
||||
return passwordHint;
|
||||
}
|
||||
set
|
||||
{
|
||||
passwordHint = value;
|
||||
OnPropertyChanged("PasswordHint");
|
||||
}
|
||||
}
|
||||
public string MenuPassword
|
||||
{
|
||||
get
|
||||
{
|
||||
return menuPassword;
|
||||
}
|
||||
set
|
||||
{
|
||||
menuPassword = value;
|
||||
OnPropertyChanged("MenuPassword");
|
||||
}
|
||||
}
|
||||
|
||||
public string SysBakTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return sysBakTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
sysBakTime = value;
|
||||
}
|
||||
}
|
||||
|
||||
public SearchType SearchType
|
||||
{
|
||||
get
|
||||
@@ -898,7 +986,7 @@ namespace GeekDesk.ViewModel
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
@@ -88,7 +89,7 @@ namespace GeekDesk.ViewModel
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
@@ -69,7 +70,7 @@ namespace GeekDesk.ViewModel
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,36 @@ namespace GeekDesk.ViewModel
|
||||
private string startArg; //启动参数
|
||||
private string lnkPath;
|
||||
|
||||
private string relativePath; //相对路径
|
||||
|
||||
private IconType iconType = IconType.OTHER;
|
||||
|
||||
|
||||
public string RelativePath_NoWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
set
|
||||
{
|
||||
relativePath = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string RelativePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
set
|
||||
{
|
||||
relativePath = value;
|
||||
OnPropertyChanged("RelativePath");
|
||||
}
|
||||
}
|
||||
|
||||
public string LnkPath_NoWrite
|
||||
{
|
||||
get
|
||||
@@ -178,6 +205,14 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
if (StringUtil.IsEmpty(Path))
|
||||
{
|
||||
content = Name + "\n使用次数: " + Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
content = Path + "\n" + Name + "\n使用次数: " + Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,6 +246,14 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
path = value;
|
||||
if (StringUtil.IsEmpty(Path))
|
||||
{
|
||||
content = Name + "\n使用次数: " + Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
content = Path + "\n" + Name + "\n使用次数: " + Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +346,7 @@ namespace GeekDesk.ViewModel
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,8 +20,22 @@ namespace GeekDesk.ViewModel
|
||||
private string menuGeometry; //菜单几何图标
|
||||
private string geometryColor; //几何图标颜色
|
||||
private ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
|
||||
private bool isEncrypt; //是否加密
|
||||
|
||||
|
||||
public bool IsEncrypt
|
||||
{
|
||||
get
|
||||
{
|
||||
return isEncrypt;
|
||||
}
|
||||
set
|
||||
{
|
||||
isEncrypt = value;
|
||||
OnPropertyChanged("IsEncrypt");
|
||||
}
|
||||
}
|
||||
|
||||
public string MenuGeometry
|
||||
{
|
||||
get
|
||||
@@ -134,7 +148,7 @@ namespace GeekDesk.ViewModel
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace GeekDesk.ViewModel
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
79
app.manifest
Normal file
79
app.manifest
Normal file
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC 清单选项
|
||||
如果想要更改 Windows 用户帐户控制级别,请使用
|
||||
以下节点之一替换 requestedExecutionLevel 节点。
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
|
||||
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
|
||||
元素。
|
||||
-->
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
|
||||
Windows 版本的列表。取消评论适当的元素,
|
||||
Windows 将自动选择最兼容的环境。 -->
|
||||
|
||||
<!-- Windows Vista -->
|
||||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
|
||||
|
||||
<!-- Windows 7 -->
|
||||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
|
||||
|
||||
<!-- Windows 8 -->
|
||||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
|
||||
|
||||
<!-- Windows 8.1 -->
|
||||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
|
||||
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
|
||||
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
|
||||
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
|
||||
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
|
||||
|
||||
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
|
||||
|
||||
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
|
||||
<!--
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
</assembly>
|
||||
@@ -3,7 +3,10 @@
|
||||
<package id="CommonServiceLocator" version="2.0.6" targetFramework="net452" requireReinstallation="true" />
|
||||
<package id="HandyControl" version="3.3.0" targetFramework="net472" />
|
||||
<package id="KeyMouseHook" version="1.0.6" targetFramework="net472" developmentDependency="true" />
|
||||
<package id="Microsoft.Build.Tasks.Git" version="1.0.0" targetFramework="net472" developmentDependency="true" />
|
||||
<package id="Microsoft.Extensions.Logging.Abstractions" version="2.1.1" targetFramework="net472" />
|
||||
<package id="Microsoft.SourceLink.Common" version="1.0.0" targetFramework="net472" developmentDependency="true" />
|
||||
<package id="Microsoft.SourceLink.GitHub" version="1.0.0" targetFramework="net472" developmentDependency="true" />
|
||||
<package id="MouseKeyHook" version="5.6.0" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
|
||||
<package id="NPinyin.Core" version="3.0.0" targetFramework="net472" />
|
||||
@@ -13,5 +16,8 @@
|
||||
<package id="System.Drawing.Common" version="6.0.0-preview.6.21352.12" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Reactive" version="5.0.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
|
||||
<package id="XamlFlair.WPF" version="1.2.13" targetFramework="net472" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user