Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18501b3afe | ||
|
|
274541303a | ||
|
|
5e81f334e2 | ||
|
|
5e1f3fea38 | ||
|
|
1459c35167 | ||
|
|
6f2a5bdc07 | ||
|
|
c231587543 | ||
|
|
787c23ef77 | ||
|
|
7e3babe0c3 | ||
|
|
fd406fea4d | ||
|
|
d46eae4c6e | ||
|
|
4a94aab3c7 | ||
|
|
8d44429bda | ||
|
|
6ecb55061f | ||
|
|
f11056c469 | ||
|
|
c9f19c5084 | ||
|
|
571d7c3d0d | ||
|
|
99eae59dc3 | ||
|
|
2d67d32b29 | ||
|
|
33560ad85a | ||
|
|
53481bf907 | ||
|
|
2673b9862c | ||
|
|
4c0a97b7b1 | ||
|
|
0a89255ad2 | ||
|
|
3c78b058cf | ||
|
|
9a5882ff98 | ||
|
|
69487b9383 | ||
|
|
0107ac8317 | ||
|
|
27e9b56b4d | ||
|
|
3c89d93cf7 | ||
|
|
1dc77da44e | ||
|
|
94f32fdb15 | ||
|
|
15a214aad0 | ||
|
|
67a3b0eddd | ||
|
|
71071a997f | ||
|
|
c2fca3e7aa | ||
|
|
488670a0fc | ||
|
|
14b2d77915 | ||
|
|
1839d310bc |
59
App.config
59
App.config
@@ -1,23 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
||||
</startup>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="CommonServiceLocator" publicKeyToken="489b6accfaf20ef0" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.6.0" newVersion="2.0.6.0"/>
|
||||
<assemblyIdentity name="CommonServiceLocator" publicKeyToken="489b6accfaf20ef0" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.6.0" newVersion="2.0.6.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<appSettings>
|
||||
<add key="Version" value="1.0-beta"/>
|
||||
|
||||
<add key="GitHubUrl" value="https://github.com/Demo-Liu/GeekDesk"/>
|
||||
<add key="GiteeUrl" value="https://gitee.com/demo_liu/GeekDesk/tree/master"/>
|
||||
|
||||
<add key="GitHubUpdateUrl" value="https://demo-liu.github.io/GeekDesk/Update.json"/>
|
||||
<add key="GiteeUpdateUrl" value="https://demo-liu.github.io/GeekDesk/Update.json"/>
|
||||
</appSettings>
|
||||
</configuration>
|
||||
<appSettings>
|
||||
<add key="Version" value="2.3.10" />
|
||||
<add key="GitHubUrl" value="https://github.com/Demo-Liu/GeekDesk" />
|
||||
<add key="GiteeUrl" value="https://gitee.com/demo_liu/GeekDesk/tree/master" />
|
||||
<add key="GitHubUpdateUrl" value="https://demo-liu.github.io/GeekDesk/Update.json" />
|
||||
<add key="GiteeUpdateUrl" value="https://demo-liu.github.io/GeekDesk/Update.json" />
|
||||
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<membership defaultProvider="ClientAuthenticationMembershipProvider">
|
||||
<providers>
|
||||
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
|
||||
</providers>
|
||||
</membership>
|
||||
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
|
||||
<providers>
|
||||
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
|
||||
</providers>
|
||||
</roleManager>
|
||||
</system.web>
|
||||
</configuration>
|
||||
11
App.xaml.cs
11
App.xaml.cs
@@ -3,6 +3,7 @@ using Microsoft.Win32;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace GeekDesk
|
||||
@@ -23,11 +24,15 @@ namespace GeekDesk
|
||||
private void App_Startup(object sender, StartupEventArgs e)
|
||||
{
|
||||
|
||||
bool ret;
|
||||
mutex = new System.Threading.Mutex(true, Constants.MY_NAME, out ret);
|
||||
mutex = new System.Threading.Mutex(true, Constants.MY_NAME, out bool ret);
|
||||
if (!ret)
|
||||
{
|
||||
Environment.Exit(0);
|
||||
System.Threading.Thread.Sleep(2000);
|
||||
mutex = new System.Threading.Mutex(true, Constants.MY_NAME, out ret);
|
||||
if (!ret)
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
Constant/CommonEnum.cs
Normal file
19
Constant/CommonEnum.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
/// <summary>
|
||||
/// 默认参数
|
||||
/// </summary>
|
||||
namespace GeekDesk.Constant
|
||||
{
|
||||
public enum CommonEnum
|
||||
{
|
||||
WINDOW_WIDTH = 666, //默认窗体宽度
|
||||
WINDOW_HEIGHT = 500, //默认窗体高度
|
||||
MENU_CARD_WIDHT = 165, //默认菜单栏宽度
|
||||
IMAGE_WIDTH = 45, //默认图标宽度
|
||||
IMAGE_HEIGHT = 45, //默认图标高度
|
||||
IMAGE_WIDTH_AM = 52, //动画变换宽度
|
||||
IMAGE_HEIGHT_AM = 52, //动画变换高度
|
||||
IMAGE_PANEL_WIDTH = 110, //图标容器宽度
|
||||
IMAGE_PANEL_HEIGHT = 90, //图标容器高度
|
||||
WINDOW_ANIMATION_TIME = 200, //主窗口动画时间,
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
14
Constant/IconType.cs
Normal file
14
Constant/IconType.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Constant
|
||||
{
|
||||
public enum IconType
|
||||
{
|
||||
OTHER = 1, //直接打开
|
||||
URL = 2 //调用浏览器打开
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/// <summary>
|
||||
/// 默认参数
|
||||
/// </summary>
|
||||
namespace GeekDesk.Constant
|
||||
{
|
||||
public enum MainWindowEnum
|
||||
{
|
||||
WINDOW_WIDTH = 666, //默认窗体宽度
|
||||
WINDOW_HEIGHT = 500, //默认窗体高度
|
||||
MENU_CARD_WIDHT = 165, //默认菜单栏宽度
|
||||
IMAGE_WIDTH = 60, //默认图标宽度
|
||||
IMAGE_HEIGHT = 60, //默认图标高度
|
||||
}
|
||||
}
|
||||
14
Constant/TodoTaskExecType.cs
Normal file
14
Constant/TodoTaskExecType.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Constant
|
||||
{
|
||||
public enum TodoTaskExecType
|
||||
{
|
||||
SET_TIME = 1, //指定时间
|
||||
CRON = 2 //cron表达式
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
using GeekDesk.Task;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Task;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Controls;
|
||||
using Quartz;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -34,8 +37,36 @@ namespace GeekDesk.Control.Other
|
||||
{
|
||||
ToDoInfo info = this.DataContext as ToDoInfo;
|
||||
info.DoneTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
appData.ToDoList.Remove(info); //执行任务删除
|
||||
appData.HiToDoList.Add(info); //添加历史任务
|
||||
if (info.ExecType == TodoTaskExecType.CRON)
|
||||
{
|
||||
CronExpression exp = new CronExpression(info.Cron);
|
||||
DateTime dtNow = DateTime.Now;
|
||||
DateTimeOffset ddo = DateTime.SpecifyKind(dtNow, DateTimeKind.Local);
|
||||
string nextExecTime = ddo.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
info.ExeTime = nextExecTime;
|
||||
|
||||
DateTime nextTime = ddo.LocalDateTime;
|
||||
TimeSpan ts = nextTime.Subtract(dtNow);
|
||||
int minutes = (int)Math.Ceiling(ts.TotalMinutes);
|
||||
if (minutes < 0)
|
||||
{
|
||||
minutes = 0;
|
||||
}
|
||||
if (minutes > 60)
|
||||
{
|
||||
int m = minutes % 60;
|
||||
int h = minutes / 60;
|
||||
Growl.SuccessGlobal("下次任务将在 " + h + " 小时零 " + m + " 分钟后提醒您!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.SuccessGlobal("下次任务将在 " + minutes + " 分钟后提醒您!");
|
||||
}
|
||||
} else
|
||||
{
|
||||
appData.ToDoList.Remove(info); //执行任务删除
|
||||
appData.HiToDoList.Add(info); //添加历史任务
|
||||
}
|
||||
ToDoTask.activityBacklog[info].Close(); //关闭桌面通知
|
||||
ToDoTask.activityBacklog.Remove(info);//激活任务删除
|
||||
CommonCode.SaveAppData(appData);
|
||||
@@ -93,9 +124,11 @@ namespace GeekDesk.Control.Other
|
||||
{
|
||||
case "分":
|
||||
info.ExeTime = DateTime.Now.AddMinutes(time).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
Growl.SuccessGlobal("将在 " + time + " 分钟后再次提醒您!");
|
||||
break;
|
||||
case "时":
|
||||
info.ExeTime = DateTime.Now.AddHours(time).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
Growl.SuccessGlobal("将在 " + time + " 小时后再次提醒您!");
|
||||
break;
|
||||
}
|
||||
ToDoTask.activityBacklog[info].Close(); //关闭桌面通知
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
CornerRadius="4"
|
||||
Width="300"
|
||||
Height="300"
|
||||
Opacity="0.9">
|
||||
>
|
||||
<Border.Resources>
|
||||
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
|
||||
<Setter Property="Width" Value="40"/>
|
||||
@@ -15,7 +15,7 @@
|
||||
</Style>
|
||||
</Border.Resources>
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="AliceBlue" Opacity="0.9"/>
|
||||
<SolidColorBrush Color="AliceBlue" Opacity="0.98"/>
|
||||
</Border.Background>
|
||||
<hc:SimplePanel Margin="10">
|
||||
<Grid Margin="8,20,8,20">
|
||||
@@ -42,9 +42,9 @@
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:Divider LineStrokeDashArray="3,3" Margin="0,200,0,-27" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,218,0,-38" Grid.ColumnSpan="4">
|
||||
<Button Content="保存" Command="hc:ControlCommands.Close" Click="SaveProperty" Margin="208,6,-208,-10"/>
|
||||
<Button Content="保存" Click="SaveProperty" Margin="208,6,-208,-10"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</Grid>
|
||||
<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" Margin="0,4,4,0"/>
|
||||
<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" Margin="0,4,4,0"/>
|
||||
</hc:SimplePanel>
|
||||
</Border>
|
||||
@@ -14,6 +14,7 @@ namespace GeekDesk.Control.Other
|
||||
/// </summary>
|
||||
public partial class IconInfoDialog
|
||||
{
|
||||
public HandyControl.Controls.Dialog dialog;
|
||||
|
||||
public IconInfoDialog()
|
||||
{
|
||||
@@ -38,6 +39,7 @@ namespace GeekDesk.Control.Other
|
||||
info.Name = IconName.Text;
|
||||
info.AdminStartUp = IconIsAdmin.IsChecked.Value;
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
dialog.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -47,7 +49,7 @@ namespace GeekDesk.Control.Other
|
||||
/// <param name="e"></param>
|
||||
private void ReStoreImage(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IconInfo info = ((Button)sender).Tag as IconInfo;
|
||||
IconInfo info = this.DataContext as IconInfo;
|
||||
info.BitmapImage = ImageUtil.ByteArrToImage(info.DefaultImage);
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<Border x:Class="GeekDesk.Control.Other.MenuGeometryDialog"
|
||||
<Border x:Class="GeekDesk.Control.Other.IconInfoUrlDialog"
|
||||
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"
|
||||
CornerRadius="10"
|
||||
CornerRadius="4"
|
||||
Width="300"
|
||||
Height="300"
|
||||
Opacity="0.9">
|
||||
<!--<Border.Resources>
|
||||
>
|
||||
<Border.Resources>
|
||||
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
|
||||
<Setter Property="Width" Value="40"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
@@ -15,42 +15,31 @@
|
||||
</Style>
|
||||
</Border.Resources>
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="AliceBlue" Opacity="0.9"/>
|
||||
<SolidColorBrush Color="AliceBlue" Opacity="0.98"/>
|
||||
</Border.Background>
|
||||
<hc:SimplePanel Margin="10">
|
||||
<Grid Margin="8,20,8,20">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="93*"/>
|
||||
<ColumnDefinition Width="38*"/>
|
||||
<ColumnDefinition Width="126*"/>
|
||||
<ColumnDefinition Width="7*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="名称:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBox x:Name="IconName" Text="{Binding Name, Mode=OneWay}" Width="180" FontSize="14"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:Divider LineStrokeDashArray="3,3" Margin="0,50,0,71" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,59,0,-9" Grid.ColumnSpan="4">
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,77,0,-27">
|
||||
<TextBlock Text="Url:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBox x:Name="IconUrl" Text="{Binding Path, Mode=OneWay}" Width="180" FontSize="14"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:Divider LineStrokeDashArray="3,3" Margin="0,128,0,23" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,133,0,27">
|
||||
<TextBlock Text="图标:" Style="{StaticResource LeftTB}"/>
|
||||
<Image x:Name="IconImg" Source="{Binding BitmapImage, Mode=OneWay}" Width="60" Height="60"/>
|
||||
<Button Content="修改" Click="EditImage"/>
|
||||
<Button Content="重置" Click="ReStoreImage"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:Divider LineStrokeDashArray="3,3" Margin="0,128,0,23" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,150,0,10" Grid.ColumnSpan="4">
|
||||
<CheckBox x:Name="IconIsAdmin" Content="始终以管理员方式启动" IsChecked="{Binding AdminStartUp, Mode=OneWay}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:Divider LineStrokeDashArray="3,3" Margin="0,200,0,-27" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,218,0,-38" Grid.ColumnSpan="4">
|
||||
<Button Content="保存" Command="hc:ControlCommands.Close" Click="SaveProperty" Margin="208,6,-208,-10"/>
|
||||
<Button Content="保存" Click="SaveProperty" Margin="208,6,-208,-10"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</Grid>
|
||||
<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" Margin="0,4,4,0"/>
|
||||
</hc:SimplePanel>-->
|
||||
<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" Margin="0,4,4,0"/>
|
||||
</hc:SimplePanel>
|
||||
</Border>
|
||||
99
Control/Other/IconInfoUrlDialog.xaml.cs
Normal file
99
Control/Other/IconInfoUrlDialog.xaml.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
|
||||
namespace GeekDesk.Control.Other
|
||||
{
|
||||
/// <summary>
|
||||
/// TextDialog.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class IconInfoUrlDialog
|
||||
{
|
||||
public HandyControl.Controls.Dialog dialog;
|
||||
|
||||
private bool newIconInfo;
|
||||
public IconInfoUrlDialog()
|
||||
{
|
||||
newIconInfo = true;
|
||||
IconInfo info = new IconInfo
|
||||
{
|
||||
BitmapImage = ImageUtil.Base64ToBitmapImage(Constants.URL_ICON_IMG_BASE64),
|
||||
};
|
||||
info.DefaultImage = info.ImageByteArr;
|
||||
info.IconType = IconType.URL;
|
||||
this.DataContext = info;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public IconInfoUrlDialog(IconInfo info)
|
||||
{
|
||||
this.DataContext = info;
|
||||
newIconInfo = false;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存修改属性
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SaveProperty(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IconInfo info = this.DataContext as IconInfo;
|
||||
info.BitmapImage = IconImg.Source as BitmapImage;
|
||||
info.Name = IconName.Text;
|
||||
info.Path = IconUrl.Text;
|
||||
if (newIconInfo)
|
||||
{
|
||||
MainWindow.appData.MenuList[MainWindow.appData.AppConfig.SelectedMenuIndex].IconList.Add(info);
|
||||
}
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
dialog.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改图标为默认
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ReStoreImage(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IconInfo info = this.DataContext as IconInfo;
|
||||
info.BitmapImage = ImageUtil.ByteArrToImage(info.DefaultImage);
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改图标
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void EditImage(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog
|
||||
{
|
||||
Multiselect = false, //只允许选中单个文件
|
||||
Filter = "所有文件(*.*)|*.*"
|
||||
};
|
||||
if (ofd.ShowDialog() == true)
|
||||
{
|
||||
IconInfo info = this.DataContext as IconInfo;
|
||||
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
}
|
||||
} catch (Exception)
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("修改图标失败,已重置为默认图标!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
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.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;
|
||||
|
||||
namespace GeekDesk.Control.Other
|
||||
{
|
||||
/// <summary>
|
||||
/// MenuGeometryDialogxaml.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MenuGeometryDialog
|
||||
{
|
||||
public MenuGeometryDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,57 +13,58 @@
|
||||
<UserControl.Resources>
|
||||
<cvt:UpdateTypeConvert x:Key="UpdateTypeConvert"/>
|
||||
</UserControl.Resources>
|
||||
<hc:SimplePanel Margin="20,50,20,20">
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Top">
|
||||
<Image Source="/Resource/Image/About.png" Width="400" Height="100"/>
|
||||
<TextBlock x:Name="AppInfo" TextAlignment="Center" Text="Copyright © 2021 GeekDesk "/>
|
||||
<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"/>
|
||||
<Grid MouseDown="DragMove" Background="AliceBlue">
|
||||
<hc:SimplePanel Margin="20,50,20,20" >
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Top">
|
||||
<Image Source="/Resource/Image/About.png" Width="400" Height="100"/>
|
||||
<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"/>
|
||||
<hc:Shield Subject="IDE" Status="VS2019" Margin="0,0,10,0" Color="#1182c3"/>
|
||||
|
||||
<hc:Shield Subject="GitHub" Visibility="Visible" Status="Demo-liu"
|
||||
<hc:Shield Subject="GitHub" Visibility="Visible" Status="Demo-liu"
|
||||
Command="hc:ControlCommands.OpenLink"
|
||||
CommandParameter="https://github.com/Demo-Liu/GeekDesk"
|
||||
Margin="0,0,10,0" Color="#24292F"/>
|
||||
<hc:Shield Subject="Gitee" Visibility="Visible" Status="Demo-liu"
|
||||
<hc:Shield Subject="Gitee" Visibility="Visible" Status="Demo-liu"
|
||||
Command="hc:ControlCommands.OpenLink"
|
||||
CommandParameter=""
|
||||
Margin="0,5,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:Poptip.Instance>
|
||||
<hc:Poptip PlacementType="Top">
|
||||
<hc:Poptip.Content>
|
||||
<Image x:Name="PublicWeChat" Width="150" Height="150" />
|
||||
</hc:Poptip.Content>
|
||||
</hc:Poptip>
|
||||
</hc:Poptip.Instance>
|
||||
</hc:Shield>
|
||||
<hc:Shield Subject="赞赏" Status="支付宝" Margin="0,0,10,0" Color="#1577FE">
|
||||
<hc:Poptip.Instance>
|
||||
<hc:Poptip PlacementType="Top">
|
||||
<hc:Poptip.Content>
|
||||
<Image x:Name="ZFBCode" Width="150" Height="150" />
|
||||
</hc:Poptip.Content>
|
||||
</hc:Poptip>
|
||||
</hc:Poptip.Instance>
|
||||
</hc:Shield>
|
||||
<hc:Shield Subject="赞赏" Status="微信" Margin="0,0,10,0" Color="#04913B">
|
||||
<hc:Poptip.Instance>
|
||||
<hc:Poptip PlacementType="Top">
|
||||
<hc:Poptip.Content>
|
||||
<Image x:Name="WeChatCode" Width="150" Height="150" />
|
||||
</hc:Poptip.Content>
|
||||
</hc:Poptip>
|
||||
</hc:Poptip.Instance>
|
||||
</hc:Shield>
|
||||
</hc:UniformSpacingPanel>
|
||||
<TextBlock Margin="0,20,0,0" FontSize="13" Width="200" TextAlignment="Center" Text="这是个人开发的程序,所有人可任意修改和免费使用(商用请联系作者)" TextWrapping="Wrap"/>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Visibility="Visible" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10,0,0">
|
||||
|
||||
</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:Poptip.Instance>
|
||||
<hc:Poptip PlacementType="Top">
|
||||
<hc:Poptip.Content>
|
||||
<Image x:Name="PublicWeChat" Width="150" Height="150" />
|
||||
</hc:Poptip.Content>
|
||||
</hc:Poptip>
|
||||
</hc:Poptip.Instance>
|
||||
</hc:Shield>
|
||||
<hc:Shield Subject="赞赏" Status="支付宝" Margin="0,0,10,0" Color="#1577FE">
|
||||
<hc:Poptip.Instance>
|
||||
<hc:Poptip PlacementType="Top">
|
||||
<hc:Poptip.Content>
|
||||
<Image x:Name="ZFBCode" Width="150" Height="150" />
|
||||
</hc:Poptip.Content>
|
||||
</hc:Poptip>
|
||||
</hc:Poptip.Instance>
|
||||
</hc:Shield>
|
||||
<hc:Shield Subject="赞赏" Status="微信" Margin="0,0,10,0" Color="#04913B">
|
||||
<hc:Poptip.Instance>
|
||||
<hc:Poptip PlacementType="Top">
|
||||
<hc:Poptip.Content>
|
||||
<Image x:Name="WeChatCode" Width="150" Height="150" />
|
||||
</hc:Poptip.Content>
|
||||
</hc:Poptip>
|
||||
</hc:Poptip.Instance>
|
||||
</hc:Shield>
|
||||
</hc:UniformSpacingPanel>
|
||||
<TextBlock Margin="0,20,0,0" FontSize="13" Width="200" TextAlignment="Center" Text="这是个人开发的程序,所有人可任意修改和免费使用(商用请联系作者)" TextWrapping="Wrap"/>
|
||||
|
||||
<!--<hc:UniformSpacingPanel Spacing="10" Visibility="Visible" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10,0,0">
|
||||
<TextBlock Text="更新源:" TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="Gitee"
|
||||
@@ -71,8 +72,10 @@
|
||||
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="GitHub"
|
||||
IsChecked="{Binding UpdateType, Mode=TwoWay, Converter={StaticResource UpdateTypeConvert}, ConverterParameter=2}"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
</hc:SimplePanel>
|
||||
</hc:UniformSpacingPanel>-->
|
||||
</StackPanel>
|
||||
</hc:SimplePanel>
|
||||
</Grid>
|
||||
|
||||
|
||||
</UserControl>
|
||||
|
||||
@@ -31,5 +31,19 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
WeChatCode.Source = ImageUtil.Base64ToBitmapImage(Constants.WE_CHAT_CODE_IMG_BASE64);
|
||||
ZFBCode.Source = ImageUtil.Base64ToBitmapImage(Constants.ZFB_CODE_IMG_BASE64);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 移动窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
Window.GetWindow(this).DragMove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
<UserControl.Resources>
|
||||
<cvt:HideTypeConvert x:Key="HideTypeConvert"/>
|
||||
</UserControl.Resources>
|
||||
<hc:SimplePanel Margin="20">
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,0,0,10" Grid.ColumnSpan="4">
|
||||
<Grid Background="AliceBlue" MouseDown="DragMove">
|
||||
<StackPanel Margin="10">
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="面板动作设置" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="30,26.394,0,-16.394" Grid.ColumnSpan="4">
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox x:Name="IconIsAdmin" Content="启动时显示主面板" IsChecked="{Binding StartedShowPanel}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
@@ -26,7 +27,7 @@
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="30,50,0,-102.337" Grid.ColumnSpan="4">
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="显示时追随鼠标位置" IsChecked="{Binding FollowMouse}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
@@ -35,10 +36,31 @@
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="30,89.49,-30,-79.49" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="面板关闭方式" VerticalAlignment="Center" Margin="-26,0,26,0"/>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="贴边隐藏" IsChecked="{Binding MarginHide}" Checked="MarginHide_Changed" Unchecked="MarginHide_Changed">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,115,20,-102.337" Grid.ColumnSpan="4">
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="主窗口动画效果" IsChecked="{Binding AppAnimation}" Checked="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"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="失去焦点后"
|
||||
IsChecked="{Binding AppHideType, Mode=TwoWay, Converter={StaticResource HideTypeConvert}, ConverterParameter=1}"/>
|
||||
@@ -50,12 +72,12 @@
|
||||
IsChecked="{Binding AppHideType, Mode=TwoWay, Converter={StaticResource HideTypeConvert}, ConverterParameter=3}"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="30,164.49,-30,-154.49" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="热键设置" VerticalAlignment="Center" Margin="-26,0,26,0"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="30,193,0,-180.337" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="主面板:" Width="55"/>
|
||||
<hc:TextBox HorizontalAlignment="Left"
|
||||
<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">
|
||||
<TextBlock Text="主面板:" VerticalAlignment="Center" Width="55"/>
|
||||
<hc:TextBox HorizontalAlignment="Left"
|
||||
Tag="Main"
|
||||
VerticalAlignment="Top"
|
||||
IsReadOnly="True"
|
||||
@@ -64,9 +86,9 @@
|
||||
Text="{Binding HotkeyStr}"
|
||||
KeyDown="HotKeyDown"
|
||||
KeyUp="HotKeyUp"
|
||||
Margin="12.967,-7.38,-12.967,0"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<!--<hc:UniformSpacingPanel Spacing="10" Margin="30,229,0,-216.337" Grid.ColumnSpan="4">
|
||||
/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="新建待办:" Width="55"/>
|
||||
<hc:TextBox HorizontalAlignment="Left"
|
||||
Tag="ToDo"
|
||||
@@ -77,9 +99,11 @@
|
||||
Text="{Binding ToDoHotkeyStr}"
|
||||
KeyDown="HotKeyDown"
|
||||
KeyUp="HotKeyUp"
|
||||
Margin="12.967,-7.38,-12.967,0"/>
|
||||
</hc:UniformSpacingPanel>-->
|
||||
<StackPanel hc:Growl.GrowlParent="True" hc:Growl.Token="HotKeyGrowl" VerticalAlignment="Top"/>
|
||||
</hc:SimplePanel>
|
||||
/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<StackPanel hc:Growl.GrowlParent="True" hc:Growl.Token="HotKeyGrowl" VerticalAlignment="Top"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
|
||||
</UserControl>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Data;
|
||||
@@ -19,6 +20,7 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using static GeekDesk.Util.GlobalHotKey;
|
||||
|
||||
namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
@@ -28,9 +30,9 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
public partial class MotionControl : UserControl
|
||||
{
|
||||
public static bool hotkeyFinished = true; //热键设置结束
|
||||
private static KeyEventArgs prevKeyTemp; //上一个按键
|
||||
private static List<KeyEventArgs> keysTemp = new List<KeyEventArgs>();//存储一次快捷键集合
|
||||
private static AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
private KeyEventArgs prevKeyTemp; //上一个按键
|
||||
private readonly List<KeyEventArgs> keysTemp = new List<KeyEventArgs>();//存储一次快捷键集合
|
||||
private readonly AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
|
||||
public MotionControl()
|
||||
{
|
||||
@@ -212,14 +214,16 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
if (MainWindow.hotKeyId != -1)
|
||||
{
|
||||
Hotkey.UnRegist(new WindowInteropHelper(MainWindow.mainWindow).Handle, Hotkey.keymap[MainWindow.hotKeyId]);
|
||||
//Hotkey.UnRegist(new WindowInteropHelper(MainWindow.mainWindow).Handle, Hotkey.keymap[MainWindow.hotKeyId]);
|
||||
GlobalHotKey.Dispose(MainWindow.hotKeyId);
|
||||
}
|
||||
MainWindow.RegisterHotKey(false);
|
||||
} else
|
||||
{
|
||||
if (MainWindow.toDoHotKeyId != -1)
|
||||
{
|
||||
Hotkey.UnRegist(new WindowInteropHelper(MainWindow.toDoInfoWindow).Handle, Hotkey.keymap[MainWindow.toDoHotKeyId]);
|
||||
//Hotkey.UnRegist(new WindowInteropHelper(MainWindow.toDoInfoWindow).Handle, Hotkey.keymap[MainWindow.toDoHotKeyId]);
|
||||
GlobalHotKey.Dispose(MainWindow.toDoHotKeyId);
|
||||
}
|
||||
MainWindow.RegisterCreateToDoHotKey(false);
|
||||
}
|
||||
@@ -229,66 +233,43 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
}
|
||||
}
|
||||
|
||||
//private void ShowApp(MainWindow mainWindow)
|
||||
//{
|
||||
// if (appConfig.FollowMouse)
|
||||
// {
|
||||
// ShowAppAndFollowMouse(mainWindow);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// this.Visibility = Visibility.Visible;
|
||||
// }
|
||||
// Keyboard.Focus(this);
|
||||
//}
|
||||
/// <summary>
|
||||
/// 移动窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
Window.GetWindow(this).DragMove();
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 随鼠标位置显示面板 (鼠标始终在中间)
|
||||
///// </summary>
|
||||
//private void ShowAppAndFollowMouse(MainWindow mainWindow)
|
||||
//{
|
||||
// //获取鼠标位置
|
||||
// System.Windows.Point p = MouseUtil.GetMousePosition();
|
||||
// double left = SystemParameters.VirtualScreenLeft;
|
||||
// double top = SystemParameters.VirtualScreenTop;
|
||||
// double width = SystemParameters.VirtualScreenWidth;
|
||||
// double height = SystemParameters.VirtualScreenHeight;
|
||||
// double right = width - Math.Abs(left);
|
||||
// double bottom = height - Math.Abs(top);
|
||||
private void MarginHide_Changed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (appConfig.MarginHide)
|
||||
{
|
||||
MainWindow.hide.TimerSet();
|
||||
} else
|
||||
{
|
||||
if (MainWindow.hide.timer != null)
|
||||
{
|
||||
MainWindow.hide.TimerStop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if (p.X - mainWindow.Width / 2 < left)
|
||||
// {
|
||||
// //判断是否在最左边缘
|
||||
// mainWindow.Left = left;
|
||||
// }
|
||||
// else if (p.X + mainWindow.Width / 2 > right)
|
||||
// {
|
||||
// //判断是否在最右边缘
|
||||
// mainWindow.Left = right - mainWindow.Width;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// mainWindow.Left = p.X - mainWindow.Width / 2;
|
||||
// }
|
||||
|
||||
|
||||
// if (p.Y - mainWindow.Height / 2 < top)
|
||||
// {
|
||||
// //判断是否在最上边缘
|
||||
// mainWindow.Top = top;
|
||||
// }
|
||||
// else if (p.Y + mainWindow.Height / 2 > bottom)
|
||||
// {
|
||||
// //判断是否在最下边缘
|
||||
// mainWindow.Top = bottom - mainWindow.Height;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// mainWindow.Top = p.Y - mainWindow.Height / 2;
|
||||
// }
|
||||
|
||||
// mainWindow.Visibility = Visibility.Visible;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,32 +14,48 @@
|
||||
<UserControl.Resources>
|
||||
<cvt:UpdateTypeConvert x:Key="UpdateTypeConvert"/>
|
||||
</UserControl.Resources>
|
||||
<hc:SimplePanel Margin="20">
|
||||
<StackPanel >
|
||||
<TextBlock Text="程序设置" />
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,5,0,0">
|
||||
<CheckBox x:Name="SelfStartUpBox" Content="开机自启动" IsChecked="{Binding SelfStartUp}" Click="SelfStartUpBox_Click">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<TextBlock Text="更新源" Margin="0,20,0,0"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,5,0,0">
|
||||
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
<Grid MouseDown="DragMove" Background="AliceBlue">
|
||||
<hc:SimplePanel Margin="20" >
|
||||
<StackPanel >
|
||||
<TextBlock Text="程序设置" />
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,8,0,0">
|
||||
<CheckBox x:Name="SelfStartUpBox" Content="开机自启动" IsChecked="{Binding SelfStartUp}" Click="SelfStartUpBox_Click">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,6,0,0">
|
||||
<CheckBox Content="性能模式" IsChecked="{Binding PMModel}"
|
||||
hc:Poptip.HitMode="None"
|
||||
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
|
||||
hc:Poptip.Content="开启性能模式将取消图标动画效果"
|
||||
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">
|
||||
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="Gitee"
|
||||
hc:IconElement.Geometry="{StaticResource Gitee}"
|
||||
Foreground="#B32225"
|
||||
IsChecked="{Binding UpdateType, Mode=TwoWay, Converter={StaticResource UpdateTypeConvert}, ConverterParameter=1}"/>
|
||||
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
hc:IconElement.Geometry="{StaticResource GitHub}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="GitHub"
|
||||
Foreground="Black"
|
||||
IsChecked="{Binding UpdateType, Mode=TwoWay, Converter={StaticResource UpdateTypeConvert}, ConverterParameter=2}"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
</hc:SimplePanel>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
</hc:SimplePanel>
|
||||
</Grid>
|
||||
|
||||
|
||||
</UserControl>
|
||||
|
||||
@@ -33,5 +33,18 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
RegisterUtil.SetSelfStarting(appConfig.SelfStartUp, Constants.MY_NAME);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移动窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
Window.GetWindow(this).DragMove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,96 +7,134 @@
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
Background="AliceBlue"
|
||||
d:DesignHeight="380" d:DesignWidth="450">
|
||||
<hc:SimplePanel Margin="20">
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,0,-40,-12" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="背景图片" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="19,20,-59,-31.5" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="图片路径:" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding BacImgName}" Width="200"
|
||||
VerticalAlignment="Center"
|
||||
hc:Poptip.HitMode="None"
|
||||
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
|
||||
hc:Poptip.Content="{Binding BacImgName}"
|
||||
hc:Poptip.Placement="TopLeft"
|
||||
/>
|
||||
<Button Content="修改" Click="BGButton_Click"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="19,60,11,-36.433" Grid.ColumnSpan="4">
|
||||
<CheckBox x:Name="IconIsAdmin" Content="毛玻璃效果" IsChecked="{Binding BlurEffect}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:Divider LineStrokeDashArray="3,3" Margin="0,91.5,0,34.5" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
|
||||
<StackPanel Margin="0,30,0,0">
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,80,-40,-89.5" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="托盘不透明度" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,110,-40,-122" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding CardOpacity}"
|
||||
Maximum="100"
|
||||
Margin="0,-12,-313.5,19.5"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
d:DesignHeight="500" d:DesignWidth="450">
|
||||
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,135,-40,-161.626" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="背景图片不透明度" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,155,-40,-183" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding BgOpacity}"
|
||||
Maximum="100"
|
||||
Margin="0,0,-313.5,7.5"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
<Grid>
|
||||
<Grid MouseDown="DragMove" Background="AliceBlue">
|
||||
<StackPanel Margin="20" >
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="背景图片" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,0,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="图片路径:" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding BacImgName}" Width="200"
|
||||
VerticalAlignment="Center"
|
||||
hc:Poptip.HitMode="None"
|
||||
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
|
||||
hc:Poptip.Content="{Binding BacImgName}"
|
||||
hc:Poptip.Placement="TopLeft"
|
||||
/>
|
||||
<Button Content="修改" Click="BGButton_Click"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,0,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox x:Name="IconIsAdmin" Content="毛玻璃效果" IsChecked="{Binding BlurEffect}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
|
||||
<StackPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="托盘不透明度" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding CardOpacity}"
|
||||
Maximum="100"
|
||||
Width="350"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,195,-40,-208.813" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="主面板不透明度" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,215,-40,-241" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding PannelOpacity}"
|
||||
Minimum="50"
|
||||
Maximum="100"
|
||||
Margin="0,0,-313.5,7.5"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
<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">
|
||||
<hc:PreviewSlider Value="{Binding BgOpacity}"
|
||||
Maximum="100"
|
||||
Width="350"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,245,-40,-279.313" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="主面板圆角大小" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,265,-40,-321" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding PannelCornerRadius}"
|
||||
Maximum="25"
|
||||
Margin="0,0,-313.5,7.5"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<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">
|
||||
<hc:PreviewSlider Value="{Binding PannelOpacity}"
|
||||
Minimum="50"
|
||||
Maximum="100"
|
||||
Width="350"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<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">
|
||||
<hc:PreviewSlider Value="{Binding PannelCornerRadius}"
|
||||
Maximum="25"
|
||||
Width="350"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
<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"
|
||||
Background="#00FFFFFF"
|
||||
PreviewMouseLeftButtonDown="PreviewSlider_MouseLeftButtonUp"
|
||||
>
|
||||
<hc:PreviewSlider Value="{Binding ImageWidth, Mode=TwoWay}"
|
||||
Minimum="40"
|
||||
Maximum="60"
|
||||
Width="350"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock VerticalAlignment="Center" Text="图标字体颜色:" />
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding TextColor}" Width="100"/>
|
||||
<Button Content="选择" Click="ColorButton_Click"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<StackPanel x:Name="ColorPanel" Visibility="Collapsed" VerticalAlignment="Center">
|
||||
<StackPanel.Background>
|
||||
<SolidColorBrush Color="AliceBlue" Opacity="0"/>
|
||||
</StackPanel.Background>
|
||||
<hc:ColorPicker
|
||||
Name="ColorPicker"
|
||||
Canceled="ColorPicker_Canceled"
|
||||
SelectedColorChanged="ColorPicker_SelectedColorChanged"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</hc:SimplePanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -3,6 +3,7 @@ using GeekDesk.ViewModel;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -23,6 +24,8 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
/// </summary>
|
||||
public partial class ThemeControl : System.Windows.Controls.UserControl
|
||||
{
|
||||
|
||||
private static AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
public ThemeControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -35,8 +38,7 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
/// <param name="e"></param>
|
||||
private void BGButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog
|
||||
@@ -56,5 +58,70 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ColorButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ColorPanel.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void ColorPicker_Canceled(object sender, EventArgs e)
|
||||
{
|
||||
ColorPanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void ColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
|
||||
{
|
||||
SolidColorBrush scb = ColorPicker.SelectedBrush;
|
||||
appConfig.TextColor = scb.ToString();
|
||||
ColorPanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移动窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
Window.GetWindow(this).DragMove();
|
||||
}
|
||||
}
|
||||
|
||||
private void PreviewSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CheckButtonUpClass cbu = new CheckButtonUpClass
|
||||
{
|
||||
e = e
|
||||
};
|
||||
System.Threading.ThreadStart ts = new System.Threading.ThreadStart(cbu.CheckButtonUp);
|
||||
System.Threading.Thread t = new System.Threading.Thread(ts);
|
||||
t.Start();
|
||||
}
|
||||
|
||||
private class CheckButtonUpClass
|
||||
{
|
||||
public MouseButtonEventArgs e;
|
||||
|
||||
public void CheckButtonUp()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Released)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke((Action)(() =>
|
||||
{
|
||||
AppData appData = MainWindow.appData;
|
||||
ObservableCollection<IconInfo> selectIcons = appData.AppConfig.SelectedMenuIcons;
|
||||
appData.AppConfig.SelectedMenuIcons = null;
|
||||
appData.AppConfig.SelectedMenuIcons = selectIcons;
|
||||
}));
|
||||
return;
|
||||
}
|
||||
System.Threading.Thread.Sleep(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<!--左侧栏样式动画-->
|
||||
<Style x:Key="MenuStyle" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItemBaseStyle}">
|
||||
<Setter Property="FontSize" Value="15"/>
|
||||
<Setter Property="FontSize" Value="16"/>
|
||||
<Setter Property="Margin" Value="0,0,0,1"/>
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
@@ -30,8 +30,8 @@
|
||||
</MultiTrigger.Conditions>
|
||||
<MultiTrigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation To="15" Duration="0:0:0.5" Storyboard.TargetProperty="FontSize"/>
|
||||
<Storyboard Timeline.DesiredFrameRate="60">
|
||||
<DoubleAnimation To="16" Duration="0:0:0.2" Storyboard.TargetProperty="FontSize"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</MultiTrigger.EnterActions>
|
||||
@@ -43,9 +43,9 @@
|
||||
</BeginStoryboard>
|
||||
</MultiTrigger.ExitActions>
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<!--<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#FFE4DBDB"/>
|
||||
</Trigger>
|
||||
</Trigger>-->
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter Property="Background" Value="#FFECECEC"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
@@ -84,7 +84,7 @@
|
||||
SelectionChanged="menus_SelectionChanged"
|
||||
>
|
||||
<ListBox.Resources>
|
||||
<ContextMenu x:Key="menuDialog" Width="200">
|
||||
<ContextMenu x:Key="MenuDialog" Width="200">
|
||||
<MenuItem Header="新建菜单" Click="CreateMenu"/>
|
||||
<MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
|
||||
<MenuItem Header="修改图标" Click="EditMenuGeometry" Tag="{Binding}"/>
|
||||
@@ -94,7 +94,7 @@
|
||||
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MenuStyle}">
|
||||
<Setter Property="ContextMenu" Value="{StaticResource menuDialog}"/>
|
||||
<Setter Property="ContextMenu" Value="{StaticResource MenuDialog}"/>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.Background>
|
||||
@@ -103,27 +103,27 @@
|
||||
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="30" ItemsWidth="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}}" HorizontalAlignment="Center" VerticalAlignment="Top" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
|
||||
<DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="33" ItemsWidth="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}, ConverterParameter=10}" HorizontalAlignment="Center" VerticalAlignment="Top" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel MouseLeftButtonDown="MenuClick" MouseRightButtonDown="MenuClick" Tag="{Binding}">
|
||||
<StackPanel.Background>
|
||||
<SolidColorBrush Color="AliceBlue" Opacity="0.01"/>
|
||||
</StackPanel.Background>
|
||||
<hc:TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
|
||||
HorizontalAlignment="Left"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}}"
|
||||
FontSize="15"
|
||||
TextAlignment="Left"
|
||||
LostFocus="LostFocusOrEnterDown"
|
||||
KeyDown="LostFocusOrEnterDown"
|
||||
Tag="{Binding}"
|
||||
IsVisibleChanged="MenuEditWhenVisibilityChanged"
|
||||
Visibility="{Binding MenuEdit}"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<hc:TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
|
||||
HorizontalAlignment="Left"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}, ConverterParameter=35}"
|
||||
FontSize="16"
|
||||
Height="25"
|
||||
VerticalAlignment="Center"
|
||||
TextAlignment="Left"
|
||||
LostFocus="LostFocusOrEnterDown"
|
||||
KeyDown="LostFocusOrEnterDown"
|
||||
Tag="{Binding}"
|
||||
Margin="2"
|
||||
IsVisibleChanged="MenuEditWhenVisibilityChanged"
|
||||
Visibility="{Binding MenuEdit}"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Background="Transparent"
|
||||
BorderThickness="0"
|
||||
hc:IconElement.Geometry="{Binding MenuGeometry}"
|
||||
|
||||
@@ -11,43 +11,29 @@
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<!--右侧栏样式动画-->
|
||||
<Style x:Key="imageStyle" TargetType="Image">
|
||||
<Setter Property="Width" Value="{Binding ImageWidth}"/>
|
||||
<Setter Property="Height" Value="{Binding ImageHeight}"/>
|
||||
<Setter Property="Source" Value="{Binding BitmapImage}"/>
|
||||
<Style.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="True"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<MultiTrigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation To="80" Duration="0:0:0.001" Storyboard.TargetProperty="Width"/>
|
||||
<DoubleAnimation To="80" Duration="0:0:0.001" Storyboard.TargetProperty="Height"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</MultiTrigger.EnterActions>
|
||||
<MultiTrigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation To="60" Duration="0:0:0.5" Storyboard.TargetProperty="Width"/>
|
||||
<DoubleAnimation To="60" Duration="0:0:0.5" Storyboard.TargetProperty="Height"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</MultiTrigger.ExitActions>
|
||||
</MultiTrigger>
|
||||
</Style.Triggers>
|
||||
<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}"/>
|
||||
<Setter Property="Source" Value="{Binding BitmapImage}"/>
|
||||
</Style>
|
||||
<Style x:Key="MyListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
||||
<Border>
|
||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
|
||||
<cvt:OpcityConvert x:Key="OpcityConvert"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<!--右侧栏-->
|
||||
<hc:Card AllowDrop="True"
|
||||
Drop="Wrap_Drop"
|
||||
|
||||
BorderThickness="1"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
Margin="5,0,5,5" Grid.ColumnSpan="2">
|
||||
@@ -57,58 +43,76 @@
|
||||
<hc:Card.BorderBrush>
|
||||
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
|
||||
</hc:Card.BorderBrush>
|
||||
<hc:Card.ContextMenu>
|
||||
<ContextMenu Width="200">
|
||||
<MenuItem Header="添加URL项目" Click="AddUrlIcon"/>
|
||||
</ContextMenu>
|
||||
</hc:Card.ContextMenu>
|
||||
<WrapPanel Orientation="Horizontal">
|
||||
<ListBox x:Name="icons" ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=TwoWay}"
|
||||
<ListBox x:Name="IconListBox" ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=TwoWay}"
|
||||
BorderThickness="0"
|
||||
SelectionChanged="IconSelectionChanged "
|
||||
VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
>
|
||||
<ListBox.Background>
|
||||
<SolidColorBrush Opacity="0"/>
|
||||
</ListBox.Background>
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="115" ItemsWidth="100" HorizontalAlignment="Center" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
|
||||
<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}}}"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.Resources>
|
||||
<ContextMenu x:Key="iconDialog" Width="200">
|
||||
<ContextMenu x:Key="IconDialog" Width="200">
|
||||
<MenuItem Header="管理员方式运行" Click="IconAdminStart" Tag="{Binding}"/>
|
||||
<MenuItem Header="打开文件所在位置" Click="ShowInExplore" Tag="{Binding}"/>
|
||||
<MenuItem Header="资源管理器菜单" Click="MenuItem_Click" Tag="{Binding}"/>
|
||||
<MenuItem Header="添加URL项目" Click="AddUrlIcon"/>
|
||||
<MenuItem Header="资源管理器菜单" Click="SystemContextMenu" Tag="{Binding}"/>
|
||||
<MenuItem Header="属性" Click="PropertyConfig" Tag="{Binding}"/>
|
||||
<MenuItem Header="从列表移除" Click="RemoveIcon" Tag="{Binding}"/>
|
||||
</ContextMenu>
|
||||
</ListBox.Resources>
|
||||
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="ContextMenu" Value="{StaticResource iconDialog}"/>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MyListBoxItemStyle}">
|
||||
<Setter Property="ContextMenu" Value="{StaticResource IconDialog}"/>
|
||||
<!--<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelWidth, Mode=OneWay}"/>
|
||||
<Setter Property="Height" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelHeight, Mode=OneWay}"/>-->
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<!--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}"-->
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Tag="{Binding}"
|
||||
MouseLeftButtonUp="IconClick"
|
||||
<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"
|
||||
Margin="5,5,5,5"
|
||||
hc:Poptip.HitMode="None"
|
||||
hc:Poptip.HitMode="None"
|
||||
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
|
||||
hc:Poptip.Content="{Binding Content}"
|
||||
hc:Poptip.Content="{Binding Content}"
|
||||
hc:Poptip.Placement="BottomLeft"
|
||||
Background="#00FFFFFF"
|
||||
MouseLeftButtonUp="IconClick"
|
||||
MouseEnter="StackPanel_MouseEnter"
|
||||
MouseLeave="StackPanel_MouseLeave"
|
||||
>
|
||||
<Image Style="{StaticResource imageStyle}" />
|
||||
<Image Style="{StaticResource ImageStyle}"/>
|
||||
<TextBlock MaxWidth="80"
|
||||
MaxHeight="40"
|
||||
TextWrapping="Wrap"
|
||||
TextTrimming="WordEllipsis"
|
||||
TextAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Name}"/>
|
||||
|
||||
</StackPanel>
|
||||
Margin="0,5,0,0"
|
||||
MaxHeight="40"
|
||||
FontSize="13"
|
||||
TextWrapping="Wrap"
|
||||
TextTrimming="WordEllipsis"
|
||||
TextAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
||||
Text="{Binding Name}"/>
|
||||
</hc:SimpleStackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
@@ -3,6 +3,7 @@ using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Other;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -11,6 +12,7 @@ using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -18,6 +20,7 @@ using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
@@ -30,6 +33,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
public partial class RightCardControl : UserControl
|
||||
{
|
||||
private AppData appData = MainWindow.appData;
|
||||
|
||||
public RightCardControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -108,41 +112,62 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (!File.Exists(icon.Path) && !Directory.Exists(icon.Path))
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
|
||||
return;
|
||||
}
|
||||
|
||||
Process p = new Process();
|
||||
p.StartInfo.FileName = icon.Path;
|
||||
|
||||
switch (type)
|
||||
if (icon.IconType == IconType.OTHER)
|
||||
{
|
||||
case IconStartType.ADMIN_STARTUP:
|
||||
p.StartInfo.Arguments = "1";//启动参数
|
||||
p.StartInfo.Verb = "runas";
|
||||
p.StartInfo.CreateNoWindow = false; //设置显示窗口
|
||||
p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序启动进程
|
||||
p.StartInfo.ErrorDialog = false;
|
||||
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
|
||||
{
|
||||
Window parentWin = Window.GetWindow(this);
|
||||
parentWin.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
break;// c#好像不能case穿透
|
||||
case IconStartType.DEFAULT_STARTUP:
|
||||
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
|
||||
{
|
||||
Window parentWin = Window.GetWindow(this);
|
||||
parentWin.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
break;
|
||||
case IconStartType.SHOW_IN_EXPLORE:
|
||||
p.StartInfo.FileName = "Explorer.exe";
|
||||
p.StartInfo.Arguments = "/e,/select," + icon.Path;
|
||||
break;
|
||||
if (!File.Exists(icon.Path) && !Directory.Exists(icon.Path))
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
|
||||
return;
|
||||
}
|
||||
p.StartInfo.WorkingDirectory = icon.Path.Substring(0, icon.Path.LastIndexOf("\\"));
|
||||
switch (type)
|
||||
{
|
||||
case IconStartType.ADMIN_STARTUP:
|
||||
p.StartInfo.Arguments = "1";//启动参数
|
||||
p.StartInfo.Verb = "runas";
|
||||
p.StartInfo.CreateNoWindow = false; //设置显示窗口
|
||||
p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序启动进程
|
||||
p.StartInfo.ErrorDialog = false;
|
||||
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MainWindow.hide.IsMargin())
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
|
||||
}
|
||||
break;// c#好像不能case穿透
|
||||
case IconStartType.DEFAULT_STARTUP:
|
||||
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MainWindow.hide.IsMargin())
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
} else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IconStartType.SHOW_IN_EXPLORE:
|
||||
p.StartInfo.FileName = "Explorer.exe";
|
||||
p.StartInfo.Arguments = "/e,/select," + icon.Path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
p.Start();
|
||||
icon.Count++;
|
||||
@@ -154,15 +179,6 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// data选中事件 设置不可选中
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void IconSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (icons.SelectedIndex != -1) icons.SelectedIndex = -1;
|
||||
}
|
||||
|
||||
|
||||
private void Wrap_Drop(object sender, DragEventArgs e)
|
||||
@@ -173,16 +189,33 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
string path = (string)obj;
|
||||
|
||||
//string base64 = ImageUtil.FileImageToBase64(path, ImageFormat.Jpeg);
|
||||
//string base64 = ImageUtil.FileImageToBase64(path, ImageFormat.Png);
|
||||
|
||||
string ext = System.IO.Path.GetExtension(path).ToLower();
|
||||
|
||||
if (".lnk".Equals(ext))
|
||||
{
|
||||
string targetPath = FileUtil.GetTargetPathByLnk(path);
|
||||
if (targetPath!=null)
|
||||
{
|
||||
path = targetPath;
|
||||
}
|
||||
}
|
||||
|
||||
BitmapImage bi = ImageUtil.GetBitmapIconByPath(path);
|
||||
IconInfo iconInfo = new IconInfo
|
||||
{
|
||||
Path = path,
|
||||
BitmapImage = ImageUtil.GetBitmapIconByPath(path)
|
||||
BitmapImage = bi
|
||||
};
|
||||
iconInfo.DefaultImage = iconInfo.ImageByteArr;
|
||||
iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(path);
|
||||
if (StringUtil.IsEmpty(iconInfo.Name))
|
||||
{
|
||||
iconInfo.Name = path;
|
||||
}
|
||||
MainWindow.appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Add(iconInfo);
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,13 +229,16 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Remove((IconInfo)((MenuItem)sender).Tag);
|
||||
}
|
||||
|
||||
private void MenuItem_Click(object sender, RoutedEventArgs e)
|
||||
private void SystemContextMenu(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
|
||||
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("Explorer.exe");
|
||||
psi.Arguments = "/e,/select," + icon.Path;
|
||||
System.Diagnostics.Process.Start(psi);
|
||||
DirectoryInfo[] folders = new DirectoryInfo[1];
|
||||
folders[0] = new DirectoryInfo(icon.Path);
|
||||
ShellContextMenu scm = new ShellContextMenu();
|
||||
System.Drawing.Point p = System.Windows.Forms.Cursor.Position;
|
||||
p.X -= 80;
|
||||
p.Y -= 80;
|
||||
scm.ShowContextMenu(folders, p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -212,7 +248,165 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
/// <param name="e"></param>
|
||||
private void PropertyConfig(object sender, RoutedEventArgs e)
|
||||
{
|
||||
HandyControl.Controls.Dialog.Show(new IconInfoDialog((IconInfo)((MenuItem)sender).Tag));
|
||||
IconInfo info = (IconInfo)((MenuItem)sender).Tag;
|
||||
switch (info.IconType)
|
||||
{
|
||||
case IconType.URL:
|
||||
IconInfoUrlDialog urlDialog = new IconInfoUrlDialog(info);
|
||||
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog);
|
||||
break;
|
||||
default:
|
||||
IconInfoDialog dialog = new IconInfoDialog(info);
|
||||
dialog.dialog = HandyControl.Controls.Dialog.Show(dialog);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void StackPanel_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
||||
double width = appData.AppConfig.ImageWidth;
|
||||
double height = appData.AppConfig.ImageHeight;
|
||||
width += width * 0.15;
|
||||
height += height * 0.15;
|
||||
ImgStoryBoard(sender, (int)width, (int)height, 1, true);
|
||||
}
|
||||
|
||||
private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
ImgStoryBoard(sender, appData.AppConfig.ImageWidth, appData.AppConfig.ImageHeight, 220);
|
||||
}
|
||||
|
||||
|
||||
private void ImgStoryBoard(object sender, int height, int width, int milliseconds, bool checkRmStoryboard = false)
|
||||
{
|
||||
|
||||
if (appData.AppConfig.PMModel) return;
|
||||
|
||||
Panel sp = sender as Panel;
|
||||
|
||||
DependencyObject dos = sp.Parent;
|
||||
|
||||
Image img = sp.Children[0] as Image;
|
||||
|
||||
double afterHeight = img.Height;
|
||||
double afterWidth = img.Width;
|
||||
|
||||
//动画定义
|
||||
Storyboard myStoryboard = new Storyboard();
|
||||
|
||||
|
||||
|
||||
DoubleAnimation heightAnimation = new DoubleAnimation
|
||||
{
|
||||
From = afterHeight,
|
||||
To = height,
|
||||
Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds))
|
||||
};
|
||||
DoubleAnimation widthAnimation = new DoubleAnimation
|
||||
{
|
||||
From = afterWidth,
|
||||
To = width,
|
||||
Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds))
|
||||
};
|
||||
|
||||
|
||||
Timeline.SetDesiredFrameRate(heightAnimation, 60);
|
||||
Timeline.SetDesiredFrameRate(widthAnimation, 60);
|
||||
|
||||
Storyboard.SetTarget(widthAnimation, img);
|
||||
Storyboard.SetTargetProperty(widthAnimation, new PropertyPath("Width"));
|
||||
Storyboard.SetTarget(heightAnimation, img);
|
||||
Storyboard.SetTargetProperty(heightAnimation, new PropertyPath("Height"));
|
||||
|
||||
myStoryboard.Children.Add(heightAnimation);
|
||||
myStoryboard.Children.Add(widthAnimation);
|
||||
|
||||
CheckRemoveStoryboard crs = new CheckRemoveStoryboard
|
||||
{
|
||||
sb = myStoryboard,
|
||||
sp = sp,
|
||||
heightAnimation = heightAnimation,
|
||||
widthAnimation = widthAnimation,
|
||||
img = img,
|
||||
isMouseOver = !checkRmStoryboard
|
||||
};
|
||||
|
||||
heightAnimation.Completed += (s, e) =>
|
||||
{
|
||||
if (checkRmStoryboard)
|
||||
{
|
||||
ThreadStart ts = new ThreadStart(crs.Remove);
|
||||
System.Threading.Thread t = new System.Threading.Thread(ts);
|
||||
t.Start();
|
||||
} else
|
||||
{
|
||||
img.BeginAnimation(WidthProperty, null);
|
||||
img.BeginAnimation(HeightProperty, null);
|
||||
}
|
||||
};
|
||||
img.BeginAnimation(WidthProperty, widthAnimation);
|
||||
img.BeginAnimation(HeightProperty, heightAnimation);
|
||||
|
||||
//myStoryboard.Completed += (s, e) =>
|
||||
//{
|
||||
// if (checkRmStoryboard || true)
|
||||
// {
|
||||
// ThreadStart ts = new ThreadStart(crs.Remove);
|
||||
// System.Threading.Thread t = new System.Threading.Thread(ts);
|
||||
// t.Start();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// myStoryboard.Remove();
|
||||
// }
|
||||
//};
|
||||
//myStoryboard.Begin();
|
||||
}
|
||||
|
||||
private class CheckRemoveStoryboard
|
||||
{
|
||||
public Storyboard sb;
|
||||
public Panel sp;
|
||||
public Image img;
|
||||
public DoubleAnimation heightAnimation;
|
||||
public DoubleAnimation widthAnimation;
|
||||
public bool isMouseOver;
|
||||
public void Remove()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (sp.IsMouseOver == isMouseOver)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke((Action)(() =>
|
||||
{
|
||||
img.BeginAnimation(WidthProperty, null);
|
||||
img.BeginAnimation(HeightProperty, null);
|
||||
//heightAnimation.FillBehavior = FillBehavior.Stop;
|
||||
//widthAnimation.FillBehavior = FillBehavior.Stop;
|
||||
}));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Threading.Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveSB(Object sb)
|
||||
{
|
||||
Storyboard sb2 = sb as Storyboard;
|
||||
System.Threading.Thread.Sleep(500);
|
||||
sb2.Remove();
|
||||
}
|
||||
|
||||
private void AddUrlIcon(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IconInfoUrlDialog urlDialog = new IconInfoUrlDialog();
|
||||
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,18 @@ using System.Windows.Shapes;
|
||||
|
||||
namespace GeekDesk.Control.UserControls.Backlog
|
||||
{
|
||||
|
||||
public enum ToDoType
|
||||
{
|
||||
HISTORY = 1,
|
||||
NEW = 2
|
||||
}
|
||||
/// <summary>
|
||||
/// BacklogControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class TodoControl : UserControl
|
||||
{
|
||||
private AppData appData = MainWindow.appData;
|
||||
public ToDoType type;
|
||||
public TodoControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -37,7 +43,14 @@ namespace GeekDesk.Control.UserControls.Backlog
|
||||
{
|
||||
if (isConfirmed)
|
||||
{
|
||||
appData.ToDoList.Remove(info);
|
||||
if (type == ToDoType.NEW)
|
||||
{
|
||||
MainWindow.appData.ToDoList.Remove(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.appData.HiToDoList.Remove(info);
|
||||
}
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
</hc:SideMenu>
|
||||
</hc:Card>
|
||||
<hc:ScrollViewer Grid.Row="0" Grid.Column="1">
|
||||
<hc:Card x:Name="RightCard" Height="448" MouseDown="DragMove">
|
||||
<hc:Card x:Name="RightCard" Height="480">
|
||||
</hc:Card>
|
||||
</hc:ScrollViewer>
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace GeekDesk.Control.Windows
|
||||
/// </summary>
|
||||
public partial class ConfigWindow
|
||||
{
|
||||
private static AboutControl about = new AboutControl();
|
||||
private static ThemeControl theme = new ThemeControl();
|
||||
private static MotionControl motion = new MotionControl();
|
||||
private static OtherControl other = new OtherControl();
|
||||
private static readonly AboutControl about = new AboutControl();
|
||||
private static readonly ThemeControl theme = new ThemeControl();
|
||||
private static readonly MotionControl motion = new MotionControl();
|
||||
private static readonly OtherControl other = new OtherControl();
|
||||
public MainWindow mainWindow;
|
||||
|
||||
private ConfigWindow(AppConfig appConfig, MainWindow mainWindow)
|
||||
@@ -31,18 +31,7 @@ namespace GeekDesk.Control.Windows
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 移动窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
DragMove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 点击关闭按钮
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
using System.Windows.Input;
|
||||
|
||||
using static GeekDesk.Util.ShowWindowFollowMouse;
|
||||
|
||||
namespace GeekDesk.Control.Windows
|
||||
{
|
||||
@@ -132,6 +132,7 @@ namespace GeekDesk.Control.Windows
|
||||
window = new IconfontWindow(listInfo, menuInfo);
|
||||
}
|
||||
window.Show();
|
||||
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
private void CustomButton_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
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:cvt="clr-namespace:GeekDesk.Converts"
|
||||
xmlns:local="clr-namespace:GeekDesk"
|
||||
mc:Ignorable="d"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Height="670"
|
||||
Height="700"
|
||||
Width="450"
|
||||
Title="TaskInfo"
|
||||
WindowStyle="None"
|
||||
@@ -15,7 +16,7 @@
|
||||
Background="Transparent" ShowInTaskbar="False"
|
||||
>
|
||||
<Window.Resources>
|
||||
|
||||
<cvt:TodoTaskExecConvert x:Key="TodoTaskExecConvert"/>
|
||||
</Window.Resources>
|
||||
<Border CornerRadius="3" BorderThickness="2" BorderBrush="Black" Margin="0,0,0,313.323" MouseDown="DragMove">
|
||||
<Border.Background>
|
||||
@@ -23,48 +24,72 @@
|
||||
</Border.Background>
|
||||
<Border.Resources>
|
||||
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
|
||||
<Setter Property="Width" Value="65"/>
|
||||
<Setter Property="Width" Value="67"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="TextAlignment" Value="Center"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
</Style>
|
||||
</Border.Resources>
|
||||
<Grid Margin="0,0,0,8">
|
||||
<hc:SimplePanel Margin="20" HorizontalAlignment="Center">
|
||||
<StackPanel Margin="20" HorizontalAlignment="Center">
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<WrapPanel>
|
||||
<WrapPanel VerticalAlignment="Center">
|
||||
<TextBlock Text="待办任务:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBlock Text="*" Foreground="Red" />
|
||||
</WrapPanel>
|
||||
<TextBox x:Name="Title" Width="290" FontSize="14" />
|
||||
<TextBox x:Name="Title" Width="290" Text="{Binding Title, Mode=OneWay}" FontSize="14" />
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,48.997,0,-48.997">
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
|
||||
<TextBlock Text="待办详情:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBox x:Name="Msg" TextWrapping="Wrap"
|
||||
Margin="5,0,0,0"
|
||||
Text="{Binding Msg, Mode=OneWay}"
|
||||
AcceptsReturn="True"
|
||||
VerticalScrollBarVisibility="Visible"
|
||||
Height="100" MaxHeight="150" MinHeight="100" Width="290" MinWidth="290"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,167.622,0,-167.622">
|
||||
<TextBlock Text="待办时间*:" Style="{StaticResource LeftTB}"/>
|
||||
<hc:DateTimePicker x:Name="ExeTime" ErrorStr="test" Width="200"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
|
||||
<TextBlock Text="运行方式:" Style="{StaticResource LeftTB}"/>
|
||||
<RadioButton Margin="10,0,0,0" Checked="ExecType_Checked" Tag="1" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="指定时间"
|
||||
IsChecked="{Binding ExecType, Mode=OneWay, Converter={StaticResource TodoTaskExecConvert}, ConverterParameter=1}"/>
|
||||
<RadioButton Margin="10,0,0,0" Checked="ExecType_Checked" Background="{DynamicResource SecondaryRegionBrush}" Tag="2"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="CRON表达式"
|
||||
IsChecked="{Binding ExecType, Mode=OneWay, Converter={StaticResource TodoTaskExecConvert}, ConverterParameter=2}"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,228,0,-228">
|
||||
<hc:UniformSpacingPanel x:Name="SetTimePanel" Visibility="Visible" Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
|
||||
<TextBlock Text="指定时间:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBlock Text="*" Foreground="Red" Margin="-10,0,0,0"/>
|
||||
<hc:DateTimePicker x:Name="ExeTime" Text="{Binding ExeTime, Mode=OneWay}" ErrorStr="Error!" Width="200" Margin="-5.2,0,0,0"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel x:Name="CronPanel" Visibility="Collapsed" Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
|
||||
<WrapPanel VerticalAlignment="Center">
|
||||
<TextBlock Text="CRON:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBlock Text="*" Foreground="Red" />
|
||||
</WrapPanel>
|
||||
<TextBox x:Name="Cron" Width="290" Text="{Binding Cron, Mode=OneWay}" FontSize="14" />
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
|
||||
<TextBlock Text="完成时间:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBlock x:Name="DoneTime" Width="200"/>
|
||||
<TextBlock x:Name="DoneTime" Text="{Binding DoneTime, Mode=OneWay}" Width="200"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,273.333,0,-93.333" Grid.ColumnSpan="4">
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
<Button Content="保存" Background="#5BC0DE"
|
||||
Foreground="White" Margin="320,6,-208,-10"
|
||||
Click="Save_Button_Click"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</hc:SimplePanel>
|
||||
</StackPanel>
|
||||
<Button Panel.ZIndex="2" Width="22" Height="22" Click="Close_Button_Click" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0"/>
|
||||
<StackPanel hc:Growl.GrowlParent="True" VerticalAlignment="Top" Margin="0,10,10,0"/>
|
||||
</Grid>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Controls;
|
||||
using Quartz;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -29,23 +31,28 @@ namespace GeekDesk.Control.Windows
|
||||
|
||||
private AppData appData = MainWindow.appData;
|
||||
|
||||
private ToDoInfo info;
|
||||
//private ToDoInfo info;
|
||||
|
||||
private ToDoInfoWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
ExeTime.SelectedDateTime = DateTime.Now.AddMinutes(10);
|
||||
|
||||
this.Topmost = true;
|
||||
ExeTime.SelectedDateTime = DateTime.Now.AddMinutes(10);
|
||||
SetTimePanel.Visibility = Visibility.Visible;
|
||||
this.DataContext = new ToDoInfo();
|
||||
}
|
||||
private ToDoInfoWindow(ToDoInfo info)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Topmost = true;
|
||||
Title.Text = info.Title;
|
||||
Msg.Text = info.Msg;
|
||||
ExeTime.Text = info.ExeTime;
|
||||
DoneTime.Text = info.DoneTime;
|
||||
this.info = info;
|
||||
this.DataContext = info;
|
||||
SetTimePanel.Visibility = Visibility.Visible;
|
||||
//Title.Text = info.Title;
|
||||
//Msg.Text = info.Msg;
|
||||
//ExeTime.Text = info.ExeTime;
|
||||
//DoneTime.Text = info.DoneTime;
|
||||
//this.info = info;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,42 +86,89 @@ namespace GeekDesk.Control.Windows
|
||||
/// <param name="e"></param>
|
||||
private void Save_Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
if (Title.Text.Trim() == "" || ExeTime.Text.Trim() == "")
|
||||
DateTime dt;
|
||||
string execTime;
|
||||
TodoTaskExecType execType;
|
||||
if (Title.Text.Trim() == "")
|
||||
{
|
||||
Growl.Warning("任务标题 和 待办时间不能为空!");
|
||||
Growl.Warning("任务标题不能为空!");
|
||||
return;
|
||||
} else
|
||||
{
|
||||
try
|
||||
if (SetTimePanel.Visibility == Visibility.Visible)
|
||||
{
|
||||
Convert.ToDateTime(ExeTime.Text);
|
||||
} catch (Exception)
|
||||
{
|
||||
Growl.Warning("请输入正确的时间!");
|
||||
return;
|
||||
execType = TodoTaskExecType.SET_TIME;
|
||||
if (ExeTime.Text.Trim() == "")
|
||||
{
|
||||
Growl.Warning("执行时间不能为空!");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
dt = Convert.ToDateTime(ExeTime.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Growl.Warning("请输入正确的时间!");
|
||||
return;
|
||||
}
|
||||
execTime = ExeTime.Text;
|
||||
} else {
|
||||
execType = TodoTaskExecType.CRON;
|
||||
if (Cron.Text.Trim() == "")
|
||||
{
|
||||
Growl.Warning("Cron表达式不能为空!");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
bool isValid = CronExpression.IsValidExpression(Cron.Text);
|
||||
if (!isValid) throw new Exception();
|
||||
} catch (Exception)
|
||||
{
|
||||
Growl.Warning("请输入正确的Cron表达式!");
|
||||
return;
|
||||
}
|
||||
CronExpression exp = new CronExpression(Cron.Text);
|
||||
DateTime dd = DateTime.Now;
|
||||
DateTimeOffset ddo = DateTime.SpecifyKind(dd, DateTimeKind.Local);
|
||||
ddo = (DateTimeOffset)exp.GetNextValidTimeAfter(ddo);
|
||||
execTime = ddo.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
}
|
||||
if (windowType == NEW_TODO)
|
||||
dt = Convert.ToDateTime(execTime);
|
||||
ToDoInfo info = new ToDoInfo
|
||||
{
|
||||
info = new ToDoInfo
|
||||
{
|
||||
Title = Title.Text,
|
||||
Msg = Msg.Text,
|
||||
ExeTime = ExeTime.Text
|
||||
};
|
||||
appData.ToDoList.Add(info);
|
||||
Title = Title.Text,
|
||||
Msg = Msg.Text,
|
||||
ExeTime = execTime,
|
||||
ExecType = execType,
|
||||
Cron = Cron.Text
|
||||
};
|
||||
if (windowType != NEW_TODO)
|
||||
{
|
||||
appData.HiToDoList.Remove(this.DataContext as ToDoInfo);
|
||||
}
|
||||
appData.ToDoList.Add(info);
|
||||
|
||||
DateTime dtNow = DateTime.Now;
|
||||
TimeSpan ts = dt.Subtract(dtNow);
|
||||
int minutes = (int)Math.Ceiling(ts.TotalMinutes);
|
||||
if (minutes < 0)
|
||||
{
|
||||
minutes = 0;
|
||||
}
|
||||
if (minutes > 60)
|
||||
{
|
||||
int m = minutes % 60;
|
||||
int h = minutes / 60;
|
||||
Growl.SuccessGlobal("设置待办任务成功, 系统将在 " + h + " 小时零 " + m + " 分钟后提醒您!");
|
||||
|
||||
} else
|
||||
{
|
||||
int index =appData.ToDoList.IndexOf(info);
|
||||
appData.ToDoList.Remove(info);
|
||||
info.Title = Title.Text;
|
||||
info.Msg = Msg.Text;
|
||||
info.ExeTime = ExeTime.Text;
|
||||
info.DoneTime = DoneTime.Text;
|
||||
appData.ToDoList.Insert(index, info);
|
||||
Growl.SuccessGlobal("设置待办任务成功, 系统将在 " + minutes + " 分钟后提醒您!");
|
||||
}
|
||||
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
this.Close();
|
||||
}
|
||||
@@ -131,6 +185,18 @@ namespace GeekDesk.Control.Windows
|
||||
window.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
public static void ShowOrHide()
|
||||
{
|
||||
if (window == null || !window.Activate())
|
||||
{
|
||||
window = new ToDoInfoWindow();
|
||||
window.Show();
|
||||
} else
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static System.Windows.Window GetThis()
|
||||
{
|
||||
@@ -154,5 +220,21 @@ namespace GeekDesk.Control.Windows
|
||||
windowType = DETAIL_TODO;
|
||||
window2.Show();
|
||||
}
|
||||
|
||||
private void ExecType_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TodoTaskExecType tag = (TodoTaskExecType)Convert.ToInt32((sender as RadioButton).Tag.ToString());
|
||||
switch (tag)
|
||||
{
|
||||
case TodoTaskExecType.SET_TIME:
|
||||
SetTimePanel.Visibility = Visibility.Visible;
|
||||
CronPanel.Visibility = Visibility.Collapsed;
|
||||
break;
|
||||
default:
|
||||
CronPanel.Visibility = Visibility.Visible;
|
||||
SetTimePanel.Visibility = Visibility.Collapsed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,9 +64,11 @@ namespace GeekDesk.Control.Windows
|
||||
{
|
||||
case "History":
|
||||
backlog.BacklogList.ItemsSource = appData.HiToDoList;
|
||||
backlog.type = ToDoType.HISTORY;
|
||||
break;
|
||||
default:
|
||||
backlog.BacklogList.ItemsSource = appData.ToDoList;
|
||||
backlog.type = ToDoType.NEW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ namespace GeekDesk.Converts
|
||||
{
|
||||
if (value != null && value.ToString().Length > 0)
|
||||
{
|
||||
return System.Convert.ToDouble(value.ToString()) - 10d;
|
||||
if (parameter == null) parameter = 0.00;
|
||||
double p = System.Convert.ToDouble(parameter.ToString());
|
||||
return System.Convert.ToDouble(value.ToString()) - p;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
29
Converts/TodoTaskExecConvert.cs
Normal file
29
Converts/TodoTaskExecConvert.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using GeekDesk.Constant;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace GeekDesk.Converts
|
||||
{
|
||||
public class TodoTaskExecConvert : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return (TodoTaskExecType)value == (TodoTaskExecType)int.Parse(parameter.ToString());
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
bool isChecked = (bool)value;
|
||||
if (!isChecked)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (TodoTaskExecType)int.Parse(parameter.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -59,16 +60,41 @@
|
||||
<Reference Include="HandyControl, Version=3.1.0.0, Culture=neutral, PublicKeyToken=45be8712787a1e5b, processorArchitecture=MSIL">
|
||||
<HintPath>packages\HandyControl.3.1.0\lib\net472\HandyControl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Quartz, Version=3.3.3.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Quartz.3.3.3\lib\net472\Quartz.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Drawing.Common, Version=4.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Drawing.Common.6.0.0-preview.3.21201.4\lib\net461\System.Drawing.Common.dll</HintPath>
|
||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Diagnostics.DiagnosticSource.4.7.1\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<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.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>
|
||||
<Reference Include="System.Numerics" />
|
||||
<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.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.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@@ -92,9 +118,11 @@
|
||||
<Compile Include="Command\DelegateCommandBase.cs" />
|
||||
<Compile Include="Constant\AppHideType.cs" />
|
||||
<Compile Include="Constant\Constants.cs" />
|
||||
<Compile Include="Constant\MainWindowEnum.cs" />
|
||||
<Compile Include="Constant\IconType.cs" />
|
||||
<Compile Include="Constant\CommonEnum.cs" />
|
||||
<Compile Include="Constant\IconStartType.cs" />
|
||||
<Compile Include="Constant\SortType.cs" />
|
||||
<Compile Include="Constant\TodoTaskExecType.cs" />
|
||||
<Compile Include="Constant\UpdateType.cs" />
|
||||
<Compile Include="Control\Other\BacklogNotificatin.xaml.cs">
|
||||
<DependentUpon>BacklogNotificatin.xaml</DependentUpon>
|
||||
@@ -102,6 +130,9 @@
|
||||
<Compile Include="Control\Other\CustomIconUrlDialog.xaml.cs">
|
||||
<DependentUpon>CustomIconUrlDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Control\Other\IconInfoUrlDialog.xaml.cs">
|
||||
<DependentUpon>IconInfoUrlDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Control\UserControls\Config\OtherControl.xaml.cs">
|
||||
<DependentUpon>OtherControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -123,9 +154,6 @@
|
||||
<Compile Include="Control\Other\IconInfoDialog.xaml.cs">
|
||||
<DependentUpon>IconInfoDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Control\Other\MenuGeometryDialog.xaml.cs">
|
||||
<DependentUpon>MenuGeometryDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Control\UserControls\Config\AboutControl.xaml.cs">
|
||||
<DependentUpon>AboutControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -148,6 +176,7 @@
|
||||
<DependentUpon>UpdateWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Converts\DoubleToGridLength.cs" />
|
||||
<Compile Include="Converts\TodoTaskExecConvert.cs" />
|
||||
<Compile Include="Converts\IntToCornerRadius.cs" />
|
||||
<Compile Include="Converts\OpcityConvert.cs" />
|
||||
<Compile Include="Converts\UpdateTypeConvert.cs" />
|
||||
@@ -157,11 +186,13 @@
|
||||
<Compile Include="Task\ToDoTask.cs" />
|
||||
<Compile Include="Thread\UpdateThread.cs" />
|
||||
<Compile Include="Util\AeroGlassHelper.cs" />
|
||||
<Compile Include="Util\GlobalHotKey.cs" />
|
||||
<Compile Include="Util\CommonCode.cs" />
|
||||
<Compile Include="Util\ConsoleManager.cs" />
|
||||
<Compile Include="Util\DragAdorner.cs" />
|
||||
<Compile Include="Util\FileIcon.cs" />
|
||||
<Compile Include="Util\HotKey.cs" />
|
||||
<Compile Include="Util\FileUtil.cs" />
|
||||
<Compile Include="Util\MarginHide.cs" />
|
||||
<Compile Include="Util\HttpUtil.cs" />
|
||||
<Compile Include="Util\ImageUtil.cs" />
|
||||
<Compile Include="Util\ListViewDragDropManager.cs" />
|
||||
@@ -169,9 +200,10 @@
|
||||
<Compile Include="Util\MouseUtil.cs" />
|
||||
<Compile Include="Util\MouseUtilities.cs" />
|
||||
<Compile Include="Util\RegisterUtil.cs" />
|
||||
<Compile Include="Util\ShellContextMenu.cs" />
|
||||
<Compile Include="Util\ShowWindowFollowMouse.cs" />
|
||||
<Compile Include="Util\StringUtil.cs" />
|
||||
<Compile Include="Util\SvgToGeometry.cs" />
|
||||
<Compile Include="Util\SystemIcon.cs" />
|
||||
<Compile Include="ViewModel\AppConfig.cs" />
|
||||
<Compile Include="ViewModel\AppData.cs" />
|
||||
<Compile Include="ViewModel\ToDoInfo.cs" />
|
||||
@@ -186,6 +218,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Control\Other\IconInfoUrlDialog.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Control\UserControls\Config\OtherControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -214,10 +250,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Control\Other\MenuGeometryDialog.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Control\UserControls\Config\AboutControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -312,5 +344,16 @@
|
||||
<ItemGroup>
|
||||
<Resource Include="Taskbar.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<COMReference Include="IWshRuntimeLibrary">
|
||||
<Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
2
LICENSE.md
Normal file
2
LICENSE.md
Normal file
@@ -0,0 +1,2 @@
|
||||
- 这是个人开发的程序,任何人可任意修改和免费使用(未做较大功能性改动不允许修改赞赏码,重新修改发布需注明出处)
|
||||
- 商用需联系作者
|
||||
@@ -14,10 +14,12 @@
|
||||
d:DesignHeight="500" d:DesignWidth="700"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Background="#00FFFFFF"
|
||||
OpacityMask ="White"
|
||||
Deactivated="window_Deactivated"
|
||||
SizeChanged="window_SizeChanged"
|
||||
ShowInTaskbar="False"
|
||||
Opacity="0"
|
||||
Deactivated="Window_Deactivated"
|
||||
SizeChanged="Window_SizeChanged"
|
||||
>
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="0" ResizeBorderThickness="10"/>
|
||||
@@ -114,7 +116,9 @@
|
||||
<ContextMenu Width="130">
|
||||
<MenuItem Header="打开面板" Click="ShowApp"/>
|
||||
<MenuItem Header="待办" Click="BacklogMenuClick"/>
|
||||
<MenuItem Header="程序目录" Click="OpenThisDir"/>
|
||||
<MenuItem Header="设置" Click="ConfigApp"/>
|
||||
<MenuItem Header="重启" Click="ReStartApp"/>
|
||||
<MenuItem Header="退出" Click="ExitApp"/>
|
||||
</ContextMenu>
|
||||
</hc:NotifyIcon.ContextMenu>
|
||||
|
||||
@@ -18,6 +18,8 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using static GeekDesk.Util.ShowWindowFollowMouse;
|
||||
|
||||
namespace GeekDesk
|
||||
{
|
||||
@@ -34,6 +36,7 @@ namespace GeekDesk
|
||||
public static int hotKeyId = -1;
|
||||
public static int toDoHotKeyId = -1;
|
||||
public static MainWindow mainWindow;
|
||||
public static MarginHide hide;
|
||||
public MainWindow()
|
||||
{
|
||||
LoadData();
|
||||
@@ -43,6 +46,13 @@ namespace GeekDesk
|
||||
this.Loaded += Window_Loaded;
|
||||
this.SizeChanged += MainWindow_Resize;
|
||||
ToDoTask.BackLogCheck();
|
||||
|
||||
////实例化隐藏 Hide类,进行时间timer设置
|
||||
hide = new MarginHide(this);
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
hide.TimerSet();
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
@@ -62,13 +72,19 @@ namespace GeekDesk
|
||||
{
|
||||
if (!appData.AppConfig.StartedShowPanel)
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
if (appData.AppConfig.AppAnimation)
|
||||
{
|
||||
this.Opacity = 0;
|
||||
} else
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
} else
|
||||
{
|
||||
ShowApp();
|
||||
}
|
||||
RegisterHotKey(true);
|
||||
//RegisterCreateToDoHotKey(true);
|
||||
RegisterCreateToDoHotKey(true);
|
||||
|
||||
if (!appData.AppConfig.SelfStartUped)
|
||||
{
|
||||
@@ -87,18 +103,18 @@ namespace GeekDesk
|
||||
{
|
||||
if (appData.AppConfig.HotkeyModifiers != 0)
|
||||
{
|
||||
//加载完毕注册热键
|
||||
hotKeyId = Hotkey.Regist(new WindowInteropHelper(MainWindow.mainWindow).Handle, appData.AppConfig.HotkeyModifiers, appData.AppConfig.Hotkey, () =>
|
||||
|
||||
hotKeyId = GlobalHotKey.RegisterHotKey(appData.AppConfig.HotkeyModifiers, appData.AppConfig.Hotkey, () =>
|
||||
{
|
||||
if (MotionControl.hotkeyFinished)
|
||||
{
|
||||
if (mainWindow.Visibility == Visibility.Collapsed)
|
||||
if (mainWindow.Visibility == Visibility.Collapsed || mainWindow.Opacity == 0)
|
||||
{
|
||||
ShowApp();
|
||||
}
|
||||
else
|
||||
{
|
||||
mainWindow.Visibility = Visibility.Collapsed;
|
||||
HideApp();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -122,6 +138,39 @@ namespace GeekDesk
|
||||
}
|
||||
}
|
||||
|
||||
public static void FadeStoryBoard(int opacity, int milliseconds, Visibility visibility)
|
||||
{
|
||||
if (appData.AppConfig.AppAnimation)
|
||||
{
|
||||
DoubleAnimation opacityAnimation = new DoubleAnimation
|
||||
{
|
||||
From = mainWindow.Opacity,
|
||||
To = opacity,
|
||||
Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds))
|
||||
};
|
||||
opacityAnimation.Completed += (s, e) =>
|
||||
{
|
||||
mainWindow.BeginAnimation(OpacityProperty, null);
|
||||
if (visibility == Visibility.Visible)
|
||||
{
|
||||
mainWindow.Opacity = 1;
|
||||
} else
|
||||
{
|
||||
mainWindow.Opacity = 0;
|
||||
}
|
||||
};
|
||||
Timeline.SetDesiredFrameRate(opacityAnimation, 30);
|
||||
mainWindow.BeginAnimation(OpacityProperty, opacityAnimation);
|
||||
} else
|
||||
{
|
||||
//防止关闭动画后 窗体仍是0透明度
|
||||
mainWindow.Opacity = 1;
|
||||
mainWindow.Visibility = visibility;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册新建待办的热键
|
||||
/// </summary>
|
||||
@@ -129,14 +178,15 @@ namespace GeekDesk
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (appData.AppConfig.ToDoHotkeyModifiers!=0)
|
||||
{
|
||||
//加载完毕注册热键
|
||||
toDoHotKeyId = Hotkey.Regist(new WindowInteropHelper(MainWindow.mainWindow).Handle, appData.AppConfig.ToDoHotkeyModifiers, appData.AppConfig.ToDoHotkey, () =>
|
||||
toDoHotKeyId = GlobalHotKey.RegisterHotKey(appData.AppConfig.ToDoHotkeyModifiers, appData.AppConfig.ToDoHotkey, () =>
|
||||
{
|
||||
if (MotionControl.hotkeyFinished)
|
||||
{
|
||||
ToDoInfoWindow.ShowNone();
|
||||
ToDoInfoWindow.ShowOrHide();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -158,22 +208,6 @@ namespace GeekDesk
|
||||
}
|
||||
}
|
||||
|
||||
//private void DisplayWindowHotKeyPress(object sender, KeyPressedEventArgs e)
|
||||
//{
|
||||
// if (e.HotKey.Key == Key.Y)
|
||||
// {
|
||||
// if (this.Visibility == Visibility.Collapsed)
|
||||
// {
|
||||
// ShowApp();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// this.Visibility = Visibility.Collapsed;
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
|
||||
void MainWindow_Resize(object sender, System.EventArgs e)
|
||||
{
|
||||
@@ -230,7 +264,13 @@ namespace GeekDesk
|
||||
/// <param name="e"></param>
|
||||
private void CloseButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
if (appData.AppConfig.AppAnimation)
|
||||
{
|
||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
||||
} else
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -260,64 +300,20 @@ namespace GeekDesk
|
||||
{
|
||||
if (appData.AppConfig.FollowMouse)
|
||||
{
|
||||
ShowAppAndFollowMouse();
|
||||
} else
|
||||
{
|
||||
mainWindow.Visibility = Visibility.Visible;
|
||||
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0, false);
|
||||
}
|
||||
FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
|
||||
Keyboard.Focus(mainWindow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 随鼠标位置显示面板 (鼠标始终在中间)
|
||||
/// </summary>
|
||||
private static void ShowAppAndFollowMouse()
|
||||
public static void HideApp()
|
||||
{
|
||||
//获取鼠标位置
|
||||
System.Windows.Point p = MouseUtil.GetMousePosition();
|
||||
double left = SystemParameters.VirtualScreenLeft;
|
||||
double top = SystemParameters.VirtualScreenTop;
|
||||
double width = SystemParameters.VirtualScreenWidth;
|
||||
double height = SystemParameters.VirtualScreenHeight;
|
||||
double right = width - Math.Abs(left);
|
||||
double bottom = height - Math.Abs(top);
|
||||
|
||||
|
||||
if (p.X - mainWindow.Width / 2 < left)
|
||||
{
|
||||
//判断是否在最左边缘
|
||||
mainWindow.Left = left;
|
||||
}
|
||||
else if (p.X + mainWindow.Width / 2 > right)
|
||||
{
|
||||
//判断是否在最右边缘
|
||||
mainWindow.Left = right - mainWindow.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
mainWindow.Left = p.X - mainWindow.Width / 2;
|
||||
}
|
||||
|
||||
|
||||
if (p.Y - mainWindow.Height / 2 < top)
|
||||
{
|
||||
//判断是否在最上边缘
|
||||
mainWindow.Top = top;
|
||||
}
|
||||
else if (p.Y + mainWindow.Height / 2 > bottom)
|
||||
{
|
||||
//判断是否在最下边缘
|
||||
mainWindow.Top = bottom - mainWindow.Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
mainWindow.Top = p.Y - mainWindow.Height / 2;
|
||||
}
|
||||
|
||||
mainWindow.Visibility = Visibility.Visible;
|
||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 图片图标单击事件
|
||||
/// </summary>
|
||||
@@ -325,13 +321,13 @@ namespace GeekDesk
|
||||
/// <param name="e"></param>
|
||||
private void NotifyIcon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.Visibility == Visibility.Collapsed)
|
||||
if (this.Visibility == Visibility.Collapsed || this.Opacity == 0)
|
||||
{
|
||||
ShowApp();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
HideApp();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,6 +341,20 @@ namespace GeekDesk
|
||||
ConfigWindow.Show(appData.AppConfig, this);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 右键任务栏图标打开程序目录
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OpenThisDir(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Process p = new Process();
|
||||
p.StartInfo.FileName = "Explorer.exe";
|
||||
p.StartInfo.Arguments = "/e,/select," + Constants.APP_DIR + Constants.MY_NAME + ".exe";
|
||||
p.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右键任务栏图标退出
|
||||
/// </summary>
|
||||
@@ -357,17 +367,6 @@ namespace GeekDesk
|
||||
|
||||
|
||||
|
||||
//public static void ShowContextMenu(IntPtr hAppWnd, Window taskBar, System.Windows.Point pt)
|
||||
//{
|
||||
// WindowInteropHelper helper = new WindowInteropHelper(taskBar);
|
||||
// IntPtr callingTaskBarWindow = helper.Handle;
|
||||
// IntPtr wMenu = GetSystemMenu(hAppWnd, false);
|
||||
// // Display the menu
|
||||
// uint command = TrackPopupMenuEx(wMenu, TPM.LEFTBUTTON | TPM.RETURNCMD, (int) pt.X, (int) pt.Y, callingTaskBarWindow, IntPtr.Zero);
|
||||
// if (command == 0) return;
|
||||
// PostMessage(hAppWnd, WM.SYSCOMMAND, new IntPtr(command), IntPtr.Zero);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 设置图标
|
||||
/// </summary>
|
||||
@@ -410,11 +409,15 @@ namespace GeekDesk
|
||||
{
|
||||
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS)
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide && !hide.IsMargin())
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void window_Deactivated(object sender, EventArgs e)
|
||||
private void Window_Deactivated(object sender, EventArgs e)
|
||||
{
|
||||
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS)
|
||||
{
|
||||
@@ -422,7 +425,7 @@ namespace GeekDesk
|
||||
}
|
||||
}
|
||||
|
||||
private void window_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
if (this.DataContext != null)
|
||||
{
|
||||
@@ -431,6 +434,20 @@ namespace GeekDesk
|
||||
appData.AppConfig.WindowHeight = this.Height;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重启
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ReStartApp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Process p = new Process();
|
||||
p.StartInfo.FileName = Constants.APP_DIR + Constants.MY_NAME + ".exe";
|
||||
p.StartInfo.WorkingDirectory = Constants.APP_DIR;
|
||||
p.Start();
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,5 +49,5 @@ using System.Windows;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0")]
|
||||
[assembly: AssemblyFileVersion("1.0")]
|
||||
[assembly: AssemblyVersion("2.3.1.0")]
|
||||
[assembly: AssemblyFileVersion("2.3.1.0")]
|
||||
|
||||
14
README.md
14
README.md
@@ -1,5 +1,5 @@
|
||||
# GeekDesk
|
||||
小巧、美观的桌面快速启动工具
|
||||
小巧、美观的桌面快速启动管理工具
|
||||
|
||||
## 开发框架
|
||||
- wpf
|
||||
@@ -9,7 +9,6 @@
|
||||
## 全局热键 鼠标跟随 快速启动 随时随地
|
||||
- 支持自定义热键
|
||||
- 支持鼠标跟随
|
||||
-
|
||||
<img src="https://z3.ax1x.com/2021/07/19/WJt4hQ.gif" alt="WJt4hQ.gif" border="0" width="800px"/>
|
||||
|
||||
## 自定义壁纸
|
||||
@@ -21,28 +20,21 @@
|
||||
- 背景图片毛玻璃效果
|
||||
- 界面透明度
|
||||
- 界面圆角
|
||||
-
|
||||
<img src="https://z3.ax1x.com/2021/07/19/WGOYSU.gif" alt="WGOYSU.gif" border="0" width="800px"/>
|
||||
|
||||
## 自定义菜单图标
|
||||
- 80多个系统图标可供选择
|
||||
- 另支持在线导入阿里巴巴icon图标
|
||||
-
|
||||
- 篇幅原因,公众号内回复 **自定义图标** 可以查看教程
|
||||
<img src="https://z3.ax1x.com/2021/07/19/WJ3fDU.png" alt="WJ3fDU.png" border="0" width="450px"/>
|
||||
|
||||
## 定时提醒 永不忘记
|
||||
<img src="https://z3.ax1x.com/2021/07/19/WJU6df.gif" alt="WJU6df.gif" border="0" width="800px"/>
|
||||
|
||||
## Release
|
||||
## LICENSE
|
||||
- 这是个人开发的程序,任何人可任意修改和免费使用(未做较大功能性改动不允许修改赞赏码,重新修改发布需注明出处)
|
||||
- 商用需联系作者
|
||||
|
||||
## 作者相关
|
||||
主业Java程序员一枚(目前北京在职), 有好的工作请联系我 :smirk:
|
||||
### 佛系公众号
|
||||
不定期更新技术相关, 或者一些牢骚
|
||||
|
||||
<img src="https://z3.ax1x.com/2021/07/19/WJaI9e.jpg" alt="WJaI9e.jpg" border="0" />
|
||||
|
||||
### 佛系赞赏
|
||||
我知道没人赞赏但我还是要放上来
|
||||
|
||||
@@ -7,6 +7,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -24,9 +25,11 @@ namespace GeekDesk.Task
|
||||
public static void BackLogCheck()
|
||||
{
|
||||
|
||||
System.Timers.Timer timer = new System.Timers.Timer();
|
||||
timer.Enabled = true;
|
||||
timer.Interval = 5000;
|
||||
System.Timers.Timer timer = new System.Timers.Timer
|
||||
{
|
||||
Enabled = true,
|
||||
Interval = 5000
|
||||
};
|
||||
timer.Start();
|
||||
timer.Elapsed += new System.Timers.ElapsedEventHandler(Check);
|
||||
}
|
||||
@@ -48,9 +51,27 @@ namespace GeekDesk.Task
|
||||
}
|
||||
}
|
||||
}
|
||||
ClearMemory();
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放内存
|
||||
/// </summary>
|
||||
public static void ClearMemory()
|
||||
{
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
{
|
||||
SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
#region 内存回收
|
||||
[DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
|
||||
public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,10 @@ namespace GeekDesk.Thread
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
//等待1分钟后再检查更新 有的网络连接过慢
|
||||
System.Threading.Thread.Sleep(60 * 1000);
|
||||
|
||||
string updateUrl;
|
||||
string nowVersion = ConfigurationManager.AppSettings["Version"];
|
||||
switch (appConfig.UpdateType)
|
||||
@@ -57,7 +61,8 @@ namespace GeekDesk.Thread
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.Message);
|
||||
//不做处理
|
||||
//MessageBox.Show(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
Update.json
10
Update.json
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"title" : "<22>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD>",
|
||||
"subTitle" : "V1.0-beta",
|
||||
"subTitle" : "V2.3.10 <20><>ʽ<EFBFBD><CABD>",
|
||||
"msgTitle" : "<22><><EFBFBD>θ<EFBFBD><CEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
"msg" : "['<27><><EFBFBD>²<EFBFBD><EFBFBD><EFBFBD>1','<EFBFBD><EFBFBD><EFBFBD>²<EFBFBD><EFBFBD><EFBFBD>23']",
|
||||
"githubUrl" : "https://github.com/Demo-Liu/GeekDesk/releases/tag/1.0-beta",
|
||||
"giteeUrl" : "https://gitee.com/demo_liu/GeekDesk/releases/1.0-beta",
|
||||
"version": "1.0-beta"
|
||||
"msg" : "['<27><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><D8BF>ٵ<EFBFBD><D9B5><EFBFBD><EFBFBD><EFBFBD>','<27><EFBFBD><DEB8><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BUG','<27><><EFBFBD>Ӷ<EFBFBD>ʱ<EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ڿ<EFBFBD>ռ<EFBFBD>ø<EFBFBD>С<EFBFBD><D0A1><EFBFBD>ڴ<EFBFBD>','<27><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ㴰<EFBFBD>ڵ<EFBFBD>BUG','<27><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>С','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>CRON<4F><4E><EFBFBD><EFBFBD>ʽ<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>']",
|
||||
"githubUrl" : "https://github.com/Demo-Liu/GeekDesk/releases/tag",
|
||||
"giteeUrl" : "https://gitee.com/demo_liu/GeekDesk/releases",
|
||||
"version": "2.3.10"
|
||||
}
|
||||
9
Update.json.bak
Normal file
9
Update.json.bak
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"title" : "版本更新",
|
||||
"subTitle" : "V2.3 正式版",
|
||||
"msgTitle" : "本次更新内容如下",
|
||||
"msg" : "['边缘吸附功能','窗口淡入淡出动画','待办任务快捷键(默认Ctrl+Shift+Q)','右键任务栏图标打开程序目录菜单']",
|
||||
"githubUrl" : "https://github.com/Demo-Liu/GeekDesk/releases/tag",
|
||||
"giteeUrl" : "https://gitee.com/demo_liu/GeekDesk/releases",
|
||||
"version": "2.3"
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.ViewModel;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// 提取一些代码
|
||||
@@ -50,8 +52,7 @@ namespace GeekDesk.Util
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
52
Util/DefaultIcons.cs
Normal file
52
Util/DefaultIcons.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public static class DefaultIcons
|
||||
{
|
||||
private static Icon folderIcon;
|
||||
|
||||
public static Icon FolderLarge => folderIcon ?? (folderIcon = GetStockIcon(SHGSI_ICON, SHGSI_LARGEICON));
|
||||
|
||||
public static Icon GetStockIcon(uint type, uint size)
|
||||
{
|
||||
var info = new SHSTOCKICONINFO();
|
||||
info.cbSize = (uint)Marshal.SizeOf(info);
|
||||
|
||||
SHGetStockIconInfo(type, SHGSI_ICON | size, ref info);
|
||||
|
||||
var icon = (Icon)Icon.FromHandle(info.hIcon).Clone(); // Get a copy that doesn't use the original handle
|
||||
DestroyIcon(info.hIcon); // Clean up native icon to prevent resource leak
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
public struct SHSTOCKICONINFO
|
||||
{
|
||||
public uint cbSize;
|
||||
public IntPtr hIcon;
|
||||
public int iSysIconIndex;
|
||||
public int iIcon;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
||||
public string szPath;
|
||||
}
|
||||
|
||||
[DllImport("shell32.dll")]
|
||||
public static extern int SHGetStockIconInfo(uint siid, uint uFlags, ref SHSTOCKICONINFO psii);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool DestroyIcon(IntPtr handle);
|
||||
|
||||
public static uint SHSIID_FOLDER = 0x3;
|
||||
public static uint SHGSI_ICON = 0x100;
|
||||
public static uint SHGSI_LARGEICON = 0x0;
|
||||
public static uint SHGSI_SMALLICON = 0x1;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using IWshRuntimeLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -6,20 +8,61 @@ using System.Windows.Media.Imaging;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
class FileIcon
|
||||
public class FileIcon
|
||||
{
|
||||
|
||||
|
||||
public static Icon GetIcon(string filePath)
|
||||
private static List<string> GetBlurExts()
|
||||
{
|
||||
IntPtr hIcon = GetJumboIcon(GetIconIndex(filePath));
|
||||
Icon ico = Icon.FromHandle(hIcon);
|
||||
return ico;
|
||||
List<string> list = new List<string>();
|
||||
list.Add(".exe");
|
||||
list.Add(".cer");
|
||||
list.Add(".lnk");
|
||||
return list;
|
||||
}
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
public static extern int PrivateExtractIcons(
|
||||
string lpszFile, //文件名可以是exe,dll,ico,cur,ani,bmp
|
||||
int nIconIndex, //从第几个图标开始获取
|
||||
int cxIcon, //获取图标的尺寸x
|
||||
int cyIcon, //获取图标的尺寸y
|
||||
IntPtr[] phicon, //获取到的图标指针数组
|
||||
int[] piconid, //图标对应的资源编号
|
||||
int nIcons, //指定获取的图标数量,仅当文件类型为.exe 和 .dll时候可用
|
||||
int flags //标志,默认0就可以,具体可以看LoadImage函数
|
||||
);
|
||||
|
||||
|
||||
public static BitmapImage GetBitmapImage(string filePath)
|
||||
{
|
||||
Icon ico = GetIcon(filePath);
|
||||
Icon ico;
|
||||
//选中文件中的图标总数
|
||||
var iconTotalCount = PrivateExtractIcons(filePath, 0, 0, 0, null, null, 0, 0);
|
||||
//用于接收获取到的图标指针
|
||||
IntPtr[] hIcons = new IntPtr[iconTotalCount];
|
||||
//对应的图标id
|
||||
int[] ids = new int[iconTotalCount];
|
||||
//成功获取到的图标个数
|
||||
var successCount = PrivateExtractIcons(filePath, 0, 256, 256, hIcons, ids, iconTotalCount, 0);
|
||||
|
||||
string ext = Path.GetExtension(filePath).ToLower();
|
||||
|
||||
IntPtr ip = IntPtr.Zero;
|
||||
if (successCount > 0)
|
||||
{
|
||||
ip = hIcons[0];
|
||||
ico = Icon.FromHandle(ip);
|
||||
}
|
||||
else if (GetBlurExts().Contains(ext))
|
||||
{
|
||||
ico = Icon.ExtractAssociatedIcon(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
ip = GetJumboIcon(GetIconIndex(filePath));
|
||||
ico = Icon.FromHandle(ip);
|
||||
}
|
||||
|
||||
Bitmap bmp = ico.ToBitmap();
|
||||
MemoryStream strm = new MemoryStream();
|
||||
bmp.Save(strm, System.Drawing.Imaging.ImageFormat.Png);
|
||||
@@ -28,10 +71,15 @@ namespace GeekDesk.Util
|
||||
strm.Seek(0, SeekOrigin.Begin);
|
||||
bmpImage.StreamSource = strm;
|
||||
bmpImage.EndInit();
|
||||
|
||||
if (ip != IntPtr.Zero)
|
||||
{
|
||||
Shell32.DestroyIcon(ip);
|
||||
}
|
||||
return bmpImage.Clone();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static int GetIconIndex(string pszFile)
|
||||
{
|
||||
SHFILEINFO sfi = new SHFILEINFO();
|
||||
|
||||
32
Util/FileUtil.cs
Normal file
32
Util/FileUtil.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using IWshRuntimeLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class FileUtil
|
||||
{
|
||||
|
||||
public static string GetTargetPathByLnk(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
WshShell shell = new WshShell();
|
||||
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
|
||||
|
||||
if (StringUtil.IsEmpty(shortcut.TargetPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return shortcut.TargetPath;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
92
Util/GlobalHotKey.cs
Normal file
92
Util/GlobalHotKey.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class GlobalHotKey
|
||||
{
|
||||
public enum HotkeyModifiers
|
||||
{
|
||||
MOD_ALT = 0x1,
|
||||
MOD_CONTROL = 0x2,
|
||||
MOD_SHIFT = 0x4,
|
||||
MOD_WIN = 0x8
|
||||
}
|
||||
|
||||
private static int currentID;
|
||||
private static readonly Dictionary<int, InvisibleWindowForMessages> handleTemp = new Dictionary<int, InvisibleWindowForMessages>();
|
||||
|
||||
public delegate void HotKeyCallBackHanlder();
|
||||
/// <summary>
|
||||
/// Registers a global hotkey
|
||||
/// </summary>
|
||||
/// <param name="aKeyGestureString">e.g. Alt + Shift + Control + Win + S</param>
|
||||
/// <param name="callback">Action to be called when hotkey is pressed</param>
|
||||
/// <returns>true, if registration succeeded, otherwise false</returns>
|
||||
public static int RegisterHotKey(string aKeyGestureString, HotKeyCallBackHanlder callback)
|
||||
{
|
||||
var c = new KeyGestureConverter();
|
||||
KeyGesture aKeyGesture = (KeyGesture)c.ConvertFrom(aKeyGestureString);
|
||||
return RegisterHotKey((HotkeyModifiers)aKeyGesture.Modifiers, aKeyGesture.Key, callback);
|
||||
}
|
||||
|
||||
public static int RegisterHotKey(HotkeyModifiers aModifier, Key key, HotKeyCallBackHanlder callback)
|
||||
{
|
||||
InvisibleWindowForMessages window = new InvisibleWindowForMessages(callback);
|
||||
currentID += 1;
|
||||
if (!RegisterHotKey(window.Handle, currentID, aModifier, (uint)KeyInterop.VirtualKeyFromKey(key)))
|
||||
{
|
||||
window.Dispose();
|
||||
throw new Exception("RegisterHotKey Failed");
|
||||
}
|
||||
handleTemp.Add(currentID, window);
|
||||
return currentID;
|
||||
}
|
||||
|
||||
public static void Dispose(int id)
|
||||
{
|
||||
bool test = UnregisterHotKey(handleTemp[id].Handle, id);
|
||||
GlobalHotKey.handleTemp[id].Dispose();
|
||||
GlobalHotKey.handleTemp.Remove(id);
|
||||
Console.WriteLine(test);
|
||||
}
|
||||
|
||||
// Registers a hot key with Windows.
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool RegisterHotKey(IntPtr hWnd, int id, HotkeyModifiers fsModifiers, uint vk);
|
||||
// Unregisters the hot key with Windows.
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
||||
|
||||
private class InvisibleWindowForMessages : NativeWindow, IDisposable
|
||||
{
|
||||
public event HotKeyCallBackHanlder callback;
|
||||
public InvisibleWindowForMessages(HotKeyCallBackHanlder callback)
|
||||
{
|
||||
CreateHandle(new CreateParams());
|
||||
this.callback += callback;
|
||||
}
|
||||
|
||||
private static readonly int WM_HOTKEY = 0x0312;
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
base.WndProc(ref m);
|
||||
if (m.Msg == WM_HOTKEY)
|
||||
{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
this.DestroyHandle();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 热键注册
|
||||
/// </summary>
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
|
||||
class Hotkey
|
||||
{
|
||||
#region 系统api
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool RegisterHotKey(IntPtr hWnd, int id, HotkeyModifiers fsModifiers, uint vk);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 注册快捷键
|
||||
/// </summary>
|
||||
/// <param name="window">持有快捷键窗口</param>
|
||||
/// <param name="fsModifiers">组合键</param>
|
||||
/// <param name="key">快捷键</param>
|
||||
/// <param name="callBack">回调函数</param>
|
||||
public static int Regist(IntPtr windowHandle, HotkeyModifiers fsModifiers, Key key, HotKeyCallBackHanlder callBack)
|
||||
{
|
||||
HwndSource hs = HwndSource.FromHwnd(windowHandle);
|
||||
hs.AddHook(WndProc);
|
||||
|
||||
int id = keyid++;
|
||||
int vk = KeyInterop.VirtualKeyFromKey(key);
|
||||
keymap.Add(id, callBack);
|
||||
if (!RegisterHotKey(windowHandle, id, fsModifiers, (uint)vk)) throw new Exception("RegisterHotKey Failed");
|
||||
return id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 快捷键消息处理
|
||||
/// </summary>
|
||||
static IntPtr WndProc(IntPtr windowHandle, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
if (msg == WM_HOTKEY)
|
||||
{
|
||||
int id = wParam.ToInt32();
|
||||
if (keymap.TryGetValue(id, out var callback))
|
||||
{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注销快捷键
|
||||
/// </summary>
|
||||
/// <param name="hWnd">持有快捷键窗口的句柄</param>
|
||||
/// <param name="callBack">回调函数</param>
|
||||
public static void UnRegist(IntPtr windowHandle, HotKeyCallBackHanlder callBack)
|
||||
{
|
||||
List<int> list = new List<int>(keymap.Keys);
|
||||
for (int i=0; i < list.Count; i++)
|
||||
{
|
||||
if (keymap[list[i]] == callBack)
|
||||
{
|
||||
HwndSource hs = HwndSource.FromHwnd(windowHandle);
|
||||
hs.RemoveHook(WndProc);
|
||||
UnregisterHotKey(windowHandle, list[i]);
|
||||
keymap.Remove(list[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const int WM_HOTKEY = 0x312;
|
||||
static int keyid = 10;
|
||||
public static Dictionary<int, HotKeyCallBackHanlder> keymap = new Dictionary<int, HotKeyCallBackHanlder>();
|
||||
|
||||
public delegate void HotKeyCallBackHanlder();
|
||||
}
|
||||
|
||||
public enum HotkeyModifiers
|
||||
{
|
||||
MOD_ALT = 0x1,
|
||||
MOD_CONTROL = 0x2,
|
||||
MOD_SHIFT = 0x4,
|
||||
MOD_WIN = 0x8
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,8 +17,10 @@ namespace GeekDesk.Util
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
||||
//创建Web访问对 象
|
||||
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
|
||||
myRequest.ContentType = "text/plain; charset=gbk";
|
||||
//通过Web访问对象获取响应内容
|
||||
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
|
||||
|
||||
//通过响应内容流创建StreamReader对象,因为StreamReader更高级更快
|
||||
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("gbk"));
|
||||
string returnStr = reader.ReadToEnd();//利用StreamReader就可以从响应内容从头读到尾
|
||||
|
||||
95
Util/IconHelper.cs
Normal file
95
Util/IconHelper.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class IconHelper
|
||||
{
|
||||
[DllImport("Shell32.dll")]
|
||||
private static extern IntPtr SHGetFileInfo
|
||||
(
|
||||
string pszPath, //һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫȡ<D2AA><C8A1><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>Ļ<EFBFBD><C4BB>塣<EFBFBD><E5A1A3><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ע[1]
|
||||
uint dwFileAttributes,//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>uFlags<67>а<EFBFBD><D0B0><EFBFBD>SHGFI_USEFILEATTRIBUTES<45><53>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(һ<>㲻ʹ<E3B2BB><CAB9>)<29><><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ե<EFBFBD><D4B5><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3>浵<EFBFBD><E6B5B5>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC>ϵͳ<CFB5>ȡ<EFBFBD>
|
||||
out SHFILEINFO psfi,
|
||||
uint cbfileInfo,//<2F>ظ<F2B5A5B5><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD>ijߴ硣
|
||||
SHGFI uFlags//<2F><><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><C4BA>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF>ܵı<DCB5>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD>Ԧ<EFBFBD><D4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ʵ<EFBFBD>ʵصõ<D8B5><C3B5><EFBFBD>Ϣ<EFBFBD><CFA2>
|
||||
);
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct SHFILEINFO
|
||||
{
|
||||
public SHFILEINFO(bool b)
|
||||
{
|
||||
hIcon = IntPtr.Zero; iIcon = 0; dwAttributes = 0; szDisplayName = ""; szTypeName = "";
|
||||
}
|
||||
public IntPtr hIcon;//ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public int iIcon;//ϵͳͼ<CDB3><CDBC><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public uint dwAttributes; //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
[MarshalAs(UnmanagedType.LPStr, SizeConst = 260)]
|
||||
public string szDisplayName;//<2F>ļ<EFBFBD><C4BC><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD> <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>256<35><36>ANSI<53><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̷<EFBFBD><CCB7><EFBFBD>X:\<5C><>3<EFBFBD>ֽڣ<D6BD>259<35>ֽڣ<D6BD><DAA3>ټ<EFBFBD><D9BC>Ͻ<EFBFBD><CFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD>ֽڣ<D6BD><DAA3><EFBFBD>260
|
||||
[MarshalAs(UnmanagedType.LPStr, SizeConst = 80)]
|
||||
public string szTypeName;//<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̶<EFBFBD>80<38>ֽ<EFBFBD>
|
||||
};
|
||||
|
||||
|
||||
|
||||
private enum SHGFI
|
||||
{
|
||||
SmallIcon = 0x00000001,
|
||||
LargeIcon = 0x00000000,
|
||||
Icon = 0x00000100,
|
||||
DisplayName = 0x00000200,//Retrieve the display name for the file, which is the name as it appears in Windows Explorer. The name is copied to the szDisplayName member of the structure specified in psfi. The returned display name uses the long file name, if there is one, rather than the 8.3 form of the file name. Note that the display name can be affected by settings such as whether extensions are shown.
|
||||
Typename = 0x00000400, //Retrieve the string that describes the file's type. The string is copied to the szTypeName member of the structure specified in psfi.
|
||||
SysIconIndex = 0x00004000, //Retrieve the index of a system image list icon. If successful, the index is copied to the iIcon member of psfi. The return value is a handle to the system image list. Only those images whose indices are successfully copied to iIcon are valid. Attempting to access other images in the system image list will result in undefined behavior.
|
||||
UseFileAttributes = 0x00000010 //Indicates that the function should not attempt to access the file specified by pszPath. Rather, it should act as if the file specified by pszPath exists with the file attributes passed in dwFileAttributes. This flag cannot be combined with the SHGFI_ATTRIBUTES, SHGFI_EXETYPE, or SHGFI_PIDL flags.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>չ<EFBFBD><D5B9><EFBFBD>õ<EFBFBD>ϵͳ<CFB5><CDB3>չ<EFBFBD><D5B9><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
||||
/// </summary>
|
||||
/// <param name="fileName"><3E>ļ<EFBFBD><C4BC><EFBFBD>(<28>磺win.rar;setup.exe;temp.txt)</param>
|
||||
/// <param name="largeIcon">ͼ<><CDBC><EFBFBD>Ĵ<EFBFBD>С</param>
|
||||
/// <returns></returns>
|
||||
public static Icon GetFileIcon(string fileName, bool largeIcon)
|
||||
{
|
||||
SHFILEINFO info = new SHFILEINFO(true);
|
||||
int cbFileInfo = Marshal.SizeOf(info);
|
||||
SHGFI flags;
|
||||
if (largeIcon)
|
||||
flags = SHGFI.Icon | SHGFI.LargeIcon | SHGFI.UseFileAttributes;
|
||||
else
|
||||
flags = SHGFI.Icon | SHGFI.SmallIcon | SHGFI.UseFileAttributes;
|
||||
IntPtr IconIntPtr = SHGetFileInfo(fileName, 256, out info, (uint)cbFileInfo, flags);
|
||||
if (IconIntPtr.Equals(IntPtr.Zero))
|
||||
return null;
|
||||
return Icon.FromHandle(info.hIcon);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ͼ<EFBFBD><CDBC>
|
||||
/// </summary>
|
||||
/// <returns>ͼ<><CDBC></returns>
|
||||
public static Icon GetDirectoryIcon(string path, bool largeIcon)
|
||||
{
|
||||
SHFILEINFO _SHFILEINFO = new SHFILEINFO();
|
||||
int cbFileInfo = Marshal.SizeOf(_SHFILEINFO);
|
||||
SHGFI flags;
|
||||
if (largeIcon)
|
||||
flags = SHGFI.Icon | SHGFI.LargeIcon;
|
||||
else
|
||||
flags = SHGFI.Icon | SHGFI.SmallIcon;
|
||||
|
||||
IntPtr IconIntPtr = SHGetFileInfo(path, 256, out _SHFILEINFO, (uint)cbFileInfo, flags);
|
||||
if (IconIntPtr.Equals(IntPtr.Zero))
|
||||
return null;
|
||||
Icon _Icon = Icon.FromHandle(_SHFILEINFO.hIcon);
|
||||
return _Icon;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
17
Util/IconUtil.cs
Normal file
17
Util/IconUtil.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class IconUtil
|
||||
{
|
||||
const string IID_IImageList = "46EB5926-582E-4017-9FDF-E8998DAA0950";
|
||||
const string IID_IImageList2 = "192B9D83-50FC-457B-90A0-2B82A8B5DAE1";
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
@@ -22,9 +23,10 @@ namespace GeekDesk.Util
|
||||
{
|
||||
using (var ms = new System.IO.MemoryStream(array))
|
||||
{
|
||||
var image = new BitmapImage();
|
||||
BitmapImage image = new BitmapImage();
|
||||
image.BeginInit();
|
||||
image.CacheOption = BitmapCacheOption.OnLoad; // here
|
||||
RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.LowQuality);
|
||||
image.StreamSource = ms;
|
||||
image.EndInit();
|
||||
return image;
|
||||
@@ -184,7 +186,7 @@ namespace GeekDesk.Util
|
||||
Bitmap bmpOut = new Bitmap(lnNewWidth, lnNewHeight);
|
||||
Graphics g = Graphics.FromImage(bmpOut);
|
||||
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
||||
g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight);
|
||||
g.FillRectangle(System.Drawing.Brushes.White, 0, 0, lnNewWidth, lnNewHeight);
|
||||
g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);
|
||||
loBMP.Dispose();
|
||||
string tempPath = Constants.APP_DIR + "\\temp";
|
||||
@@ -211,6 +213,7 @@ namespace GeekDesk.Util
|
||||
BitmapImage bmImg = new BitmapImage();
|
||||
bmImg.BeginInit();
|
||||
bmImg.CacheOption = BitmapCacheOption.OnLoad;
|
||||
RenderOptions.SetBitmapScalingMode(bmImg, BitmapScalingMode.LowQuality);
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
bmImg.StreamSource = fs;
|
||||
@@ -268,21 +271,13 @@ namespace GeekDesk.Util
|
||||
|
||||
public static BitmapImage Bitmap2BitmapImage(Bitmap bitmap)
|
||||
{
|
||||
IntPtr hBitmap = bitmap.GetHbitmap();
|
||||
BitmapImage retval;
|
||||
try
|
||||
{
|
||||
retval = (BitmapImage)Imaging.CreateBitmapSourceFromHBitmap(
|
||||
hBitmap,
|
||||
IntPtr.Zero,
|
||||
Int32Rect.Empty,
|
||||
BitmapSizeOptions.FromEmptyOptions());
|
||||
}
|
||||
finally
|
||||
{
|
||||
DeleteObject(hBitmap);
|
||||
}
|
||||
return retval;
|
||||
MemoryStream ms = new MemoryStream();
|
||||
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
|
||||
BitmapImage bit3 = new BitmapImage();
|
||||
bit3.BeginInit();
|
||||
bit3.StreamSource = ms;
|
||||
bit3.EndInit();
|
||||
return bit3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
204
Util/MarginHide.cs
Normal file
204
Util/MarginHide.cs
Normal file
@@ -0,0 +1,204 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using System.Drawing; //添加引用
|
||||
using System.Windows.Forms;//添加引用
|
||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
|
||||
enum HidePosition
|
||||
{
|
||||
TOP = 1,
|
||||
LEFT = 2,
|
||||
RIGHT = 3
|
||||
}
|
||||
|
||||
public class MarginHide
|
||||
{
|
||||
readonly Window window;//定义使用该方法的窗体
|
||||
|
||||
private readonly int hideTime = 80;
|
||||
|
||||
private readonly int taskTime = 200;
|
||||
|
||||
private double showMarginWidth = 1;
|
||||
|
||||
private bool isHide;
|
||||
|
||||
public Timer timer;
|
||||
//构造函数,传入将要匹配的窗体
|
||||
public MarginHide(Window window)
|
||||
{
|
||||
this.window = window;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 窗体是否贴边
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsMargin()
|
||||
{
|
||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||
double screenTop = SystemParameters.VirtualScreenTop;
|
||||
double screenWidth = SystemParameters.VirtualScreenWidth;
|
||||
|
||||
double windowWidth = window.Width;
|
||||
|
||||
double windowTop = window.Top;
|
||||
double windowLeft = window.Left;
|
||||
|
||||
//窗体是否贴边
|
||||
return (windowLeft <= screenLeft
|
||||
|| windowTop <= screenTop
|
||||
|| windowLeft + windowWidth + Math.Abs(screenLeft) >= screenWidth);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 窗体贴边隐藏功能
|
||||
private void TimerDealy(object o, EventArgs e)
|
||||
{
|
||||
if (window.Visibility != Visibility.Visible) return;
|
||||
|
||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||
double screenTop = SystemParameters.VirtualScreenTop;
|
||||
double screenWidth = SystemParameters.VirtualScreenWidth;
|
||||
|
||||
double windowHeight = window.Height;
|
||||
double windowWidth = window.Width;
|
||||
|
||||
double windowTop = window.Top;
|
||||
double windowLeft = window.Left;
|
||||
|
||||
//获取鼠标位置
|
||||
System.Windows.Point p = MouseUtil.GetMousePosition();
|
||||
double mouseX = p.X;
|
||||
double mouseY = p.Y;
|
||||
|
||||
//鼠标不在窗口上
|
||||
if (mouseX < windowLeft || mouseX > windowLeft + windowWidth
|
||||
|| mouseY < windowTop || mouseY > windowTop + windowHeight)
|
||||
{
|
||||
//上方隐藏条件
|
||||
if (windowTop <= screenTop)
|
||||
{
|
||||
HideAnimation(windowTop, screenTop - windowHeight + showMarginWidth, Window.TopProperty);
|
||||
isHide = true;
|
||||
return;
|
||||
}
|
||||
//左侧隐藏条件
|
||||
if (windowLeft <= screenLeft)
|
||||
{
|
||||
HideAnimation(windowLeft, screenLeft - windowWidth + showMarginWidth, Window.LeftProperty);
|
||||
return;
|
||||
}
|
||||
//右侧隐藏条件
|
||||
if (windowLeft + windowWidth + Math.Abs(screenLeft) >= screenWidth)
|
||||
{
|
||||
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - showMarginWidth, Window.LeftProperty);
|
||||
return;
|
||||
}
|
||||
} else if (mouseX >= windowLeft && mouseX <= windowLeft + windowWidth
|
||||
&& mouseY >= windowTop && mouseY <= windowTop + windowHeight)
|
||||
{
|
||||
//上方显示
|
||||
if (windowTop <= screenTop - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowTop, screenTop, Window.TopProperty);
|
||||
return;
|
||||
}
|
||||
//左侧显示
|
||||
if (windowLeft <= screenLeft - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowLeft, screenLeft, Window.LeftProperty);
|
||||
return;
|
||||
}
|
||||
//右侧显示
|
||||
if (windowLeft + Math.Abs(screenLeft) == screenWidth - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public void TimerSet()
|
||||
{
|
||||
if (timer != null) return;
|
||||
timer = new Timer();//添加timer计时器,隐藏功能
|
||||
#region 计时器设置,隐藏功能
|
||||
timer.Interval = taskTime;
|
||||
timer.Tick += TimerDealy;
|
||||
timer.Start();
|
||||
#endregion
|
||||
}
|
||||
|
||||
public void TimerStop()
|
||||
{
|
||||
timer.Stop();
|
||||
timer.Dispose();
|
||||
timer = null;
|
||||
//功能关闭 如果界面是隐藏状态 那么要显示界面 ↓
|
||||
|
||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||
double screenTop = SystemParameters.VirtualScreenTop;
|
||||
double screenWidth = SystemParameters.VirtualScreenWidth;
|
||||
|
||||
double windowWidth = window.Width;
|
||||
|
||||
double windowTop = window.Top;
|
||||
double windowLeft = window.Left;
|
||||
|
||||
//左侧显示
|
||||
if (windowLeft <= screenLeft - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowLeft, screenLeft, Window.LeftProperty);
|
||||
return;
|
||||
}
|
||||
|
||||
//上方显示
|
||||
if (windowTop <= screenTop - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowTop, screenTop, Window.TopProperty);
|
||||
return;
|
||||
}
|
||||
|
||||
//右侧显示
|
||||
if (windowLeft + Math.Abs(screenLeft) == screenWidth - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void HideAnimation(double from, double to, DependencyProperty property)
|
||||
{
|
||||
DoubleAnimation da = new DoubleAnimation
|
||||
{
|
||||
From = from,
|
||||
To = to,
|
||||
Duration = new Duration(TimeSpan.FromMilliseconds(hideTime))
|
||||
};
|
||||
da.Completed += (s, e) =>
|
||||
{
|
||||
window.BeginAnimation(property, null);
|
||||
};
|
||||
Timeline.SetDesiredFrameRate(da, 60);
|
||||
window.BeginAnimation(property, da);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
72
Util/NativeMethods.cs
Normal file
72
Util/NativeMethods.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 保存文件信息的结构体
|
||||
/// </summary>
|
||||
///
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
struct SHFILEINFO
|
||||
{
|
||||
public IntPtr hIcon;
|
||||
public int iIcon;
|
||||
public uint dwAttributes;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
||||
public string szDisplayName;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
|
||||
public string szTypeName;
|
||||
}
|
||||
|
||||
class NativeMethods
|
||||
{
|
||||
|
||||
[DllImport("Shell32.dll", EntryPoint = "SHGetFileInfo", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbFileInfo, uint uFlags);
|
||||
|
||||
[DllImport("User32.dll", EntryPoint = "DestroyIcon")]
|
||||
public static extern int DestroyIcon(IntPtr hIcon);
|
||||
|
||||
#region API 参数的常量定义
|
||||
|
||||
public const uint SHGFI_ICON = 0x100;
|
||||
public const uint SHGFI_LARGEICON = 0x0; //大图标 32×32
|
||||
public const uint SHGFI_SMALLICON = 0x1; //小图标 16×16
|
||||
public const uint SHGFI_USEFILEATTRIBUTES = 0x10;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件类型的关联图标
|
||||
/// </summary>
|
||||
/// <param name="fileName">文件类型的扩展名或文件的绝对路径</param>
|
||||
/// <param name="isLargeIcon">是否返回大图标</param>
|
||||
/// <returns>获取到的图标</returns>
|
||||
static Icon GetIcon(string fileName, bool isLargeIcon)
|
||||
{
|
||||
SHFILEINFO shfi = new SHFILEINFO();
|
||||
IntPtr hI;
|
||||
|
||||
if (isLargeIcon)
|
||||
hI = NativeMethods.SHGetFileInfo(fileName, 0, ref shfi, (uint)Marshal.SizeOf(shfi), NativeMethods.SHGFI_ICON | NativeMethods.SHGFI_USEFILEATTRIBUTES | NativeMethods.SHGFI_LARGEICON);
|
||||
else
|
||||
hI = NativeMethods.SHGetFileInfo(fileName, 0, ref shfi, (uint)Marshal.SizeOf(shfi), NativeMethods.SHGFI_ICON | NativeMethods.SHGFI_USEFILEATTRIBUTES | NativeMethods.SHGFI_SMALLICON);
|
||||
|
||||
Icon icon = Icon.FromHandle(shfi.hIcon).Clone() as Icon;
|
||||
|
||||
NativeMethods.DestroyIcon(shfi.hIcon); //释放资源
|
||||
return icon;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
1584
Util/ShellContextMenu.cs
Normal file
1584
Util/ShellContextMenu.cs
Normal file
File diff suppressed because it is too large
Load Diff
111
Util/ShowWindowFollowMouse.cs
Normal file
111
Util/ShowWindowFollowMouse.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class ShowWindowFollowMouse
|
||||
{
|
||||
|
||||
public enum MousePosition
|
||||
{
|
||||
CENTER = 1,
|
||||
LEFT_TOP = 2,
|
||||
LEFT_BOTTOM = 3,
|
||||
RIGHT_TOP = 4,
|
||||
RIGHT_BOTTOM = 5,
|
||||
LEFT_CENTER = 6,
|
||||
RIGHT_CENTER = 7
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 随鼠标位置显示面板
|
||||
/// </summary>
|
||||
public static void Show(Window window, MousePosition position, double widthOffset = 0, double heightOffset = 0, bool visibility = true)
|
||||
{
|
||||
//获取鼠标位置
|
||||
System.Windows.Point p = MouseUtil.GetMousePosition();
|
||||
double left = SystemParameters.VirtualScreenLeft;
|
||||
double top = SystemParameters.VirtualScreenTop;
|
||||
double width = SystemParameters.VirtualScreenWidth;
|
||||
double height = SystemParameters.VirtualScreenHeight;
|
||||
double right = width - Math.Abs(left);
|
||||
double bottom = height - Math.Abs(top);
|
||||
|
||||
double afterWidth;
|
||||
double afterHeight;
|
||||
|
||||
switch (position)
|
||||
{
|
||||
|
||||
case MousePosition.LEFT_BOTTOM:
|
||||
afterWidth = 0;
|
||||
afterHeight = window.Height;
|
||||
break;
|
||||
case MousePosition.LEFT_TOP:
|
||||
afterWidth = 0;
|
||||
afterHeight = 0;
|
||||
break;
|
||||
case MousePosition.LEFT_CENTER:
|
||||
afterWidth = 0;
|
||||
afterHeight = window.Height / 2;
|
||||
break;
|
||||
case MousePosition.RIGHT_BOTTOM:
|
||||
afterWidth = window.Width;
|
||||
afterHeight = window.Height;
|
||||
break;
|
||||
case MousePosition.RIGHT_TOP:
|
||||
afterWidth = window.Width;
|
||||
afterHeight = 0;
|
||||
break;
|
||||
case MousePosition.RIGHT_CENTER:
|
||||
afterWidth = window.Width;
|
||||
afterHeight = window.Height / 2;
|
||||
break;
|
||||
default:
|
||||
afterWidth = window.Width / 2;
|
||||
afterHeight = window.Height / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
afterWidth += widthOffset;
|
||||
afterHeight -= heightOffset;
|
||||
|
||||
if (p.X - afterWidth < left)
|
||||
{
|
||||
//判断是否在最左边缘
|
||||
window.Left = left;
|
||||
}
|
||||
else if (p.X + afterWidth > right)
|
||||
{
|
||||
//判断是否在最右边缘
|
||||
window.Left = right - window.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
window.Left = p.X - afterWidth;
|
||||
}
|
||||
|
||||
|
||||
if (p.Y - afterHeight < top)
|
||||
{
|
||||
//判断是否在最上边缘
|
||||
window.Top = top;
|
||||
}
|
||||
else if (p.Y + afterHeight > bottom)
|
||||
{
|
||||
//判断是否在最下边缘
|
||||
window.Top = bottom - window.Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
window.Top = p.Y - afterHeight;
|
||||
}
|
||||
if (visibility)
|
||||
{
|
||||
window.Opacity = 0;
|
||||
window.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
class SystemIcon
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
public struct SHFILEINFO
|
||||
{
|
||||
public IntPtr hIcon;
|
||||
public int iIcon;
|
||||
public uint dwAttributes;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
||||
public string szDisplayName;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
|
||||
public string szTypeName;
|
||||
}
|
||||
[DllImport("Shell32.dll", EntryPoint = "SHGetFileInfo", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbFileInfo, uint uFlags);
|
||||
[DllImport("User32.dll", EntryPoint = "DestroyIcon")]
|
||||
public static extern int DestroyIcon(IntPtr hIcon);
|
||||
#region API 参数的常量定义
|
||||
public enum FileInfoFlags : uint
|
||||
{
|
||||
SHGFI_ICON = 0x000000100, // get icon
|
||||
SHGFI_DISPLAYNAME = 0x000000200, // get display name
|
||||
SHGFI_TYPENAME = 0x000000400, // get type name
|
||||
SHGFI_ATTRIBUTES = 0x000000800, // get attributes
|
||||
SHGFI_ICONLOCATION = 0x000001000, // get icon location
|
||||
SHGFI_EXETYPE = 0x000002000, // return exe type
|
||||
SHGFI_SYSICONINDEX = 0x000004000, // get system icon index
|
||||
SHGFI_LINKOVERLAY = 0x000008000, // put a link overlay on icon
|
||||
SHGFI_SELECTED = 0x000010000, // show icon in selected state
|
||||
SHGFI_ATTR_SPECIFIED = 0x000020000, // get only specified attributes
|
||||
SHGFI_LARGEICON = 0x000000000, // get large icon
|
||||
SHGFI_SMALLICON = 0x000000001, // get small icon
|
||||
SHGFI_OPENICON = 0x000000002, // get open icon
|
||||
SHGFI_SHELLICONSIZE = 0x000000004, // get shell size icon
|
||||
SHGFI_PIDL = 0x000000008, // pszPath is a pidl
|
||||
SHGFI_USEFILEATTRIBUTES = 0x000000010, // use passed dwFileAttribute
|
||||
SHGFI_ADDOVERLAYS = 0x000000020, // apply the appropriate overlays
|
||||
SHGFI_OVERLAYINDEX = 0x000000040 // Get the index of the overlay
|
||||
}
|
||||
public enum FileAttributeFlags : uint
|
||||
{
|
||||
FILE_ATTRIBUTE_READONLY = 0x00000001,
|
||||
FILE_ATTRIBUTE_HIDDEN = 0x00000002,
|
||||
FILE_ATTRIBUTE_SYSTEM = 0x00000004,
|
||||
FILE_ATTRIBUTE_DIRECTORY = 0x00000010,
|
||||
FILE_ATTRIBUTE_ARCHIVE = 0x00000020,
|
||||
FILE_ATTRIBUTE_DEVICE = 0x00000040,
|
||||
FILE_ATTRIBUTE_NORMAL = 0x00000080,
|
||||
FILE_ATTRIBUTE_TEMPORARY = 0x00000100,
|
||||
FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200,
|
||||
FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400,
|
||||
FILE_ATTRIBUTE_COMPRESSED = 0x00000800,
|
||||
FILE_ATTRIBUTE_OFFLINE = 0x00001000,
|
||||
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000,
|
||||
FILE_ATTRIBUTE_ENCRYPTED = 0x00004000
|
||||
}
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// 获取文件类型的关联图标
|
||||
/// </summary>
|
||||
/// <param name="fileName">文件类型的扩展名或文件的绝对路径</param>
|
||||
/// <param name="isLargeIcon">是否返回大图标</param>
|
||||
/// <returns>获取到的图标</returns>
|
||||
public static Icon GetIcon(string fileName, bool isLargeIcon)
|
||||
{
|
||||
//SHFILEINFO shfi = new SHFILEINFO();
|
||||
//IntPtr hI;
|
||||
//if (isLargeIcon)
|
||||
// hI = SHGetFileInfo(fileName, 0, ref shfi, (uint)Marshal.SizeOf(shfi), (uint)FileInfoFlags.SHGFI_ICON | (uint)FileInfoFlags.SHGFI_USEFILEATTRIBUTES | (uint)FileInfoFlags.SHGFI_LARGEICON);
|
||||
//else
|
||||
// hI = SHGetFileInfo(fileName, 0, ref shfi, (uint)Marshal.SizeOf(shfi), (uint)FileInfoFlags.SHGFI_ICON | (uint)FileInfoFlags.SHGFI_USEFILEATTRIBUTES | (uint)FileInfoFlags.SHGFI_SMALLICON);
|
||||
//Icon icon = Icon.FromHandle(shfi.hIcon).Clone() as Icon;
|
||||
//DestroyIcon(shfi.hIcon); //释放资源
|
||||
|
||||
//选中文件中的图标总数
|
||||
//var iconTotalCount = PrivateExtractIcons(fileName, 0, 0, 0, null, null, 1, 0);
|
||||
//用于接收获取到的图标指针
|
||||
//IntPtr[] hIcons = new IntPtr[1];
|
||||
////对应的图标id
|
||||
//int[] ids = new int[1];
|
||||
////成功获取到的图标个数
|
||||
//int successCount = PrivateExtractIcons(fileName, 0, 0, 0, hIcons, ids, 1, 0);
|
||||
//Icon ico = Icon.FromHandle(hIcons[0]);
|
||||
//var myIcon = ico.ToBitmap();
|
||||
//myIcon.Save("D:\\" + ids[0].ToString("000") + ".png", ImageFormat.Png);
|
||||
IntPtr hIcon = FileIcon.GetJumboIcon(FileIcon.GetIconIndex(fileName));
|
||||
//IntPtr hIcon = GetJumboIcon(GetIconIndex("*." + ext));
|
||||
|
||||
// from native to managed
|
||||
Icon ico = Icon.FromHandle(hIcon);
|
||||
string path = "D:\\test\\" + System.Guid.NewGuid().ToString() + ".png";
|
||||
//using ( ico = (Icon)Icon.FromHandle(hIcon).Clone())
|
||||
//{
|
||||
// // save to file (or show in a picture box)
|
||||
// ico.ToBitmap().Save(path, ImageFormat.Png);
|
||||
//}
|
||||
//FileIcon.Shell32.DestroyIcon(hIcon); // don't forget to cleanup
|
||||
|
||||
return ico;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取文件夹图标
|
||||
/// </summary>
|
||||
/// <returns>图标</returns>
|
||||
public static Icon GetDirectoryIcon(bool isLargeIcon)
|
||||
{
|
||||
SHFILEINFO _SHFILEINFO = new SHFILEINFO();
|
||||
IntPtr _IconIntPtr;
|
||||
if (isLargeIcon)
|
||||
{
|
||||
_IconIntPtr = SHGetFileInfo(@"", 0, ref _SHFILEINFO, (uint)Marshal.SizeOf(_SHFILEINFO), ((uint)FileInfoFlags.SHGFI_ICON | (uint)FileInfoFlags.SHGFI_LARGEICON));
|
||||
}
|
||||
else
|
||||
{
|
||||
_IconIntPtr = SHGetFileInfo(@"", 0, ref _SHFILEINFO, (uint)Marshal.SizeOf(_SHFILEINFO), ((uint)FileInfoFlags.SHGFI_ICON | (uint)FileInfoFlags.SHGFI_SMALLICON));
|
||||
}
|
||||
if (_IconIntPtr.Equals(IntPtr.Zero)) return null;
|
||||
Icon _Icon = System.Drawing.Icon.FromHandle(_SHFILEINFO.hIcon);
|
||||
return _Icon;
|
||||
}
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
public static extern int PrivateExtractIcons(
|
||||
string lpszFile, //file name
|
||||
int nIconIndex, //The zero-based index of the first icon to extract.
|
||||
int cxIcon, //The horizontal icon size wanted.
|
||||
int cyIcon, //The vertical icon size wanted.
|
||||
IntPtr[] phicon, //(out) A pointer to the returned array of icon handles.
|
||||
int[] piconid, //(out) A pointer to a returned resource identifier.
|
||||
int nIcons, //The number of icons to extract from the file. Only valid when *.exe and *.dll
|
||||
int flags //Specifies flags that control this function.
|
||||
);
|
||||
|
||||
//[DllImport("User32.dll")]
|
||||
//public static extern bool DestroyIcon(
|
||||
// IntPtr hIcon //A handle to the icon to be destroyed. The icon must not be in use.
|
||||
// );
|
||||
}
|
||||
}
|
||||
442
Util/WindowsThumbnailProvider.cs
Normal file
442
Util/WindowsThumbnailProvider.cs
Normal file
@@ -0,0 +1,442 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Media;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class WindowsThumbnailProvider
|
||||
{
|
||||
private struct RECT
|
||||
{
|
||||
public int Left;
|
||||
public int Top;
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
}
|
||||
private struct POINT
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
}
|
||||
// Constants that we need in the function call
|
||||
|
||||
private const int SHGFI_ICON = 0x100;
|
||||
|
||||
private const int SHGFI_SMALLICON = 0x1;
|
||||
|
||||
private const int SHGFI_LARGEICON = 0x0;
|
||||
|
||||
private const int SHIL_JUMBO = 0x4;
|
||||
private const int SHIL_EXTRALARGE = 0x2;
|
||||
|
||||
// This structure will contain information about the file
|
||||
|
||||
public struct SHFILEINFO
|
||||
{
|
||||
|
||||
// Handle to the icon representing the file
|
||||
|
||||
public IntPtr hIcon;
|
||||
|
||||
// Index of the icon within the image list
|
||||
|
||||
public int iIcon;
|
||||
|
||||
// Various attributes of the file
|
||||
|
||||
public uint dwAttributes;
|
||||
|
||||
// Path to the file
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
|
||||
public string szDisplayName;
|
||||
|
||||
// File type
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
|
||||
|
||||
public string szTypeName;
|
||||
|
||||
};
|
||||
|
||||
[System.Runtime.InteropServices.DllImport("Kernel32.dll")]
|
||||
public static extern Boolean CloseHandle(IntPtr handle);
|
||||
|
||||
private struct IMAGELISTDRAWPARAMS
|
||||
{
|
||||
public int cbSize;
|
||||
public IntPtr himl;
|
||||
public int i;
|
||||
public IntPtr hdcDst;
|
||||
public int x;
|
||||
public int y;
|
||||
public int cx;
|
||||
public int cy;
|
||||
public int xBitmap; // x offest from the upperleft of bitmap
|
||||
public int yBitmap; // y offset from the upperleft of bitmap
|
||||
public int rgbBk;
|
||||
public int rgbFg;
|
||||
public int fStyle;
|
||||
public int dwRop;
|
||||
public int fState;
|
||||
public int Frame;
|
||||
public int crEffect;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct IMAGEINFO
|
||||
{
|
||||
public IntPtr hbmImage;
|
||||
public IntPtr hbmMask;
|
||||
public int Unused1;
|
||||
public int Unused2;
|
||||
public RECT rcImage;
|
||||
}
|
||||
|
||||
#region Private ImageList COM Interop (XP)
|
||||
[ComImportAttribute()]
|
||||
[GuidAttribute("46EB5926-582E-4017-9FDF-E8998DAA0950")]
|
||||
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
//helpstring("Image List"),
|
||||
interface IImageList
|
||||
{
|
||||
[PreserveSig]
|
||||
int Add(
|
||||
IntPtr hbmImage,
|
||||
IntPtr hbmMask,
|
||||
ref int pi);
|
||||
|
||||
[PreserveSig]
|
||||
int ReplaceIcon(
|
||||
int i,
|
||||
IntPtr hicon,
|
||||
ref int pi);
|
||||
|
||||
[PreserveSig]
|
||||
int SetOverlayImage(
|
||||
int iImage,
|
||||
int iOverlay);
|
||||
|
||||
[PreserveSig]
|
||||
int Replace(
|
||||
int i,
|
||||
IntPtr hbmImage,
|
||||
IntPtr hbmMask);
|
||||
|
||||
[PreserveSig]
|
||||
int AddMasked(
|
||||
IntPtr hbmImage,
|
||||
int crMask,
|
||||
ref int pi);
|
||||
|
||||
[PreserveSig]
|
||||
int Draw(
|
||||
ref IMAGELISTDRAWPARAMS pimldp);
|
||||
|
||||
[PreserveSig]
|
||||
int Remove(
|
||||
int i);
|
||||
|
||||
[PreserveSig]
|
||||
int GetIcon(
|
||||
int i,
|
||||
int flags,
|
||||
ref IntPtr picon);
|
||||
|
||||
[PreserveSig]
|
||||
int GetImageInfo(
|
||||
int i,
|
||||
ref IMAGEINFO pImageInfo);
|
||||
|
||||
[PreserveSig]
|
||||
int Copy(
|
||||
int iDst,
|
||||
IImageList punkSrc,
|
||||
int iSrc,
|
||||
int uFlags);
|
||||
|
||||
[PreserveSig]
|
||||
int Merge(
|
||||
int i1,
|
||||
IImageList punk2,
|
||||
int i2,
|
||||
int dx,
|
||||
int dy,
|
||||
ref Guid riid,
|
||||
ref IntPtr ppv);
|
||||
|
||||
[PreserveSig]
|
||||
int Clone(
|
||||
ref Guid riid,
|
||||
ref IntPtr ppv);
|
||||
|
||||
[PreserveSig]
|
||||
int GetImageRect(
|
||||
int i,
|
||||
ref RECT prc);
|
||||
|
||||
[PreserveSig]
|
||||
int GetIconSize(
|
||||
ref int cx,
|
||||
ref int cy);
|
||||
|
||||
[PreserveSig]
|
||||
int SetIconSize(
|
||||
int cx,
|
||||
int cy);
|
||||
|
||||
[PreserveSig]
|
||||
int GetImageCount(
|
||||
ref int pi);
|
||||
|
||||
[PreserveSig]
|
||||
int SetImageCount(
|
||||
int uNewCount);
|
||||
|
||||
[PreserveSig]
|
||||
int SetBkColor(
|
||||
int clrBk,
|
||||
ref int pclr);
|
||||
|
||||
[PreserveSig]
|
||||
int GetBkColor(
|
||||
ref int pclr);
|
||||
|
||||
[PreserveSig]
|
||||
int BeginDrag(
|
||||
int iTrack,
|
||||
int dxHotspot,
|
||||
int dyHotspot);
|
||||
|
||||
[PreserveSig]
|
||||
int EndDrag();
|
||||
|
||||
[PreserveSig]
|
||||
int DragEnter(
|
||||
IntPtr hwndLock,
|
||||
int x,
|
||||
int y);
|
||||
|
||||
[PreserveSig]
|
||||
int DragLeave(
|
||||
IntPtr hwndLock);
|
||||
|
||||
[PreserveSig]
|
||||
int DragMove(
|
||||
int x,
|
||||
int y);
|
||||
|
||||
[PreserveSig]
|
||||
int SetDragCursorImage(
|
||||
ref IImageList punk,
|
||||
int iDrag,
|
||||
int dxHotspot,
|
||||
int dyHotspot);
|
||||
|
||||
[PreserveSig]
|
||||
int DragShowNolock(
|
||||
int fShow);
|
||||
|
||||
[PreserveSig]
|
||||
int GetDragImage(
|
||||
ref POINT ppt,
|
||||
ref POINT pptHotspot,
|
||||
ref Guid riid,
|
||||
ref IntPtr ppv);
|
||||
|
||||
[PreserveSig]
|
||||
int GetItemFlags(
|
||||
int i,
|
||||
ref int dwFlags);
|
||||
|
||||
[PreserveSig]
|
||||
int GetOverlayImage(
|
||||
int iOverlay,
|
||||
ref int piIndex);
|
||||
};
|
||||
#endregion
|
||||
|
||||
///
|
||||
/// SHGetImageList is not exported correctly in XP. See KB316931
|
||||
/// http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q316931
|
||||
/// Apparently (and hopefully) ordinal 727 isn't going to change.
|
||||
///
|
||||
[DllImport("shell32.dll", EntryPoint = "#727")]
|
||||
private extern static int SHGetImageList(
|
||||
int iImageList,
|
||||
ref Guid riid,
|
||||
out IImageList ppv
|
||||
);
|
||||
|
||||
// The signature of SHGetFileInfo (located in Shell32.dll)
|
||||
[DllImport("Shell32.dll")]
|
||||
public static extern int SHGetFileInfo(string pszPath, int dwFileAttributes, ref SHFILEINFO psfi, int cbFileInfo, uint uFlags);
|
||||
|
||||
[DllImport("Shell32.dll")]
|
||||
public static extern int SHGetFileInfo(IntPtr pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, int cbFileInfo, uint uFlags);
|
||||
|
||||
[DllImport("shell32.dll", SetLastError = true)]
|
||||
static extern int SHGetSpecialFolderLocation(IntPtr hwndOwner, Int32 nFolder,
|
||||
ref IntPtr ppidl);
|
||||
|
||||
[DllImport("user32")]
|
||||
public static extern int DestroyIcon(IntPtr hIcon);
|
||||
|
||||
public struct pair
|
||||
{
|
||||
public System.Drawing.Icon icon { get; set; }
|
||||
public IntPtr iconHandleToDestroy { set; get; }
|
||||
|
||||
}
|
||||
|
||||
public static int DestroyIcon2(IntPtr hIcon)
|
||||
{
|
||||
return DestroyIcon(hIcon);
|
||||
}
|
||||
|
||||
private static BitmapSource bitmap_source_of_icon(System.Drawing.Icon ic)
|
||||
{
|
||||
var ic2 = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(ic.Handle,
|
||||
System.Windows.Int32Rect.Empty,
|
||||
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
|
||||
ic2.Freeze();
|
||||
return ((BitmapSource)ic2);
|
||||
}
|
||||
|
||||
//public static BitmapSource SystemIcon(bool small, ShellLib.ShellApi.CSIDL csidl)
|
||||
//{
|
||||
|
||||
// IntPtr pidlTrash = IntPtr.Zero;
|
||||
// int hr = SHGetSpecialFolderLocation(IntPtr.Zero, (int)csidl, ref pidlTrash);
|
||||
// Debug.Assert(hr == 0);
|
||||
|
||||
// SHFILEINFO shinfo = new SHFILEINFO();
|
||||
|
||||
// uint SHGFI_USEFILEATTRIBUTES = 0x000000010;
|
||||
|
||||
// // Get a handle to the large icon
|
||||
// uint flags;
|
||||
// uint SHGFI_PIDL = 0x000000008;
|
||||
// if (!small)
|
||||
// {
|
||||
// flags = SHGFI_PIDL | SHGFI_ICON | SHGFI_LARGEICON | SHGFI_USEFILEATTRIBUTES;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// flags = SHGFI_PIDL | SHGFI_ICON | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES;
|
||||
// }
|
||||
|
||||
// var res = SHGetFileInfo(pidlTrash, 0, ref shinfo, Marshal.SizeOf(shinfo), flags);
|
||||
// Debug.Assert(res != 0);
|
||||
|
||||
// var myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon);
|
||||
// Marshal.FreeCoTaskMem(pidlTrash);
|
||||
// var bs = bitmap_source_of_icon(myIcon);
|
||||
// myIcon.Dispose();
|
||||
// bs.Freeze(); // importantissimo se no fa memory leak
|
||||
// DestroyIcon(shinfo.hIcon);
|
||||
// CloseHandle(shinfo.hIcon);
|
||||
// return bs;
|
||||
|
||||
//}
|
||||
|
||||
public static BitmapSource icon_of_path(string FileName, bool small, bool checkDisk, bool addOverlay)
|
||||
{
|
||||
SHFILEINFO shinfo = new SHFILEINFO();
|
||||
|
||||
uint SHGFI_USEFILEATTRIBUTES = 0x000000010;
|
||||
uint SHGFI_LINKOVERLAY = 0x000008000;
|
||||
|
||||
uint flags;
|
||||
if (small)
|
||||
{
|
||||
flags = SHGFI_ICON | SHGFI_SMALLICON;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags = SHGFI_ICON | SHGFI_LARGEICON;
|
||||
}
|
||||
if (!checkDisk)
|
||||
flags |= SHGFI_USEFILEATTRIBUTES;
|
||||
if (addOverlay)
|
||||
flags |= SHGFI_LINKOVERLAY;
|
||||
|
||||
var res = SHGetFileInfo(FileName, 0, ref shinfo, Marshal.SizeOf(shinfo), flags);
|
||||
if (res == 0)
|
||||
{
|
||||
throw (new System.IO.FileNotFoundException());
|
||||
}
|
||||
|
||||
var myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon);
|
||||
|
||||
var bs = bitmap_source_of_icon(myIcon);
|
||||
myIcon.Dispose();
|
||||
bs.Freeze(); // importantissimo se no fa memory leak
|
||||
DestroyIcon(shinfo.hIcon);
|
||||
CloseHandle(shinfo.hIcon);
|
||||
return bs;
|
||||
|
||||
}
|
||||
|
||||
public static Icon icon_of_path_large(string FileName, bool jumbo, bool checkDisk)
|
||||
{
|
||||
|
||||
SHFILEINFO shinfo = new SHFILEINFO();
|
||||
|
||||
uint SHGFI_USEFILEATTRIBUTES = 0x000000010;
|
||||
uint SHGFI_SYSICONINDEX = 0x4000;
|
||||
|
||||
int FILE_ATTRIBUTE_NORMAL = 0x80;
|
||||
|
||||
uint flags;
|
||||
flags = SHGFI_SYSICONINDEX;
|
||||
|
||||
if (!checkDisk) // This does not seem to work. If I try it, a folder icon is always returned.
|
||||
flags |= SHGFI_USEFILEATTRIBUTES;
|
||||
|
||||
var res = SHGetFileInfo(FileName, FILE_ATTRIBUTE_NORMAL, ref shinfo, Marshal.SizeOf(shinfo), flags);
|
||||
if (res == 0)
|
||||
{
|
||||
throw (new System.IO.FileNotFoundException());
|
||||
}
|
||||
var iconIndex = shinfo.iIcon;
|
||||
|
||||
// Get the System IImageList object from the Shell:
|
||||
Guid iidImageList = new Guid("46EB5926-582E-4017-9FDF-E8998DAA0950");
|
||||
|
||||
IImageList iml;
|
||||
int size = jumbo ? SHIL_JUMBO : SHIL_EXTRALARGE;
|
||||
var hres = SHGetImageList(size, ref iidImageList, out iml); // writes iml
|
||||
//if (hres == 0)
|
||||
//{
|
||||
// throw (new System.Exception("Error SHGetImageList"));
|
||||
//}
|
||||
|
||||
IntPtr hIcon = IntPtr.Zero;
|
||||
int ILD_TRANSPARENT = 1;
|
||||
hres = iml.GetIcon(iconIndex, ILD_TRANSPARENT, ref hIcon);
|
||||
//if (hres == 0)
|
||||
//{
|
||||
// throw (new System.Exception("Error iml.GetIcon"));
|
||||
//}
|
||||
|
||||
var myIcon = System.Drawing.Icon.FromHandle(hIcon);
|
||||
var bs = bitmap_source_of_icon(myIcon);
|
||||
myIcon.Dispose();
|
||||
bs.Freeze(); // very important to avoid memory leak
|
||||
//DestroyIcon(hIcon);
|
||||
//CloseHandle(hIcon);
|
||||
|
||||
return myIcon;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Imaging;
|
||||
using static GeekDesk.Util.GlobalHotKey;
|
||||
|
||||
/// <summary>
|
||||
/// 程序设置
|
||||
@@ -19,9 +20,9 @@ namespace GeekDesk.ViewModel
|
||||
{
|
||||
private SortType menuSortType = SortType.CUSTOM; //菜单排序类型
|
||||
private SortType iconSortType = SortType.CUSTOM; //图表排序类型
|
||||
private double windowWidth = (double)MainWindowEnum.WINDOW_WIDTH; //窗口宽度
|
||||
private double windowHeight = (double)MainWindowEnum.WINDOW_HEIGHT; //窗口高度
|
||||
private double menuCardWidth = (double)MainWindowEnum.MENU_CARD_WIDHT;//菜单栏宽度
|
||||
private double windowWidth = (double)CommonEnum.WINDOW_WIDTH; //窗口宽度
|
||||
private double windowHeight = (double)CommonEnum.WINDOW_HEIGHT; //窗口高度
|
||||
private double menuCardWidth = (double)CommonEnum.MENU_CARD_WIDHT;//菜单栏宽度
|
||||
private int selectedMenuIndex = 0; //上次选中菜单索引
|
||||
private bool followMouse = true; //面板跟随鼠标 默认是
|
||||
private Visibility configIconVisible = Visibility.Visible; // 设置按钮是否显示
|
||||
@@ -42,9 +43,9 @@ namespace GeekDesk.ViewModel
|
||||
private HotkeyModifiers hotkeyModifiers = HotkeyModifiers.MOD_CONTROL; //默认启动面板快捷键
|
||||
private Key hotkey = Key.Q; //默认启动面板快捷键
|
||||
|
||||
private string toDoHotkeyStr; //待办任务快捷键
|
||||
private string toDoHotkeyStr = "Ctrl + Shift + Q"; //待办任务快捷键
|
||||
private HotkeyModifiers toDoHotkeyModifiers; //待办任务快捷键
|
||||
private Key toDoHotkey; //待办任务快捷键
|
||||
private Key toDoHotkey = Key.E; //待办任务快捷键
|
||||
|
||||
private string customIconUrl; //自定义图标url
|
||||
private string customIconJsonUrl; //自定义图标json信息url
|
||||
@@ -56,9 +57,174 @@ namespace GeekDesk.ViewModel
|
||||
|
||||
private bool selfStartUp = true; //开机自启动设置
|
||||
private bool selfStartUped = false; //是否已设置
|
||||
private bool pmModel = false; //性能模式
|
||||
private string textColor = "#000000"; //字体颜色
|
||||
private double imgPanelWidth = (double)CommonEnum.IMAGE_PANEL_WIDTH;
|
||||
private double imgPanelHeight = (double)CommonEnum.IMAGE_PANEL_HEIGHT;
|
||||
private bool marginHide = false; //贴边隐藏
|
||||
private bool appAnimation = false; //主窗口动画效果
|
||||
private int imageWidth = (int)CommonEnum.IMAGE_WIDTH; //图片宽度
|
||||
private int imageHeight = (int)CommonEnum.IMAGE_HEIGHT; //图片高度
|
||||
|
||||
#region GetSet
|
||||
public int ImageWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
// 为了兼容旧版 暂时使用默认
|
||||
if (imageWidth == 0)
|
||||
{
|
||||
return (int)CommonEnum.IMAGE_WIDTH;
|
||||
} else
|
||||
{
|
||||
return imageWidth;
|
||||
}
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
imageWidth = value;
|
||||
//同时设置高度
|
||||
ImageHeight = value;
|
||||
|
||||
|
||||
//计算 容器宽度因子
|
||||
double i = ((double)imageWidth - (double)CommonEnum.IMAGE_WIDTH) / 5d;
|
||||
double s = 2.44;
|
||||
i *= 2d;
|
||||
while (i > 1)
|
||||
{
|
||||
i /= 10d;
|
||||
}
|
||||
|
||||
if (i > 0d)
|
||||
{
|
||||
s -= i;
|
||||
}
|
||||
//设置容器宽度
|
||||
ImgPanelWidth = (int)(ImageWidth * s);
|
||||
|
||||
OnPropertyChanged("ImageWidth");
|
||||
}
|
||||
}
|
||||
|
||||
public int ImageHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
//都使用宽度来确定大小
|
||||
// 为了兼容旧版 暂时使用默认
|
||||
if (imageHeight == 0)
|
||||
{
|
||||
return (int)CommonEnum.IMAGE_HEIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return imageHeight;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
imageHeight = value;
|
||||
|
||||
//计算容器高度因子
|
||||
double i = ((double)imageHeight - (double)CommonEnum.IMAGE_HEIGHT) / 5d;
|
||||
while (i > 1)
|
||||
{
|
||||
i /= 10d;
|
||||
}
|
||||
double s = 2.00;
|
||||
if (i > 0d)
|
||||
{
|
||||
s -= i;
|
||||
}
|
||||
|
||||
//设置容器高度
|
||||
ImgPanelHeight = ImageHeight * s;
|
||||
OnPropertyChanged("ImageHeight");
|
||||
}
|
||||
}
|
||||
|
||||
public bool AppAnimation
|
||||
{
|
||||
get
|
||||
{
|
||||
return appAnimation;
|
||||
}
|
||||
set
|
||||
{
|
||||
appAnimation = value;
|
||||
OnPropertyChanged("AppAnimation");
|
||||
}
|
||||
}
|
||||
|
||||
public bool MarginHide
|
||||
{
|
||||
get
|
||||
{
|
||||
return marginHide;
|
||||
}
|
||||
set
|
||||
{
|
||||
marginHide = value;
|
||||
OnPropertyChanged("MarginHide");
|
||||
}
|
||||
}
|
||||
|
||||
public double ImgPanelWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
if (imgPanelWidth == 0d) return (double)CommonEnum.IMAGE_PANEL_WIDTH;
|
||||
return imgPanelWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
imgPanelWidth = value;
|
||||
OnPropertyChanged("ImgPanelWidth");
|
||||
}
|
||||
}
|
||||
|
||||
public double ImgPanelHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
if (imgPanelHeight == 0d) return (double)CommonEnum.IMAGE_PANEL_HEIGHT;
|
||||
return imgPanelHeight;
|
||||
}
|
||||
set
|
||||
{
|
||||
imgPanelHeight = value;
|
||||
OnPropertyChanged("ImgPanelHeight");
|
||||
}
|
||||
}
|
||||
|
||||
public string TextColor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (textColor == null) return "#000000";
|
||||
return textColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
textColor = value;
|
||||
OnPropertyChanged("TextColor");
|
||||
}
|
||||
}
|
||||
|
||||
public bool PMModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return pmModel;
|
||||
}
|
||||
set
|
||||
{
|
||||
pmModel = value;
|
||||
OnPropertyChanged("PMModel");
|
||||
}
|
||||
}
|
||||
|
||||
public bool SelfStartUped
|
||||
{
|
||||
@@ -91,6 +257,11 @@ namespace GeekDesk.ViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
//兼容老版本
|
||||
if (toDoHotkey == Key.None)
|
||||
{
|
||||
toDoHotkey = Key.Q;
|
||||
}
|
||||
return toDoHotkey;
|
||||
}
|
||||
set
|
||||
@@ -105,6 +276,10 @@ namespace GeekDesk.ViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (toDoHotkeyModifiers == 0)
|
||||
{
|
||||
toDoHotkeyModifiers = HotkeyModifiers.MOD_CONTROL | HotkeyModifiers.MOD_SHIFT;
|
||||
}
|
||||
return toDoHotkeyModifiers;
|
||||
}
|
||||
set
|
||||
@@ -118,6 +293,11 @@ namespace GeekDesk.ViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
//兼容老版本
|
||||
if (toDoHotkeyStr == null)
|
||||
{
|
||||
toDoHotkeyStr = "Ctrl + Shift + Q";
|
||||
}
|
||||
return toDoHotkeyStr;
|
||||
}
|
||||
set
|
||||
@@ -224,6 +404,10 @@ namespace GeekDesk.ViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (hotkeyModifiers == 0)
|
||||
{
|
||||
hotkeyModifiers = HotkeyModifiers.MOD_CONTROL;
|
||||
}
|
||||
return hotkeyModifiers;
|
||||
}
|
||||
set
|
||||
|
||||
@@ -20,13 +20,26 @@ namespace GeekDesk.ViewModel
|
||||
private BitmapImage bitmapImage; //位图
|
||||
private byte[] imageByteArr; //图片 byte数组
|
||||
private string content; //显示信息
|
||||
private int imageWidth = (int)MainWindowEnum.IMAGE_WIDTH; //图片宽度
|
||||
private int imageHeight = (int)MainWindowEnum.IMAGE_HEIGHT; //图片高度
|
||||
private bool adminStartUp = false; //始终管理员方式启动 默认否
|
||||
private byte[] defaultImage; //默认图标
|
||||
|
||||
private IconType iconType = IconType.OTHER;
|
||||
|
||||
|
||||
public IconType IconType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (iconType == 0) return IconType.OTHER;
|
||||
return iconType;
|
||||
}
|
||||
set
|
||||
{
|
||||
iconType = value;
|
||||
OnPropertyChanged("IconType");
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] DefaultImage
|
||||
{
|
||||
get
|
||||
@@ -137,31 +150,7 @@ namespace GeekDesk.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public int ImageWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return imageWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
imageWidth = value;
|
||||
OnPropertyChanged("ImageWidth");
|
||||
}
|
||||
}
|
||||
|
||||
public int ImageHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return imageHeight;
|
||||
}
|
||||
set
|
||||
{
|
||||
imageHeight = value;
|
||||
OnPropertyChanged("ImageHeight");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -17,8 +18,38 @@ namespace GeekDesk.ViewModel
|
||||
private string msg; //事项详情
|
||||
private string exeTime; //待办时间
|
||||
private string doneTime; //完成时间
|
||||
private TodoTaskExecType execType = TodoTaskExecType.SET_TIME;
|
||||
private string cron; //cron表达式
|
||||
//private int status; //状态 0 未处理 1 已处理
|
||||
|
||||
public string Cron
|
||||
{
|
||||
get
|
||||
{
|
||||
return cron;
|
||||
}
|
||||
set
|
||||
{
|
||||
cron = value;
|
||||
OnPropertyChanged("Cron");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public TodoTaskExecType ExecType
|
||||
{
|
||||
get
|
||||
{
|
||||
//兼容老版本 需要给个默认值
|
||||
if (execType == 0) return TodoTaskExecType.SET_TIME;
|
||||
return execType;
|
||||
}
|
||||
set
|
||||
{
|
||||
execType = value;
|
||||
OnPropertyChanged("ExecType");
|
||||
}
|
||||
}
|
||||
|
||||
public string DoneTime
|
||||
{
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
<packages>
|
||||
<package id="CommonServiceLocator" version="2.0.6" targetFramework="net452" requireReinstallation="true" />
|
||||
<package id="HandyControl" version="3.1.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Extensions.Logging.Abstractions" version="2.1.1" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
|
||||
<package id="System.Drawing.Common" version="6.0.0-preview.3.21201.4" targetFramework="net472" />
|
||||
<package id="Quartz" version="3.3.3" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="4.7.1" targetFramework="net472" />
|
||||
<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.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user