80 Commits

Author SHA1 Message Date
liufei
56584e1c99 已知问题修复 2022-03-25 15:29:06 +08:00
liufei
05b63d107d 屏幕靠边优化 2022-03-25 15:28:50 +08:00
liufei
eaa37aacae 贴边隐藏优化 2022-03-25 15:28:35 +08:00
liufei
0c9cd85b82 增加搜索功能 2022-03-25 15:28:13 +08:00
liufei
3e0d0c502b 修复拾色工具的bug 2022-03-25 15:25:49 +08:00
liufei
5a89b40244 优化修改菜单图标时的样式及逻辑 2022-01-26 10:20:36 +08:00
liufei
0495b8a121 BUG 2022-01-22 15:11:36 +08:00
liufei
1ef3129017 增加图标排序 2022-01-22 14:20:04 +08:00
liufei
ca3d6b50e3 增加鼠标悬停切换菜单 2022-01-22 14:18:16 +08:00
liufei
683b4bc870 修改包名 防止跟系统包名冲突 2022-01-22 11:08:31 +08:00
liufei
abdc4b6046 修复失去焦点方式关闭窗口的bug 2022-01-20 17:13:37 +08:00
liufei
ff2a103682 优化修改菜单名时的样式 2022-01-20 15:47:40 +08:00
liufei
9c687117f9 优化修改菜单名时的样式 2022-01-20 15:47:27 +08:00
liufei
d61bf2af11 修改错别字 2022-01-20 15:47:06 +08:00
liufei
6fcc599eff 修改默认窗口大小 2022-01-20 15:46:52 +08:00
liufei
9bf0e6ad23 修改程序集版本信息 2022-01-13 09:53:10 +08:00
liufei
fadf020ecf 更新信息 2022-01-13 09:49:19 +08:00
liufei
c062f332ff 修复遮挡任务栏 2022-01-13 09:49:10 +08:00
liufei
4d416e673e 修复无法拖动图标 2022-01-13 09:49:00 +08:00
liufei
a03fb713e4 修改样式和待办中保存无法删除原有任务的bug 2022-01-10 17:56:52 +08:00
liufei
489a27a0ef 2.4.11 2022-01-10 17:29:16 +08:00
liufei
e112dfebea windir 转义 2022-01-10 17:27:29 +08:00
liufei
9ca443acf6 优化代码 2022-01-10 17:27:12 +08:00
liufei
dd17bbc2b3 增加 服务 选项 2022-01-10 16:23:42 +08:00
liufei
c9bb1c2fad 优化样式细节 2022-01-10 11:50:21 +08:00
liufei
8decd923ff 关闭窗口时 将数据设置为null 2022-01-09 17:44:25 +08:00
liufei
65d57b69b6 释放启动进程 2022-01-09 17:42:44 +08:00
liufei
28a523fb04 增加数据持活 2022-01-09 17:37:25 +08:00
liufei
a38ecab5fa 捕获异常, 写出日志 2022-01-09 17:36:15 +08:00
liufei
145564bfc5 捕获异常, 写出日志 2022-01-09 17:33:49 +08:00
liufei
fdd8c8bb10 更新日志 2022-01-09 17:11:05 +08:00
liufei
fce6f47fbe 修改为非开发模式 2022-01-09 17:06:50 +08:00
liufei
c9bc4282c0 增加启动参数 2022-01-09 16:19:27 +08:00
liufei
54200c8254 修复cron任务重复执行bug 2022-01-09 16:17:58 +08:00
liufei
72bcbee888 修改样式 2022-01-09 16:17:43 +08:00
liufei
de02248e75 增加启动参数 2022-01-09 16:17:13 +08:00
liufei
78b5b52c2a 增加启动参数 2022-01-09 16:12:15 +08:00
liufei
b66c9cd082 更新日志说明 2022-01-09 16:12:07 +08:00
liufei
83cdaa4491 修改程序集信息 2022-01-09 16:08:35 +08:00
liufei
9e3c6f67c8 修改错误样式 2022-01-09 16:08:29 +08:00
liufei
1a24222f3f 优化版本 2022-01-09 16:02:43 +08:00
liufei
1b9e4fc79d 优化贴边隐藏动画 2022-01-09 16:00:47 +08:00
liufei
9eaca05012 增加 教程链接 2022-01-09 16:00:02 +08:00
liufei
d82ce80374 修复遮罩层过大 2022-01-09 15:42:19 +08:00
liufei
4444e6000c 提取方法 2022-01-09 15:39:14 +08:00
liufei
46f6de321c 增加日志写入 2022-01-09 15:39:00 +08:00
liufei
c3e46bc751 优化贴边隐藏动画 2022-01-09 15:38:46 +08:00
liufei
b23a1d91c5 修改公共样式 2022-01-09 15:38:30 +08:00
liufei
edacf3249c 增加双击打开 修复重复进程导致不能关闭程序 2022-01-09 15:38:18 +08:00
liufei
ab13cff769 增加 添加系统和开始菜单项目功能 2022-01-09 15:37:37 +08:00
liufei
8ee27e247b 修改编码 2021-12-20 16:51:59 +08:00
liufei
cf8f983f1a 2.3.21 2021-12-20 16:42:58 +08:00
liufei
37e8631f73 修复一个测试遗留bug 2021-12-20 16:39:51 +08:00
liufei
0f6119c0ba 去除选中控件后的虚线 2021-12-20 10:59:37 +08:00
liufei
caf75e2427 不开启中键启动时不再占用线程 2021-12-20 09:56:43 +08:00
liufei
c13593bdf4 Esc退出窗口 2021-12-20 09:42:13 +08:00
liufei
e6a95c4668 增加Esc退出窗口 2021-12-20 09:39:27 +08:00
liufei
3483bf88c2 修复未完全关闭进程的bug 2021-12-13 13:03:50 +08:00
liufei
f96a76e6fb 修改编码 2021-12-13 12:18:13 +08:00
liufei
71f18b801a 修改为utf-8 2021-12-13 12:17:19 +08:00
liufei
1bf0f9c38b 更新信息 2021-12-13 12:07:42 +08:00
Demo-Liu
2efcabe570 Merge branch 'master' into 2.3.20 2021-12-13 11:16:43 +08:00
liufei
8958bddb25 增加隐藏托盘图标的功能 2021-12-13 10:53:55 +08:00
liufei
00f581a03e 删除开发模式代码 增加更新日志 2021-12-13 10:04:15 +08:00
liufei
24ba279b18 样式优化 bug修改 鼠标中键呼出 2021-12-10 17:58:23 +08:00
liufei
ba59e8c354 fix github url 2021-09-15 16:31:32 +08:00
liufei
1c486a5c8a 修改正确的github更新rul 2021-09-15 16:25:51 +08:00
Demo-Liu
95e704279e Update README.md 2021-09-15 16:15:58 +08:00
liufei
8b115ef27c 修改微信赞赏码 2021-09-15 10:54:07 +08:00
liufei
b097001e6c 更新版本信息 2021-09-15 10:12:44 +08:00
Demo-Liu
79de085158 Update README.md 2021-09-13 19:54:23 +08:00
Demo-Liu
cfd2d041af Merge pull request #23 from Demo-Liu/2.3.11
更新说明
2021-09-11 22:06:08 +08:00
Demo_Liu
3d877092e5 更新说明 2021-09-11 22:04:16 +08:00
Demo-Liu
f7ff6e4a46 Merge pull request #22 from Demo-Liu/2.3.11
2.3.11
2021-09-11 21:58:24 +08:00
Demo_Liu
63f9043e00 修复打开项目程序崩溃bug 2021-09-11 21:57:37 +08:00
Demo_Liu
7bfe14c211 修复打开项目程序崩溃的bug 2021-09-11 21:54:54 +08:00
Demo-Liu
af8e0b7df2 Merge pull request #21 from Demo-Liu/2.3
gitee 链接
2021-09-11 17:11:29 +08:00
liufei
b7431c0408 gitee 链接 2021-09-11 17:10:39 +08:00
Demo-Liu
a301e051b6 Merge pull request #20 from Demo-Liu/2.3
修复一个小bug
2021-09-11 16:31:37 +08:00
liufei
d60435cd61 修复一个小bug 2021-09-11 16:28:55 +08:00
85 changed files with 3869 additions and 1173 deletions

View File

@@ -1,5 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="SystemIcons" type="System.Configuration.DictionarySectionHandler" />
</configSections>
<SystemIcons>
<add key="Calculator" value="计算器" />
<add key="Computer" value="此电脑" />
<add key="GroupPolicy" value="组策略" />
<add key="Network" value="网络连接" />
<add key="RecycleBin" value="回收站" />
<add key="Registry" value="注册表编辑器" />
<add key="Notepad" value="记事本" />
<add key="Mstsc" value="远程桌面连接" />
<add key="Control" value="控制面板" />
<add key="CMD" value="命令行" />
<add key="Services" value="服务" />
</SystemIcons>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
@@ -28,12 +44,13 @@
</assemblyBinding>
</runtime>
<appSettings>
<add key="Version" value="2.3.10" />
<add key="Version" value="2.4.13" />
<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="" />
<add key="CustomIconTeachUrl" value="https://mp.weixin.qq.com/s/LxoHAekho9HBVl4FRw_Law" />
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">

View File

@@ -12,6 +12,7 @@
<ResourceDictionary Source="/GeekDesk;component/Resource/Dictionary/Geometry.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
<ResourceDictionary Source="/GeekDesk;component/Resource/Dictionary/CommonStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

View File

@@ -1,7 +1,9 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using Microsoft.Win32;
using System;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Threading;
@@ -19,6 +21,8 @@ namespace GeekDesk
public App()
{
this.Startup += new StartupEventHandler(App_Startup);
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}
private void App_Startup(object sender, StartupEventArgs e)
@@ -35,47 +39,24 @@ namespace GeekDesk
}
}
}
void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
e.Handled = true;//使用这一行代码告诉运行时该异常被处理了不再作为UnhandledException抛出了。
LogUtil.WriteErrorLog(e, "未捕获异常!");
if (Constants.DEV)
{
MessageBox.Show("GeekDesk遇到一个问题, 不用担心, 这不影响其它操作!");
}
}
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
LogUtil.WriteErrorLog(e, "严重异常!");
MessageBox.Show("GeekDesk遇到未知问题崩溃!");
}
}
// private void WriteLog(object exception)
// {
// Exception ex = exception as Exception;
// using (FileStream fs = File.Open(".//ErrorLog.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite))
// {
// fs.Seek(0, SeekOrigin.End);
// byte[] buffer = Encoding.Default.GetBytes("-------------------------------------------------------\r\n");
// fs.Write(buffer, 0, buffer.Length);
// buffer = Encoding.Default.GetBytes(DateTime.Now.ToString() + "\r\n");
// fs.Write(buffer, 0, buffer.Length);
// if (ex != null)
// {
// buffer = Encoding.Default.GetBytes("成员名: " + ex.TargetSite + "\r\n");
// fs.Write(buffer, 0, buffer.Length);
// buffer = Encoding.Default.GetBytes("引发异常的类: " + ex.TargetSite.DeclaringType + "\r\n");
// fs.Write(buffer, 0, buffer.Length);
// buffer = Encoding.Default.GetBytes("异常信息: " + ex.Message + "\r\n");
// fs.Write(buffer, 0, buffer.Length);
// buffer = Encoding.Default.GetBytes("引发异常的程序集或对象: " + ex.Source + "\r\n");
// fs.Write(buffer, 0, buffer.Length);
// buffer = Encoding.Default.GetBytes("栈:" + ex.StackTrace + "\r\n");
// fs.Write(buffer, 0, buffer.Length);
// }
// else
// {
// buffer = Encoding.Default.GetBytes("应用程序错误: " + exception.ToString() + "\r\n");
// fs.Write(buffer, 0, buffer.Length);
// }
// }
//}
}

View File

@@ -5,8 +5,8 @@ namespace GeekDesk.Constant
{
public enum CommonEnum
{
WINDOW_WIDTH = 666, //默认窗体宽度
WINDOW_HEIGHT = 500, //默认窗体高度
WINDOW_WIDTH = 850, //默认窗体宽度
WINDOW_HEIGHT = 600, //默认窗体高度
MENU_CARD_WIDHT = 165, //默认菜单栏宽度
IMAGE_WIDTH = 45, //默认图标宽度
IMAGE_HEIGHT = 45, //默认图标高度

File diff suppressed because one or more lines are too long

View File

@@ -3,7 +3,9 @@
public enum SortType
{
CUSTOM = 1, //自定义排序
NAME = 2, //按名称排
COUNT = 3 //按使用次数
COUNT_UP = 2, //按使用次数升
COUNT_LOW = 3, //按使用次数
NAME_UP = 4, //按名称升序
NAME_LOW = 5, //按名称降序
}
}

View File

@@ -2,11 +2,15 @@
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"
Background="AliceBlue"
BorderThickness="1"
BorderThickness="0"
Style="{StaticResource BorderBG}"
Margin="15"
BorderBrush="{DynamicResource BorderBrush}"
Width="320"
Height="450">
<Border.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0.96"/>
</Border.Background>
<Grid>
<Image Source="/Resource/Image/BacklogImg.png" Margin="22,35,22,361" />
@@ -32,7 +36,7 @@
</hc:Card.Footer>
</hc:Card>
<hc:UniformSpacingPanel Spacing="20" HorizontalAlignment="Center" Margin="0,346,0,0">
<hc:UniformSpacingPanel Spacing="20" HorizontalAlignment="Center" Margin="45.5,310,42.5,36">
<hc:TextBox x:Name="DelayTime" Height="20" Width="60" Text="10" PreviewTextInput="DelayTime_PreviewTextInput" PreviewLostKeyboardFocus="DelayTime_PreviewLostKeyboardFocus" />
<ComboBox x:Name="DelayType" hc:DropDownElement.ConsistentWidth="False" SelectedIndex="0" Height="20" Width="60">
<ComboBox.Items>

View File

@@ -40,13 +40,15 @@ namespace GeekDesk.Control.Other
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 nowTime = DateTime.Now;
DateTime nextTime = ddo.LocalDateTime;
TimeSpan ts = nextTime.Subtract(dtNow);
//计算下次执行时间
DateTime nextTime = DateTime.SpecifyKind(exp.GetNextValidTimeAfter(nowTime).Value.LocalDateTime, DateTimeKind.Local);
string nextTimeStr = nextTime.ToString("yyyy-MM-dd HH:mm:ss");
info.ExeTime = nextTimeStr;
TimeSpan ts = nextTime.Subtract(nowTime);
int minutes = (int)Math.Ceiling(ts.TotalMinutes);
if (minutes < 0)
{
@@ -62,7 +64,8 @@ namespace GeekDesk.Control.Other
{
Growl.SuccessGlobal("下次任务将在 " + minutes + " 分钟后提醒您!");
}
} else
}
else
{
appData.ToDoList.Remove(info); //执行任务删除
appData.HiToDoList.Add(info); //添加历史任务
@@ -120,7 +123,7 @@ namespace GeekDesk.Control.Other
ToDoInfo info = this.DataContext as ToDoInfo;
int time = int.Parse(DelayTime.Text);
string type = DelayType.Text;
switch(type)
switch (type)
{
case "分":
info.ExeTime = DateTime.Now.AddMinutes(time).ToString("yyyy-MM-dd HH:mm:ss");

View File

@@ -5,7 +5,8 @@
CornerRadius="3"
Width="400"
Height="230"
Opacity="0.95">
Opacity="0.95"
Style="{StaticResource BorderBG}">
<Border.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<Setter Property="Width" Value="100"/>
@@ -14,10 +15,7 @@
<Setter Property="FontSize" Value="14"/>
</Style>
</Border.Resources>
<Border.Background>
<SolidColorBrush Color="AliceBlue" Opacity="1"/>
</Border.Background>
<hc:SimplePanel Margin="10">
<StackPanel Margin="10">
<Grid Margin="8,20,8,20">
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,-10">
@@ -37,15 +35,16 @@
</hc:UniformSpacingPanel>
<TextBlock Text="注: 需配置正确的url方可加载远程图标!" Foreground="Red" Margin="10,95,-10,-92" />
<hc:UniformSpacingPanel Spacing="10" Margin="246.206,124.551,-246.206,-124.551">
<Button Content="取消" Command="hc:ControlCommands.Close"
<hc:UniformSpacingPanel Spacing="10" Margin="203,125,-203,-125">
<Button Content="取消" Command="hc:ControlCommands.Close" HorizontalAlignment="Stretch" Margin="-1,1,1,1" VerticalAlignment="Stretch"
/>
<Button Content="教程" Click="Teach_Click"
Style="{StaticResource Btn1}"/>
<Button Content="保存" Click="Confirm_Click"
Command="hc:ControlCommands.Close"
Background="#5BC0DE"
Foreground="White"/>
Style="{StaticResource Btn1}"/>
</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>
</StackPanel>
</Border>

View File

@@ -3,6 +3,8 @@ using GeekDesk.Util;
using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
using System.Configuration;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
@@ -35,10 +37,18 @@ namespace GeekDesk.Control.Other
if (!StringUtil.IsEmpty(IconUrl.Text) && !StringUtil.IsEmpty(JsonUrl.Text))
{
IconfontWindow.vm.IsSettingUrl = "true";
} else
}
else
{
IconfontWindow.vm.IsSettingUrl = "false";
}
}
private void Teach_Click(object sender, RoutedEventArgs e)
{
string url = ConfigurationManager.AppSettings["CustomIconTeachUrl"];
Process.Start(url);
}
}
}

View File

@@ -3,35 +3,36 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
CornerRadius="4"
Width="300"
Height="300"
Width="350"
Height="450"
Style="{StaticResource BorderBG}"
>
<Border.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<Setter Property="Width" Value="40"/>
<Setter Property="Width" Value="75"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,8,0,0"/>
<Setter Property="FontSize" Value="14"/>
</Style>
</Border.Resources>
<Border.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0.98"/>
</Border.Background>
<hc:SimplePanel Margin="10">
<Grid Margin="8,20,8,20">
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<hc:SimplePanel Margin="10" VerticalAlignment="Center">
<StackPanel>
<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<hc:UniformSpacingPanel Spacing="10">
<TextBlock Text="名称:" Style="{StaticResource LeftTB}"/>
<TextBox x:Name="IconName" Text="{Binding Name, Mode=OneWay}" Width="180" FontSize="14"/>
<TextBox x:Name="IconName" Text="{Binding Name, Mode=OneWay}" Width="230" 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:Divider LineStrokeDashArray="3,3" LineStroke="Black"/>
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<TextBlock Text="图标:" Style="{StaticResource LeftTB}"/>
<Image x:Name="IconImg" Source="{Binding BitmapImage, Mode=OneWay}" Width="60" Height="60"/>
<Image x:Name="IconImg" Source="{Binding BitmapImage, Mode=OneWay}" RenderOptions.BitmapScalingMode="HighQuality" Width="60" Height="60"/>
<Button Content="修改" Click="EditImage"/>
<Button Content="重置" Click="ReStoreImage"/>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" Margin="0,128,0,23" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10" Margin="0,150,0,10" Grid.ColumnSpan="4">
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10">
<CheckBox x:Name="IconIsAdmin" Content="始终以管理员方式启动" IsChecked="{Binding AdminStartUp, Mode=OneWay}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
@@ -40,11 +41,14 @@
</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="保存" Click="SaveProperty" Margin="208,6,-208,-10"/>
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10">
<TextBlock Text="启动参数:" Style="{StaticResource LeftTB}"/>
<TextBox x:Name="StartArg" Text="{Binding StartArg, Mode=OneWay}" Width="230" Height="100" TextWrapping="Wrap" FontSize="14"/>
</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:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<Button Content="保存" Style="{StaticResource Btn1}" Click="SaveProperty" Margin="265,10,0,0"/>
</hc:UniformSpacingPanel>
</StackPanel>
</hc:SimplePanel>
</Border>

View File

@@ -38,6 +38,7 @@ namespace GeekDesk.Control.Other
info.BitmapImage = IconImg.Source as BitmapImage;
info.Name = IconName.Text;
info.AdminStartUp = IconIsAdmin.IsChecked.Value;
info.StartArg = StartArg.Text;
CommonCode.SaveAppData(MainWindow.appData);
dialog.Close();
}
@@ -74,9 +75,11 @@ namespace GeekDesk.Control.Other
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
CommonCode.SaveAppData(MainWindow.appData);
}
} catch (Exception)
}
catch (Exception e1)
{
HandyControl.Controls.Growl.WarningGlobal("修改图标失败,已重置为默认图标!");
LogUtil.WriteErrorLog(e1, "修改图标失败!");
}
}

View File

@@ -4,42 +4,43 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
CornerRadius="4"
Width="300"
Height="300"
Height="340"
Style="{StaticResource BorderBG}"
>
<Border.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<Setter Property="Width" Value="40"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,8,0,0"/>
<Setter Property="FontSize" Value="14"/>
</Style>
</Border.Resources>
<Border.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0.98"/>
</Border.Background>
<hc:SimplePanel Margin="10">
<Grid Margin="8,20,8,20">
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<StackPanel>
<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<hc:UniformSpacingPanel Spacing="10" VerticalAlignment="Center">
<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,77,0,-27">
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black"/>
<hc:UniformSpacingPanel Spacing="10" VerticalAlignment="Center">
<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">
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black"/>
<hc:UniformSpacingPanel Spacing="10" VerticalAlignment="Center">
<TextBlock Text="图标:" Style="{StaticResource LeftTB}"/>
<Image x:Name="IconImg" Source="{Binding BitmapImage, Mode=OneWay}" Width="60" Height="60"/>
<Image x:Name="IconImg" Source="{Binding BitmapImage, Mode=OneWay}" RenderOptions.BitmapScalingMode="HighQuality" Width="60" Height="60"/>
<Button Content="修改" Click="EditImage"/>
<Button Content="重置" Click="ReStoreImage"/>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" Margin="0,200,0,-27" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10" Margin="0,218,0,-38" Grid.ColumnSpan="4">
<Button Content="保存" Click="SaveProperty" Margin="208,6,-208,-10"/>
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black"/>
<hc:UniformSpacingPanel Spacing="10">
<Button Content="保存" Click="SaveProperty" Style="{StaticResource Btn1}" Margin="224,-10,-224,0" />
</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"/>
</StackPanel>
</hc:SimplePanel>
</Border>

View File

@@ -89,9 +89,10 @@ namespace GeekDesk.Control.Other
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
CommonCode.SaveAppData(MainWindow.appData);
}
} catch (Exception)
} catch (Exception ex)
{
HandyControl.Controls.Growl.WarningGlobal("修改图标失败,已重置为默认图标!");
LogUtil.WriteErrorLog(ex, "修改图标失败!");
}
}

View File

@@ -4,16 +4,15 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Background="AliceBlue"
Background="Transparent"
d:DesignHeight="400" d:DesignWidth="500">
<UserControl.Resources>
<cvt:UpdateTypeConvert x:Key="UpdateTypeConvert"/>
</UserControl.Resources>
<Grid MouseDown="DragMove" Background="AliceBlue">
<Grid MouseDown="DragMove">
<hc:SimplePanel Margin="20,50,20,20" >
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="/Resource/Image/About.png" Width="400" Height="100"/>
@@ -22,14 +21,14 @@
<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="Star"
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="Star"
Command="hc:ControlCommands.OpenLink"
CommandParameter=""
Margin="0,5,10,0" Color="#C71D23"/>
CommandParameter="https://gitee.com/demo_liu/GeekDesk"
Margin="0,0,10,0" Color="#C71D23"/>
</hc:UniformSpacingPanel>
@@ -62,17 +61,9 @@
</hc:Poptip.Instance>
</hc:Shield>
</hc:UniformSpacingPanel>
<TextBlock Margin="0,20,0,0" FontSize="13" Width="200" TextAlignment="Center" Text="这是个人开发的程序,所有人可任意修改和免费使用(商用请联系作者)" TextWrapping="Wrap"/>
<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"
IsChecked="{Binding UpdateType, Mode=TwoWay, Converter={StaticResource UpdateTypeConvert}, ConverterParameter=1}"/>
<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>
</Grid>

View File

@@ -6,13 +6,16 @@
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Background="AliceBlue"
Background="Transparent"
d:DesignHeight="300" d:DesignWidth="450">
<UserControl.Resources>
<cvt:HideTypeConvert x:Key="HideTypeConvert"/>
</UserControl.Resources>
<Grid Background="AliceBlue" MouseDown="DragMove">
<Grid Background="Transparent" MouseDown="DragMove"
>
<StackPanel Panel.ZIndex="1" hc:Growl.GrowlParent="True" hc:Growl.Token="HotKeyGrowl"></StackPanel>
<StackPanel Margin="10">
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<TextBlock Text="面板动作设置" VerticalAlignment="Center"/>
@@ -38,7 +41,27 @@
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<CheckBox Content="贴边隐藏" IsChecked="{Binding MarginHide}" Checked="MarginHide_Changed" Unchecked="MarginHide_Changed">
<CheckBox Content="鼠标中键呼出" Click="MouseMiddle_Changed" IsChecked="{Binding MouseMiddleShow}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<CheckBox Content="双击启动" IsChecked="{Binding DoubleOpen}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<CheckBox Content="悬停切换菜单" IsChecked="{Binding HoverMenu}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
@@ -48,7 +71,17 @@
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<CheckBox Content="主窗口动画效果" IsChecked="{Binding AppAnimation}" Checked="Animation_Checked">
<CheckBox Content="贴边隐藏" IsChecked="{Binding MarginHide}" Click="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,5,0,0" Grid.ColumnSpan="4">
<CheckBox Content="主窗口动画效果" IsChecked="{Binding AppAnimation}" Click="Animation_Checked">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
@@ -89,8 +122,8 @@
/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<TextBlock Text="新建待办:" Width="55"/>
<hc:TextBox HorizontalAlignment="Left"
<TextBlock Text="新建待办:" Width="55"/>
<hc:TextBox HorizontalAlignment="Left"
Tag="ToDo"
VerticalAlignment="Top"
IsReadOnly="True"
@@ -100,8 +133,7 @@
KeyDown="HotKeyDown"
KeyUp="HotKeyUp"
/>
</hc:UniformSpacingPanel>
<StackPanel hc:Growl.GrowlParent="True" hc:Growl.Token="HotKeyGrowl" VerticalAlignment="Top"/>
</hc:UniformSpacingPanel>
</StackPanel>
</Grid>

View File

@@ -1,5 +1,6 @@
using GeekDesk.Constant;
using GeekDesk.Control.Windows;
using GeekDesk.MyThread;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Data;
@@ -30,7 +31,7 @@ namespace GeekDesk.Control.UserControls.Config
public partial class MotionControl : UserControl
{
public static bool hotkeyFinished = true; //热键设置结束
private KeyEventArgs prevKeyTemp; //上一个按键
private Key prevKeyTemp = Key.None; //上一个按键
private readonly List<KeyEventArgs> keysTemp = new List<KeyEventArgs>();//存储一次快捷键集合
private readonly AppConfig appConfig = MainWindow.appData.AppConfig;
@@ -49,13 +50,19 @@ namespace GeekDesk.Control.UserControls.Config
{
string tag = (sender as TextBox).Tag.ToString();
Key downKey = e.Key;
if (downKey == Key.System)
{
downKey = e.SystemKey;
}
bool main = false;
if ("Main".Equals(tag))
{
main = true;
}
if (!e.IsRepeat)
if (prevKeyTemp == Key.None || prevKeyTemp != downKey)
{
if (hotkeyFinished)
{
@@ -64,32 +71,33 @@ namespace GeekDesk.Control.UserControls.Config
appConfig.Hotkey = 0;
appConfig.HotkeyStr = "";
appConfig.HotkeyModifiers = 0;
} else
}
else
{
appConfig.ToDoHotkey = 0;
appConfig.ToDoHotkeyStr = "";
appConfig.ToDoHotkeyModifiers = 0;
}
hotkeyFinished = false;
}
//首次按下按键
if ((main && (appConfig.HotkeyStr == null || appConfig.HotkeyStr.Length == 0))
|| (!main && (appConfig.ToDoHotkeyStr == null || appConfig.ToDoHotkeyStr.Length == 0)))
{
if (CheckModifierKeys(e))
if (CheckModifierKeys(downKey))
{
//辅助键
if (main)
{
appConfig.HotkeyStr = GetKeyName(e);
appConfig.HotkeyModifiers = GetModifierKeys(e);
} else
{
appConfig.ToDoHotkeyStr = GetKeyName(e);
appConfig.ToDoHotkeyModifiers = GetModifierKeys(e);
appConfig.HotkeyStr = GetKeyName(downKey);
appConfig.HotkeyModifiers = GetModifierKeys(downKey);
}
prevKeyTemp = e;
else
{
appConfig.ToDoHotkeyStr = GetKeyName(downKey);
appConfig.ToDoHotkeyModifiers = GetModifierKeys(downKey);
}
prevKeyTemp = downKey;
keysTemp.Add(e);
}
}
@@ -97,48 +105,50 @@ namespace GeekDesk.Control.UserControls.Config
{
//非首次按下 需要判断前一个键值是否为辅助键
if (CheckModifierKeys(prevKeyTemp)
&& ((e.Key >= Key.A && e.Key <= Key.Z)
|| (e.Key >= Key.F1 && e.Key <= Key.F12)
|| (e.Key >= Key.D0 && e.Key <= Key.D9)))
&& ((downKey >= Key.A && downKey <= Key.Z)
|| (downKey >= Key.F1 && downKey <= Key.F12)
|| (downKey >= Key.D0 && downKey <= Key.D9)))
{
if (main)
{
appConfig.Hotkey = e.Key;
appConfig.HotkeyStr += e.Key.ToString();
} else
{
appConfig.ToDoHotkey = e.Key;
appConfig.ToDoHotkeyStr += e.Key.ToString();
appConfig.Hotkey = downKey;
appConfig.HotkeyStr += downKey.ToString();
}
prevKeyTemp = e;
else
{
appConfig.ToDoHotkey = downKey;
appConfig.ToDoHotkeyStr += downKey.ToString();
}
prevKeyTemp = downKey;
keysTemp.Add(e);
}
else if (CheckModifierKeys(e))
else if (CheckModifierKeys(downKey))
{
if (main)
{
appConfig.HotkeyStr += GetKeyName(e);
appConfig.HotkeyModifiers |= GetModifierKeys(e);
} else
appConfig.HotkeyStr += GetKeyName(downKey);
appConfig.HotkeyModifiers |= GetModifierKeys(downKey);
}
else
{
appConfig.ToDoHotkeyStr += GetKeyName(e);
appConfig.ToDoHotkeyModifiers |= GetModifierKeys(e);
appConfig.ToDoHotkeyStr += GetKeyName(downKey);
appConfig.ToDoHotkeyModifiers |= GetModifierKeys(downKey);
}
prevKeyTemp = e;
prevKeyTemp = downKey;
keysTemp.Add(e);
}
}
}
}
private string GetKeyName(KeyEventArgs e)
private string GetKeyName(Key key)
{
Key key = e.Key;
if (key == Key.LeftCtrl || key == Key.RightCtrl)
{
return "Ctrl + ";
} else if (key == Key.LWin || key == Key.RWin)
}
else if (key == Key.LWin || key == Key.RWin)
{
return "Win + ";
}
@@ -150,12 +160,10 @@ namespace GeekDesk.Control.UserControls.Config
{
return "Alt + ";
}
}
private HotkeyModifiers GetModifierKeys(KeyEventArgs e)
private HotkeyModifiers GetModifierKeys(Key key)
{
Key key = e.Key;
if (key == Key.LeftCtrl || key == Key.RightCtrl)
{
return HotkeyModifiers.MOD_CONTROL;
@@ -174,9 +182,8 @@ namespace GeekDesk.Control.UserControls.Config
}
}
private bool CheckModifierKeys(KeyEventArgs e)
private bool CheckModifierKeys(Key key)
{
Key key = e.Key;
return key == Key.LeftCtrl || key == Key.RightCtrl
|| key == Key.LWin || key == Key.RWin
|| key == Key.LeftShift || key == Key.RightShift
@@ -185,7 +192,7 @@ namespace GeekDesk.Control.UserControls.Config
[MethodImpl(MethodImplOptions.Synchronized)]
private void HotKeyUp(object sender, KeyEventArgs e)
private void HotKeyUp(object sender, KeyEventArgs e)
{
string tag = (sender as TextBox).Tag.ToString();
bool main = false;
@@ -193,7 +200,7 @@ namespace GeekDesk.Control.UserControls.Config
{
main = true;
}
lock(this)
lock (this)
{
bool allKeyUp = true;
//判断所有键是否都松开
@@ -208,6 +215,7 @@ namespace GeekDesk.Control.UserControls.Config
if (allKeyUp && !hotkeyFinished)
{
keysTemp.Clear();
prevKeyTemp = Key.None;
hotkeyFinished = true;
if (main)
@@ -218,7 +226,8 @@ namespace GeekDesk.Control.UserControls.Config
GlobalHotKey.Dispose(MainWindow.hotKeyId);
}
MainWindow.RegisterHotKey(false);
} else
}
else
{
if (MainWindow.toDoHotKeyId != -1)
{
@@ -250,13 +259,11 @@ namespace GeekDesk.Control.UserControls.Config
{
if (appConfig.MarginHide)
{
MainWindow.hide.TimerSet();
} else
MarginHide.StartHide();
}
else
{
if (MainWindow.hide.timer != null)
{
MainWindow.hide.TimerStop();
}
MarginHide.StopHide();
}
}
@@ -271,5 +278,22 @@ namespace GeekDesk.Control.UserControls.Config
}
/// <summary>
/// 鼠标中键呼出 change
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MouseMiddle_Changed(object sender, RoutedEventArgs e)
{
if (appConfig.MouseMiddleShow)
{
MouseHookThread.MiddleHook();
}
else
{
MouseHookThread.Dispose();
}
}
}
}

View File

@@ -7,14 +7,15 @@
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Background="AliceBlue"
Background="Transparent"
d:DesignHeight="400" d:DesignWidth="500"
>
<UserControl.Resources>
<cvt:UpdateTypeConvert x:Key="UpdateTypeConvert"/>
<cvt:SortTypeConvert x:Key="SortTypeConvert"/>
</UserControl.Resources>
<Grid MouseDown="DragMove" Background="AliceBlue">
<Grid MouseDown="DragMove" Background="Transparent">
<hc:SimplePanel Margin="20" >
<StackPanel >
<TextBlock Text="程序设置" />
@@ -40,6 +41,45 @@
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<TextBlock Text="排序方式" Margin="0,25,0,0"/>
<hc:UniformSpacingPanel Spacing="10" Margin="20,8,0,0">
<RadioButton x:Name="CustomSort" Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
Style="{StaticResource RadioButtonIcon}" Content="自定义"
Tag="1"
hc:IconElement.Geometry="{StaticResource CustomSort}"
PreviewMouseLeftButtonDown="SortType_PreviewMouseLeftButtonDown"
IsChecked="{Binding IconSortType, Mode=OneWay, Converter={StaticResource SortTypeConvert}, ConverterParameter=1}"/>
<RadioButton x:Name="CountUpSort" Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
hc:IconElement.Geometry="{StaticResource UpSort}"
Style="{StaticResource RadioButtonIcon}" Content="使用次数"
Tag="2"
PreviewMouseLeftButtonDown="SortType_PreviewMouseLeftButtonDown"
IsChecked="{Binding IconSortType, Mode=OneWay, Converter={StaticResource SortTypeConvert}, ConverterParameter=2}"/>
<RadioButton x:Name="CountLowSort" Margin="10,0,0,0" Visibility="Collapsed" Background="{DynamicResource SecondaryRegionBrush}"
hc:IconElement.Geometry="{StaticResource LowSort}"
Style="{StaticResource RadioButtonIcon}" Content="使用次数"
Tag="3"
PreviewMouseLeftButtonDown="SortType_PreviewMouseLeftButtonDown"
IsChecked="{Binding IconSortType, Mode=OneWay, Converter={StaticResource SortTypeConvert}, ConverterParameter=3}"/>
<RadioButton x:Name="NameUpSort" Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
hc:IconElement.Geometry="{StaticResource UpSort}"
Style="{StaticResource RadioButtonIcon}" Content="名称"
Tag="4"
PreviewMouseLeftButtonDown="SortType_PreviewMouseLeftButtonDown"
IsChecked="{Binding IconSortType, Mode=OneWay, Converter={StaticResource SortTypeConvert}, ConverterParameter=4}"/>
<RadioButton x:Name="NameLowSort" Margin="10,0,0,0" Visibility="Collapsed" Background="{DynamicResource SecondaryRegionBrush}"
hc:IconElement.Geometry="{StaticResource LowSort}"
Style="{StaticResource RadioButtonIcon}" Content="名称"
Tag="5"
PreviewMouseLeftButtonDown="SortType_PreviewMouseLeftButtonDown"
IsChecked="{Binding IconSortType, Mode=OneWay, Converter={StaticResource SortTypeConvert}, ConverterParameter=5}"/>
</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}"

View File

@@ -26,6 +26,13 @@ namespace GeekDesk.Control.UserControls.Config
public OtherControl()
{
InitializeComponent();
this.Loaded += OtherControl_Loaded;
}
private void OtherControl_Loaded(object sender, RoutedEventArgs e)
{
Sort_Check();
}
private void SelfStartUpBox_Click(object sender, RoutedEventArgs e)
@@ -46,5 +53,70 @@ namespace GeekDesk.Control.UserControls.Config
Window.GetWindow(this).DragMove();
}
}
private void SortType_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
RadioButton rb = sender as RadioButton;
SortType type = (SortType)int.Parse(rb.Tag.ToString());
SortType resType = type;
switch (type)
{
case SortType.CUSTOM:
break;
case SortType.COUNT_UP:
if (rb.IsChecked == true)
{
CountLowSort.IsChecked = true;
CountUpSort.Visibility = Visibility.Collapsed;
CountLowSort.Visibility = Visibility.Visible;
resType = SortType.COUNT_LOW;
}
break;
case SortType.COUNT_LOW:
if (rb.IsChecked == true)
{
CountUpSort.IsChecked = true;
CountLowSort.Visibility = Visibility.Collapsed;
CountUpSort.Visibility = Visibility.Visible;
resType = SortType.COUNT_UP;
}
break;
case SortType.NAME_UP:
if (rb.IsChecked == true)
{
NameLowSort.IsChecked = true;
NameUpSort.Visibility = Visibility.Collapsed;
NameLowSort.Visibility = Visibility.Visible;
resType = SortType.NAME_LOW;
}
break;
case SortType.NAME_LOW:
if (rb.IsChecked == true)
{
NameUpSort.IsChecked = true;
NameLowSort.Visibility = Visibility.Collapsed;
NameUpSort.Visibility = Visibility.Visible;
resType = SortType.NAME_UP;
}
break;
}
MainWindow.appData.AppConfig.IconSortType = resType;
CommonCode.SortIconList();
}
private void Sort_Check()
{
if (NameLowSort.IsChecked == true)
{
NameUpSort.Visibility = Visibility.Collapsed;
NameLowSort.Visibility = Visibility.Visible;
}
if (CountLowSort.IsChecked == true)
{
CountUpSort.Visibility = Visibility.Collapsed;
CountLowSort.Visibility = Visibility.Visible;
}
}
}
}

View File

@@ -3,137 +3,155 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.Config"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Background="AliceBlue"
Background="Transparent"
d:DesignHeight="500" d:DesignWidth="450">
<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"
<Grid MouseDown="DragMove" Background="Transparent">
<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" Margin="0,5,0,0"/>
<TextBlock Text="{Binding BacImgName}" Width="200"
Margin="0,5,0,0"
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"/>
<Button Content="修改" Click="BGButton_Click"/>
<Button Content="默认" Click="DefaultButton_Click"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<hc:PreviewSlider Value="{Binding CardOpacity}"
<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:UniformSpacingPanel Spacing="10" Margin="20,5,0,0" Grid.ColumnSpan="4">
<CheckBox x:Name="BarIcon" Content="显示托盘图标" IsChecked="{Binding ShowBarIcon}">
<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: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}"
<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: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}"
<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: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}"
<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"
<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}"
<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: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="选择" Margin="0,-10,0,0" Click="ColorButton_Click"/>
</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>
</Grid>
<StackPanel x:Name="ColorPanel" Visibility="Collapsed" VerticalAlignment="Center">
<StackPanel x:Name="ColorPanel" Panel.ZIndex="1"
Visibility="Collapsed"
Height="500"
Width="450"
VerticalAlignment="Center">
<StackPanel.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0"/>
</StackPanel.Background>
<hc:ColorPicker
Name="ColorPicker"
Canceled="ColorPicker_Canceled"
SelectedColorChanged="ColorPicker_SelectedColorChanged"/>
<hc:ColorPicker Name="MyColorPicker"
ToggleButton.Checked="MyColorPicker_Checked"
Canceled="MyColorPicker_Canceled"
Confirmed="MyColorPicker_Confirmed"
SelectedColorChanged="MyColorPicker_SelectedColorChanged"/>
</StackPanel>
</Grid>

View File

@@ -1,17 +1,22 @@
using GeekDesk.Util;
using GeekDesk.Constant;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
@@ -26,6 +31,8 @@ namespace GeekDesk.Control.UserControls.Config
{
private static AppConfig appConfig = MainWindow.appData.AppConfig;
private System.Windows.Controls.Primitives.ToggleButton toggleButton = null;
public ThemeControl()
{
InitializeComponent();
@@ -52,28 +59,55 @@ namespace GeekDesk.Control.UserControls.Config
appConfig.BacImgName = ofd.FileName;
}
}
catch (Exception)
catch (Exception ex)
{
LogUtil.WriteErrorLog(ex, "修改背景失败,已重置为默认背景!");
HandyControl.Controls.Growl.WarningGlobal("修改背景失败,已重置为默认背景!");
}
}
private void DefaultButton_Click(object sender, RoutedEventArgs e)
{
try
{
appConfig.BitmapImage = ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_BAC_IMAGE_BASE64);
appConfig.BacImgName = "系统默认";
}
catch (Exception ex)
{
LogUtil.WriteErrorLog(ex, "修改背景失败2,已重置为默认背景!");
HandyControl.Controls.Growl.WarningGlobal("修改背景失败,已重置为默认背景!");
}
}
private void ColorButton_Click(object sender, RoutedEventArgs e)
{
ColorPanel.Visibility = Visibility.Visible;
}
private void ColorPicker_Canceled(object sender, EventArgs e)
/// <summary>
/// 取消按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MyColorPicker_Canceled(object sender, EventArgs e)
{
ColorPanel.Visibility = Visibility.Collapsed;
MyColorPickerClose(sender);
}
private void MyColorPicker_Confirmed(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
{
MyColorPickerClose(sender);
}
private void ColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
private void MyColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
{
SolidColorBrush scb = ColorPicker.SelectedBrush;
SolidColorBrush scb = MyColorPicker.SelectedBrush;
appConfig.TextColor = scb.ToString();
ColorPanel.Visibility = Visibility.Collapsed;
}
/// <summary>
@@ -123,5 +157,27 @@ namespace GeekDesk.Control.UserControls.Config
}
}
}
private void MyColorPicker_Checked(object sender, RoutedEventArgs e)
{
toggleButton = e.OriginalSource as System.Windows.Controls.Primitives.ToggleButton;
}
private void MyColorPickerClose(object sender)
{
if (toggleButton != null && toggleButton.IsChecked == true)
{
HandyControl.Controls.ColorPicker cp = sender as HandyControl.Controls.ColorPicker;
const BindingFlags InstanceBindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
Type type = cp.GetType();
toggleButton.IsChecked = false;
MethodInfo mi = type.GetMethod("ToggleButtonDropper_Click", InstanceBindFlags);
mi.Invoke(cp, new object[] { null, null });
}
ColorPanel.Visibility = Visibility.Collapsed;
}
}
}

View File

@@ -6,9 +6,10 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.IconFont"
mc:Ignorable="d"
Background="#00FFFFFF"
>
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Top">
<ListBox x:Name="IconListBox" ItemsSource="{Binding Iconfonts}" BorderThickness="0" Background="AliceBlue">
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Top" Background="Transparent">
<ListBox x:Name="IconListBox" ItemsSource="{Binding Iconfonts}" BorderThickness="0" Background="Transparent">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" Background="Transparent"/>

View File

@@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
@@ -20,8 +19,9 @@
<SolidColorBrush Opacity="0"/>
</Setter.Value>
</Setter>
<EventSetter Event="MouseLeftButtonDown" Handler="MenuClick"/>
<EventSetter Event="MouseRightButtonDown" Handler="MenuClick"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<EventSetter Event="MouseEnter" Handler="Menu_MouseEnter"/>
<!--<EventSetter Event="Unselected" Handler="ListBoxItem_Unselected"/>-->
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
@@ -42,109 +42,136 @@
</Storyboard>
</BeginStoryboard>
</MultiTrigger.ExitActions>
<MultiTrigger.Setters>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="Black"/>
</MultiTrigger.Setters>
</MultiTrigger>
<!--<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FFE4DBDB"/>
</Trigger>-->
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="#FFECECEC"/>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#ECECEC"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
<!--<Trigger Property="IsSelected" Value="False">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#ECECEC"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>-->
<!--<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property=""></Condition>
</MultiTrigger.Conditions>
</MultiTrigger>-->
</Style.Triggers>
</Style>
<cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
<cvt:OpcityConvert x:Key="OpcityConvert"/>
</UserControl.Resources>
<!--左侧栏-->
<hc:Card x:Name="MyCard"
<!--左侧栏-->
<hc:Card x:Name="MyCard"
BorderThickness="1"
Effect="{DynamicResource EffectShadow2}"
Margin="5,0,0,5"
>
<hc:Card.Background>
<SolidColorBrush Color="#FFFFFFFF" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
<hc:Card.Background>
<SolidColorBrush Color="#FFFFFFFF" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
</SolidColorBrush>
</hc:Card.Background>
<hc:Card.BorderBrush>
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
</hc:Card.BorderBrush>
<hc:Card.ContextMenu>
<ContextMenu Width="200">
<MenuItem Header="新建菜单" Click="CreateMenu"/>
</ContextMenu>
</hc:Card.ContextMenu>
<WrapPanel Orientation="Horizontal">
<ListBox x:Name="MenuListBox"
ItemsSource="{Binding MenuList}"
Tag="{Binding AppConfig.MenuCardWidth}"
BorderThickness="0" Foreground="{x:Null}"
SelectedIndex="{Binding AppConfig.SelectedMenuIndex}"
VirtualizingPanel.VirtualizationMode="Recycling"
SelectionChanged="menus_SelectionChanged"
>
<ListBox.Resources>
<ContextMenu x:Key="MenuDialog" Width="200">
<MenuItem Header="新建菜单" Click="CreateMenu"/>
<MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
<MenuItem Header="修改图标" Click="EditMenuGeometry" Tag="{Binding}"/>
<MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
</SolidColorBrush>
</hc:Card.Background>
<hc:Card.BorderBrush>
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
</hc:Card.BorderBrush>
<hc:Card.ContextMenu>
<ContextMenu Width="200">
<MenuItem Header="新建菜单" Click="CreateMenu"/>
</ContextMenu>
</hc:Card.ContextMenu>
<WrapPanel Orientation="Horizontal">
<ListBox x:Name="MenuListBox"
Padding="2,3,0,2"
ItemsSource="{Binding MenuList}"
Tag="{Binding AppConfig.MenuCardWidth}"
BorderThickness="0" Foreground="{x:Null}"
SelectedIndex="{Binding AppConfig.SelectedMenuIndex}"
VirtualizingPanel.VirtualizationMode="Recycling"
SelectionChanged="Menu_SelectionChanged"
>
<ListBox.Resources>
<ContextMenu x:Key="MenuDialog" Width="200">
<MenuItem Header="新建菜单" Click="CreateMenu"/>
<MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
<MenuItem Header="修改图标" Click="EditMenuGeometry" Tag="{Binding}"/>
<MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
</ContextMenu>
</ListBox.Resources>
</ListBox.Resources>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MenuStyle}">
<Setter Property="ContextMenu" Value="{StaticResource MenuDialog}"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0"/>
</ListBox.Background>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MenuStyle}">
<Setter Property="ContextMenu" Value="{StaticResource MenuDialog}"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0"/>
</ListBox.Background>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<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>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel MouseLeftButtonDown="MenuClick" MouseRightButtonDown="MenuClick" Tag="{Binding}">
<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}"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
IsEnabled="False"
Opacity="1"
Foreground="{Binding GeometryColor}"
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Tag="{Binding}">
<TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
HorizontalAlignment="Left"
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}, ConverterParameter=35}"
FontSize="16"
Height="28"
VerticalAlignment="Center"
TextAlignment="Left"
LostFocus="LostFocusOrEnterDown"
KeyDown="LostFocusOrEnterDown"
Tag="{Binding}"
Padding="2"
BorderThickness="0"
IsVisibleChanged="MenuEditWhenVisibilityChanged"
Visibility="{Binding MenuEdit}"/>
<StackPanel Orientation="Horizontal"
IsVisibleChanged="MenuWhenVisibilityChanged"
Visibility="{Binding NotMenuEdit}">
<Button Background="Transparent"
BorderThickness="0"
hc:IconElement.Geometry="{Binding MenuGeometry}"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
IsEnabled="False"
Opacity="1"
Foreground="{Binding GeometryColor}"
/>
<TextBlock Text="{Binding MenuName}"
HorizontalAlignment="Center"
TextAlignment="Center"
VerticalAlignment="Center"
/>
<TextBlock Text="{Binding MenuName}"
HorizontalAlignment="Center"
TextAlignment="Center"
VerticalAlignment="Center"
IsVisibleChanged="MenuWhenVisibilityChanged"
Visibility="{Binding NotMenuEdit}"
/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</hc:Card>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</hc:Card>
</UserControl>

View File

@@ -1,16 +1,18 @@
using DraggAnimatedPanelExample;
using GeekDesk.Control.Windows;
using GeekDesk.MyThread;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using System;
using System.Collections.ObjectModel;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
namespace GeekDesk.Control.UserControls.PannelCard
{
@@ -22,17 +24,20 @@ namespace GeekDesk.Control.UserControls.PannelCard
private int menuSelectIndexTemp = -1;
private AppData appData = MainWindow.appData;
//是否正在修改菜单
private static bool IS_EDIT = false;
public LeftCardControl()
{
InitializeComponent();
if (appData.AppConfig.SelectedMenuIndex >= appData.MenuList.Count || appData.AppConfig.SelectedMenuIndex == -1)
{
appData.AppConfig.SelectedMenuIcons = appData.MenuList[0].IconList;
} else
}
else
{
appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
}
}
DelegateCommand<int[]> _swap;
@@ -60,13 +65,13 @@ namespace GeekDesk.Control.UserControls.PannelCard
}
}
////菜单点击事件
private void MenuClick(object sender, MouseButtonEventArgs e)
{
//设置对应菜单的图标列表
MenuInfo mi = (MenuInfo)(((StackPanel)sender).Tag);
appData.AppConfig.SelectedMenuIcons = mi.IconList;
}
//////菜单点击事件
//private void MenuClick(object sender, MouseButtonEventArgs e)
//{
// //设置对应菜单的图标列表
// MenuInfo mi = (MenuInfo)(((StackPanel)sender).Tag);
// appData.AppConfig.SelectedMenuIcons = mi.IconList;
//}
/// <summary>
/// 当修改菜单元素可见时 设置原菜单为不可见 并且不可选中
@@ -76,9 +81,14 @@ namespace GeekDesk.Control.UserControls.PannelCard
/// <param name="e"></param>
private void MenuWhenVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
{
TextBlock tb = sender as TextBlock;
if (tb.Visibility == Visibility.Collapsed)
StackPanel sp = sender as StackPanel;
//ListBoxItem lbi = (sp.TemplatedParent as ContentPresenter).TemplatedParent as ListBoxItem;
if (sp.Visibility == Visibility.Collapsed)
{
//SolidColorBrush scb = new SolidColorBrush(Colors.Red);
//lbi.MouseEnter += Lbi_MouseEnter;
if (MenuListBox.SelectedIndex != -1)
{
menuSelectIndexTemp = MenuListBox.SelectedIndex;
@@ -88,9 +98,33 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
MenuListBox.SelectedIndex = menuSelectIndexTemp;
}
} else
{
//SolidColorBrush bac = new SolidColorBrush(Color.FromRgb(236, 236, 236));
//SolidColorBrush fontColor = new SolidColorBrush(Colors.Black);
//lbi.MouseEnter += (s, me) =>
//{
// lbi.Background = bac;
//};
//lbi.MouseLeave += Lbi_MouseLeave;
//lbi.Selected += (s, me) =>
//{
// lbi.MouseLeave -= Lbi_MouseLeave;
// lbi.Background = bac;
// lbi.Foreground = fontColor;
//};
}
}
//private void Lbi_MouseEnter(object sender, MouseEventArgs e)
//{
// ListBoxItem lbi = sender as ListBoxItem;
// lbi.Background = Brushes.Transparent;
//}
/// <summary>
/// 新建菜单
/// </summary>
@@ -104,6 +138,27 @@ namespace GeekDesk.Control.UserControls.PannelCard
MenuListBox.SelectedIndex = appData.MenuList.Count - 1;
appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
appData.AppConfig.SelectedMenuIcons = info.IconList;
//ItemCollection ic = MenuListBox.Items;
//SolidColorBrush bac = new SolidColorBrush(Color.FromRgb(236, 236, 236));
//SolidColorBrush fontColor = new SolidColorBrush(Colors.Black);
//foreach (var icItem in ic)
//{
// ListBoxItem lbi = icItem as ListBoxItem;
// lbi.MouseEnter += (s, me) =>
// {
// lbi.Background = bac;
// };
// lbi.MouseLeave += Lbi_MouseLeave;
// lbi.Selected += (s, me) =>
// {
// lbi.MouseLeave -= Lbi_MouseLeave;
// lbi.Background = bac;
// lbi.Foreground = fontColor;
// };
//}
}
/// <summary>
@@ -115,6 +170,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
menuInfo.MenuEdit = (int)Visibility.Visible;
IS_EDIT = true;
}
/// <summary>
@@ -153,6 +209,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
/// <param name="e"></param>
private void LostFocusOrEnterDown(object sender, EventArgs e)
{
bool done = true;
TextBox menuBox = null;
if (e.GetType() == typeof(KeyEventArgs))
{
@@ -160,19 +217,26 @@ namespace GeekDesk.Control.UserControls.PannelCard
if (eKey.Key == Key.Enter)
{
menuBox = ((TextBox)sender);
} else
{
done = false;
}
}
else if (e.GetType() == typeof(RoutedEventArgs))
} else if (e.GetType() == typeof(RoutedEventArgs))
{
menuBox = ((TextBox)sender);
}
if (menuBox != null)
if (done)
{
MenuInfo menuInfo = menuBox.Tag as MenuInfo;
string text = menuBox.Text;
menuInfo.MenuName = text;
menuInfo.MenuEdit = Visibility.Collapsed;
if (menuBox != null)
{
MenuInfo menuInfo = menuBox.Tag as MenuInfo;
string text = menuBox.Text;
menuInfo.MenuName = text;
menuInfo.MenuEdit = Visibility.Collapsed;
}
IS_EDIT = false;
MenuListBox.SelectedIndex = menuSelectIndexTemp;
}
}
@@ -184,6 +248,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
private void MenuEditWhenVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
{
TextBox box = sender as TextBox;
MenuInfo mi = box.Tag as MenuInfo;
if (box.Visibility == Visibility.Visible)
{
Keyboard.Focus(box);
@@ -202,16 +267,58 @@ namespace GeekDesk.Control.UserControls.PannelCard
IconfontWindow.Show(SvgToGeometry.GetIconfonts(), menuInfo);
}
private void menus_SelectionChanged(object sender, SelectionChangedEventArgs e)
private void Menu_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//设置对应菜单的图标列表
if (MenuListBox.SelectedIndex == -1)
{
appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.MenuList.Count-1].IconList;
} else
//appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.MenuList.Count - 1].IconList;
}
else
{
appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList;
}
}
//private void ListBoxItem_Unselected(object sender, RoutedEventArgs e)
//{
// //添加Leave效果
// ListBoxItem lbi = sender as ListBoxItem;
// //lbi.Background = Brushes.Transparent;
// //lbi.MouseLeave += Lbi_MouseLeave;
//}
//private void Lbi_MouseLeave(object sender, MouseEventArgs e)
//{
// ListBoxItem lbi = sender as ListBoxItem;
// lbi.Background = Brushes.Transparent;
//}
/// <summary>
/// 鼠标悬停切换菜单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Menu_MouseEnter(object sender, MouseEventArgs e)
{
if (appData.AppConfig.HoverMenu && !IS_EDIT)
{
new Thread(() =>
{
Thread.Sleep(200);
this.Dispatcher.Invoke(() =>
{
ListBoxItem lbi = sender as ListBoxItem;
if (lbi.IsMouseOver)
{
int index = MenuListBox.ItemContainerGenerator.IndexFromContainer(lbi);
MenuListBox.SelectedIndex = index;
}
});
}).Start();
}
}
}
}

View File

@@ -3,20 +3,30 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:temp="clr-namespace:GeekDesk.ViewModel.Temp"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
d:DesignHeight="450" d:DesignWidth="800"
>
<UserControl.Resources>
<!--右侧栏样式动画-->
<!--<Style x:Key="PanelStyle" TargetType="hc:SimpleStackPanel">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Cursor" Value="Hand"/>
</Trigger>
</Style.Triggers>
</Style>-->
<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="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
@@ -29,93 +39,181 @@
</Style>
<cvt:OpcityConvert x:Key="OpcityConvert"/>
<cvt:SearchResWidth x:Key="SearchResWidth"/>
<temp:SearchIconList x:Key="SearchIconList"/>
</UserControl.Resources>
<!--右侧栏-->
<hc:Card AllowDrop="True"
Drop="Wrap_Drop"
BorderThickness="1"
Effect="{DynamicResource EffectShadow2}"
Margin="5,0,5,5" Grid.ColumnSpan="2">
<hc:Card.Background>
<SolidColorBrush Color="AliceBlue" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
</hc:Card.Background>
<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="IconListBox" ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=TwoWay}"
<Grid>
<hc:Card AllowDrop="True"
x:Name="WrapCard"
Visibility="Visible"
Drop="Wrap_Drop"
BorderThickness="1"
Effect="{DynamicResource EffectShadow2}"
Margin="5,0,5,5" Grid.ColumnSpan="2">
<hc:Card.Background>
<SolidColorBrush Color="AliceBlue" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
</hc:Card.Background>
<hc:Card.BorderBrush>
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
</hc:Card.BorderBrush>
<hc:Card.ContextMenu>
<ContextMenu Width="200">
<MenuItem Header="添加URL项目" Click="AddUrlIcon"/>
<MenuItem Header="添加系统项目" Click="AddSystemIcon"/>
</ContextMenu>
</hc:Card.ContextMenu>
<Grid>
<StackPanel Panel.ZIndex="1" Margin="0,-10,-300,0" hc:Growl.GrowlParent="True" hc:Growl.Token="MainWindowGrowl"/>
<WrapPanel Orientation="Horizontal" VirtualizingPanel.VirtualizationMode="Recycling"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.IsContainerVirtualizable="True"
>
<ListBox x:Name="IconListBox" ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=TwoWay}"
BorderThickness="0"
Padding="0,10,0,0"
>
<ListBox.Background>
<SolidColorBrush Opacity="0"/>
</ListBox.Background>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<DraggAnimatedPanel:DraggAnimatedPanel Background="#00FFFFFF"
<ListBox.Background>
<SolidColorBrush Opacity="0"/>
</ListBox.Background>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<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>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Resources>
<ContextMenu x:Key="IconDialog" Width="200">
<MenuItem Header="管理员方式运行" Click="IconAdminStart" Tag="{Binding}"/>
<MenuItem Header="打开文件所在位置" Click="ShowInExplore" 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.Resources>
<ContextMenu x:Key="IconDialog" Width="200">
<MenuItem Header="管理员方式运行" Click="IconAdminStart" Tag="{Binding}"/>
<MenuItem Header="打开文件所在位置" Click="ShowInExplore" Tag="{Binding}"/>
<MenuItem Header="添加URL项目" Click="AddUrlIcon"/>
<MenuItem Header="添加系统项目" Click="AddSystemIcon"/>
<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" 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.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MyListBoxItemStyle}">
<Setter Property="ContextMenu" Value="{StaticResource IconDialog}"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<hc:SimpleStackPanel Tag="{Binding}"
Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelHeight, Mode=OneWay}"
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelWidth, Mode=OneWay}"
HorizontalAlignment="Center"
hc:Poptip.HitMode="None"
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
hc:Poptip.Content="{Binding Content}"
hc:Poptip.Placement="BottomLeft"
Background="#00FFFFFF"
MouseLeftButtonUp="IconClick"
MouseEnter="StackPanel_MouseEnter"
MouseLeave="StackPanel_MouseLeave"
>
<Image Style="{StaticResource ImageStyle}"/>
<TextBlock MaxWidth="80"
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>
</WrapPanel>
</hc:Card>
<ListBox.ItemTemplate>
<DataTemplate>
<hc:SimpleStackPanel Tag="{Binding}"
Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelHeight, Mode=OneWay}"
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelWidth, Mode=OneWay}"
HorizontalAlignment="Center"
hc:Poptip.Content="{Binding Content}"
hc:Poptip.Placement="BottomLeft"
Background="#00FFFFFF"
MouseEnter="StackPanel_MouseEnter"
MouseLeave="StackPanel_MouseLeave"
>
<Image Style="{StaticResource ImageStyle}" RenderOptions.BitmapScalingMode="HighQuality"/>
<TextBlock MaxWidth="80"
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>
</WrapPanel>
</Grid>
</hc:Card>
<hc:Card
x:Name="VerticalCard"
Visibility="Hidden"
BorderThickness="1"
Effect="{DynamicResource EffectShadow2}"
Margin="5,0,5,5" Grid.ColumnSpan="2">
<hc:Card.Background>
<SolidColorBrush Color="AliceBlue" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
</hc:Card.Background>
<hc:Card.BorderBrush>
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
</hc:Card.BorderBrush>
<Grid>
<StackPanel Panel.ZIndex="1" Margin="0,-10,-300,0" hc:Growl.GrowlParent="True" hc:Growl.Token="MainWindowGrowl"/>
<WrapPanel Orientation="Horizontal" VirtualizingPanel.VirtualizationMode="Recycling"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.IsContainerVirtualizable="True"
>
<ListBox ItemsSource="{Binding Source={StaticResource SearchIconList},Path=IconList}"
BorderThickness="0"
Padding="0,10,0,0"
>
<ListBox.Background>
<SolidColorBrush Opacity="0"/>
</ListBox.Background>
<ListBox.Resources>
<ContextMenu x:Key="IconDialog" Width="200">
<MenuItem Header="管理员方式运行" Click="IconAdminStart" Tag="{Binding}"/>
<MenuItem Header="打开文件所在位置" Click="ShowInExplore" Tag="{Binding}"/>
<MenuItem Header="添加URL项目" Click="AddUrlIcon"/>
<MenuItem Header="添加系统项目" Click="AddSystemIcon"/>
<MenuItem Header="资源管理器菜单" Click="SystemContextMenu" Tag="{Binding}"/>
<MenuItem Header="属性" Click="PropertyConfig" Tag="{Binding}"/>
</ContextMenu>
</ListBox.Resources>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MyListBoxItemStyle}">
<Setter Property="ContextMenu" Value="{StaticResource IconDialog}"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<WrapPanel Tag="{Binding}"
Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.MenuCardWidth, Mode=OneWay, Converter={StaticResource SearchResWidth}}"
HorizontalAlignment="Left"
hc:Poptip.HitMode="None"
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
hc:Poptip.Content="{Binding Content}"
hc:Poptip.Placement="BottomLeft"
Background="#00FFFFFF"
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
Margin="25,20,0,0"
>
<Image Style="{StaticResource ImageStyle}" RenderOptions.BitmapScalingMode="HighQuality"/>
<TextBlock
Margin="10,5,0,0"
MaxHeight="40"
FontSize="13"
TextWrapping="Wrap"
TextTrimming="WordEllipsis"
TextAlignment="Left"
VerticalAlignment="Center"
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
Text="{Binding Name}"/>
</WrapPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</Grid>
</hc:Card>
</Grid>
</UserControl>

View File

@@ -1,29 +1,21 @@
using DraggAnimatedPanelExample;
using GeekDesk.Constant;
using GeekDesk.Control.Other;
using GeekDesk.Control.Windows;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
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.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GeekDesk.Control.UserControls.PannelCard
{
@@ -34,6 +26,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
private AppData appData = MainWindow.appData;
private volatile static bool DROP_ICON = false;
private Thread dropCheckThread = null;
public RightCardControl()
{
InitializeComponent();
@@ -50,6 +45,34 @@ namespace GeekDesk.Control.UserControls.PannelCard
_swap = new DelegateCommand<int[]>(
(indexes) =>
{
DROP_ICON = true;
if (appData.AppConfig.IconSortType != SortType.CUSTOM
&& (dropCheckThread == null || !dropCheckThread.IsAlive))
{
dropCheckThread = new Thread(() =>
{
do
{
DROP_ICON = false;
Thread.Sleep(1000);
} while (DROP_ICON);
MainWindow.appData.AppConfig.IconSortType = SortType.CUSTOM;
App.Current.Dispatcher.Invoke(() =>
{
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed
|| MainWindow.mainWindow.Opacity != 1)
{
Growl.WarningGlobal("已将图标排序规则重置为自定义!");
}
else
{
Growl.Warning("已将图标排序规则重置为自定义!", "MainWindowGrowl");
}
});
});
dropCheckThread.Start();
}
int fromS = indexes[0];
int to = indexes[1];
ObservableCollection<IconInfo> iconList = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
@@ -68,6 +91,23 @@ namespace GeekDesk.Control.UserControls.PannelCard
private void Icon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (appData.AppConfig.DoubleOpen)
{
IconClick(sender, e);
}
}
private void Icon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (!appData.AppConfig.DoubleOpen)
{
IconClick(sender, e);
}
}
/// <summary>
/// 图标点击事件
/// </summary>
@@ -75,15 +115,31 @@ namespace GeekDesk.Control.UserControls.PannelCard
/// <param name="e"></param>
private void IconClick(object sender, MouseButtonEventArgs e)
{
IconInfo icon = (IconInfo)((StackPanel)sender).Tag;
if (icon.AdminStartUp)
if (appData.AppConfig.DoubleOpen && e.ClickCount >= 2)
{
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
IconInfo icon = (IconInfo)((SimpleStackPanel)sender).Tag;
if (icon.AdminStartUp)
{
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
}
else
{
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
}
}
else
else if (!appData.AppConfig.DoubleOpen && e.ClickCount == 1)
{
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
IconInfo icon = (IconInfo)((SimpleStackPanel)sender).Tag;
if (icon.AdminStartUp)
{
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
}
else
{
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
}
}
}
/// <summary>
@@ -112,30 +168,85 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
try
{
Process p = new Process();
p.StartInfo.FileName = icon.Path;
if (icon.IconType == IconType.OTHER)
using (Process p = new Process())
{
if (!File.Exists(icon.Path) && !Directory.Exists(icon.Path))
string startArg = icon.StartArg;
if (startArg != null && Constants.SYSTEM_ICONS.ContainsKey(startArg))
{
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
return;
StartSystemApp(startArg, type);
}
p.StartInfo.WorkingDirectory = icon.Path.Substring(0, icon.Path.LastIndexOf("\\"));
switch (type)
else
{
case IconStartType.ADMIN_STARTUP:
p.StartInfo.Arguments = "1";//启动参数
p.StartInfo.Verb = "runas";
p.StartInfo.CreateNoWindow = false; //设置显示窗口
p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序启动进程
p.StartInfo.ErrorDialog = false;
p.StartInfo.FileName = icon.Path;
if (!StringUtil.IsEmpty(startArg))
{
p.StartInfo.Arguments = startArg;
}
if (icon.IconType == IconType.OTHER)
{
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 = true;//不使用操作系统外壳程序启动进程
//p.StartInfo.ErrorDialog = false;
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
{
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
if (appData.AppConfig.MarginHide)
{
if (!MarginHide.IS_HIDE)
{
MainWindow.HideApp();
}
}
else
{
MainWindow.HideApp();
}
}
break;// c#好像不能case穿透
case IconStartType.DEFAULT_STARTUP:
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
{
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
if (appData.AppConfig.MarginHide)
{
if (!MarginHide.IS_HIDE)
{
MainWindow.HideApp();
}
}
else
{
MainWindow.HideApp();
}
}
break;
case IconStartType.SHOW_IN_EXPLORE:
p.StartInfo.FileName = "Explorer.exe";
p.StartInfo.Arguments = "/e,/select," + icon.Path;
break;
}
}
else
{
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
{
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
if (appData.AppConfig.MarginHide)
{
if (!MainWindow.hide.IsMargin())
if (!MarginHide.IS_HIDE)
{
MainWindow.HideApp();
}
@@ -144,43 +255,103 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
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();
}
}
p.Start();
icon.Count++;
}
catch (Exception)
catch (Exception e)
{
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(不支持的启动方式)!");
LogUtil.WriteErrorLog(e, "程序启动失败:path=" + icon.Path + ",type=" + type);
}
}
private void StartSystemApp(string startArg, IconStartType type)
{
if (type == IconStartType.SHOW_IN_EXPLORE)
{
Growl.WarningGlobal("系统项目不支持打开文件位置操作!");
return;
}
switch (startArg)
{
case "Calculator":
Process.Start("calc.exe");
break;
case "Computer":
Process.Start("explorer.exe");
break;
case "GroupPolicy":
Process.Start("gpedit.msc");
break;
case "Notepad":
Process.Start("notepad");
break;
case "Network":
Process.Start("ncpa.cpl");
break;
case "RecycleBin":
Process.Start("shell:RecycleBinFolder");
break;
case "Registry":
Process.Start("regedit.exe");
break;
case "Mstsc":
if (type == IconStartType.ADMIN_STARTUP)
{
Process.Start("mstsc", "-admin");
}
else
{
Process.Start("mstsc");
}
break;
case "Control":
Process.Start("Control");
break;
case "CMD":
if (type == IconStartType.ADMIN_STARTUP)
{
using (Process process = new Process())
{
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Verb = "runas";
process.Start();
}
}
else
{
Process.Start("cmd");
}
break;
case "Services":
Process.Start("services.msc");
break;
}
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
if (appData.AppConfig.MarginHide)
{
if (!MarginHide.IS_HIDE)
{
MainWindow.HideApp();
}
}
else
{
MainWindow.HideApp();
}
}
/// <summary>
/// 拖动添加项目
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Wrap_Drop(object sender, DragEventArgs e)
{
Array dropObject = (System.Array)e.Data.GetData(DataFormats.FileDrop);
@@ -188,35 +359,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
foreach (object obj in dropObject)
{
string path = (string)obj;
//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 = bi
};
iconInfo.DefaultImage = iconInfo.ImageByteArr;
iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(path);
if (StringUtil.IsEmpty(iconInfo.Name))
{
iconInfo.Name = path;
}
IconInfo iconInfo = CommonCode.GetIconInfoByPath(path);
MainWindow.appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Add(iconInfo);
CommonCode.SaveAppData(MainWindow.appData);
}
CommonCode.SortIconList();
CommonCode.SaveAppData(MainWindow.appData);
}
/// <summary>
@@ -253,14 +400,13 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
case IconType.URL:
IconInfoUrlDialog urlDialog = new IconInfoUrlDialog(info);
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog);
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "IconInfoDialog");
break;
default:
IconInfoDialog dialog = new IconInfoDialog(info);
dialog.dialog = HandyControl.Controls.Dialog.Show(dialog);
dialog.dialog = HandyControl.Controls.Dialog.Show(dialog, "IconInfoDialog");
break;
}
}
private void StackPanel_MouseEnter(object sender, MouseEventArgs e)
@@ -286,7 +432,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
Panel sp = sender as Panel;
DependencyObject dos = sp.Parent;
DependencyObject dos = sp.Parent;
Image img = sp.Children[0] as Image;
@@ -340,7 +486,8 @@ namespace GeekDesk.Control.UserControls.PannelCard
ThreadStart ts = new ThreadStart(crs.Remove);
System.Threading.Thread t = new System.Threading.Thread(ts);
t.Start();
} else
}
else
{
img.BeginAnimation(WidthProperty, null);
img.BeginAnimation(HeightProperty, null);
@@ -403,10 +550,38 @@ namespace GeekDesk.Control.UserControls.PannelCard
sb2.Remove();
}
/// <summary>
/// 添加URL项目
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AddUrlIcon(object sender, RoutedEventArgs e)
{
IconInfoUrlDialog urlDialog = new IconInfoUrlDialog();
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog);
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "IconInfoDialog");
}
/// <summary>
/// 添加系统项目
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AddSystemIcon(object sender, RoutedEventArgs e)
{
SystemItemWindow.Show();
}
public void VisibilitySearchCard(Visibility vb)
{
VerticalCard.Visibility = vb;
if (vb == Visibility.Visible)
{
WrapCard.Visibility = Visibility.Collapsed;
} else
{
WrapCard.Visibility = Visibility.Visible;
}
}
}
}

View File

@@ -0,0 +1,57 @@
<UserControl x:Class="GeekDesk.Control.UserControls.SystemItem.SystemItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.IconFont"
mc:Ignorable="d"
Background="#00FFFFFF"
>
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Top" Background="Transparent">
<ListBox x:Name="ItemListBox" ItemsSource="{Binding IconInfos}" BorderThickness="0"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.IsContainerVirtualizable="True"
>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" Background="#00FFFFFF"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Background>
<SolidColorBrush Opacity="0"/>
</ListBox.Background>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Width="80" Height="80" HorizontalAlignment="Center"
Background="#00FFFFFF"
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
hc:Poptip.Content="{Binding Content_NoWrite, Mode=OneWay}"
Tag="{Binding}"
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
hc:Poptip.Placement="BottomLeft"
hc:Poptip.HitMode="None"
>
<Image Source="{Binding BitmapImage_NoWrite, Mode=OneWay}" Width="45" Height="45" RenderOptions.BitmapScalingMode="HighQuality" />
<TextBlock TextAlignment="Center"
HorizontalAlignment="Center"
VerticalAlignment="Center"
TextWrapping="Wrap"
MaxHeight="40"
FontSize="13"
TextTrimming="WordEllipsis"
Width="65" Text="{Binding Name_NoWrite, Mode=OneWay}"
/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</UserControl>

View File

@@ -0,0 +1,60 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using GeekDesk.ViewModel;
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.UserControls.SystemItem
{
/// <summary>
/// IconPannel.xaml 的交互逻辑
/// </summary>
public partial class SystemItem : UserControl
{
public SystemItem()
{
InitializeComponent();
}
private void Icon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
IconInfo thisInfo = (sender as StackPanel).Tag as IconInfo;
MenuInfo menuInfo = MainWindow.appData.MenuList[MainWindow.appData.AppConfig.SelectedMenuIndex];
string startArg = thisInfo.StartArg;
IconInfo iconInfo;
if (Constants.SYSTEM_ICONS.ContainsKey(startArg))
{
//系统项
iconInfo = new IconInfo
{
Name_NoWrite = thisInfo.Name_NoWrite,
Path_NoWrite = thisInfo.Path_NoWrite,
StartArg_NoWrite = thisInfo.StartArg_NoWrite,
BitmapImage_NoWrite = thisInfo.BitmapImage_NoWrite
};
iconInfo.Content_NoWrite = iconInfo.Name_NoWrite
+ "\n使用次数:" + iconInfo.Count;
} else
{
//startupMenu or Store
iconInfo = CommonCode.GetIconInfoByPath(thisInfo.LnkPath_NoWrite);
}
menuInfo.IconList.Add(iconInfo);
CommonCode.SortIconList();
CommonCode.SaveAppData(MainWindow.appData);
}
}
}

View File

@@ -4,13 +4,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:ToDoInfo}"
mc:Ignorable="d"
Background="AliceBlue"
Background="Transparent"
>
<hc:SimplePanel Margin="20">
<Grid>
<hc:SimplePanel Margin="20" Background="Transparent">
<Grid Background="Transparent">
<DataGrid x:Name="BacklogList"
HeadersVisibility="All"
AutoGenerateColumns="False"
@@ -26,13 +26,29 @@
</DataGrid.ContextMenu>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource DataGridRowStyle}">
<EventSetter Event="MouseRightButtonUp" Handler="DataGridRow_MouseRightButtonUp" />
<EventSetter Event="MouseRightButtonDown" Handler="DataGridRow_MouseRightButtonDown" />
<Setter Property="Background" Value="White"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{StaticResource BtnBG}"/>
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter Property="Background" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell" BasedOn="{StaticResource DataGridCellStyle}">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Background" Value="Transparent"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
<DataGrid.ColumnHeaderStyle>
@@ -42,7 +58,7 @@
</DataGrid.ColumnHeaderStyle>
<DataGrid.Background>
<SolidColorBrush Color="AliceBlue"/>
<SolidColorBrush Color="Transparent"/>
</DataGrid.Background>
<DataGrid.Columns>
<DataGridTextColumn Width="120" Binding="{Binding Title}" Header="待办任务"/>

View File

@@ -73,13 +73,31 @@ namespace GeekDesk.Control.UserControls.Backlog
BacklogList.ContextMenu = null;
}
private void DataGridRow_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
/// <summary>
/// 打开右键菜单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DataGridRow_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
BacklogList.SelectedIndex = ((DataGridRow)sender).GetIndex();
Menu.IsOpen = true;
}
/// <summary>
/// 选中时颜色变化
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DataGridRow_Selected(object sender, RoutedEventArgs e)
{
Color c = Color.FromRgb(91, 192, 222);
SolidColorBrush b = new SolidColorBrush
{
Color = c,
Opacity = 0.9
};
((DataGridRow)sender).Background = b;
}
}
}

View File

@@ -8,75 +8,61 @@
Title="Setting"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Height="450"
Width="600"
Height="550"
Width="750"
WindowStyle="None"
ResizeMode="NoResize"
AllowsTransparency="True"
Background="Transparent" ShowInTaskbar="False"
Background="#00FFFFFF" ShowInTaskbar="False"
BorderThickness="0"
Focusable="True"
KeyDown="OnKeyDown"
>
<Window.Resources>
<Style x:Key="MenuStyle" TargetType="hc:SideMenuItem" BasedOn="{StaticResource SideMenuItemBaseStyle}">
<Style.Setters>
<Setter Property="Background" Value="AliceBlue"/>
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FFE2E2E2"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FFDAD7D7"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Border CornerRadius="8" BorderThickness="0">
<Border.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0.9"/>
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="140"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Margin="30">
<Grid.Effect>
<DropShadowEffect BlurRadius="20" Direction="-90" Color="Gray"
RenderingBias="Quality" ShadowDepth="2"/>
</Grid.Effect>
<Border Style="{StaticResource BorderBG}">
<Grid Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="140"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<hc:Card Grid.Row="0" Grid.Column="0">
<hc:SideMenu BorderThickness="1"
AutoSelect="True"
>
<hc:SideMenu.Background>
<SolidColorBrush Color="AliceBlue"/>
</hc:SideMenu.Background>
<hc:Card Grid.Row="0" Grid.Column="0" Background="Transparent" BorderThickness="0">
<hc:SideMenu.ItemContainerStyle>
<Style TargetType="hc:SideMenuItem" BasedOn="{StaticResource MenuStyle}"/>
</hc:SideMenu.ItemContainerStyle>
<hc:SideMenu AutoSelect="True" Background="Transparent" Margin="1,7,0,3">
<hc:SideMenu.ItemContainerStyle>
<Style TargetType="hc:SideMenuItem" BasedOn="{StaticResource MyMenuStyle}"/>
</hc:SideMenu.ItemContainerStyle>
<hc:SideMenuItem Header="关于"
<hc:SideMenuItem Header="关于"
IsSelected="True"
Selected="MemuClick"
Tag="About"
>
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
IsEnabled="False"
Opacity="1"
Opacity="0.9"
BorderThickness="0"
hc:IconElement.Geometry="{StaticResource About}"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
HorizontalAlignment="Right"
/>
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem Header="显示设置"
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem Header="显示设置"
Tag="Theme"
Selected="MemuClick">
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
IsEnabled="False"
Opacity="1"
BorderThickness="0"
@@ -85,14 +71,14 @@
hc:IconElement.Width="18"
HorizontalAlignment="Right"
/>
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem Header="动作"
<hc:SideMenuItem Header="动作"
Tag="Motion"
Selected="MemuClick">
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
IsEnabled="False"
Opacity="1"
BorderThickness="0"
@@ -101,13 +87,13 @@
hc:IconElement.Width="18"
HorizontalAlignment="Right"
/>
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem Header="其它"
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem Header="其它"
Tag="Other"
Selected="MemuClick">
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
IsEnabled="False"
Opacity="1"
BorderThickness="0"
@@ -116,17 +102,21 @@
hc:IconElement.Width="18"
HorizontalAlignment="Right"
/>
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
</hc:SideMenu>
</hc:Card>
<hc:ScrollViewer Grid.Row="0" Grid.Column="1">
<hc:Card x:Name="RightCard" Height="480">
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
</hc:SideMenu>
</hc:Card>
</hc:ScrollViewer>
<hc:ScrollViewer Grid.Row="0" Grid.Column="1" BorderThickness="0" Margin="0,5,1,5">
<hc:Card x:Name="RightCard" Height="480" BorderThickness="0" MouseDown="DragMove">
<hc:Card.Background>
<SolidColorBrush Opacity="0"/>
</hc:Card.Background>
</hc:Card>
</hc:ScrollViewer>
<Button 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" Grid.Column="1"/>
</Grid>
</Border>
<Button 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" Grid.Column="1"/>
</Grid>
</Border>
</Grid>
</hc:Window>

View File

@@ -1,6 +1,9 @@

using GeekDesk.Constant;
using GeekDesk.Control.UserControls;
using GeekDesk.Control.UserControls.Config;
using GeekDesk.Interface;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using HandyControl.Data;
@@ -13,7 +16,7 @@ namespace GeekDesk.Control.Windows
/// <summary>
/// ConfigDialog.xaml 的交互逻辑
/// </summary>
public partial class ConfigWindow
public partial class ConfigWindow : IWindowCommon
{
private static readonly AboutControl about = new AboutControl();
private static readonly ThemeControl theme = new ThemeControl();
@@ -24,6 +27,7 @@ namespace GeekDesk.Control.Windows
private ConfigWindow(AppConfig appConfig, MainWindow mainWindow)
{
InitializeComponent();
//BG.Source = ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_BAC_IMAGE_BASE64);
this.DataContext = appConfig;
RightCard.Content = about;
this.Topmost = true;
@@ -63,6 +67,19 @@ 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)
{
this.DragMove();
}
}
private static System.Windows.Window window = null;
public static void Show(AppConfig appConfig, MainWindow mainWindow)
{
@@ -71,6 +88,16 @@ namespace GeekDesk.Control.Windows
window = new ConfigWindow(appConfig, mainWindow);
}
window.Show();
Keyboard.Focus(window);
}
public void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.DataContext = null;
this.Close();
}
}
}
}

View File

@@ -8,46 +8,80 @@
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.IconFont"
mc:Ignorable="d"
Title="Svg"
Height="450" Width="600"
Height="520" Width="700"
WindowStyle="None"
ResizeMode="NoResize"
AllowsTransparency="True"
Background="AliceBlue"
MouseDown="DragMove"
Background="Transparent" ShowInTaskbar="False"
BorderThickness="0"
Focusable="True"
KeyDown="OnKeyDown"
>
<Window.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<Setter Property="Width" Value="80"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="11"/>
<Style x:Key="HcTabControl" TargetType="hc:TabControl" BasedOn="{StaticResource TabControlInLine}">
<Style.Setters>
<Setter Property="Background" Value="Transparent"/>
</Style.Setters>
</Style>
<Style x:Key="TabTitle" TargetType="hc:TabItem" BasedOn="{StaticResource TabItemInLine}">
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="White" Opacity="0.68"/>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</Window.Resources>
<Border MouseDown="DragMove">
<Grid MouseDown="DragMove">
<TextBox x:Name="CheckSettingUrl" Visibility="Collapsed" Text="{Binding IsSettingUrl}" TextChanged="CheckSettingUrl_TextChanged"/>
<hc:TabControl x:Name="MyTabControl" IsAnimationEnabled="True" SelectionChanged="TabControl_SelectionChanged" ShowContextMenu="True" IsTabFillEnabled="True" Margin="20,30,20,20" Height="350" VerticalAlignment="Top">
<hc:TabItem Tag="System" IsSelected="True" Header="系统图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource SystemIcon}" >
<hc:SimplePanel Background="AliceBlue">
<uc:IconPannel x:Name="SystemIcon"/>
</hc:SimplePanel>
</hc:TabItem>
<hc:TabItem Tag="Custom" Header="自定义图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CustomIcon}">
<hc:SimplePanel Background="AliceBlue">
<uc:IconPannel x:Name="CustomIcon"/>
<hc:LoadingCircle x:Name="LoadingEle"/>
</hc:SimplePanel>
</hc:TabItem>
</hc:TabControl>
<Grid Margin="20">
<Grid.Effect>
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
RenderingBias="Quality" ShadowDepth="2"/>
</Grid.Effect>
<Border MouseDown="DragMove" Style="{StaticResource BorderBG}" hc:Dialog.Token="IconUrlDialog">
<!--<Border.Background>
--><!--<SolidColorBrush Color="AliceBlue" Opacity="0.9"/>--><!--
<LinearGradientBrush Opacity="0.97">
<GradientStop Color="#D1F0A4" Offset="0"/>
<GradientStop Color="#97D282" Offset="1"/>
</LinearGradientBrush>
</Border.Background>-->
<hc:DialogContainer>
<Grid MouseDown="DragMove">
<TextBox x:Name="CheckSettingUrl" Visibility="Collapsed" Text="{Binding IsSettingUrl}" TextChanged="CheckSettingUrl_TextChanged"/>
<hc:TabControl x:Name="MyTabControl"
IsAnimationEnabled="True"
SelectionChanged="TabControl_SelectionChanged"
ShowContextMenu="True"
IsTabFillEnabled="True"
Margin="20,30,20,20"
Height="350"
VerticalAlignment="Top"
Style="{StaticResource HcTabControl}">
<hc:TabItem Tag="System" IsSelected="True" Header="系统图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource SystemIcon}" Style="{StaticResource TabTitle}">
<hc:SimplePanel>
<uc:IconPannel x:Name="SystemIcon"/>
</hc:SimplePanel>
</hc:TabItem>
<hc:TabItem Tag="Custom" Header="自定义图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CustomIcon}" Style="{StaticResource TabTitle}">
<hc:SimplePanel>
<uc:IconPannel x:Name="CustomIcon"/>
<hc:LoadingCircle x:Name="LoadingEle"/>
</hc:SimplePanel>
</hc:TabItem>
</hc:TabControl>
<Button Content="取消" Click="Close_Click" Margin="391,397.5,163,22.5"/>
<Button Content="自定义设置" Click="CustomButton_Click" IsEnabled="False" Name="CustomButton" Background="#5BC0DE" Foreground="White" RenderTransformOrigin="-0.868,0.583" Margin="447,397.5,71,22.5"/>
<Button Content="确定" Click="Confirm_Click" Background="#5BC0DE" Foreground="White" Margin="534,397.5,20,22.5" RenderTransformOrigin="0.696,0.45"/>
</Grid>
</Border>
<Button Content="取消" Click="Close_Click" Margin="391,397.5,163,22.5"/>
<Button Content="自定义设置" Click="CustomButton_Click" IsEnabled="False" Name="CustomButton" Style="{StaticResource Btn1}" Margin="447,397.5,71,22.5"/>
<Button Content="确定" Click="Confirm_Click" Style="{StaticResource Btn1}" Margin="534,397.5,20,22.5" />
</Grid>
</hc:DialogContainer>
</Border>
</Grid>
</Window>

View File

@@ -1,4 +1,5 @@
using GeekDesk.Control.Other;
using GeekDesk.Interface;
using GeekDesk.Util;
using GeekDesk.ViewModel;
@@ -17,7 +18,7 @@ namespace GeekDesk.Control.Windows
/// <summary>
/// IconfontWindow.xaml 的交互逻辑
/// </summary>
public partial class IconfontWindow : Window
public partial class IconfontWindow : Window, IWindowCommon
{
private static AppConfig appConfig = MainWindow.appData.AppConfig;
private static MenuInfo menuInfo;
@@ -56,6 +57,7 @@ namespace GeekDesk.Control.Windows
private void Close_Click(object sender, RoutedEventArgs e)
{
this.DataContext = null;
this.Close();
}
@@ -71,14 +73,16 @@ namespace GeekDesk.Control.Windows
{
LoadingEle.Visibility = Visibility.Visible;
CustomIcon.Visibility = Visibility.Collapsed;
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig));
} else
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig), "IconUrlDialog");
}
else
{
if (customIcons == null)
{
vm.Iconfonts = null;
LoadingOnlineIcon();
} else
}
else
{
vm.Iconfonts = customIcons;
LoadingEle.Visibility = Visibility.Collapsed;
@@ -120,6 +124,7 @@ namespace GeekDesk.Control.Windows
}
break;
}
this.DataContext = null;
this.Close();
}
@@ -132,12 +137,13 @@ namespace GeekDesk.Control.Windows
window = new IconfontWindow(listInfo, menuInfo);
}
window.Show();
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0);
Keyboard.Focus(window);
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
}
private void CustomButton_Click(object sender, RoutedEventArgs e)
{
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig));
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig), "IconUrlDialog");
}
@@ -146,7 +152,8 @@ namespace GeekDesk.Control.Windows
if (CheckSettingUrl.Text == "true")
{
LoadingOnlineIcon();
} else
}
else
{
LoadingEle.IsRunning = true;
CustomIcon.Visibility = Visibility.Collapsed;
@@ -166,12 +173,21 @@ namespace GeekDesk.Control.Windows
LoadingEle.Visibility = Visibility.Collapsed;
CustomIcon.Visibility = Visibility.Visible;
}
catch (Exception)
catch (Exception e)
{
HandyControl.Controls.Growl.WarningGlobal("加载远程图标异常!");
LogUtil.WriteErrorLog(e, "加载远程图标异常!");
}
}
public void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.DataContext = null;
this.Close();
}
}
public class IconfontViewModel : INotifyPropertyChanged
{

View File

@@ -0,0 +1,100 @@
<Window x:Class="GeekDesk.Control.Windows.SystemItemWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GeekDesk.Control.Windows"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.SystemItem"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
mc:Ignorable="d"
Title="Svg"
Height="520" Width="700"
WindowStyle="None"
ResizeMode="NoResize"
AllowsTransparency="True"
Background="Transparent" ShowInTaskbar="False"
BorderThickness="0"
Focusable="True"
KeyDown="OnKeyDown"
>
<Window.Resources>
<Style x:Key="HcTabControl" TargetType="hc:TabControl" BasedOn="{StaticResource TabControlInLine}">
<Style.Setters>
<Setter Property="Background" Value="Transparent"/>
</Style.Setters>
</Style>
<Style x:Key="TabTitle" TargetType="hc:TabItem" BasedOn="{StaticResource TabItemInLine}">
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="White" Opacity="0.68"/>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
<cvt:MenuInfoConvert x:Key="MenuInfoConvert"/>
</Window.Resources>
<Grid Margin="20">
<Grid.Effect>
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
RenderingBias="Quality" ShadowDepth="2"/>
</Grid.Effect>
<Border MouseDown="DragMove" Style="{StaticResource BorderBG}" hc:Dialog.Token="IconUrlDialog">
<hc:DialogContainer>
<Grid MouseDown="DragMove">
<StackPanel HorizontalAlignment="Center" Margin="10">
<Border CornerRadius="8" Height="30" Width="150">
<Border.Background>
<SolidColorBrush Color="White" Opacity="0.7"/>
</Border.Background>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Background="Transparent"
BorderThickness="0"
hc:IconElement.Geometry="{Binding AppConfig.SelectedMenuIndex, Mode=OneWay, Converter={StaticResource MenuInfoConvert}, ConverterParameter=1}"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
IsEnabled="False"
Opacity="1"
>
</Button>
<TextBlock x:Name="MenuName" Text="{Binding AppConfig.SelectedMenuIndex, Mode=OneWay, Converter={StaticResource MenuInfoConvert}, ConverterParameter=2}" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</StackPanel>
<hc:TabControl x:Name="MyTabControl"
IsAnimationEnabled="True"
SelectionChanged="TabControl_SelectionChanged"
ShowContextMenu="True"
IsTabFillEnabled="True"
Margin="20,60,20,20"
Height="350"
VerticalAlignment="Top"
Style="{StaticResource HcTabControl}">
<hc:TabItem Tag="System" IsSelected="True" Header="系统应用" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource SystemIcon}" Style="{StaticResource TabTitle}">
<hc:SimplePanel>
<uc:SystemItem x:Name="SystemItem"/>
</hc:SimplePanel>
</hc:TabItem>
<hc:TabItem x:Name="StartMenu" Tag="StartMenu" Header="开始菜单应用" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource SystemIcon}" Style="{StaticResource TabTitle}">
<hc:SimplePanel>
<uc:SystemItem x:Name="StartMenuItem"/>
<hc:LoadingCircle x:Name="StartMenuLoading"/>
</hc:SimplePanel>
</hc:TabItem>
<!--<hc:TabItem Tag="Store" Header="商店应用(未开放)" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CustomIcon}" Style="{StaticResource TabTitle}">
<hc:SimplePanel>
<uc:SystemItem x:Name="StoreItem"/>
</hc:SimplePanel>
</hc:TabItem>-->
</hc:TabControl>
<Button Content="关闭" Click="Close_Click" Margin="594,420,20,31.5"/>
</Grid>
</hc:DialogContainer>
</Border>
</Grid>
</Window>

View File

@@ -0,0 +1,301 @@
using GeekDesk.Constant;
using GeekDesk.Control.Other;
using GeekDesk.Interface;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Resources;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using static GeekDesk.Util.ShowWindowFollowMouse;
namespace GeekDesk.Control.Windows
{
/// <summary>
/// SystemItemWindow.xaml 的交互逻辑
/// 添加系统项目到对应菜单
/// </summary>
public partial class SystemItemWindow : Window, IWindowCommon
{
private static AppConfig appConfig = MainWindow.appData.AppConfig;
private static SystemItemViewModel vm;
private List<IconInfo> systemIcons;
private List<IconInfo> startMenuIcons;
private List<IconInfo> storeIcons;
private SystemItemWindow()
{
vm = new SystemItemViewModel();
this.DataContext = vm;
InitializeComponent();
this.Topmost = true;
}
/// <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();
}
}
private void Close_Click(object sender, RoutedEventArgs e)
{
this.DataContext = null;
this.Close();
}
/// <summary>
/// 切换选项卡
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
TabItem ti = this.MyTabControl.SelectedItem as TabItem;
List<IconInfo> systemInfos = vm.IconInfos;
if (systemInfos == null)
{
systemInfos = new List<IconInfo>();
}
switch (ti.Tag.ToString())
{
case "StartMenu": //开始菜单
if (startMenuIcons == null)
{
vm.IconInfos = null;
System.Threading.Thread t = new System.Threading.Thread(new ThreadStart(GetStartMenuInfos))
{
IsBackground = true
};
t.Start();
} else
{
StartMenuLoading.Visibility = Visibility.Collapsed;
vm.IconInfos = startMenuIcons;
}
break;
case "Store": //应用商店
if (storeIcons == null)
{
vm.IconInfos = null;
storeIcons = new List<IconInfo>();
vm.IconInfos = storeIcons;
}
else
{
vm.IconInfos = storeIcons;
}
break;
default: //默认系统项
if (systemIcons == null)
{
vm.IconInfos = null;
systemIcons = GetSysteIconInfos();
vm.IconInfos = systemIcons;
} else
{
vm.IconInfos = systemIcons;
}
break;
}
}
/// <summary>
/// 获取开始菜单路径下项目
/// </summary>
/// <returns></returns>
private void GetStartMenuInfos()
{
App.Current.Dispatcher.Invoke((Action)(() =>
{
StartMenuLoading.Visibility = Visibility.Visible;
}));
List<IconInfo> infos = new List<IconInfo>();
//获取开始菜单路径
string path = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs";
//递归获取信息
GetInfos(path, infos);
App.Current.Dispatcher.Invoke((Action)(() =>
{
if (StartMenu.IsSelected)
{
startMenuIcons = infos;
vm.IconInfos = startMenuIcons;
}
StartMenuLoading.Visibility = Visibility.Collapsed;
}));
}
/// <summary>
/// 递归获取文件信息
/// </summary>
/// <param name="path"></param>
/// <param name="listInfos"></param>
private void GetInfos(string filePath, List<IconInfo> listInfos)
{
DirectoryInfo di = new DirectoryInfo(filePath);
string[] filePaths = Directory.GetFiles(filePath);
string[] dirPaths = Directory.GetDirectories(filePath);
string[] paths = new string[filePaths.Length + dirPaths.Length];
filePaths.CopyTo(paths, 0);
if (filePaths == null || filePaths.Length == 0)
{
dirPaths.CopyTo(paths, 0);
} else
{
dirPaths.CopyTo(paths, filePaths.Length - 1);
}
foreach (string path in paths)
{
if (File.Exists(path))
{
string ext = Path.GetExtension(path).ToLower();
if (".exe".Equals(ext) || ".lnk".Equals(ext))
{
try
{
IconInfo iconInfo = CommonCode.GetIconInfoByPath_NoWrite(path);
if (iconInfo.Path_NoWrite != null)
{
iconInfo.Content_NoWrite = iconInfo.Path_NoWrite + "\n" + iconInfo.Name_NoWrite;
listInfos.Add(iconInfo);
}
}
catch (Exception) { }
}
}
else if (Directory.Exists(path))
{
GetInfos(path, listInfos);
}
}
//FileSystemInfo[] fileInfoArr = di.GetFileSystemInfos();
//foreach(FileSystemInfo fi in fileInfoArr)
//{
// string path = fi.FullName;
//}
}
/// <summary>
/// 获取系统项目
/// </summary>
/// <returns></returns>
private List<IconInfo> GetSysteIconInfos()
{
List<IconInfo> iconInfos = new List<IconInfo>();
Hashtable systemIcons = Constants.SYSTEM_ICONS;
IconInfo iconInfo;
foreach (object key in systemIcons.Keys)
{
string keyStr = key.ToString();
iconInfo = new IconInfo
{
Name_NoWrite = systemIcons[key].ToString()
};
iconInfo.BitmapImage_NoWrite = new BitmapImage(
new Uri("pack://application:,,,/GeekDesk;component/Resource/Image/SystemIcon/" + keyStr + ".png"
, UriKind.RelativeOrAbsolute));
iconInfo.StartArg = keyStr;
iconInfo.Content_NoWrite = iconInfo.Name_NoWrite;
iconInfos.Add(iconInfo);
}
return iconInfos;
}
public class SystemItemViewModel : INotifyPropertyChanged
{
private List<IconInfo> iconInfos;
private AppConfig appConfig;
public SystemItemViewModel()
{
this.AppConfig = MainWindow.appData.AppConfig;
}
public AppConfig AppConfig
{
get
{
return appConfig;
}
set
{
appConfig = value;
OnPropertyChanged("AppConfig");
}
}
public List<IconInfo> IconInfos
{
get
{
return iconInfos;
}
set
{
iconInfos = value;
OnPropertyChanged("IconInfos");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
private static System.Windows.Window window = null;
public static void Show()
{
if (window == null || !window.Activate())
{
window = new SystemItemWindow();
}
window.Show();
Keyboard.Focus(window);
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
}
public void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.DataContext = null;
this.Close();
}
}
}
}

View File

@@ -8,91 +8,101 @@
xmlns:local="clr-namespace:GeekDesk"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Height="700"
Width="450"
Title="TaskInfo"
Height="450"
Width="510"
WindowStyle="None"
Title=""
AllowsTransparency="True"
Background="Transparent" ShowInTaskbar="False"
>
Focusable="True"
KeyDown="OnKeyDown"
>
<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>
<SolidColorBrush Color="AliceBlue"/>
</Border.Background>
<Border.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<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">
<StackPanel Margin="20" HorizontalAlignment="Center">
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<WrapPanel VerticalAlignment="Center">
<TextBlock Text="待办任务:" Style="{StaticResource LeftTB}"/>
<TextBlock Text="*" Foreground="Red" />
</WrapPanel>
<TextBox x:Name="Title" Width="290" Text="{Binding Title, Mode=OneWay}" FontSize="14" />
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
<TextBlock Text="待办详情:" Style="{StaticResource LeftTB}"/>
<TextBox x:Name="Msg" TextWrapping="Wrap"
<Grid Margin="20">
<Grid.Effect>
<DropShadowEffect BlurRadius="20" Direction="-90" Color="Gray"
RenderingBias="Quality" ShadowDepth="2"/>
</Grid.Effect>
<Border Style="{StaticResource BorderBG}" MouseDown="DragMove">
<Border.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<Setter Property="Width" Value="67"/>
<Setter Property="Margin" Value="0,5,0,0"/>
<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,15,0,0">
<StackPanel Margin="20" HorizontalAlignment="Center">
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<WrapPanel VerticalAlignment="Center">
<TextBlock Text="待办任务:" Style="{StaticResource LeftTB}"/>
<TextBlock Text="*" Foreground="Red" />
</WrapPanel>
<TextBox x:Name="Title" Width="290" Text="{Binding Title, Mode=OneWay}" FontSize="14" />
</hc:UniformSpacingPanel>
<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>
<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}"
<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"
<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>
<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="SetTimePanel" Height="30" Visibility="Visible" Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
<WrapPanel VerticalAlignment="Center">
<TextBlock Text="指定时间:" Style="{StaticResource LeftTB}"/>
<TextBlock Text="*" Foreground="Red"/>
</WrapPanel>
<hc:DateTimePicker x:Name="ExeTime" Text="{Binding ExeTime, Mode=OneWay}" ErrorStr="Error!" Width="200" Margin="1.6,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 x:Name="CronPanel" Height="30" 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" Text="{Binding DoneTime, Mode=OneWay}" Width="200"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
<WrapPanel VerticalAlignment="Center">
<TextBlock Text="完成时间:" Style="{StaticResource LeftTB}"/>
</WrapPanel>
<TextBlock x:Name="DoneTime" VerticalAlignment="Center" Margin="5,6,0,0" Text="{Binding DoneTime, Mode=OneWay}" Width="200"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<Button Content="保存" Background="#5BC0DE"
Foreground="White" Margin="320,6,-208,-10"
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<Button Content="保存" Style="{StaticResource Btn1}" Margin="320,6,-208,-10"
Click="Save_Button_Click"/>
</hc:UniformSpacingPanel>
</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>
</hc:UniformSpacingPanel>
</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>
</Border>
</Border>
</Grid>
</Window>

View File

@@ -1,4 +1,5 @@
using GeekDesk.Constant;
using GeekDesk.Interface;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Controls;
@@ -22,7 +23,7 @@ namespace GeekDesk.Control.Windows
/// <summary>
/// BacklogInfoWindow.xaml 的交互逻辑
/// </summary>
public partial class ToDoInfoWindow
public partial class ToDoInfoWindow : IWindowCommon
{
private static int windowType = -1;
@@ -38,9 +39,12 @@ namespace GeekDesk.Control.Windows
InitializeComponent();
this.Topmost = true;
ExeTime.SelectedDateTime = DateTime.Now.AddMinutes(10);
DateTime time = DateTime.Now.AddMinutes(10);
ExeTime.SelectedDateTime = time;
SetTimePanel.Visibility = Visibility.Visible;
this.DataContext = new ToDoInfo();
this.DataContext = new ToDoInfo {
ExeTime = time.ToString("yyyy-MM-dd HH:mm:ss")
};
}
private ToDoInfoWindow(ToDoInfo info)
{
@@ -147,7 +151,14 @@ namespace GeekDesk.Control.Windows
};
if (windowType != NEW_TODO)
{
appData.HiToDoList.Remove(this.DataContext as ToDoInfo);
ToDoInfo tdi = this.DataContext as ToDoInfo;
if (appData.HiToDoList.Contains(tdi))
{
appData.HiToDoList.Remove(tdi);
} else if (appData.ToDoList.Contains(tdi))
{
appData.ToDoList.Remove(tdi);
}
}
appData.ToDoList.Add(info);
@@ -204,6 +215,7 @@ namespace GeekDesk.Control.Windows
{
window = new ToDoInfoWindow();
window.Show();
Keyboard.Focus(window);
}
window.Visibility = Visibility.Collapsed;
windowType = NEW_TODO;
@@ -219,6 +231,7 @@ namespace GeekDesk.Control.Windows
}
windowType = DETAIL_TODO;
window2.Show();
Keyboard.Focus(window2);
}
private void ExecType_Checked(object sender, RoutedEventArgs e)
@@ -236,5 +249,14 @@ namespace GeekDesk.Control.Windows
break;
}
}
public void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.DataContext = null;
this.Close();
}
}
}
}

View File

@@ -7,60 +7,50 @@
xmlns:local="clr-namespace:GeekDesk"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Height="450"
Width="850"
Height="550"
Width="1000"
Title="Task"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent" ShowInTaskbar="False"
Focusable="True"
KeyDown="OnKeyDown"
>
<Window.Resources>
<Style x:Key="MenuStyle" TargetType="hc:SideMenuItem" BasedOn="{StaticResource SideMenuItemBaseStyle}">
<Style.Setters>
<Setter Property="Background" Value="AliceBlue"/>
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FFE2E2E2"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FFDAD7D7"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Border CornerRadius="4" BorderThickness="0">
<Border.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0.9"/>
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="140"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<hc:Card Grid.Row="0" Grid.Column="0">
<hc:SideMenu BorderThickness="1"
<Grid Margin="50">
<Grid.Effect>
<DropShadowEffect BlurRadius="20" Direction="-90" Color="Gray"
RenderingBias="Quality" ShadowDepth="2"/>
</Grid.Effect>
<Border Style="{StaticResource BorderBG}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="140"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<hc:Card Grid.Row="0" Grid.Column="0" Background="Transparent" BorderThickness="0">
<hc:SideMenu BorderThickness="0"
AutoSelect="True"
Background="Transparent"
Margin="5"
>
<hc:SideMenu.Background>
<SolidColorBrush Color="AliceBlue"/>
</hc:SideMenu.Background>
<hc:SideMenu.ItemContainerStyle>
<Style TargetType="hc:SideMenuItem" BasedOn="{StaticResource MenuStyle}"/>
</hc:SideMenu.ItemContainerStyle>
<hc:SideMenu.ItemContainerStyle>
<Style TargetType="hc:SideMenuItem" BasedOn="{StaticResource MyMenuStyle}"/>
</hc:SideMenu.ItemContainerStyle>
<hc:SideMenuItem Header="待办列表"
<hc:SideMenuItem Header="待办列表"
IsSelected="True"
Selected="MemuClick"
Tag="ExeList"
>
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
IsEnabled="False"
Opacity="1"
BorderThickness="0"
@@ -69,13 +59,13 @@
hc:IconElement.Width="18"
HorizontalAlignment="Right"
/>
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem Header="历史待办"
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem Header="历史待办"
Tag="History"
Selected="MemuClick">
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
IsEnabled="False"
Opacity="1"
BorderThickness="0"
@@ -84,21 +74,22 @@
hc:IconElement.Width="18"
HorizontalAlignment="Right"
/>
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
</hc:SideMenu>
</hc:Card>
<hc:Card Grid.Row="0" Grid.Column="1" x:Name="RightCard" Height="450" MouseDown="DragMove" />
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
</hc:SideMenu>
</hc:Card>
<hc:Card Grid.Row="0" MouseDown="DragMove" Background="Transparent" BorderThickness="0" Grid.Column="1" x:Name="RightCard" Height="450">
</hc:Card>
<Button 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" Grid.Column="1"/>
<Button Content="新建待办"
<Button 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" Grid.Column="1"/>
<Button Content="新建待办"
Panel.ZIndex="1"
Background="#5BC0DE"
Foreground="White"
Style="{StaticResource Btn1}"
Grid.Column="1"
Margin="590.01,29,10,384"
Click="CreateBacklog_BtnClick"/>
</Grid>
</Border>
</Grid>
</Border>
</Grid>
</Window>

View File

@@ -1,4 +1,5 @@
using GeekDesk.Control.UserControls.Backlog;
using GeekDesk.Interface;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using System;
@@ -21,7 +22,7 @@ namespace GeekDesk.Control.Windows
/// <summary>
/// BacklogWindow.xaml 的交互逻辑
/// </summary>
public partial class ToDoWindow
public partial class ToDoWindow : IWindowCommon
{
private static TodoControl backlog = new TodoControl();
private AppData appData = MainWindow.appData;
@@ -85,15 +86,25 @@ namespace GeekDesk.Control.Windows
private static System.Windows.Window window = null;
#pragma warning disable CS0108 // “ToDoWindow.Show()”隐藏继承的成员“Window.Show()”。如果是有意隐藏,请使用关键字 new。
public static void Show()
#pragma warning restore CS0108 // “ToDoWindow.Show()”隐藏继承的成员“Window.Show()”。如果是有意隐藏,请使用关键字 new。
{
if (window == null || !window.Activate())
{
window = new ToDoWindow();
}
window.Show();
Keyboard.Focus(window);
}
public void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.DataContext = null;
this.Close();
}
}
}
}

View File

@@ -6,39 +6,52 @@
xmlns:local="clr-namespace:GeekDesk.Control.Windows"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Title="UpdateWindow" Height="300" Width="450"
Height="460" Width="610"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent" ShowInTaskbar="False">
<Border CornerRadius="4" Background="AliceBlue" BorderThickness="1" BorderBrush="Green" MouseDown="DragMove">
<StackPanel HorizontalAlignment="Center">
<hc:Card BorderThickness="0" Effect="{DynamicResource EffectShadow2}" Margin="20,20,20,0">
<!--Card 的内容部分-->
<Border CornerRadius="4,4,0,0" Height="160">
<StackPanel>
<TextBlock Margin="10" x:Name="MsgTitle" TextWrapping="Wrap" FontSize="16" HorizontalAlignment="Left" Style="{DynamicResource TextBlockLargeBold}" Text="测试"/>
<TextBlock Margin="15" x:Name="Msg" TextWrapping="Wrap" VerticalAlignment="Center" Text=""/>
</StackPanel>
</Border>
<!--Card 的尾部部分-->
<hc:Card.Footer>
<StackPanel Margin="10" Width="420">
<!--Card 的一级内容-->
<TextBlock TextWrapping="NoWrap" x:Name="Title" Style="{DynamicResource TextBlockLargeBold}" TextTrimming="CharacterEllipsis"
Title=""
Background="Transparent" ShowInTaskbar="False"
Focusable="True"
KeyDown="OnKeyDown">
<Grid Margin="20">
<Grid.Effect>
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
RenderingBias="Quality" ShadowDepth="2"/>
</Grid.Effect>
<Border CornerRadius="4" Background="White" BorderThickness="0" MouseDown="DragMove">
<StackPanel HorizontalAlignment="Center">
<hc:Card BorderThickness="0" Effect="{DynamicResource EffectShadow2}" Margin="20,20,20,0">
<!--Card 的内容部分-->
<Border CornerRadius="4,4,0,0" Height="260">
<StackPanel>
<TextBlock Margin="10" x:Name="MsgTitle" TextWrapping="Wrap" FontSize="16" HorizontalAlignment="Left" Style="{DynamicResource TextBlockLargeBold}" Text="测试"/>
<StackPanel x:Name="MsgPanel">
<hc:ScrollViewer x:Name="MsgBar" HorizontalScrollBarVisibility="Visible" IsInertiaEnabled="True" Margin="10" Width="430">
<TextBlock Width="430" FontSize="15" LineHeight="22" x:Name="Msg" TextWrapping="Wrap" VerticalAlignment="Center" Text="测试"/>
</hc:ScrollViewer>
</StackPanel>
</StackPanel>
</Border>
<!--Card 的尾部部分-->
<hc:Card.Footer>
<StackPanel Margin="10" Width="520">
<!--Card 的一级内容-->
<TextBlock TextWrapping="NoWrap" x:Name="Title" Style="{DynamicResource TextBlockLargeBold}" TextTrimming="CharacterEllipsis"
Text=""
HorizontalAlignment="Left"/>
<!--Card 的二级内容-->
<TextBlock TextWrapping="NoWrap" x:Name="SubTitle" Style="{DynamicResource TextBlockDefault}" TextTrimming="CharacterEllipsis"
<!--Card 的二级内容-->
<TextBlock TextWrapping="NoWrap" x:Name="SubTitle" Style="{DynamicResource TextBlockDefault}" TextTrimming="CharacterEllipsis"
Margin="0,6,0,0"
HorizontalAlignment="Left"/>
</StackPanel>
</hc:Card.Footer>
</hc:Card>
<hc:UniformSpacingPanel Spacing="100" HorizontalAlignment="Center" Margin="0,10,0,0">
<Button Content="暂不更新" Click="Close_Click" />
<Button Content="前往更新" Click="Confirm_Click" Background="#5BC0DE" Foreground="White" RenderTransformOrigin="0.696,0.45"/>
</hc:UniformSpacingPanel>
</StackPanel>
</StackPanel>
</hc:Card.Footer>
</hc:Card>
<hc:UniformSpacingPanel Spacing="100" HorizontalAlignment="Center" Margin="0,10,0,0">
<Button Content="暂不更新" Click="Close_Click" />
<Button Content="前往更新" Click="Confirm_Click" Style="{StaticResource Btn1}"/>
</hc:UniformSpacingPanel>
</StackPanel>
</Border>
</Border>
</Grid>
</Window>

View File

@@ -1,4 +1,5 @@
using GeekDesk.Constant;
using GeekDesk.Interface;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using Newtonsoft.Json.Linq;
@@ -23,7 +24,7 @@ namespace GeekDesk.Control.Windows
/// <summary>
/// UpdateWindow.xaml 的交互逻辑
/// </summary>
public partial class UpdateWindow : Window
public partial class UpdateWindow : Window, IWindowCommon
{
private static AppConfig appConfig = MainWindow.appData.AppConfig;
private static string githubUrl = "";
@@ -33,6 +34,7 @@ namespace GeekDesk.Control.Windows
try
{
WindowStartupLocation = WindowStartupLocation.CenterScreen;
this.Topmost = true;
InitializeComponent();
DataHandle(jo);
}
@@ -68,7 +70,7 @@ namespace GeekDesk.Control.Windows
string msg = "";
for (int i=0; i<ja.Count; i++)
{
msg += "•" + ja[i].ToString() + "\n";
msg += "• " + ja[i].ToString() + "\n";
}
Msg.Text = msg;
}
@@ -102,6 +104,16 @@ namespace GeekDesk.Control.Windows
window = new UpdateWindow(jo);
}
window.Show();
Keyboard.Focus(window);
}
public void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.DataContext = null;
this.Close();
}
}
}
}

View File

@@ -0,0 +1,45 @@
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 MenuInfoConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int menuIndex = MainWindow.appData.AppConfig.SelectedMenuIndex;
if (menuIndex == -1)
{
return "";
} else
{
string type = parameter.ToString();
if ("1".Equals(type))
{
return MainWindow.appData.MenuList[menuIndex].MenuGeometry;
}
else
{
return MainWindow.appData.MenuList[menuIndex].MenuName;
}
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
//bool isChecked = (bool)value;
//if (!isChecked)
//{
// return null;
//}
//return (AppHideType)int.Parse(parameter.ToString());
}
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace GeekDesk.Converts
{
class SearchResWidth : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double menuLeftWidth = double.Parse(value.ToString());
return MainWindow.mainWindow.Width - menuLeftWidth;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View 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 SortTypeConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (SortType)value == (SortType)int.Parse(parameter.ToString());
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
bool isChecked = (bool)value;
if (!isChecked)
{
return null;
}
return (SortType)int.Parse(parameter.ToString());
}
}
}

View File

@@ -57,8 +57,14 @@
<Reference Include="CommonServiceLocator, Version=2.0.6.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
<HintPath>packages\CommonServiceLocator.2.0.6\lib\net45\CommonServiceLocator.dll</HintPath>
</Reference>
<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 Include="Gma.System.MouseKeyHook, Version=5.6.130.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\MouseKeyHook.5.6.0\lib\net40\Gma.System.MouseKeyHook.dll</HintPath>
</Reference>
<Reference Include="HandyControl, Version=3.3.0.0, Culture=neutral, PublicKeyToken=45be8712787a1e5b, processorArchitecture=MSIL">
<HintPath>packages\HandyControl.3.3.0\lib\net472\HandyControl.dll</HintPath>
</Reference>
<Reference Include="KeyMouseHook, Version=1.0.6.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\KeyMouseHook.1.0.6\lib\net40\KeyMouseHook.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>
@@ -66,6 +72,9 @@
<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="NPinyin.Core, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\NPinyin.Core.3.0.0\lib\net45\NPinyin.Core.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>
@@ -136,12 +145,18 @@
<Compile Include="Control\UserControls\Config\OtherControl.xaml.cs">
<DependentUpon>OtherControl.xaml</DependentUpon>
</Compile>
<Compile Include="Control\UserControls\SystemItem\SystemItem.xaml.cs">
<DependentUpon>SystemItem.xaml</DependentUpon>
</Compile>
<Compile Include="Control\UserControls\ToDo\TodoControl.xaml.cs">
<DependentUpon>TodoControl.xaml</DependentUpon>
</Compile>
<Compile Include="Control\UserControls\IconFont\IconPannel.xaml.cs">
<DependentUpon>IconPannel.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Windows\SystemItemWindow.xaml.cs">
<DependentUpon>SystemItemWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Windows\ToDoInfoWindow.xaml.cs">
<DependentUpon>ToDoInfoWindow.xaml</DependentUpon>
</Compile>
@@ -175,7 +190,10 @@
<Compile Include="Control\Windows\UpdateWindow.xaml.cs">
<DependentUpon>UpdateWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Converts\SearchResWidth.cs" />
<Compile Include="Converts\DoubleToGridLength.cs" />
<Compile Include="Converts\SortTypeConvert.cs" />
<Compile Include="Converts\MenuInfoConvert.cs" />
<Compile Include="Converts\TodoTaskExecConvert.cs" />
<Compile Include="Converts\IntToCornerRadius.cs" />
<Compile Include="Converts\OpcityConvert.cs" />
@@ -183,8 +201,11 @@
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
<Compile Include="Converts\HideTypeConvert.cs" />
<Compile Include="Interface\IWindowCommon.cs" />
<Compile Include="Task\ToDoTask.cs" />
<Compile Include="Thread\UpdateThread.cs" />
<Compile Include="MyThread\MouseHookThread.cs" />
<Compile Include="MyThread\DispatcherBuild.cs" />
<Compile Include="MyThread\UpdateThread.cs" />
<Compile Include="Util\AeroGlassHelper.cs" />
<Compile Include="Util\GlobalHotKey.cs" />
<Compile Include="Util\CommonCode.cs" />
@@ -192,6 +213,7 @@
<Compile Include="Util\DragAdorner.cs" />
<Compile Include="Util\FileIcon.cs" />
<Compile Include="Util\FileUtil.cs" />
<Compile Include="Util\LogUtil.cs" />
<Compile Include="Util\MarginHide.cs" />
<Compile Include="Util\HttpUtil.cs" />
<Compile Include="Util\ImageUtil.cs" />
@@ -206,6 +228,7 @@
<Compile Include="Util\SvgToGeometry.cs" />
<Compile Include="ViewModel\AppConfig.cs" />
<Compile Include="ViewModel\AppData.cs" />
<Compile Include="ViewModel\Temp\SearchIconList.cs" />
<Compile Include="ViewModel\ToDoInfo.cs" />
<Compile Include="ViewModel\IconfontInfo.cs" />
<Compile Include="ViewModel\IconInfo.cs" />
@@ -226,6 +249,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\UserControls\SystemItem\SystemItem.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Control\UserControls\ToDo\TodoControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -234,6 +261,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\Windows\SystemItemWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Control\Windows\ToDoInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -294,6 +325,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resource\Dictionary\CommonStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
@@ -355,5 +390,21 @@
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\SystemIcon\Services.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\SystemIcon\Calculator.png" />
<Resource Include="Resource\Image\SystemIcon\CMD.png" />
<Resource Include="Resource\Image\SystemIcon\Computer.png" />
<Resource Include="Resource\Image\SystemIcon\Control.png" />
<Resource Include="Resource\Image\SystemIcon\GroupPolicy.png" />
<Resource Include="Resource\Image\SystemIcon\Mstsc.png" />
<Resource Include="Resource\Image\SystemIcon\Network.png" />
<Resource Include="Resource\Image\SystemIcon\Notepad.png" />
<Resource Include="Resource\Image\SystemIcon\RecycleBin.png" />
<Resource Include="Resource\Image\SystemIcon\Registry.png" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace GeekDesk.Interface
{
public interface IWindowCommon
{
void OnKeyDown(object sender, KeyEventArgs e);
}
}

View File

@@ -3,79 +3,100 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GeekDesk"
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
mc:Ignorable="d"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
x:Name="window"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:AppData}"
Title="GeekDesk"
d:DesignHeight="500" d:DesignWidth="700"
MinWidth="600"
MinHeight="400"
WindowStyle="None"
AllowsTransparency="True"
Background="#00FFFFFF"
OpacityMask ="White"
Background="Transparent"
ShowInTaskbar="False"
Opacity="0"
Deactivated="Window_Deactivated"
Deactivated="App_LostFocus"
SizeChanged="Window_SizeChanged"
KeyDown="OnKeyDown"
Focusable="True"
MouseDown="MainWindow_MouseDown"
>
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="0" ResizeBorderThickness="10"/>
<WindowChrome CaptionHeight="0" ResizeBorderThickness="15"/>
</WindowChrome.WindowChrome>
<Window.Resources>
<RoutedUICommand x:Key="SearchItem" Text="SearchItem"/>
<cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
<cvt:OpcityConvert x:Key="OpcityConvert"/>
<cvt:IntToCornerRadius x:Key="IntToCornerRadius"/>
<cvt:DoubleToGridLength x:Key="DoubleToGridLength"/>
</Window.Resources>
<Window.InputBindings>
<KeyBinding Gesture="Ctrl+F" Key="F" Command="{StaticResource SearchItem}"/>
</Window.InputBindings>
<Window.CommandBindings>
<CommandBinding Command="{StaticResource SearchItem}" CanExecute="SearchItem"/>
</Window.CommandBindings>
<Window.Effect>
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
RenderingBias="Quality" ShadowDepth="2"/>
</Window.Effect>
<Border Margin="20" CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}" BorderThickness="0"
Background="AliceBlue"
Opacity="{Binding AppConfig.PannelOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"
VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.IsContainerVirtualizable="True"
hc:Dialog.Token="IconInfoDialog"
Focusable="True"
>
<hc:DialogContainer Focusable="True">
<Border CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}" BorderThickness="0">
<!--背景图片-->
<Border.Background>
<VisualBrush>
<VisualBrush.Visual>
<Grid ClipToBounds="True">
<Image Source="{Binding AppConfig.BitmapImage}" Margin="-30" Opacity="{Binding AppConfig.BgOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
<Image.Effect>
<BlurEffect Radius="{Binding AppConfig.BlurValue}"/>
</Image.Effect>
</Image>
</Grid>
</VisualBrush.Visual>
</VisualBrush>
</Border.Background>
<Border CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}" BorderThickness="0"
Background="AliceBlue" LostFocus="App_LostFocus"
Opacity="{Binding AppConfig.PannelOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
<Border CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}" BorderThickness="0">
<!--背景图片-->
<Border.Background>
<VisualBrush>
<VisualBrush.Visual>
<Grid ClipToBounds="True">
<Image Source="{Binding AppConfig.BitmapImage}" Margin="-30" Opacity="{Binding AppConfig.BgOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
<Image.Effect>
<BlurEffect Radius="{Binding AppConfig.BlurValue}"/>
</Image.Effect>
</Image>
</Grid>
</VisualBrush.Visual>
</VisualBrush>
<!--<ImageBrush ImageSource="{Binding AppConfig.BitmapImage}" Opacity="{Binding AppConfig.BgOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"></ImageBrush>-->
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" MouseMove="DragMove"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="LeftColumn" MinWidth="80" Width="{Binding AppConfig.MenuCardWidth, Mode=TwoWay, Converter={StaticResource DoubleToGridLength}}" MaxWidth="200"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" MouseMove="DragMove"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="LeftColumn" MinWidth="80" Width="{Binding AppConfig.MenuCardWidth, Mode=TwoWay, Converter={StaticResource DoubleToGridLength}}" MaxWidth="200"></ColumnDefinition>
<ColumnDefinition x:Name="RightColumn" Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--获取焦点用-->
<TextBox x:Name="EmptyTextBox" Width="0"/>
<DockPanel Grid.Row="0" Grid.Column="0" MouseMove="DragMove">
<DockPanel.Background>
<SolidColorBrush Opacity="0.01"/>
</DockPanel.Background>
<Image Source="/Resource/Image/TitleLogo.png" Margin="10,0,0,0" Width="94" Height="30" HorizontalAlignment="Left"/>
</DockPanel>
<DockPanel Grid.Row="0" Grid.Column="0" MouseMove="DragMove">
<DockPanel.Background>
<SolidColorBrush Opacity="0.01"/>
</DockPanel.Background>
<Image Source="/Resource/Image/TitleLogo.png" Margin="10,0,0,0" Width="94" Height="30" HorizontalAlignment="Left"/>
</DockPanel>
<DockPanel Grid.Row="0" Grid.Column="2" MouseMove="DragMove">
<DockPanel.Background>
<SolidColorBrush Opacity="0.01"/>
</DockPanel.Background>
<hc:UniformSpacingPanel Spacing="0" Grid.ColumnSpan="4" HorizontalAlignment="Right" VerticalAlignment="Center">
<Button Background="Transparent"
<DockPanel Grid.Row="0" Grid.Column="2" MouseMove="DragMove">
<DockPanel.Background>
<SolidColorBrush Opacity="0.01"/>
</DockPanel.Background>
<hc:UniformSpacingPanel Grid.ColumnSpan="4" HorizontalAlignment="Right" VerticalAlignment="Center">
<Button Background="Transparent"
BorderThickness="0"
hc:IconElement.Geometry="M917.930667 512c0-57.6 36.181333-106.496 86.869333-125.952a505.429333 505.429333 0 0 0-55.210667-133.461333A134.826667 134.826667 0 0 1 771.413333 74.410667 507.733333 507.733333 0 0 0 637.952 19.2 135.168 135.168 0 0 1 512 106.069333 134.912 134.912 0 0 1 386.048 19.2 505.429333 505.429333 0 0 0 252.586667 74.410667c22.186667 49.749333 13.141333 109.824-27.562667 150.528a135.168 135.168 0 0 1-150.528 27.648 502.016 502.016 0 0 0-55.296 133.461333c50.688 19.626667 86.869333 68.437333 86.869333 125.952 0 57.6-36.181333 106.496-86.869333 125.952 12.117333 47.530667 30.72 92.330667 55.210667 133.461333a134.826667 134.826667 0 0 1 178.090666 178.176 507.733333 507.733333 0 0 0 133.546667 55.210667A135.168 135.168 0 0 1 512 917.930667c57.6 0 106.496 36.181333 125.952 86.869333a505.429333 505.429333 0 0 0 133.461333-55.210667 134.912 134.912 0 0 1 27.562667-150.528 135.168 135.168 0 0 1 150.528-27.648 502.016 502.016 0 0 0 55.296-133.461333A134.912 134.912 0 0 1 917.930667 512zM512 647.338667a135.338667 135.338667 0 1 1 0.085333-270.762667A135.338667 135.338667 0 0 1 512 647.338667z"
hc:IconElement.Height="18"
@@ -84,51 +105,69 @@
Click="ConfigButtonClick"
Initialized="SettingButton_Initialized"
x:Name="SettingButton"
FocusVisualStyle="{x:Null}"
>
<Button.ContextMenu>
<ContextMenu x:Name="SettingMenus" Width="130">
<MenuItem Header="设置" Click="ConfigMenuClick"/>
<MenuItem Header="待办" Click="BacklogMenuClick"/>
</ContextMenu>
</Button.ContextMenu>
</Button>
<Button Background="Transparent"
<Button.ContextMenu>
<ContextMenu x:Name="SettingMenus" Width="130">
<MenuItem Header="设置" Click="ConfigMenuClick"/>
<MenuItem Header="待办" Click="BacklogMenuClick"/>
</ContextMenu>
</Button.ContextMenu>
</Button>
<Button Background="Transparent"
BorderThickness="0"
hc:IconElement.Geometry="M828.770654 148.714771C641.293737-20.89959 354.184117-19.590868 168.245698 152.630946c-212.062907 196.418185-212.062907 522.329912 0 718.748098 185.93842 172.221815 473.048039 173.520546 660.524956 3.916176 219.435707-198.536117 219.435707-528.054322 0-726.580449z m-121.880976 569.643707c-11.708566 11.708566-30.680039 11.708566-42.388605 0L502.729054 556.586459c-0.659356-0.659356-1.728312-0.659356-2.397659 0L338.609327 718.318517c-11.708566 11.708566-30.680039 11.708566-42.388605 0l-0.039961-0.039961c-11.708566-11.708566-11.708566-30.680039 0-42.388605l161.732059-161.732058c0.659356-0.659356 0.659356-1.728312 0-2.397659L296.1408 350.008195c-11.708566-11.708566-11.708566-30.680039 0-42.388605l0.039961-0.039961c11.708566-11.708566 30.680039-11.708566 42.388605 0l161.772019 161.77202c0.659356 0.659356 1.728312 0.659356 2.397659 0L664.551024 307.539668c11.708566-11.708566 30.680039-11.708566 42.388605 0l0.039961 0.039961c11.708566 11.708566 11.708566 30.680039 0 42.388605L545.15762 511.770224c-0.659356 0.659356-0.659356 1.728312 0 2.397659L706.919649 675.939902c11.708566 11.708566 11.708566 30.680039 0 42.388605l-0.029971 0.029971z"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
HorizontalAlignment="Right"
Click="CloseButtonClick"
FocusVisualStyle="{x:Null}"
/>
</hc:UniformSpacingPanel>
</hc:UniformSpacingPanel>
</DockPanel>
</DockPanel>
<uc:LeftCardControl Grid.Row="1" Grid.Column="0"/>
<!--分割线-->
<GridSplitter Opacity="0" Grid.Row="1" Grid.Column="0" Width="1" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
<uc:LeftCardControl Grid.Row="1" Grid.Column="0"/>
<uc:RightCardControl Grid.Row="1" Grid.Column="1"/>
<!--分割线-->
<GridSplitter Opacity="0" Grid.Row="1" Grid.Column="0" Width="1" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
<hc:NotifyIcon Icon="/Taskbar.ico" Text="GeekDesk" Click="NotifyIcon_Click">
<hc:NotifyIcon.ContextMenu>
<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>
<!--搜索输入框-->
<TextBox Panel.ZIndex="2" Grid.Row="0" Grid.Column="1"
x:Name="SearchBox"
Visibility="Collapsed"
LostFocus="SearchBox_LostFocus"
Margin="-100,5,0,0"
Height="32"
FontSize="16"
Width="400"
BorderThickness="0"
TextChanged="SearchBox_TextChanged"
/>
</hc:NotifyIcon>
<StackPanel hc:Growl.GrowlParent="True" VerticalAlignment="Top" Margin="0,10,10,0"/>
</Grid>
</Border>
<uc:RightCardControl x:Name="RightCard" Grid.Row="1" Grid.Column="1"/>
<hc:NotifyIcon Icon="/Taskbar.ico" Click="NotifyIcon_Click" x:Name="BarIcon"
Visibility="{Binding AppConfig.ShowBarIcon, Mode=TwoWay, Converter={StaticResource Boolean2VisibilityConverter}}">
<hc:NotifyIcon.ContextMenu>
<ContextMenu Width="130">
<MenuItem Header="打开面板" Click="ShowApp"/>
<MenuItem Header="隐藏图标" Click="CloseBarIcon"/>
<MenuItem Header="待办" Click="BacklogMenuClick"/>
<MenuItem Header="程序目录" Click="OpenThisDir"/>
<MenuItem Header="设置" Click="ConfigApp"/>
<MenuItem Header="重启" Click="ReStartApp"/>
<MenuItem Header="退出" Click="ExitApp"/>
</ContextMenu>
</hc:NotifyIcon.ContextMenu>
</hc:NotifyIcon>
<StackPanel hc:Growl.GrowlParent="True" VerticalAlignment="Top" Margin="0,10,10,0"/>
</Grid>
</Border>
</hc:DialogContainer>
</Border>
</Window>

View File

@@ -1,25 +1,22 @@
using DraggAnimatedPanelExample;
using GeekDesk.Constant;
using GeekDesk.Control;
using GeekDesk.Constant;
using GeekDesk.Control.UserControls.Config;
using GeekDesk.Control.Windows;
using GeekDesk.Interface;
using GeekDesk.Task;
using GeekDesk.Thread;
using GeekDesk.MyThread;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Data;
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows;
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;
using System.Collections.ObjectModel;
using NPinyin;
using GeekDesk.ViewModel.Temp;
namespace GeekDesk
{
@@ -27,16 +24,14 @@ namespace GeekDesk
/// MainWindow.xaml 的交互逻辑
/// </summary>
///
public partial class MainWindow : Window
public partial class MainWindow : Window, IWindowCommon
{
public static AppData appData = CommonCode.GetAppDataByFile();
//public static ToDoInfoWindow toDoInfoWindow = (ToDoInfoWindow)ToDoInfoWindow.GetThis();
public static ToDoInfoWindow toDoInfoWindow;
public static int hotKeyId = -1;
public static int toDoHotKeyId = -1;
public static MainWindow mainWindow;
public static MarginHide hide;
public MainWindow()
{
LoadData();
@@ -47,27 +42,89 @@ namespace GeekDesk
this.SizeChanged += MainWindow_Resize;
ToDoTask.BackLogCheck();
////实例化隐藏 Hide类进行时间timer设置
hide = new MarginHide(this);
MarginHide.ReadyHide(this);
if (appData.AppConfig.MarginHide)
{
hide.TimerSet();
MarginHide.StartHide();
}
}
/// <summary>
/// 显示搜索框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SearchItem(object sender, CanExecuteRoutedEventArgs e)
{
RightCard.VisibilitySearchCard(Visibility.Visible);
SearchBox.Visibility = Visibility.Visible;
SearchBox.Focus();
}
/// <summary>
/// 搜索开始
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
{
string inputText = SearchBox.Text.ToLower();
if (!string.IsNullOrEmpty(inputText))
{
SearchIconList.IconList.Clear();
ObservableCollection<MenuInfo> menuList = appData.MenuList;
foreach (MenuInfo menu in menuList)
{
ObservableCollection<IconInfo> iconList = menu.IconList;
foreach (IconInfo icon in iconList)
{
string pyName = Pinyin.GetInitials(icon.Name).ToLower();
if (icon.Name.Contains(inputText) || pyName.Contains(inputText)) {
SearchIconList.IconList.Add(icon);
}
}
}
} else
{
SearchIconList.IconList.Clear();
}
}
/// <summary>
/// 隐藏搜索框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SearchBox_LostFocus(object sender, RoutedEventArgs e)
{
SearchIconList.IconList.Clear();
RightCard.VisibilitySearchCard(Visibility.Collapsed);
SearchBox.Visibility = Visibility.Collapsed;
SearchBox.Text = "";
}
/// <summary>
/// 加载缓存数据
/// </summary>
private void LoadData()
{
GC.KeepAlive(appData); // 持活
this.DataContext = appData;
if (appData.MenuList.Count == 0)
{
appData.MenuList.Add(new MenuInfo() { MenuName = "NewMenu", MenuId = System.Guid.NewGuid().ToString(), MenuEdit = Visibility.Collapsed});
appData.MenuList.Add(new MenuInfo() { MenuName = "NewMenu", MenuId = System.Guid.NewGuid().ToString(), MenuEdit = Visibility.Collapsed });
}
this.Width = appData.AppConfig.WindowWidth;
this.Height = appData.AppConfig.WindowHeight;
}
/// <summary>
/// 窗口加载完毕 执行方法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Window_Loaded(object sender, RoutedEventArgs e)
{
if (!appData.AppConfig.StartedShowPanel)
@@ -75,23 +132,38 @@ namespace GeekDesk
if (appData.AppConfig.AppAnimation)
{
this.Opacity = 0;
} else
}
else
{
this.Visibility = Visibility.Collapsed;
}
} else
}
else
{
ShowApp();
}
//给任务栏图标一个名字
BarIcon.Text = Constants.MY_NAME;
//注册热键
RegisterHotKey(true);
RegisterCreateToDoHotKey(true);
if (!appData.AppConfig.SelfStartUped)
//注册自启动
if (!appData.AppConfig.SelfStartUped && !Constants.DEV)
{
RegisterUtil.SetSelfStarting(appData.AppConfig.SelfStartUp, Constants.MY_NAME);
}
UpdateThread.Update();
//注册鼠标中键监听事件
if (appData.AppConfig.MouseMiddleShow)
{
MouseHookThread.MiddleHook();
}
//更新线程开启 检测更新
UpdateThread.Update();
}
/// <summary>
@@ -108,7 +180,7 @@ namespace GeekDesk
{
if (MotionControl.hotkeyFinished)
{
if (mainWindow.Visibility == Visibility.Collapsed || mainWindow.Opacity == 0)
if (mainWindow.Visibility == Visibility.Collapsed || mainWindow.Opacity == 0 || MarginHide.IS_HIDE)
{
ShowApp();
}
@@ -138,39 +210,8 @@ 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>
@@ -179,7 +220,7 @@ namespace GeekDesk
try
{
if (appData.AppConfig.ToDoHotkeyModifiers!=0)
if (appData.AppConfig.ToDoHotkeyModifiers != 0)
{
//加载完毕注册热键
toDoHotKeyId = GlobalHotKey.RegisterHotKey(appData.AppConfig.ToDoHotkeyModifiers, appData.AppConfig.ToDoHotkey, () =>
@@ -209,6 +250,11 @@ namespace GeekDesk
}
/// <summary>
/// 重置窗体大小 写入缓存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void MainWindow_Resize(object sender, System.EventArgs e)
{
if (this.DataContext != null)
@@ -221,13 +267,13 @@ namespace GeekDesk
/// <summary>
/// 程序窗体拖动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DragMove(object sender, MouseEventArgs e)
{
//if (e.LeftButton == MouseButtonState.Pressed)
//{
// this.DragMove();
//}
if (e.LeftButton == MouseButtonState.Pressed)
{
@@ -244,7 +290,6 @@ namespace GeekDesk
(When clicking the drag area, make the window follow) */
DragMove();
if (this.ResizeMode != windowMode)
{
this.ResizeMode = windowMode;
@@ -267,7 +312,8 @@ namespace GeekDesk
if (appData.AppConfig.AppAnimation)
{
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
} else
}
else
{
this.Visibility = Visibility.Collapsed;
}
@@ -298,12 +344,21 @@ namespace GeekDesk
}
public static void ShowApp()
{
//有全屏化应用则不显示
//if (CommonCode.IsPrimaryFullScreen())
//{
// return;
//}
//修改贴边隐藏状态为未隐藏
mainWindow.Activate();
MarginHide.IS_HIDE = false;
if (appData.AppConfig.FollowMouse)
{
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0, false);
}
FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
Keyboard.Focus(mainWindow);
mainWindow.Focus();
}
public static void HideApp()
@@ -311,6 +366,50 @@ namespace GeekDesk
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
}
/// <summary>
/// 淡入淡出效果
/// </summary>
/// <param name="opacity"></param>
/// <param name="milliseconds"></param>
/// <param name="visibility"></param>
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;
CommonCode.SortIconList();
}
};
Timeline.SetDesiredFrameRate(opacityAnimation, 60);
mainWindow.BeginAnimation(OpacityProperty, opacityAnimation);
}
else
{
//防止关闭动画后 窗体仍是0透明度
mainWindow.Opacity = 1;
mainWindow.Visibility = visibility;
if (visibility == Visibility.Collapsed)
{
CommonCode.SortIconList();
}
}
}
@@ -355,15 +454,6 @@ namespace GeekDesk
p.Start();
}
/// <summary>
/// 右键任务栏图标退出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ExitApp(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
@@ -405,26 +495,19 @@ namespace GeekDesk
SettingButton.ContextMenu = null;
}
private void App_LostFocus(object sender, RoutedEventArgs e)
private void App_LostFocus(object sender, EventArgs e)
{
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS)
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS
&& this.Opacity == 1)
{
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
if (appData.AppConfig.MarginHide && !hide.IsMargin())
if (!appData.AppConfig.MarginHide || (appData.AppConfig.MarginHide && !MarginHide.IS_HIDE))
{
this.Visibility = Visibility.Collapsed;
HideApp();
}
}
}
private void Window_Deactivated(object sender, EventArgs e)
{
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS)
{
this.Visibility = Visibility.Collapsed;
}
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (this.DataContext != null)
@@ -435,6 +518,21 @@ namespace GeekDesk
}
}
/// <summary>
/// 右键任务栏图标退出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ExitApp(object sender, RoutedEventArgs e)
{
if (appData.AppConfig.MouseMiddleShow)
{
MouseHookThread.Dispose();
}
Application.Current.Shutdown();
}
/// <summary>
/// 重启
/// </summary>
@@ -442,15 +540,47 @@ namespace GeekDesk
/// <param name="e"></param>
private void ReStartApp(object sender, RoutedEventArgs e)
{
if (appData.AppConfig.MouseMiddleShow)
{
MouseHookThread.Dispose();
}
Process p = new Process();
p.StartInfo.FileName = Constants.APP_DIR + Constants.MY_NAME + ".exe";
p.StartInfo.FileName = Constants.APP_DIR + "GeekDesk.exe";
p.StartInfo.WorkingDirectory = Constants.APP_DIR;
p.Start();
Application.Current.Shutdown();
}
/// <summary>
/// 关闭托盘图标
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CloseBarIcon(object sender, RoutedEventArgs e)
{
appData.AppConfig.ShowBarIcon = false;
}
public void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
HideApp();
}
}
/// <summary>
/// 为了让修改菜单的textBox失去焦点
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MainWindow_MouseDown(object sender, MouseButtonEventArgs e)
{
EmptyTextBox.Focus();
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Threading;
namespace GeekDesk.MyThread
{
public class DispatcherBuild
{
//创建一个Dispatcher来单独使用ui线程
public static Dispatcher Build()
{
Dispatcher dispatcher = null;
var manualResetEvent = new ManualResetEvent(false);
var thread = new System.Threading.Thread(() =>
{
dispatcher = Dispatcher.CurrentDispatcher;
var synchronizationContext = new DispatcherSynchronizationContext(dispatcher);
SynchronizationContext.SetSynchronizationContext(synchronizationContext);
manualResetEvent.Set();
Dispatcher.Run();
});
thread.Start();
manualResetEvent.WaitOne();
manualResetEvent.Dispose();
return dispatcher;
}
}
}

View File

@@ -0,0 +1,67 @@
using GeekDesk.Control.UserControls.Config;
using GeekDesk.ViewModel;
using Gma.System.MouseKeyHook;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
namespace GeekDesk.MyThread
{
public class MouseHookThread
{
private static AppConfig appConfig = MainWindow.appData.AppConfig;
private static IKeyboardMouseEvents m_GlobalHook = Hook.GlobalEvents();
private static Dispatcher dispatcher;
public static void MiddleHook()
{
//使用dispatcher来单独监听UI线程 防止程序卡顿
dispatcher = DispatcherBuild.Build();
dispatcher.Invoke((Action)(() =>
{
m_GlobalHook.MouseDownExt += M_GlobalHook_MouseDownExt;
}));
}
public static void Dispose()
{
m_GlobalHook.MouseDownExt -= M_GlobalHook_MouseDownExt;
m_GlobalHook.Dispose();
dispatcher.InvokeShutdown();
}
/// <summary>
/// 鼠标中键呼出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void M_GlobalHook_MouseDownExt(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (appConfig.MouseMiddleShow && e.Button == System.Windows.Forms.MouseButtons.Middle)
{
if (MotionControl.hotkeyFinished)
{
MainWindow.mainWindow.Dispatcher.Invoke((Action)(() =>
{
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed || MainWindow.mainWindow.Opacity == 0)
{
MainWindow.ShowApp();
}
else
{
MainWindow.HideApp();
}
}));
}
}
}
}
}

View File

@@ -12,7 +12,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows;
namespace GeekDesk.Thread
namespace GeekDesk.MyThread
{
public class UpdateThread
{
@@ -59,10 +59,9 @@ namespace GeekDesk.Thread
}));
}
}
} catch (Exception e)
} catch (Exception ex)
{
//不做处理
//MessageBox.Show(e.Message);
LogUtil.WriteErrorLog(ex, "获取更新失败!");
}
}
}

View File

@@ -49,5 +49,5 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.1.0")]
[assembly: AssemblyFileVersion("2.3.1.0")]
[assembly: AssemblyVersion("2.4.1.3")]
[assembly: AssemblyFileVersion("2.4.1.3")]

View File

@@ -1,6 +1,16 @@
# GeekDesk
小巧、美观的桌面快速启动管理工具
# GeekDesk 极客桌面
小巧、**美观**的桌面快速启动管理工具
谈一谈做GeekDesk的原因:
目前的市场上也有一部分桌面图标管理工具, 但是**界面好点的收费**, **免费的界面差**
**windows11**都来了, 难道还要用界面停留在**win7时代**的软件吗
所以就萌生了做这款软件的想法, **免费 / 美观 / 高度定制化** 是从GeekDesk诞生开始就有的需求和方向, 未来也会向着这些方向发展
目前GeekDesk只有一个人在开发, 大家如果有好的建议也可以提Issue
另外如果你喜欢 GeekDesk的话, 或许可以为作者购买防脱洗发水
<img src="https://z3.ax1x.com/2021/07/20/WYdfmR.jpg" alt="WYdfmR.jpg" border="0" width="400px"/>
## 开发框架
- wpf
- .net 4.7.2
@@ -34,9 +44,3 @@
## LICENSE
- 这是个人开发的程序,任何人可任意修改和免费使用(未做较大功能性改动不允许修改赞赏码,重新修改发布需注明出处)
- 商用需联系作者
### 佛系赞赏
我知道没人赞赏但我还是要放上来
<img src="https://z3.ax1x.com/2021/07/20/WYdfmR.jpg" alt="WYdfmR.jpg" border="0" width="500px"/>

View File

@@ -0,0 +1,60 @@
<ResourceDictionary 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">
<!--整体样式-->
<Style x:Key="BorderBG" TargetType="Border">
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush Opacity="0.97">
<GradientStop Color="#EBF7E3" Offset="0"/>
<GradientStop Color="#A8E4C0" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="CornerRadius" Value="8"/>
<Setter Property="BorderThickness" Value="0"/>
</Style.Setters>
</Style>
<LinearGradientBrush x:Key="BtnBG" Opacity="0.97">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
<!--按钮样式-->
<Style x:Key="Btn1" TargetType="Button" BasedOn="{StaticResource ButtonInfo}">
<Setter Property="Background" Value="{StaticResource BtnBG}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush">
<Setter.Value>
<SolidColorBrush Color="#E5E5E2"/>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="Black"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#E5E5E2"/>
</Trigger>
</Style.Triggers>
</Style>
<!--菜单样式-->
<Style x:Key="MyMenuStyle" TargetType="hc:SideMenuItem" BasedOn="{StaticResource SideMenuItemBaseStyle}">
<Style.Setters>
<Setter Property="Background" Value="Transparent"/>
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View File

@@ -37,6 +37,7 @@
M512 0c282.775704 0 512 229.224296 512 512S794.775704 1024 512 1024 0 794.775704 0 512 229.224296 0 512 0zM303.407407 455.111111a56.888889 56.888889 0 1 0 0 113.777778 56.888889 56.888889 0 0 0 0-113.777778z m208.592593 0a56.888889 56.888889 0 1 0 0 113.777778 56.888889 56.888889 0 0 0 0-113.777778z m208.592593 0a56.888889 56.888889 0 1 0 0 113.777778 56.888889 56.888889 0 0 0 0-113.777778z
</Geometry>
<!--更新源-->
<Geometry x:Key="Gitee">
M512 0C230.4 0 0 230.4 0 512s230.4 512 512 512 512-230.4 512-512S793.6 0 512 0z m284.8 313.6c0 12.8-12.8 25.6-25.6 25.6H416c-41.6 0-76.8 35.2-76.8 76.8v243.2c0 12.8 12.8 25.6 25.6 25.6h240c41.6 0 76.8-35.2 76.8-76.8v-12.8c0-12.8-12.8-25.6-25.6-25.6H480c-12.8 0-25.6-12.8-25.6-25.6v-64c0-12.8 12.8-25.6 25.6-25.6h291.2c12.8 0 25.6 12.8 25.6 25.6v144c0 92.8-76.8 169.6-169.6 169.6H252.8c-12.8 0-25.6-12.8-25.6-25.6V412.8C227.2 310.4 310.4 224 416 224h355.2c12.8 0 25.6 12.8 25.6 25.6v64z
</Geometry>
@@ -44,6 +45,23 @@
<Geometry x:Key="GitHub">
M1021.72444445 512a495.16088889 495.16088889 0 0 1-97.57582223 299.64515555 500.62222222 500.62222222 0 0 1-250.85724444 184.22897778 30.58346667 30.58346667 0 0 1-26.2144-4.73315555 25.85031111 25.85031111 0 0 1-8.00995556-20.02488889v-139.81013334a119.05706667 119.05706667 0 0 0-34.58844444-94.29902222 473.31555555 473.31555555 0 0 0 67.72053333-11.65084444 248.30862222 248.30862222 0 0 0 62.2592-26.2144 187.50577778 187.50577778 0 0 0 53.52106667-43.69066667 209.35111111 209.35111111 0 0 0 36.40888889-69.90506667 334.2336 334.2336 0 0 0 13.83537778-100.12444444 191.87484445 191.87484445 0 0 0-52.7928889-136.53333333 176.21902222 176.21902222 0 0 0-5.09724444-135.44106667 87.01724445 87.01724445 0 0 0-53.52106666 7.28177778 341.87946667 341.87946667 0 0 0-61.16693334 29.12711111l-25.12213333 15.65582222a473.31555555 473.31555555 0 0 0-254.86222223 0c-7.28177778-5.09724445-16.384-10.55857778-28.03484444-17.84035555A371.00657778 371.00657778 0 0 0 300.82844445 220.72888889a94.29902222 94.29902222 0 0 0-57.16195556-9.10222222 178.40355555 178.40355555 0 0 0-4.73315556 136.53333333 197.70026667 197.70026667 0 0 0-52.4288 137.26151111A327.68 327.68 0 0 0 200.33991111 584.81777778a223.55057778 223.55057778 0 0 0 36.40888889 69.90506667 172.94222222 172.94222222 0 0 0 53.52106667 44.41884444 304.7424 304.7424 0 0 0 62.2592 26.2144 471.13102222 471.13102222 0 0 0 68.08462222 11.65084444 105.22168889 105.22168889 0 0 0-32.768 68.44871112 112.86755555 112.86755555 0 0 1-30.21937778 9.4663111 190.41848889 190.41848889 0 0 1-36.40888889 3.2768A78.6432 78.6432 0 0 1 274.61404445 803.27111111a124.5184 124.5184 0 0 1-36.4088889-41.50613333 109.22666667 109.22666667 0 0 0-32.03982222-34.58844445 91.7504 91.7504 0 0 0-32.768-16.01991111h-13.1072a47.33155555 47.33155555 0 0 0-19.29671111 2.91271111q-5.46133333 3.2768-3.2768 7.64586667a50.24426667 50.24426667 0 0 0 6.18951111 9.10222222 62.98737778 62.98737778 0 0 0 8.73813334 8.37404445l4.73315555 2.91271111a88.83768889 88.83768889 0 0 1 29.12711111 25.12213333 179.49582222 179.49582222 0 0 1 20.75306667 33.49617778l6.5536 15.29173333a82.28408889 82.28408889 0 0 0 29.12711111 41.14204445 109.22666667 109.22666667 0 0 0 44.05475556 18.93262222 223.18648889 223.18648889 0 0 0 45.8752 4.73315556 207.16657778 207.16657778 0 0 0 36.40888888-2.54862223l15.29173334-2.54862222v95.39128889a26.2144 26.2144 0 0 1-8.73813334 20.02488889 31.67573333 31.67573333 0 0 1-26.57848888 4.73315555 498.43768889 498.43768889 0 0 1-249.40088889-185.32124444A486.78684445 486.78684445 0 0 1 2.27555555 512a497.70951111 497.70951111 0 0 1 68.44871112-254.86222222A504.6272 504.6272 0 0 1 257.13777778 70.72426667 497.70951111 497.70951111 0 0 1 512 2.27555555a497.70951111 497.70951111 0 0 1 254.86222222 68.44871112A504.6272 504.6272 0 0 1 953.27573333 257.13777778 496.98133333 496.98133333 0 0 1 1021.72444445 512z
</Geometry>
<!--更新源-->
<!--排序方式-->
<Geometry x:Key="CustomSort">
M950.896028 907.262252 799.11209 753.232157c-12.108782-12.302187-31.893384-12.434194-44.163849-0.325411-12.286838 12.103666-12.434194 31.878035-0.325411 44.163849l151.783938 154.030096c6.110161 6.206352 14.177907 9.31311 22.24463 9.31311 7.919367 0 15.839757-2.989077 21.919219-8.987698C962.857455 939.323459 963.004811 919.54909 950.896028 907.262252z
M884.039341 602.546226c30.65723-17.944697 39.848567-39.624463 42.156122-54.645574 2.26253-14.700817 0.147356-37.530778-22.773679-62.84021-44.830021-49.441039-119.794363-128.689964-142.222165-152.352897-5.586229-32.177863-24.425296-139.980101-37.535895-206.1655-4.869914-24.50716-19.174712-44.387953-39.248909-54.53915-19.896142-10.060123-43.38102-9.739828-66.149583 0.919952-61.168128 28.716019-160.318312 77.455069-189.568497 91.861174-32.803103-3.975545-145.002488-17.466814-211.030297-24.145933-21.283746-2.170432-42.202171 5.363148-57.380872 20.608364-15.971763 16.038278-24.099884 38.928614-21.751397 61.238736 7.060813 67.115584 20.99415 179.407066 25.055652 211.919551-14.049994 29.635971-62.535265 132.146693-90.514503 194.163141-13.837146 30.555923-8.352225 53.30402-1.311879 67.004043 9.378601 18.249643 27.083845 31.165814 48.677653 35.461653 64.594157 12.617365 177.831174 32.345686 211.060997 38.104853 23.967878 22.915919 104.747669 99.984179 153.59826 144.738475 19.759019 18.116613 38.028105 22.941502 51.890834 22.941502 3.360538 0 6.461155-0.284479 9.261944-0.726547 14.365172-2.292206 34.922371-11.127432 51.245128-40.153512 33.336246-59.07342 87.722924-160.679539 103.425557-190.086289 28.390607-15.70775 124.57218-69.067029 183.102225-103.293551C884.029108 602.551342 884.034225 602.551342 884.039341 602.546226zM852.482625 548.642548c-68.234057 39.898709-188.638311 106.333794-189.842743 106.998943-5.301749 2.922563-9.642614 7.324826-12.484336 12.672624-0.681522 1.276063-68.345598 128.328737-107.075691 196.964954-2.948145 5.236258-5.428639 7.848759-6.699586 8.860808-1.514493-0.568958-4.666276-2.272763-9.06854-6.308683-57.065693-52.281737-158.473291-149.420101-159.490457-150.396335-4.493338-4.306072-10.17678-7.172353-16.312524-8.230452-1.428535-0.243547-143.858432-24.786523-218.98548-39.45664-2.917446-0.579191-4.793166-1.942235-5.195326-2.725064-0.457418-0.889253-0.873903-4.900613 2.673899-12.728906 32.568766-72.198346 93.310176-200.045105 93.920066-201.331401 2.562359-5.383614 3.523243-11.391445 2.780323-17.309224-0.178055-1.408069-17.827017-141.622508-26.047236-219.706911-0.381693-3.634784 1.183965-7.90504 3.89368-10.623965 2.115174-2.124384 4.122901-2.592035 5.779633-2.592035 0.37146 0 0.721431 0.020466 1.057075 0.056282 76.915787 7.777127 217.582527 24.954345 218.995713 25.127284 6.019087 0.726547 12.164041-0.310062 17.619286-2.99931 1.245364-0.615007 125.360126-61.899792 196.786898-95.439676 4.895497-2.297322 9.063423-2.922563 11.437493-1.733481 2.699482 1.367137 5.118578 5.67321 6.17156 10.959609 15.310707 77.302597 38.628786 212.590839 38.862099 213.947743 1.046842 6.089695 3.883447 11.732206 8.138354 16.211217 0.950651 0.9967 95.328136 100.345406 147.737786 158.14788 5.880941 6.491855 7.284917 10.608615 7.345292 11.30037C864.163665 539.349905 861.291245 543.483038 852.482625 548.642548z
M348.905458 492.080322c-12.169157-12.220323-31.948643-12.266371-44.168965-0.085958-12.220323 12.169157-12.261255 31.943526-0.085958 44.168965l22.676465 22.768563c6.099928 6.125511 14.111392 9.190313 22.127973 9.190313 7.970532 0 15.94618-3.035126 22.040992-9.104355 12.220323-12.169157 12.261255-31.948643 0.085958-44.168965L348.905458 492.080322z
M508.766352 376.774179c6.105045 6.125511 14.116509 9.190313 22.127973 9.190313 7.970532 0 15.94618-3.035126 22.040992-9.104355 12.220323-12.174274 12.261255-31.948643 0.085958-44.168965l-22.681582-22.768563c-12.17939-12.220323-31.948643-12.256138-44.168965-0.085958-12.220323 12.174274-12.261255 31.948643-0.085958 44.168965L508.766352 376.774179z
M564.67878 441.515692c-16.851806 3.680832-27.53103 20.322861-23.856337 37.174668 0.056282 0.248663 4.707209 25.564235-11.290137 41.621956-15.524578 15.575744-39.035038 11.153014-40.616046 10.832719-16.673751-3.715625-33.310663 6.668886-37.225833 23.352871-3.934612 16.790408 6.486738 33.596166 23.281239 37.535895 6.003737 1.408069 13.852496 2.409886 22.748097 2.409886 22.895453 0 52.745295-6.634094 76.067466-30.04734 32.16763-32.289404 32.777521-77.43972 28.065196-99.023294C598.167498 448.51613 581.51933 437.856349 564.67878 441.515692z
</Geometry>
<Geometry x:Key="UpSort">
M470.016 976.896q-44.032 0-59.392-20.48t-15.36-65.536q0-20.48-0.512-64.512t-1.024-93.696-1.536-96.768-1.024-74.752q0-39.936-7.68-62.464t-35.328-21.504q-20.48 0-48.64-1.024t-49.664 0q-35.84 0-45.568-19.456t13.824-50.176q24.576-30.72 57.344-72.704t67.584-86.016 68.096-87.04 58.88-75.776q23.552-29.696 45.568-30.72t46.592 26.624q24.576 29.696 56.832 69.632t67.072 82.432 68.608 83.968 60.416 73.216q29.696 35.84 23.04 58.88t-43.52 23.04q-11.264 0-25.088 0.512t-29.184 1.024-30.208 1.024-27.136 0.512q-25.6 1.024-32.256 16.384t-5.632 41.984q0 29.696 0.512 77.824t1.024 100.352 1.536 101.376 1.024 79.872q0 13.312-2.048 27.648t-9.728 26.112-21.504 19.968-36.352 8.192q-27.648 0-52.736 0.512t-56.832 1.536z
</Geometry>
<Geometry x:Key="LowSort">
M564.224 44.032q43.008 0 58.368 20.48t15.36 65.536q0 20.48 0.512 64.512t0.512 93.696 0.512 96.768 0.512 74.752q0 38.912 7.68 61.952t35.328 22.016q19.456 0 48.128 1.024t49.152 1.024q35.84 0 45.568 18.944t-13.824 49.664q-24.576 30.72-57.344 72.704t-68.096 86.016-69.12 86.528-59.392 75.264q-23.552 29.696-45.568 30.72t-45.568-27.648q-24.576-29.696-57.344-69.632t-67.072-82.432-67.584-83.968-59.904-74.24q-29.696-35.84-22.528-58.88t44.032-23.04l24.576 0q14.336 0 29.696-0.512t30.208-1.536 26.112-1.024q26.624 0 32.768-15.36t6.144-41.984q0-29.696-0.512-77.824t-0.512-100.352-0.512-101.376-0.512-79.872q0-13.312 2.048-27.648t9.728-26.112 20.992-19.456 36.864-7.68q27.648 0 53.248-0.512t57.344-0.512z
</Geometry>
<!--排序方式-->
</ResourceDictionary>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -1,9 +1,9 @@
{
"title" : "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
"subTitle" : "V2.3.10 <20><>ʽ<EFBFBD><CABD>",
"msgTitle" : "<EFBFBD><EFBFBD><EFBFBD>θ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
"msg" : "['<EFBFBD>޸<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><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ㴰<DAB5>ڵ<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"
"title": "GeekDesk版本更新",
"subTitle": "V2.4.12",
"msgTitle": "本次更新内容如下",
"msg": "['各位兄弟去给我点个免费Star呗','这是个修复版本,主要修复上个版本的bug','修复图标无法拖动','修复界面遮挡任务栏']",
"githubUrl": "https://github.com/Demo-Liu/GeekDesk/releases",
"giteeUrl": "https://gitee.com/demo_liu/GeekDesk/releases",
"version": "2.4.12"
}

View File

@@ -1,9 +0,0 @@
{
"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"
}

View File

@@ -1,9 +1,13 @@
using GeekDesk.Constant;
using GeekDesk.ViewModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows;
using System.Windows.Media.Imaging;
/// <summary>
/// 提取一些代码
@@ -44,7 +48,6 @@ namespace GeekDesk.Util
/// <param name="appData"></param>
public static void SaveAppData(AppData appData)
{
using (FileStream fs = new FileStream(Constants.DATA_FILE_PATH, FileMode.Create))
{
BinaryFormatter bf = new BinaryFormatter();
@@ -54,6 +57,170 @@ namespace GeekDesk.Util
/// <summary>
/// 判断当前屏幕(鼠标最后活动屏幕)是否有全屏化应用
/// </summary>
/// <returns></returns>
public static bool IsPrimaryFullScreen()
{
RECT rect = new RECT();
GetWindowRect(new HandleRef(null, GetForegroundWindow()), ref rect);
int windowHeight = rect.bottom - rect.top;
int screenHeight = (int)SystemParameters.PrimaryScreenHeight;
if (windowHeight >= screenHeight)
{
return true;
}
return false;
}
/// <summary>
/// 根据路径获取文件图标等信息
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static IconInfo GetIconInfoByPath(string path)
{
string tempPath = path;
//string base64 = ImageUtil.FileImageToBase64(path, System.Drawing.Imaging.ImageFormat.Png);
//string ext = "";
//if (!ImageUtil.IsSystemItem(path))
//{
// ext = System.IO.Path.GetExtension(path).ToLower();
//}
string iconPath = null;
//if (".lnk".Equals(ext))
//{
string targetPath = FileUtil.GetTargetPathByLnk(path);
iconPath = FileUtil.GetIconPathByLnk(path);
if (targetPath != null)
{
path = targetPath;
}
//}
if (StringUtil.IsEmpty(iconPath))
{
iconPath = path;
}
BitmapImage bi = ImageUtil.GetBitmapIconByPath(iconPath);
IconInfo iconInfo = new IconInfo
{
Path = path,
LnkPath = tempPath,
BitmapImage = bi,
StartArg = FileUtil.GetArgByLnk(tempPath)
};
iconInfo.DefaultImage = iconInfo.ImageByteArr;
iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(tempPath);
if (StringUtil.IsEmpty(iconInfo.Name))
{
iconInfo.Name = path;
}
return iconInfo;
}
public static IconInfo GetIconInfoByPath_NoWrite(string path)
{
string tempPath = path;
//string base64 = ImageUtil.FileImageToBase64(path, System.Drawing.Imaging.ImageFormat.Png);
string ext = "";
if (!ImageUtil.IsSystemItem(path))
{
ext = System.IO.Path.GetExtension(path).ToLower();
}
string iconPath = null;
if (".lnk".Equals(ext))
{
string targetPath = FileUtil.GetTargetPathByLnk(path);
iconPath = FileUtil.GetIconPathByLnk(path);
if (targetPath != null)
{
path = targetPath;
}
}
if (StringUtil.IsEmpty(iconPath))
{
iconPath = path;
}
BitmapImage bi = ImageUtil.GetBitmapIconByPath(iconPath);
IconInfo iconInfo = new IconInfo
{
Path_NoWrite = path,
LnkPath_NoWrite = tempPath,
BitmapImage_NoWrite = bi,
StartArg_NoWrite = FileUtil.GetArgByLnk(tempPath)
};
iconInfo.DefaultImage_NoWrite = iconInfo.ImageByteArr;
iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(tempPath);
if (StringUtil.IsEmpty(iconInfo.Name))
{
iconInfo.Name_NoWrite = path;
}
return iconInfo;
}
[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("user32.dll")]
private static extern bool GetWindowRect(HandleRef hWnd, [In, Out] ref RECT rect);
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
/// <summary>
/// 排序图标
/// </summary>
public static void SortIconList()
{
if (MainWindow.appData.AppConfig.IconSortType != SortType.CUSTOM)
{
ObservableCollection<MenuInfo> menuList = MainWindow.appData.MenuList;
//List<IconInfo> list = new List<IconInfo>(menuList[MainWindow.appData.AppConfig.SelectedMenuIndex].IconList);
List<IconInfo> list;
foreach (MenuInfo menuInfo in menuList)
{
list = new List<IconInfo>(menuInfo.IconList);
switch (MainWindow.appData.AppConfig.IconSortType)
{
case SortType.COUNT_UP:
list.Sort((x, y) => x.Count.CompareTo(y.Count));
break;
case SortType.COUNT_LOW:
list.Sort((x, y) => y.Count.CompareTo(x.Count));
break;
case SortType.NAME_UP:
list.Sort((x, y) => x.Name.CompareTo(y.Name));
break;
case SortType.NAME_LOW:
list.Sort((x, y) => y.Name.CompareTo(x.Name));
break;
}
menuInfo.IconList = new ObservableCollection<IconInfo>(list);
}
MainWindow.appData.AppConfig.SelectedMenuIcons = MainWindow.appData.MenuList[MainWindow.appData.AppConfig.SelectedMenuIndex].IconList;
}
}
}
}

View File

@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Media.Imaging;
@@ -65,7 +66,14 @@ namespace GeekDesk.Util
Bitmap bmp = ico.ToBitmap();
MemoryStream strm = new MemoryStream();
bmp.Save(strm, System.Drawing.Imaging.ImageFormat.Png);
ImageCodecInfo myImageCodecInfo = GetEncoderInfo("image/png");
Encoder myEncoder = Encoder.Quality;
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 75L);
EncoderParameters myEncoderParameters = new EncoderParameters(1);
myEncoderParameters.Param[0] = myEncoderParameter;
bmp.Save(strm, myImageCodecInfo, myEncoderParameters);
BitmapImage bmpImage = new BitmapImage();
bmpImage.BeginInit();
strm.Seek(0, SeekOrigin.Begin);
@@ -78,6 +86,19 @@ namespace GeekDesk.Util
return bmpImage.Clone();
}
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for (j = 0; j < encoders.Length; ++j)
{
if (encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}
public static int GetIconIndex(string pszFile)

View File

@@ -2,7 +2,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace GeekDesk.Util
@@ -10,23 +12,152 @@ namespace GeekDesk.Util
public class FileUtil
{
private static readonly string NO_PATH = "{(.*)}";
private static readonly string NO_ICO = "^,(.*)";
private static readonly string HAVE_ICO = "(.*),(.*)";
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;
string path = shortcut.TargetPath;
if (path == null || Regex.IsMatch(path, NO_PATH))
{
path = ParseShortcut(filePath);
}
return path;
}
catch (Exception e)
{
LogUtil.WriteErrorLog(e, "获取目标路径失败! filePath=" + filePath);
return null;
}
}
/// <summary>
/// 获取启动参数
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static string GetArgByLnk(string filePath)
{
try
{
WshShell shell = new WshShell();
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
return shortcut.Arguments;
}
catch (Exception e)
{
LogUtil.WriteErrorLog(e, "获取启动参数失败! filePath=" + filePath);
return "";
}
}
/// <summary>
/// 获取iconpath
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static string GetIconPathByLnk(string filePath)
{
try
{
WshShell shell = new WshShell();
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
var iconPath = shortcut.IconLocation;
if (StringUtil.IsEmpty(iconPath)
|| Regex.IsMatch(iconPath, NO_ICO)
|| Regex.IsMatch(iconPath, NO_PATH)
|| !Regex.IsMatch(iconPath, HAVE_ICO))
{
return null;
}
else
{
return iconPath.Split(',')[0];
}
}
catch (Exception e)
{
LogUtil.WriteErrorLog(e, "获取图标路径失败! filePath=" + filePath);
return null;
}
}
/*
UINT MsiGetShortcutTarget(
LPCTSTR szShortcutTarget,
LPTSTR szProductCode,
LPTSTR szFeatureId,
LPTSTR szComponentCode
);
*/
[DllImport("msi.dll", CharSet = CharSet.Auto)]
static extern int MsiGetShortcutTarget(string targetFile, StringBuilder productCode, StringBuilder featureID, StringBuilder componentCode);
public enum InstallState
{
NotUsed = -7,
BadConfig = -6,
Incomplete = -5,
SourceAbsent = -4,
MoreData = -3,
InvalidArg = -2,
Unknown = -1,
Broken = 0,
Advertised = 1,
Removed = 1,
Absent = 2,
Local = 3,
Source = 4,
Default = 5
}
public const int MaxFeatureLength = 38;
public const int MaxGuidLength = 38;
public const int MaxPathLength = 1024;
/*
INSTALLSTATE MsiGetComponentPath(
LPCTSTR szProduct,
LPCTSTR szComponent,
LPTSTR lpPathBuf,
DWORD* pcchBuf
);
*/
[DllImport("msi.dll", CharSet = CharSet.Auto)]
static extern InstallState MsiGetComponentPath(string productCode, string componentCode, StringBuilder componentPath, ref int componentPathBufferSize);
public static string ParseShortcut(string file)
{
StringBuilder product = new StringBuilder(MaxGuidLength + 1);
StringBuilder feature = new StringBuilder(MaxFeatureLength + 1);
StringBuilder component = new StringBuilder(MaxGuidLength + 1);
MsiGetShortcutTarget(file, product, feature, component);
int pathLength = MaxPathLength;
StringBuilder path = new StringBuilder(pathLength);
InstallState installState = MsiGetComponentPath(product.ToString(), component.ToString(), path, ref pathLength);
if (installState == InstallState.Local)
{
return path.ToString();
}
else
{
return null;
}
}
}
}

View File

@@ -1,10 +1,8 @@
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
{
@@ -50,10 +48,17 @@ namespace GeekDesk.Util
public static void Dispose(int id)
{
bool test = UnregisterHotKey(handleTemp[id].Handle, id);
GlobalHotKey.handleTemp[id].Dispose();
GlobalHotKey.handleTemp.Remove(id);
Console.WriteLine(test);
try
{
UnregisterHotKey(handleTemp[id].Handle, id);
GlobalHotKey.handleTemp[id].Dispose();
GlobalHotKey.handleTemp.Remove(id);
} catch
{
//nothing
}
}
// Registers a hot key with Windows.

View File

@@ -17,12 +17,12 @@ namespace GeekDesk.Util
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
//创建Web访问对 象
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
myRequest.ContentType = "text/plain; charset=gbk";
myRequest.ContentType = "text/plain; charset=utf-8";
//通过Web访问对象获取响应内容
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
//通过响应内容流创建StreamReader对象因为StreamReader更高级更快
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("gbk"));
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("utf-8"));
string returnStr = reader.ReadToEnd();//利用StreamReader就可以从响应内容从头读到尾
reader.Close();
myResponse.Close();

View File

@@ -4,6 +4,7 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
@@ -13,6 +14,7 @@ namespace GeekDesk.Util
{
class ImageUtil
{
private static readonly string SYSTEM_ITEM = "::{.*}";
/// <summary>
/// 图片数组转 BitmapImage
@@ -84,18 +86,37 @@ namespace GeekDesk.Util
/// <returns></returns>
public static BitmapImage GetBitmapIconByPath(string filePath)
{
if (File.Exists(filePath))
if (filePath.Contains("%windir%"))
{
if (IsImage(filePath)) {
filePath = filePath.Replace("%windir%", System.Environment.GetEnvironmentVariable("windir"));
}
if (File.Exists(filePath) || IsSystemItem(filePath))
{
if (IsImage(filePath))
{
//图片
return GetThumbnailByFile(filePath, 256, 256);
} else
}
else
{ //其它文件
return FileIcon.GetBitmapImage(filePath);
}
} else if(Directory.Exists(filePath)) {
//文件夹
return ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_DIR_IMAGE_BASE64);
}
else if (Directory.Exists(filePath))
{
if ((filePath.IndexOf("\\") == filePath.LastIndexOf("\\")) && filePath.IndexOf("\\") == filePath.Length - 1)
{
//磁盘
return ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_DISK_IMAGE_BASE64);
}
else
{
//文件夹
return ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_DIR_IMAGE_BASE64);
}
}
return null;
}
@@ -200,8 +221,9 @@ namespace GeekDesk.Util
return bm;
}
}
catch (Exception)
catch (Exception e)
{
LogUtil.WriteErrorLog(e, "获取文件缩略图失败!filePath=" + filePath);
return Base64ToBitmapImage(Constants.DEFAULT_IMG_IMAGE_BASE64);
}
@@ -300,8 +322,9 @@ namespace GeekDesk.Util
ms.Close();
return Convert.ToBase64String(arr);
}
catch (Exception)
catch (Exception e)
{
LogUtil.WriteErrorLog(e, "图片文件转base64失败!Imagefilename=" + Imagefilename + ",ImageFormat=" + format);
return null;
}
}
@@ -334,5 +357,15 @@ namespace GeekDesk.Util
}
/// <summary>
/// 判断是否为系统项
/// </summary>
/// <returns></returns>
public static bool IsSystemItem(string path)
{
return Regex.IsMatch(path, SYSTEM_ITEM);
}
}
}

76
Util/LogUtil.cs Normal file
View File

@@ -0,0 +1,76 @@
using GeekDesk.Constant;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Util
{
public class LogUtil
{
public static void WriteErrorLog(object exception, string msg = "")
{
try
{
Exception ex = exception as Exception;
using (FileStream fs = File.Open(Constants.ERROR_FILE_PATH, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
fs.Seek(0, SeekOrigin.End);
byte[] buffer = Encoding.Default.GetBytes("-------------------------------------------------------\r\n");
fs.Write(buffer, 0, buffer.Length);
buffer = Encoding.Default.GetBytes(DateTime.Now.ToString() + msg + "\r\n");
fs.Write(buffer, 0, buffer.Length);
if (ex != null)
{
buffer = Encoding.Default.GetBytes("成员名: " + ex.TargetSite + "\r\n");
fs.Write(buffer, 0, buffer.Length);
buffer = Encoding.Default.GetBytes("引发异常的类: " + ex.TargetSite.DeclaringType + "\r\n");
fs.Write(buffer, 0, buffer.Length);
buffer = Encoding.Default.GetBytes("异常信息: " + ex.Message + "\r\n");
fs.Write(buffer, 0, buffer.Length);
buffer = Encoding.Default.GetBytes("引发异常的程序集或对象: " + ex.Source + "\r\n");
fs.Write(buffer, 0, buffer.Length);
buffer = Encoding.Default.GetBytes("栈:" + ex.StackTrace + "\r\n");
fs.Write(buffer, 0, buffer.Length);
}
else
{
buffer = Encoding.Default.GetBytes("应用程序错误: " + exception.ToString() + "\r\n");
fs.Write(buffer, 0, buffer.Length);
}
}
} catch
{
}
}
public static void WriteLog(string msg)
{
try {
using (FileStream fs = File.Open(Constants.LOG_FILE_PATH, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
fs.Seek(0, SeekOrigin.End);
byte[] buffer = Encoding.Default.GetBytes("-------------------------------------------------------\r\n");
fs.Write(buffer, 0, buffer.Length);
buffer = Encoding.Default.GetBytes(DateTime.Now.ToString() + msg + "\r\n" );
fs.Write(buffer, 0, buffer.Length);
}
} catch { }
}
}
}

View File

@@ -1,43 +1,45 @@
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.Forms;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Media;
using GeekDesk.Constant;
namespace GeekDesk.Util
{
enum HidePosition
enum HideType
{
TOP = 1,
LEFT = 2,
RIGHT = 3
TOP_SHOW = 1,
LEFT_SHOW = 2,
RIGHT_SHOW = 3,
TOP_HIDE = 4,
LEFT_HIDE = 5,
RIGHT_HIDE = 6
}
public class MarginHide
{
readonly Window window;//定义使用该方法的窗体
private static Window window;//定义使用该方法的窗体
private readonly int hideTime = 80;
private static readonly int hideTime = 200;
private static readonly int fadeHideTime = 180;
private static readonly int fadeShowTime = 200;
private static readonly int taskTime = 250;
private readonly int taskTime = 200;
public static readonly int shadowWidth = 20;
private double showMarginWidth = 1;
private bool isHide;
private static double showMarginWidth = 1;
public Timer timer;
//构造函数,传入将要匹配的窗体
public MarginHide(Window window)
public static bool IS_HIDE = false;
private static Timer timer = null;
public static void ReadyHide(Window window)
{
this.window = window;
MarginHide.window = window;
}
@@ -45,7 +47,7 @@ namespace GeekDesk.Util
/// 窗体是否贴边
/// </summary>
/// <returns></returns>
public bool IsMargin()
public static bool IsMargin()
{
double screenLeft = SystemParameters.VirtualScreenLeft;
double screenTop = SystemParameters.VirtualScreenTop;
@@ -65,7 +67,7 @@ namespace GeekDesk.Util
#region
private void TimerDealy(object o, EventArgs e)
private static void HideWindow(object o, EventArgs e)
{
if (window.Visibility != Visibility.Visible) return;
@@ -85,47 +87,59 @@ namespace GeekDesk.Util
double mouseY = p.Y;
//鼠标不在窗口上
if (mouseX < windowLeft || mouseX > windowLeft + windowWidth
|| mouseY < windowTop || mouseY > windowTop + windowHeight)
if ((mouseX < windowLeft || mouseX > windowLeft + windowWidth
|| mouseY < windowTop || mouseY > windowTop + windowHeight) && !IS_HIDE)
{
//上方隐藏条件
if (windowTop <= screenTop)
{
HideAnimation(windowTop, screenTop - windowHeight + showMarginWidth, Window.TopProperty);
isHide = true;
IS_HIDE = true;
FadeAnimation(1, 0);
HideAnimation(windowTop, screenTop - windowHeight + showMarginWidth, Window.TopProperty, HideType.TOP_HIDE);
return;
}
//左侧隐藏条件
if (windowLeft <= screenLeft)
{
HideAnimation(windowLeft, screenLeft - windowWidth + showMarginWidth, Window.LeftProperty);
IS_HIDE = true;
FadeAnimation(1, 0);
HideAnimation(windowLeft, screenLeft - windowWidth + showMarginWidth, Window.LeftProperty, HideType.LEFT_HIDE);
return;
}
//右侧隐藏条件
if (windowLeft + windowWidth + Math.Abs(screenLeft) >= screenWidth)
{
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - showMarginWidth, Window.LeftProperty);
IS_HIDE = true;
FadeAnimation(1, 0);
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - showMarginWidth, Window.LeftProperty, HideType.RIGHT_HIDE);
return;
}
} else if (mouseX >= windowLeft && mouseX <= windowLeft + windowWidth
&& mouseY >= windowTop && mouseY <= windowTop + windowHeight)
}
else if (mouseX >= windowLeft && mouseX <= windowLeft + windowWidth
&& mouseY >= windowTop && mouseY <= windowTop + windowHeight && IS_HIDE)
{
//上方显示
if (windowTop <= screenTop - showMarginWidth)
{
HideAnimation(windowTop, screenTop, Window.TopProperty);
IS_HIDE = false;
HideAnimation(windowTop, screenTop, Window.TopProperty, HideType.TOP_SHOW);
FadeAnimation(0, 1);
return;
}
//左侧显示
if (windowLeft <= screenLeft - showMarginWidth)
{
HideAnimation(windowLeft, screenLeft, Window.LeftProperty);
IS_HIDE = false;
HideAnimation(windowLeft, screenLeft, Window.LeftProperty, HideType.LEFT_SHOW);
FadeAnimation(0, 1);
return;
}
//右侧显示
if (windowLeft + Math.Abs(screenLeft) == screenWidth - showMarginWidth)
{
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty);
IS_HIDE = false;
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty, HideType.RIGHT_SHOW);
FadeAnimation(0, 1);
return;
}
}
@@ -134,71 +148,153 @@ namespace GeekDesk.Util
#endregion
public void TimerSet()
public static void StartHide()
{
if (timer != null) return;
timer = new Timer();//添加timer计时器隐藏功能
#region
timer.Interval = taskTime;
timer.Tick += TimerDealy;
timer = new Timer
{
Interval = taskTime
};//添加timer计时器隐藏功能
timer.Tick += HideWindow;
timer.Start();
#endregion
}
public void TimerStop()
public static void StopHide()
{
if (timer == null) return;
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)
if (IS_HIDE)
{
HideAnimation(windowLeft, screenLeft, Window.LeftProperty);
return;
}
double screenLeft = SystemParameters.VirtualScreenLeft;
double screenTop = SystemParameters.VirtualScreenTop;
double screenWidth = SystemParameters.VirtualScreenWidth;
//上方显示
if (windowTop <= screenTop - showMarginWidth)
{
HideAnimation(windowTop, screenTop, Window.TopProperty);
return;
}
double windowWidth = window.Width;
//右侧显示
if (windowLeft + Math.Abs(screenLeft) == screenWidth - showMarginWidth)
{
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty);
return;
double windowTop = window.Top;
double windowLeft = window.Left;
//左侧显示
if (windowLeft <= screenLeft - showMarginWidth)
{
IS_HIDE = false;
FadeAnimation(0, 1);
HideAnimation(windowLeft, screenLeft, Window.LeftProperty, HideType.LEFT_SHOW);
return;
}
//上方显示
if (windowTop <= screenTop - showMarginWidth)
{
IS_HIDE = false;
FadeAnimation(0, 1);
HideAnimation(windowTop, screenTop, Window.TopProperty, HideType.TOP_SHOW);
return;
}
//右侧显示
if (windowLeft + Math.Abs(screenLeft) == screenWidth - showMarginWidth)
{
IS_HIDE = false;
FadeAnimation(0, 1);
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty, HideType.RIGHT_SHOW);
return;
}
}
}
private void HideAnimation(double from, double to, DependencyProperty property)
private static void HideAnimation(double from, double to, DependencyProperty property, HideType hideType)
{
double toTemp = to;
double leftT = window.Width / 4 * 3;
double topT = window.Height / 4 * 3;
switch (hideType)
{
case HideType.LEFT_HIDE:
to += leftT;
break;
case HideType.LEFT_SHOW:
to -= leftT;
break;
case HideType.RIGHT_HIDE:
to -= leftT;
break;
case HideType.RIGHT_SHOW:
to += leftT;
break;
case HideType.TOP_HIDE:
to += topT;
break;
case HideType.TOP_SHOW:
to -= topT;
break;
}
DoubleAnimation da = new DoubleAnimation
{
From = from,
To = to,
Duration = new Duration(TimeSpan.FromMilliseconds(hideTime))
};
// 如果是显示 则贴屏幕侧不显示阴影
bool isShow = false;
int shadowWidthTemp = Constants.SHADOW_WIDTH;
if (hideType <= HideType.RIGHT_SHOW)
{
isShow = true;
if (hideType == HideType.RIGHT_SHOW)
{
shadowWidthTemp = -shadowWidthTemp;
}
}
da.Completed += (s, e) =>
{
if ("Top".Equals(property.Name))
{
window.Top = isShow ? toTemp - shadowWidthTemp : toTemp;
}
else
{
window.Left = isShow ? toTemp - shadowWidthTemp : toTemp;
}
window.BeginAnimation(property, null);
};
Timeline.SetDesiredFrameRate(da, 60);
window.BeginAnimation(property, da);
}
private static void FadeAnimation(double from, double to)
{
double time;
if (to == 0D)
{
time = fadeHideTime;
}
else
{
time = fadeShowTime;
}
DoubleAnimation opacityAnimation = new DoubleAnimation
{
From = from,
To = to,
Duration = new Duration(TimeSpan.FromMilliseconds(time))
};
opacityAnimation.Completed += (s, e) =>
{
//window.Opacity = to;
window.BeginAnimation(Window.OpacityProperty, null);
};
Timeline.SetDesiredFrameRate(opacityAnimation, 60);
window.BeginAnimation(Window.OpacityProperty, opacityAnimation);
}
}
}

View File

@@ -50,6 +50,7 @@ namespace GeekDesk.Util
}
catch (Exception ex)
{
LogUtil.WriteErrorLog(ex, "设置开机/取消失败!started=" + started);
return false;
}
}
@@ -62,6 +63,7 @@ namespace GeekDesk.Util
}
catch (Exception ex)
{
LogUtil.WriteErrorLog(ex, "取消开机启动失败!started=" + started);
return false;
}
}
@@ -69,6 +71,7 @@ namespace GeekDesk.Util
}
catch (Exception ex)
{
LogUtil.WriteErrorLog(ex, "取消/开机/失败!started=" + started);
if (key != null)
{
key.Close();

View File

@@ -1509,7 +1509,9 @@ namespace GeekDesk.Util
m_hookType,
m_filterFunc,
IntPtr.Zero,
#pragma warning disable CS0618 // <20><>AppDomain.GetCurrentThreadId()<29><><EFBFBD>ѹ<EFBFBD>ʱ:<3A><>AppDomain.GetCurrentThreadId has been deprecated because it does not provide a stable Id when managed threads are running on fibers (aka lightweight threads). To get a stable identifier for a managed thread, use the ManagedThreadId property on Thread. http://go.microsoft.com/fwlink/?linkid=14202<30><32>
(int)AppDomain.GetCurrentThreadId());
#pragma warning restore CS0618 // <20><>AppDomain.GetCurrentThreadId()<29><><EFBFBD>ѹ<EFBFBD>ʱ:<3A><>AppDomain.GetCurrentThreadId has been deprecated because it does not provide a stable Id when managed threads are running on fibers (aka lightweight threads). To get a stable identifier for a managed thread, use the ManagedThreadId property on Thread. http://go.microsoft.com/fwlink/?linkid=14202<30><32>
}
// ************************************************************************

View File

@@ -1,4 +1,5 @@
using System;
using GeekDesk.Constant;
using System;
using System.Windows;
namespace GeekDesk.Util
@@ -27,7 +28,7 @@ namespace GeekDesk.Util
double left = SystemParameters.VirtualScreenLeft;
double top = SystemParameters.VirtualScreenTop;
double width = SystemParameters.VirtualScreenWidth;
double height = SystemParameters.VirtualScreenHeight;
double height = SystemParameters.WorkArea.Height;
double right = width - Math.Abs(left);
double bottom = height - Math.Abs(top);
@@ -73,12 +74,12 @@ namespace GeekDesk.Util
if (p.X - afterWidth < left)
{
//判断是否在最左边缘
window.Left = left;
window.Left = left - Constants.SHADOW_WIDTH;
}
else if (p.X + afterWidth > right)
{
//判断是否在最右边缘
window.Left = right - window.Width;
window.Left = right - window.Width + Constants.SHADOW_WIDTH;
}
else
{
@@ -89,12 +90,12 @@ namespace GeekDesk.Util
if (p.Y - afterHeight < top)
{
//判断是否在最上边缘
window.Top = top;
window.Top = top - Constants.SHADOW_WIDTH;
}
else if (p.Y + afterHeight > bottom)
{
//判断是否在最下边缘
window.Top = bottom - window.Height;
window.Top = bottom - window.Height + Constants.SHADOW_WIDTH;
}
else
{

View File

@@ -1,6 +1,7 @@

using GeekDesk.Constant;
using GeekDesk.Util;
using Newtonsoft.Json;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
@@ -66,7 +67,68 @@ namespace GeekDesk.ViewModel
private int imageWidth = (int)CommonEnum.IMAGE_WIDTH; //图片宽度
private int imageHeight = (int)CommonEnum.IMAGE_HEIGHT; //图片高度
private bool mouseMiddleShow = false; //鼠标中键呼出 默认不启用
private bool showBarIcon = true; //显示托盘图标 默认显示
private bool doubleOpen = false; //双击打开项目 默认关闭
private bool hoverMenu = false; //悬停切换菜单 默认关闭
#region GetSet
public bool HoverMenu
{
get
{
return hoverMenu;
}
set
{
hoverMenu = value;
OnPropertyChanged("HoverMenu");
}
}
public bool DoubleOpen
{
get
{
return doubleOpen;
}
set
{
doubleOpen = value;
OnPropertyChanged("DoubleOpen");
}
}
public bool ShowBarIcon
{
get
{
return showBarIcon;
}
set
{
showBarIcon = value;
OnPropertyChanged("ShowBarIcon");
}
}
public bool MouseMiddleShow
{
get
{
return mouseMiddleShow;
}
set
{
mouseMiddleShow = value;
OnPropertyChanged("MouseMiddleShow");
}
}
public int ImageWidth
{
get
@@ -75,7 +137,8 @@ namespace GeekDesk.ViewModel
if (imageWidth == 0)
{
return (int)CommonEnum.IMAGE_WIDTH;
} else
}
else
{
return imageWidth;
}
@@ -101,6 +164,10 @@ namespace GeekDesk.ViewModel
{
s -= i;
}
if (s < 2.2)
{
s = 2.2;
}
//设置容器宽度
ImgPanelWidth = (int)(ImageWidth * s);
@@ -138,6 +205,7 @@ namespace GeekDesk.ViewModel
{
s -= i;
}
if (s < 1.5) s = 1.5;
//设置容器高度
ImgPanelHeight = ImageHeight * s;
@@ -345,7 +413,8 @@ namespace GeekDesk.ViewModel
if (blurEffect)
{
BlurValue = 100;
} else
}
else
{
BlurValue = 0;
}
@@ -517,7 +586,8 @@ namespace GeekDesk.ViewModel
bacImgName = "系统默认";
//Image image = ImageUtil.ByteArrayToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
return ImageUtil.ByteArrToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
} else
}
else
{
return ImageUtil.ByteArrToImage(ImageByteArr);
}
@@ -672,5 +742,9 @@ namespace GeekDesk.ViewModel
#endregion
public override String ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}

View File

@@ -1,8 +1,11 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using Newtonsoft.Json;
using System;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows.Media.Imaging;
/// <summary>
@@ -22,10 +25,60 @@ namespace GeekDesk.ViewModel
private string content; //显示信息
private bool adminStartUp = false; //始终管理员方式启动 默认否
private byte[] defaultImage; //默认图标
private string startArg; //启动参数
private string lnkPath;
private IconType iconType = IconType.OTHER;
public string LnkPath_NoWrite
{
get
{
return lnkPath;
}
set
{
lnkPath = value;
}
}
public string LnkPath
{
get
{
return lnkPath;
}
set
{
lnkPath = value;
OnPropertyChanged("LnkPath");
}
}
public string StartArg
{
get
{
return startArg;
}
set
{
startArg = value;
OnPropertyChanged("StartArg");
}
}
public string StartArg_NoWrite
{
get
{
return startArg;
}
set
{
startArg = value;
}
}
public IconType IconType
{
get
@@ -53,6 +106,18 @@ namespace GeekDesk.ViewModel
}
}
public byte[] DefaultImage_NoWrite
{
get
{
return defaultImage;
}
set
{
defaultImage = value;
}
}
public bool AdminStartUp
{
get
@@ -75,7 +140,14 @@ namespace GeekDesk.ViewModel
set
{
count = value;
Content = Path + "\n" + Name + "\n使用次数: " + Count;
if (StringUtil.IsEmpty(Path))
{
Content = Name + "\n使用次数: " + Count;
}
else
{
Content = Path + "\n" + Name + "\n使用次数: " + Count;
}
OnPropertyChanged("Count");
}
}
@@ -89,11 +161,30 @@ namespace GeekDesk.ViewModel
set
{
name = value;
Content = Path + "\n" + Name + "\n使用次数: " + Count;
if (StringUtil.IsEmpty(Path))
{
Content = Name + "\n使用次数: " + Count;
}
else
{
Content = Path + "\n" + Name + "\n使用次数: " + Count;
}
OnPropertyChanged("Name");
}
}
public string Name_NoWrite
{
get
{
return name;
}
set
{
name = value;
}
}
public string Path
{
get
@@ -103,11 +194,31 @@ namespace GeekDesk.ViewModel
set
{
path = value;
Content = Path + "\n" + Name + "\n使用次数: " + Count;
if (StringUtil.IsEmpty(Path))
{
Content = Name + "\n使用次数: " + Count;
}
else
{
Content = Path + "\n" + Name + "\n使用次数: " + Count;
}
OnPropertyChanged("Path");
}
}
public string Path_NoWrite
{
get
{
return path;
}
set
{
path = value;
}
}
public BitmapImage BitmapImage
{
get
@@ -123,6 +234,20 @@ namespace GeekDesk.ViewModel
}
}
public BitmapImage BitmapImage_NoWrite
{
get
{
return ImageUtil.ByteArrToImage(ImageByteArr_NoWrite);
}
set
{
bitmapImage = value;
ImageByteArr_NoWrite = ImageUtil.BitmapImageToByte(bitmapImage);
}
}
public byte[] ImageByteArr
{
get
@@ -137,6 +262,19 @@ namespace GeekDesk.ViewModel
}
}
public byte[] ImageByteArr_NoWrite
{
get
{
return imageByteArr;
}
set
{
imageByteArr = value;
}
}
public string Content
{
get
@@ -151,9 +289,17 @@ namespace GeekDesk.ViewModel
}
public string Content_NoWrite
{
get
{
return content;
}
set
{
content = value;
}
}
[field: NonSerializedAttribute()]

View File

@@ -1,6 +1,8 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
@@ -17,11 +19,29 @@ namespace GeekDesk.ViewModel
private string menuId;
private Visibility menuEdit = Visibility.Collapsed;
private Visibility notMenuEdit = Visibility.Visible;
private bool isEdit = false;
private string menuGeometry; //菜单几何图标
private string geometryColor; //几何图标颜色
private ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
[field: NonSerializedAttribute()]
private static string[] NO_WRITE_ARR = new string[] { "IsEdit"};
public bool IsEdit
{
get
{
return isEdit;
}
set
{
isEdit = value;
OnPropertyChanged("IsEdit");
}
}
public string MenuGeometry
{
get
@@ -93,9 +113,12 @@ namespace GeekDesk.ViewModel
menuEdit = value;
if (menuEdit == Visibility.Visible)
{
IsEdit = true;
NotMenuEdit = Visibility.Collapsed;
} else
}
else
{
IsEdit = false;
NotMenuEdit = Visibility.Visible;
}
OnPropertyChanged("MenuEdit");
@@ -128,11 +151,23 @@ namespace GeekDesk.ViewModel
}
}
public override String ToString()
{
return JsonConvert.SerializeObject(this);
}
[field: NonSerializedAttribute()]
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
foreach (string field in NO_WRITE_ARR)
{
if (field.Equals(propertyName))
{
return;
}
}
CommonCode.SaveAppData(MainWindow.appData);
}
}

View File

@@ -0,0 +1,31 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
namespace GeekDesk.ViewModel.Temp
{
public class SearchIconList
{
private static ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
public static ObservableCollection<IconInfo> IconList
{
get
{
return iconList;
}
set
{
iconList = value;
OnPropertyChanged("IconList");
}
}
public static event PropertyChangedEventHandler PropertyChanged;
private static void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(null, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="2.0.6" targetFramework="net452" requireReinstallation="true" />
<package id="HandyControl" version="3.1.0" targetFramework="net472" />
<package id="HandyControl" version="3.3.0" targetFramework="net472" />
<package id="KeyMouseHook" version="1.0.6" targetFramework="net472" developmentDependency="true" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="2.1.1" targetFramework="net472" />
<package id="MouseKeyHook" version="5.6.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="NPinyin.Core" version="3.0.0" targetFramework="net472" />
<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" />