27 Commits

Author SHA1 Message Date
liufei
cbaeb71a0c 🧑‍💻 配置文件控制公众号显示 2022-06-17 10:20:36 +08:00
liufei
b8a6c9b91d 🚑 更新信息 2022-06-17 10:05:34 +08:00
liufei
001d807bb3 🐛 修复了某些路径无法建立相对路径导致程序启动崩溃的bug 2022-06-17 10:03:35 +08:00
liufei
240008ce2c :bug:修改提示 2022-06-15 17:40:43 +08:00
liufei
8f043ffd05 ♻️ 优化贴边隐藏的动画时间 2022-06-14 11:49:46 +08:00
liufei
6e58afcdea ♻️ 优化动画及部分样式 2022-06-14 10:37:24 +08:00
liufei
896dc26f11 🐛 修复路径可能为空导致创建相对路径报错的问题 2022-06-14 09:48:13 +08:00
liufei
d44cc90100 💥 2.5.10 2022-06-13 20:59:31 +08:00
liufei
da7588273e 🩹 修复关闭后仍有后台窗口, 优化主窗口动画 2022-06-13 20:35:48 +08:00
liufei
c7ef24a5b1 🚩 增加面板按钮点击运行时状态,此时不执行gotfocus 2022-06-11 17:25:09 +08:00
liufei
6b6372847c 🚩 增加列表加密功能 2022-06-11 17:15:56 +08:00
liufei
3995084776 🚩 增加相对路径功能 2022-06-08 15:52:48 +08:00
liufei
7d061abadc 🎉 增加了相对路径 2022-06-07 16:34:07 +08:00
liufei
9d174ed2fc 💩 优化一部分代码 2022-06-07 11:16:14 +08:00
liufei
444697b457 🚀 优化部分图标为小图标问题 2022-06-06 16:37:12 +08:00
liufei
2ecad2fea2 :bug:修复F1--F12快捷键不显示的问题 2022-06-03 23:53:03 +08:00
liufei
e46d64193b 🐛 修改了log文件夹 2022-06-03 23:42:45 +08:00
liufei
e42f2c3c73 🚑 增加了备份和自动备份功能 端午节快乐 🎉 2022-06-03 22:04:10 +08:00
liufei
0aa7969e4a 📱 🔍 优化搜索功能/优化动画 2022-06-02 17:37:22 +08:00
liufei
1a88194d26 🔖 2022-06-01 15:56:32 +08:00
liufei
b47dd0fbf7 增加可拖动到其它菜单功能 切换了icon动画 2022-06-01 15:55:33 +08:00
liufei
4c5c88769f 🐛 修复无法点击切换菜单的bug 2022-05-27 16:17:02 +08:00
liufei
c310fd441f 📝 更新信息 2022-05-27 15:23:27 +08:00
liufei
12ac544e42 📝 更新信息 2022-05-27 15:08:34 +08:00
liufei
f868eb77b6 2.4.16 补丁版本 2022-05-27 14:55:53 +08:00
liufei
f56991410b 🐛 修复无法修改菜单名称的问题 2022-05-27 11:19:54 +08:00
liufei
9cbbd6cf45 🐛 修复通过任务栏图标打开拾色器, 菜单消失问题 2022-05-27 10:48:34 +08:00
72 changed files with 3404 additions and 670 deletions

View File

@@ -19,13 +19,14 @@
<add key="Services" value="服务" />
</SystemIcons>
<SystemBGs>
<GradientBGParam Color1="#FCCF31" Color2="#F55555" Name="诸神黄昏"/>
<GradientBGParam Color1="#FCCF31" Color2="#F55555" Name="诸神黄昏" />
</SystemBGs>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib" />
<dependentAssembly>
<assemblyIdentity name="CommonServiceLocator" publicKeyToken="489b6accfaf20ef0" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.6.0" newVersion="2.0.6.0" />
@@ -46,17 +47,22 @@
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.1.0" newVersion="2.1.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<appSettings>
<add key="Version" value="2.4.15" />
<add key="Version" value="2.5.11" />
<add key="GitHubUrl" value="https://github.com/BookerLiu/GeekDesk" />
<add key="GiteeUrl" value="https://gitee.com/BookerLiu/GeekDesk/tree/master" />
<add key="GitHubUpdateUrl" value="https://raw.githubusercontent.com/BookerLiu/GeekDesk/master/Update.json" />
<add key="GiteeUpdateUrl" value="https://gitee.com/BookerLiu/GeekDesk/raw/master/Update.json" />
<!--<add key="GiteeUpdateUrl" value="file:///C:/Users/Fei/Desktop/GeekDesk/Update.json" />-->
<!--<add key="GiteeUpdateUrl" value="file:///D:/WorkSpace/workspace-VS/GeekDesk/Update.json" />-->
<add key="ClientSettingsProvider.ServiceUri" value="" />
<add key="CustomIconTeachUrl" value="https://mp.weixin.qq.com/s/LxoHAekho9HBVl4FRw_Law" />
<add key="CustomIconTeachUrl" value="https://mp.weixin.qq.com/s/LxoHAekho9HBVl4FRw_Law" />
<add key="ShowPublicWeChat" value="Y"/>
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">

View File

@@ -13,6 +13,8 @@
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
<ResourceDictionary Source="/GeekDesk;component/Resource/Dictionary/CommonStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/XamlFlair.WPF;component/DefaultAnimations.xaml"/>
<ResourceDictionary Source="/GeekDesk;component/Resource/Dictionary/XamlFlairSettings.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

View File

@@ -13,14 +13,22 @@ namespace GeekDesk.Constant
public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk";
/// <summary>
/// app数据文件路径
/// </summary>
public static string DATA_FILE_PATH = APP_DIR + "Data"; //app数据文件路径
public static string LOG_FILE_PATH = APP_DIR + "Log.log";
/// <summary>
/// 备份文件路径
/// </summary>
public static string DATA_FILE_BAK_PATH = APP_DIR + "bak\\Data.bak"; //app备份数据文件路径
public static string ERROR_FILE_PATH = APP_DIR + "Error.log";
public static string PW_FILE_BAK_PATH = APP_DIR + "bak\\pw.txt"; //密码文件路径
public static string LOG_FILE_PATH = APP_DIR + "logs\\log.log"; //日志文件
public static string ERROR_FILE_PATH = APP_DIR + "logs\\error.log"; // 错误日志
public static int SHADOW_WIDTH = 20;

16
Constant/PasswordType.cs Normal file
View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Constant
{
public enum PasswordType
{
INPUT = 0, //键入密码
CREATE = 1, //新建密码
ALTER = 2, //修改密码
CANCEL = 3, //取消密码
}
}

View File

@@ -20,7 +20,25 @@
public static bool LOCK_APP_PANEL = false;
/// <summary>
/// 是否弹出了菜单密码框
/// </summary>
public static bool SHOW_MENU_PASSWORDBOX = false;
/// <summary>
/// 是否弹出了右键菜单
/// </summary>
public static bool SHOW_RIGHT_BTN_MENU = false;
/// <summary>
/// 是否点击了面板功能按钮
/// </summary>
public static bool APP_BTN_IS_DOWN = false;
/// <summary>
/// 是否正在编辑菜单
/// </summary>
public static bool IS_MENU_EDIT = false;
}
}

View File

@@ -62,7 +62,7 @@ namespace GeekDesk.Control.Other
}
ToDoTask.activityBacklog[info].Close(); //关闭桌面通知
ToDoTask.activityBacklog.Remove(info);//激活任务删除
CommonCode.SaveAppData(appData);
CommonCode.SaveAppData(appData, Constants.DATA_FILE_PATH);
}

View File

@@ -0,0 +1,54 @@
<Border x:Class="GeekDesk.Control.Other.GlobalMsgNotification"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
BorderThickness="0"
Style="{StaticResource BorderBG}"
Margin="15"
BorderBrush="{DynamicResource BorderBrush}"
Width="320"
Height="400">
<Border.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0.96"/>
</Border.Background>
<Grid>
<StackPanel>
<Image Source="/Resource/Image/BacklogImg.png" Width="260" Margin="0,20,0,0"/>
<hc:Card Width="260" Height="220" BorderThickness="0" Effect="{DynamicResource EffectShadow2}" Margin="0,20,0,0">
<Border CornerRadius="4,4,0,0" Height="160" Padding="10,0,10,0">
<ScrollViewer>
<TextBlock TextOptions.TextFormattingMode="Display"
TextOptions.TextHintingMode="Animated"
UseLayoutRounding="True"
TextWrapping="Wrap"
FontStyle="Normal"
FontSize="15"
LineHeight="22"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Text="{Binding Msg}"/>
</ScrollViewer>
</Border>
<!--<hc:Card.Footer>
<StackPanel Margin="10" Width="160">
<TextBlock TextWrapping="NoWrap" FontSize="20" Style="{DynamicResource TextBlockLargeBold}" TextTrimming="CharacterEllipsis"
Text="{Binding Title}"
HorizontalAlignment="Left"/>
<TextBlock TextWrapping="NoWrap" Style="{DynamicResource TextBlockDefault}" TextTrimming="CharacterEllipsis"
Margin="0,6,0,0"
HorizontalAlignment="Left"/>
</StackPanel>
</hc:Card.Footer>-->
</hc:Card>
</StackPanel>
<Button Click="Close_Click" Content="朕已阅" Margin="10,0,10,20" Width="298" VerticalAlignment="Bottom"/>
</Grid>
</Border>

View File

@@ -0,0 +1,61 @@
using GeekDesk.Constant;
using GeekDesk.Task;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using Quartz;
using System;
using System.Windows;
using System.Windows.Input;
namespace GeekDesk.Control.Other
{
/// <summary>
/// BacklogNotificatin.xaml 的交互逻辑
/// </summary>
public partial class GlobalMsgNotification
{
public Notification ntf;
public GlobalMsgNotification(DialogMsg msg)
{
InitializeComponent();
this.DataContext = msg;
}
public class DialogMsg
{
public string msg;
public string title;
public string Msg
{
get
{
return msg;
}
set
{
msg = value;
}
}
public string Title
{
get
{
return title;
}
set
{
title = value;
}
}
}
private void Close_Click(object sender, RoutedEventArgs e)
{
ntf.Close();
}
}
}

View File

@@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
CornerRadius="4"
Width="350"
Height="450"
@@ -10,29 +11,39 @@
<Border.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<Setter Property="Width" Value="75"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="TextAlignment" Value="Left"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,8,0,0"/>
<Setter Property="Margin" Value="5,8,0,0"/>
<Setter Property="FontSize" Value="14"/>
</Style>
<cvt:StringAppendConvert x:Key="StringAppendConvert"/>
</Border.Resources>
<hc:SimplePanel Margin="10" VerticalAlignment="Center">
<StackPanel>
<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<hc:UniformSpacingPanel Spacing="10">
<hc:UniformSpacingPanel Spacing="10" Margin="0,15,0,0">
<TextBlock Text="名称:" Style="{StaticResource LeftTB}"/>
<TextBox x:Name="IconName" Text="{Binding Name, Mode=OneWay}" Width="230" FontSize="14"/>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black"/>
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<hc:UniformSpacingPanel Spacing="10" Margin="0,15,0,0">
<TextBlock Text="相对路径:" Style="{StaticResource LeftTB}"/>
<TextBlock Text="{Binding RelativePath, Mode=OneWay}"
VerticalAlignment="Center"
Margin="0,8,0,0"
Width="230"
FontSize="14"
TextTrimming="WordEllipsis"
hc:Poptip.Placement="Bottom"
hc:Poptip.Content="{Binding RelativePath, Mode=OneWay, Converter={StaticResource StringAppendConvert}, ConverterParameter='\{\}\\\n(同盘符下才会建立相对路径)'}"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,15,0,0">
<TextBlock Text="图标:" Style="{StaticResource LeftTB}"/>
<Image x:Name="IconImg" Source="{Binding BitmapImage, Mode=OneWay}" RenderOptions.BitmapScalingMode="HighQuality" Width="60" Height="60"/>
<Button Content="修改" Click="EditImage"/>
<Button Content="重置" Click="ReStoreImage"/>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10">
<hc:UniformSpacingPanel Spacing="10" Margin="4,15,0,0">
<CheckBox x:Name="IconIsAdmin" Content="始终以管理员方式启动" IsChecked="{Binding AdminStartUp, Mode=OneWay}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
@@ -41,12 +52,11 @@
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10">
<hc:UniformSpacingPanel Spacing="10" Margin="0,15,0,0">
<TextBlock Text="启动参数:" Style="{StaticResource LeftTB}"/>
<TextBox x:Name="StartArg" Text="{Binding StartArg, Mode=OneWay}" Width="230" Height="100" TextWrapping="Wrap" FontSize="14"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<hc:UniformSpacingPanel Margin="0,25,0,0" Spacing="10" Grid.ColumnSpan="4">
<Button Content="保存" Style="{StaticResource Btn1}" Click="SaveProperty" Margin="265,10,0,0"/>
</hc:UniformSpacingPanel>
</StackPanel>

View File

@@ -1,4 +1,5 @@
using GeekDesk.Util;
using GeekDesk.Constant;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
@@ -38,7 +39,7 @@ namespace GeekDesk.Control.Other
info.Name = IconName.Text;
info.AdminStartUp = IconIsAdmin.IsChecked.Value;
info.StartArg = StartArg.Text;
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
dialog.Close();
}
@@ -51,7 +52,7 @@ namespace GeekDesk.Control.Other
{
IconInfo info = this.DataContext as IconInfo;
info.BitmapImage = ImageUtil.ByteArrToImage(info.DefaultImage);
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
/// <summary>
@@ -72,7 +73,7 @@ namespace GeekDesk.Control.Other
{
IconInfo info = this.DataContext as IconInfo;
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
}
catch (Exception e1)

View File

@@ -52,7 +52,7 @@ namespace GeekDesk.Control.Other
{
MainWindow.appData.MenuList[MainWindow.appData.AppConfig.SelectedMenuIndex].IconList.Add(info);
}
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
dialog.Close();
}
@@ -65,7 +65,7 @@ namespace GeekDesk.Control.Other
{
IconInfo info = this.DataContext as IconInfo;
info.BitmapImage = ImageUtil.ByteArrToImage(info.DefaultImage);
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
/// <summary>
@@ -86,7 +86,7 @@ namespace GeekDesk.Control.Other
{
IconInfo info = this.DataContext as IconInfo;
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
}
catch (Exception ex)

View File

@@ -0,0 +1,75 @@
<Border x:Class="GeekDesk.Control.Other.PasswordDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
CornerRadius="6"
Width="300"
Height="150"
BorderThickness="0"
>
<Border.Resources>
<Style x:Key="PassBox" TargetType="PasswordBox" BasedOn="{StaticResource PasswordBoxBaseStyle}">
<Setter Property="Height" Value="40"/>
<Setter Property="Width" Value="40"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Focusable" Value="True"/>
<Setter Property="MaxLength" Value="1"/>
<EventSetter Event="PasswordChanged" Handler="PasswordBox_PasswordChanged"/>
<EventSetter Event="PreviewKeyDown" Handler="PasswordBox_KeyDown"/>
</Style>
<Style x:Key="NextTB" TargetType="TextBlock">
<Setter Property="Foreground" Value="#408CCB"/>
<Setter Property="TextDecorations" Value="Underline"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</Border.Resources>
<Border.Background>
<SolidColorBrush Color="White" Opacity="0.7"/>
</Border.Background>
<StackPanel VerticalAlignment="Center">
<hc:UniformSpacingPanel Spacing="10" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock x:Name="Title" Text="请输入密码"
FontSize="15"/>
</hc:UniformSpacingPanel>
<Grid Height="65" x:Name="PasswordGrid" Visibility="Visible" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndGrowHorizontally}, Event=Visibility}">
<TextBlock x:Name="HintMsg"
Visibility="Hidden"
VerticalAlignment="Top"
HorizontalAlignment="Center"
Width="250"
TextAlignment="Center"
Margin="0,3,0,0"
Text="提示:"
hc:Poptip.Content="{Binding ElementName=HintMsg, Path=Text}"
Foreground="Gray"/>
<hc:UniformSpacingPanel Margin="0,20,0,0" Spacing="10" VerticalAlignment="Center" HorizontalAlignment="Center">
<PasswordBox x:Name="P1" Tag="P1" Style="{StaticResource PassBox}"/>
<PasswordBox x:Name="P2" Tag="P2" Style="{StaticResource PassBox}"/>
<PasswordBox x:Name="P3" Tag="P3" Style="{StaticResource PassBox}"/>
<PasswordBox x:Name="P4" Tag="P4" Style="{StaticResource PassBox}"/>
</hc:UniformSpacingPanel>
<TextBlock HorizontalAlignment="Right"
x:Name="ErrorMsg"
Margin="0,65,37,-65"
Foreground="Red"
Text="密码输入错误"
Visibility="Visible"/>
</Grid>
<Grid Height="65" x:Name="HintGrid" Visibility="Collapsed" Margin="0,20,0,0" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, Event=Visibility}">
<hc:UniformSpacingPanel Spacing="10" VerticalAlignment="Top" HorizontalAlignment="Center">
<hc:TextBox x:Name="HintBox" TextAlignment="Left" Width="220"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="202,35,0,0" VerticalAlignment="Top" HorizontalAlignment="Left">
<TextBlock Text="跳过" MouseLeftButtonDown="NextTB_MouseLeftButtonDown" Style="{StaticResource NextTB}"/>
<TextBlock Text="完成" MouseLeftButtonDown="DoneTB_MouseLeftButtonDown" Style="{StaticResource NextTB}"/>
</hc:UniformSpacingPanel>
</Grid>
</StackPanel>
</Border>

View File

@@ -0,0 +1,280 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
namespace GeekDesk.Control.Other
{
/// <summary>
/// TextDialog.xaml 的交互逻辑
/// </summary>
public partial class PasswordDialog
{
private AppData appData = MainWindow.appData;
public PasswordType type;
public MenuInfo menuInfo;
public int count = 0;
private string tempPassword = null;
private PasswordType tempType;
public PasswordDialog()
{
InitializeComponent();
}
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
{
PasswordBox pb = sender as PasswordBox;
if (!string.IsNullOrEmpty(pb.Password))
{
char c = pb.Password.ToCharArray()[0];
if (c > '9' || c < '0')
{
pb.Password = "";
return;
}
}
string tag = pb.Tag.ToString();
switch (tag)
{
case "P1":
if (!string.IsNullOrEmpty(pb.Password))
{
P2.Focus();
}
break;
case "P2":
if (!string.IsNullOrEmpty(pb.Password))
{
P3.Focus();
}
break;
case "P3":
if (!string.IsNullOrEmpty(pb.Password))
{
P4.Focus();
}
break;
case "P4":
if (string.IsNullOrEmpty(pb.Password))
{
P3.Focus();
}
break;
}
if (!string.IsNullOrEmpty(P1.Password)
&& !string.IsNullOrEmpty(P2.Password)
&& !string.IsNullOrEmpty(P3.Password)
&& !string.IsNullOrEmpty(P4.Password))
{
string pw = P1.Password
+ P2.Password
+ P3.Password
+ P4.Password;
pw = MD5Util.CreateMD5(pw);
if (type == PasswordType.INPUT || type == PasswordType.CANCEL)
{
if (pw.Equals(appData.AppConfig.MenuPassword))
{
//隐藏弹框
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Collapsed;
//赋值
MainWindow.appData.AppConfig.SelectedMenuIcons
= appData.MenuList[
MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex
].IconList;
//显示数据托盘
MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Visible;
//取消加密操作
if (type == PasswordType.CANCEL)
{
menuInfo.IsEncrypt = false;
}
} else
{
//密码比对不一致
ErrorMsg.Text = "密码输入错误";
ErrorMsg.Visibility = Visibility.Visible;
if (!string.IsNullOrEmpty(appData.AppConfig.PasswordHint))
{
//显示提示信息
HintMsg.Visibility = Visibility.Visible;
}
}
} else if (type == PasswordType.CREATE)
{
//创建密码
if (count == 0)
{
count++;
tempPassword = pw;
Title.Text = "再次输入密码";
ClearVal();
SetFocus(0);
} else
{
if (tempPassword.Equals(pw))
{
//两次密码设置一致 显示提示输入框
Title.Text = "填写密码提示";
PasswordGrid.Visibility = Visibility.Collapsed;
HintGrid.Visibility = Visibility.Visible;
HintBox.Focus();
} else
{
ErrorMsg.Text = "两次密码输入不一致";
ErrorMsg.Visibility = Visibility.Visible;
}
}
} else if (type == PasswordType.ALTER)
{
//修改密码
if (appData.AppConfig.MenuPassword.Equals(pw))
{
tempType = type;
type = PasswordType.CREATE;
Title.Text = "设置新密码";
ClearVal();
SetFocus(0);
} else
{
//密码比对不一致
ErrorMsg.Text = "密码输入错误";
ErrorMsg.Visibility = Visibility.Visible;
HintMsg.Text = MainWindow.appData.AppConfig.PasswordHint;
HintMsg.Visibility = Visibility.Visible;
}
}
} else
{
//密码未输入完全 隐藏错误信息
if (ErrorMsg.IsVisible)
{
ErrorMsg.Visibility = Visibility.Hidden;
HintMsg.Visibility = Visibility.Hidden;
HintMsg.Visibility = Visibility.Hidden;
}
}
}
public void SetFocus(int time = 100)
{
new Thread(() =>
{
Thread.Sleep(time);
Dispatcher.Invoke(() =>
{
if (string.IsNullOrEmpty(P1.Password))
{
P1.Focus();
return;
}
if (string.IsNullOrEmpty(P2.Password))
{
P2.Focus();
return;
}
if (string.IsNullOrEmpty(P3.Password))
{
P3.Focus();
return;
}
P4.Focus();
});
}).Start();
}
public void ClearVal()
{
P1.Clear();
P2.Clear();
P3.Clear();
P4.Clear();
}
/// <summary>
/// 跳过设置密码提示
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void NextTB_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
appData.AppConfig.PasswordHint = "";
DonePassword();
}
private void DoneTB_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
string hint = HintBox.Text.Trim();
appData.AppConfig.PasswordHint = hint;
DonePassword();
}
private void DonePassword()
{
appData.AppConfig.MenuPassword = tempPassword;
CommonCode.SavePassword(tempPassword);
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Collapsed;
PasswordGrid.Visibility = Visibility.Visible;
HintGrid.Visibility = Visibility.Collapsed;
if (tempType == PasswordType.ALTER)
{
HandyControl.Controls.Growl.Success("密码修改成功!", "MainWindowGrowl");
} else
{
menuInfo.IsEncrypt = true;
HandyControl.Controls.Growl.Success(menuInfo.MenuName + " 已加密!", "MainWindowGrowl");
}
}
private void PasswordBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Back)
{
if (P2.IsKeyboardFocused)
{
if (string.IsNullOrEmpty(P2.Password))
{
P1.Password = "";
} else
{
P2.Password = "";
}
}
if (P3.IsKeyboardFocused)
{
if (string.IsNullOrEmpty(P3.Password))
{
P2.Password = "";
}
else
{
P3.Password = "";
}
}
if (P4.IsKeyboardFocused)
{
if (string.IsNullOrEmpty(P4.Password))
{
P3.Password = "";
}
else
{
P4.Password = "";
}
}
}
SetFocus(0);
}
}
}

View File

@@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
@@ -16,7 +17,11 @@
<Grid MouseDown="DragMove">
<hc:SimplePanel Margin="20,50,20,20" >
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="/Resource/Image/About.png" Width="400" Height="100"/>
<Image Source="/Resource/Image/About.png"
Width="400"
Height="100"
xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndContract}, Delay=250}"
/>
<TextBlock x:Name="AppInfo" TextAlignment="Center" Text="Copyright © 2021 GeekDesk V"/>
<hc:UniformSpacingPanel Spacing="5" HorizontalAlignment="Center" Margin="10,10,0,0" VerticalAlignment="Center">
<hc:Shield Subject=".net" Status=">=4.72" Margin="0,0,10,0" Color="#1182c3"/>
@@ -27,18 +32,21 @@
MouseLeave="SC_MouseLeave"
Command="hc:ControlCommands.OpenLink"
CommandParameter="https://github.com/BookerLiu/GeekDesk"
Margin="0,0,10,0" Color="#24292F"/>
Margin="0,0,10,0" Color="#24292F"
/>
<hc:Shield Subject="Gitee" Visibility="Visible" Status="Star"
MouseEnter="SC_MouseEnter"
MouseLeave="SC_MouseLeave"
Command="hc:ControlCommands.OpenLink"
CommandParameter="https://gitee.com/BookerLiu/GeekDesk"
Margin="0,0,10,0" Color="#C71D23"/>
Margin="0,0,10,0" Color="#C71D23"
/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" HorizontalAlignment="Center" Margin="0,5,0,0">
<hc:Shield Subject="公众号" Visibility="Visible" Status="抓几个娃" Margin="0,0,5,0" Color="#04913B">
<hc:Shield x:Name="PublicWeChatPanel" Subject="公众号" Visibility="Visible" Status="抓几个娃" Margin="0,0,5,0" Color="#04913B">
<hc:Poptip.Instance>
<hc:Poptip PlacementType="Top">
<hc:Poptip.Content>

View File

@@ -16,6 +16,15 @@ namespace GeekDesk.Control.UserControls.Config
{
InitializeComponent();
AppInfo.Text += ConfigurationManager.AppSettings["Version"];
string showPublicWeChat = ConfigurationManager.AppSettings["ShowPublicWeChat"];
if ("Y".Equals(showPublicWeChat))
{
PublicWeChatPanel.Visibility = Visibility.Visible;
} else
{
PublicWeChatPanel.Visibility = Visibility.Collapsed;
}
PublicWeChat.Source = ImageUtil.Base64ToBitmapImage(Constants.PUBLIC_WE_CHAT_IMG_BASE64);
WeChatCode.Source = ImageUtil.Base64ToBitmapImage(Constants.WE_CHAT_CODE_IMG_BASE64);
ZFBCode.Source = ImageUtil.Base64ToBitmapImage(Constants.ZFB_CODE_IMG_BASE64);

View File

@@ -84,15 +84,7 @@
</CheckBox>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<CheckBox Content="主窗口动画效果" IsChecked="{Binding AppAnimation}" Click="Animation_Checked">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<TextBlock Text="面板关闭方式" VerticalAlignment="Center"/>

View File

@@ -35,8 +35,6 @@ namespace GeekDesk.Control.UserControls.Config
/// <param name="e"></param>
private void HotKeyDown(object sender, KeyEventArgs e)
{
Console.WriteLine("downKey:" + e.Key.ToString());
lock (this)
{
HotKeyType hkType = (HotKeyType)(sender as TextBox).Tag;
@@ -49,8 +47,6 @@ namespace GeekDesk.Control.UserControls.Config
if (!CheckIsEnable(hkType)) return;
Console.WriteLine("prevKeyTemp:" + prevKeyTemp.ToString());
if (prevKeyTemp == Key.None || prevKeyTemp != downKey)
{
@@ -101,7 +97,6 @@ namespace GeekDesk.Control.UserControls.Config
appConfig.ColorPickerHotkeyModifiers = GetModifierKeys(downKey);
break;
}
Console.WriteLine("进入设置" + downKey.ToString());
prevKeyTemp = downKey;
keysTemp.Add(e);
}
@@ -119,7 +114,10 @@ namespace GeekDesk.Control.UserControls.Config
KeyUtil.KeyProp keyProp = new KeyUtil.KeyProp();
KeyUtil.KeyToChar(downKey, ref keyProp, true);
string downKeyStr = keyProp.character.ToString();
//string downKeyStr = "";
if (keyProp.character == '\x00')
{
downKeyStr = downKey.ToString();
}
switch (hkType)
{
case HotKeyType.Main:
@@ -308,15 +306,6 @@ namespace GeekDesk.Control.UserControls.Config
}
}
private void Animation_Checked(object sender, RoutedEventArgs e)
{
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed)
{
MainWindow.mainWindow.Visibility = Visibility.Visible;
// 执行一下动画 防止太过突兀
MainWindow.FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
}
}
/// <summary>

View File

@@ -93,6 +93,16 @@
Foreground="Black"
IsChecked="{Binding UpdateType, Mode=TwoWay, Converter={StaticResource UpdateTypeConvert}, ConverterParameter=2}"/>
</hc:UniformSpacingPanel>
<TextBlock Text="其它" Margin="0,25,0,0"/>
<hc:UniformSpacingPanel Spacing="10" Margin="20,8,0,0">
<Button Content="备份数据"
hc:Poptip.Content="当数据文件损坏时, 以便能够恢复部分数据 (损坏时将有操作提示)"
hc:Poptip.Placement="TopLeft"
hc:Poptip.Offset="10"
Style="{StaticResource Btn1}"
Click="BakDataFile"/>
</hc:UniformSpacingPanel>
</StackPanel>
</hc:SimplePanel>
</Grid>

View File

@@ -107,5 +107,10 @@ namespace GeekDesk.Control.UserControls.Config
CountLowSort.Visibility = Visibility.Visible;
}
}
private void BakDataFile(object sender, RoutedEventArgs e)
{
CommonCode.BakAppData();
}
}
}

View File

@@ -110,7 +110,25 @@
<hc:Divider LineStrokeDashArray="3,3" Margin="0,0,0,0" Height="20" LineStroke="Black" Grid.ColumnSpan="1"/>
<hc:UniformSpacingPanel Spacing="10" Margin="5,-10,0,0" Grid.ColumnSpan="4">
<hc:UniformSpacingPanel Spacing="10" Margin="5,-10,0,0" Grid.ColumnSpan="4">
<CheckBox Content="主窗口动画" IsChecked="{Binding AppAnimation}" Click="Animation_Checked">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="5,10,0,0" Grid.ColumnSpan="4">
<CheckBox Content="列表展开动画" IsChecked="{Binding ItemSpradeAnimation}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="5,10,0,0" Grid.ColumnSpan="4">
<CheckBox x:Name="BarIcon" Content="显示托盘图标" IsChecked="{Binding ShowBarIcon}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
@@ -120,7 +138,7 @@
</CheckBox>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="5,5,0,0" Grid.ColumnSpan="4">
<hc:UniformSpacingPanel Spacing="10" Margin="5,10,0,0" Grid.ColumnSpan="4">
<CheckBox Content="显示主面板Logo" IsChecked="{Binding TitleLogoVisible, Mode=TwoWay, Converter={StaticResource Visibility2BooleanConverter}}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
@@ -149,7 +167,7 @@
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<TextBlock Text="背景图片不透明度" VerticalAlignment="Center"/>
<TextBlock Text="背景不透明度" VerticalAlignment="Center"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<hc:PreviewSlider Value="{Binding BgOpacity}"
@@ -164,7 +182,7 @@
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<!--<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<TextBlock Text="主面板不透明度" VerticalAlignment="Center"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
@@ -177,7 +195,7 @@
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
</hc:PreviewSlider.PreviewContent>
</hc:PreviewSlider>
</hc:UniformSpacingPanel>
</hc:UniformSpacingPanel>-->
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<TextBlock Text="主面板圆角大小" VerticalAlignment="Center"/>

View File

@@ -157,5 +157,16 @@ namespace GeekDesk.Control.UserControls.Config
GradientBGDialog gbg = new GradientBGDialog();
gbg.dialog = HandyControl.Controls.Dialog.Show(gbg, "ConfigWindowDialog");
}
private void Animation_Checked(object sender, RoutedEventArgs e)
{
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed)
{
appConfig.IsShow = true;
}
appConfig.IsShow = null;
}
}
}

View File

@@ -6,6 +6,7 @@
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:cst="clr-namespace:GeekDesk.Constant"
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
@@ -18,11 +19,18 @@
<Setter Property="Margin" Value="0,0,0,1"/>
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Opacity="0"/>
<SolidColorBrush Color="Black" Opacity="0.01"/>
</Setter.Value>
</Setter>
<Setter Property="AllowDrop" Value="True"/>
<EventSetter Event="Drop" Handler="Menu_Drop"/>
<EventSetter Event="PreviewDragEnter" Handler="Menu_PreviewDragEnter"/>
<EventSetter Event="PreviewDragLeave" Handler="Menu_PreviewDragLeave"/>
<EventSetter Event="MouseLeave" Handler="Menu_MouseLeave"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<EventSetter Event="MouseEnter" Handler="Menu_MouseEnter"/>
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListBoxItem_MouseDown"/>
<EventSetter Event="PreviewMouseRightButtonDown" Handler="ListBoxItem_PreviewMouseRightButtonDown"/>
<!--<EventSetter Event="Unselected" Handler="Lbi_Unselected"/>-->
<Style.Triggers>
<MultiTrigger>
@@ -45,7 +53,11 @@
</BeginStoryboard>
</MultiTrigger.ExitActions>
<MultiTrigger.Setters>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="Black" Opacity="0.01"/>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="Black"/>
</MultiTrigger.Setters>
</MultiTrigger>
@@ -66,110 +78,149 @@
<Setter Property="Foreground" Value="Black"/>
</Trigger>-->
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Background" Value="#00FFFFFF"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="MyPoptipStyle" TargetType="Border">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
<Setter Property="Padding" Value="{StaticResource DefaultControlPadding}"/>
<!--<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="hc:Poptip">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}">
<ContentPresenter Margin="{TemplateBinding Padding}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>-->
</Style>
<cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
<cvt:OpcityConvert x:Key="OpcityConvert"/>
<cvt:StringAppendConvert x:Key="StringAppendConvert"/>
</UserControl.Resources>
<!--左侧栏-->
<hc:Card x:Name="MyCard"
BorderThickness="1"
Effect="{DynamicResource EffectShadow2}"
Margin="5,0,0,5"
MouseDown="MyCard_MouseDown"
>
<hc:Card.Background>
<SolidColorBrush Color="#FFFFFFFF" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
<Grid Background="Transparent">
<Popup Name="MyPoptip" FlowDirection="LeftToRight"
PopupAnimation="None" Placement="Mouse" IsOpen="False"
AllowsTransparency="True"
>
<Grid Background="Transparent">
<Border Style="{StaticResource MyPoptipStyle}">
<TextBlock Name="MyPoptipContent" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" Text="Test" FontSize="14"/>
</Border>
</Grid>
</Popup>
</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"
PreviewMouseWheel="Menu_MouseWheel"
>
<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>
<!--左侧栏-->
<hc:Card x:Name="MyCard"
BorderThickness="1"
Effect="{DynamicResource EffectShadow2}"
Margin="5,0,0,5"
MouseDown="MyCard_MouseDown"
PreviewMouseRightButtonDown="MyCard_PreviewMouseRightButtonDown"
>
<hc:Card.Background>
<SolidColorBrush Color="#FFFFFFFF" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
<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>
</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"/>
<MenuItem x:Name="AlterPW1" Header="修改密码" Click="AlterPassword"/>
</ContextMenu>
</hc:Card.ContextMenu>
<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>
<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"
PreviewMouseWheel="Menu_MouseWheel"
PreviewMouseRightButtonDown="MyCard_PreviewMouseRightButtonDown"
>
<ListBox.Resources>
<ContextMenu x:Key="MenuDialog" Width="200">
<MenuItem Header="新建菜单" Click="CreateMenu"/>
<MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
<MenuItem Header="加密此列表" Click="EncryptMenu" Tag="{Binding}"/>
<MenuItem x:Name="AlterPW2" Header="修改密码" Click="AlterPassword"/>
<MenuItem Header="修改图标" Click="EditMenuGeometry" Tag="{Binding}"/>
<MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
</ContextMenu>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Tag="{Binding}" MouseDown="ListBoxItem_MouseDown">
<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"
<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>
<DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="33" ItemsWidth="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}, ConverterParameter=10}" HorizontalAlignment="Center" VerticalAlignment="Top" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel 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"
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}"
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"
/>
</StackPanel>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</hc:Card>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</hc:Card>
</Grid>
</UserControl>

View File

@@ -1,5 +1,6 @@
using DraggAnimatedPanelExample;
using GeekDesk.Constant;
using GeekDesk.Control.Other;
using GeekDesk.Control.Windows;
using GeekDesk.Util;
using GeekDesk.ViewModel;
@@ -24,9 +25,6 @@ namespace GeekDesk.Control.UserControls.PannelCard
private SolidColorBrush bac = new SolidColorBrush(Color.FromRgb(236, 236, 236));
//是否正在修改菜单
private static bool IS_EDIT = false;
public LeftCardControl()
{
InitializeComponent();
@@ -205,9 +203,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
/// <param name="e"></param>
private void RenameMenu(object sender, RoutedEventArgs e)
{
RunTimeStatus.IS_MENU_EDIT = true;
MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
menuInfo.MenuEdit = (int)Visibility.Visible;
IS_EDIT = true;
}
/// <summary>
@@ -275,7 +273,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
menuInfo.MenuName = text;
menuInfo.MenuEdit = Visibility.Collapsed;
}
IS_EDIT = false;
RunTimeStatus.IS_MENU_EDIT = false;
//为了解决无法修改菜单的问题
MainWindow.mainWindow.SearchBox.Focus();
MenuListBox.SelectedIndex = menuSelectIndexTemp;
}
}
@@ -309,6 +309,14 @@ namespace GeekDesk.Control.UserControls.PannelCard
private void Menu_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (RunTimeStatus.IS_MENU_EDIT) return;
if (appData.AppConfig.ItemSpradeAnimation)
{
//是否启用列表展开动画
MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Collapsed;
}
//设置对应菜单的图标列表
if (MenuListBox.SelectedIndex == -1)
{
@@ -316,8 +324,20 @@ namespace GeekDesk.Control.UserControls.PannelCard
}
else
{
appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList;
if (appData.MenuList[MenuListBox.SelectedIndex].IsEncrypt)
{
appData.AppConfig.SelectedMenuIcons = null;
RunTimeStatus.SHOW_MENU_PASSWORDBOX = true;
MainWindow.mainWindow.RightCard.PDDialog.Title.Text = "输入密码";
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Visible;
}
else
{
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Collapsed;
appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList;
}
}
MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Visible;
}
@@ -328,7 +348,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
/// <param name="e"></param>
private void Menu_MouseEnter(object sender, MouseEventArgs e)
{
if (appData.AppConfig.HoverMenu && !IS_EDIT)
if (appData.AppConfig.HoverMenu && !RunTimeStatus.IS_MENU_EDIT)
{
Thread t = new Thread(() =>
{
@@ -359,8 +379,31 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
MainWindow.mainWindow.HidedSearchBox();
}
ListBoxItem lbi = sender as ListBoxItem;
MenuInfo mi = lbi.DataContext as MenuInfo;
int index = MenuListBox.Items.IndexOf(mi);
MenuListBox.SelectedIndex = index;
}
///// <summary>
///// 点击菜单后 隐藏搜索框
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//private void ListBoxItemPanel_MouseDown(object sender, MouseButtonEventArgs e)
//{
// if (RunTimeStatus.SEARCH_BOX_SHOW)
// {
// MainWindow.mainWindow.HidedSearchBox();
// }
// MenuInfo mi = (sender as StackPanel).Tag as MenuInfo;
// int index = MenuListBox.Items.IndexOf(mi);
// MenuListBox.SelectedIndex = index;
//}
/// <summary>
/// 隐藏搜索框
/// </summary>
@@ -376,6 +419,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
private void Menu_MouseWheel(object sender, MouseWheelEventArgs e)
{
if (RunTimeStatus.IS_MENU_EDIT) return;
if (e.Delta < 0)
{
int index = MenuListBox.SelectedIndex;
@@ -401,5 +445,134 @@ namespace GeekDesk.Control.UserControls.PannelCard
MenuListBox.SelectedIndex = index;
}
}
private void Menu_PreviewDragLeave(object sender, DragEventArgs e)
{
MyPoptip.IsOpen = false;
}
private void Menu_PreviewDragEnter(object sender, DragEventArgs e)
{
MenuInfo mi = (sender as ListBoxItem).DataContext as MenuInfo;
MyPoptipContent.Text = "移动至:" + mi.MenuName;
MyPoptip.VerticalOffset = 30;
MyPoptip.IsOpen = true;
}
private void Menu_MouseLeave(object sender, MouseEventArgs e)
{
MyPoptip.IsOpen = false;
}
private void Menu_Drop(object sender, DragEventArgs e)
{
MyPoptip.IsOpen = false;
MenuInfo mi = (sender as ListBoxItem).DataContext as MenuInfo;
IconInfo iconInfo = (IconInfo)e.Data.GetData(typeof(IconInfo));
appData.MenuList[MenuListBox.SelectedIndex].IconList.Remove(iconInfo);
appData.MenuList[MenuListBox.Items.IndexOf(mi)].IconList.Add(iconInfo);
}
private void EncryptMenu(object sender, RoutedEventArgs e)
{
MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
if (menuInfo.IsEncrypt)
{
MainWindow.mainWindow.RightCard.PDDialog.menuInfo = menuInfo;
MainWindow.mainWindow.RightCard.PDDialog.Title.Text = "输入密码";
MainWindow.mainWindow.RightCard.PDDialog.type = PasswordType.CANCEL;
RunTimeStatus.SHOW_MENU_PASSWORDBOX = true;
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Visible;
//单独设置焦点
MainWindow.mainWindow.RightCard.PDDialog.SetFocus();
} else
{
if (string.IsNullOrEmpty(appData.AppConfig.MenuPassword))
{
MainWindow.mainWindow.RightCard.PDDialog.menuInfo = menuInfo;
MainWindow.mainWindow.RightCard.PDDialog.Title.Text = "设置新密码";
MainWindow.mainWindow.RightCard.PDDialog.type = PasswordType.CREATE;
RunTimeStatus.SHOW_MENU_PASSWORDBOX = true;
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Visible;
}
else
{
menuInfo.IsEncrypt = true;
HandyControl.Controls.Growl.Success(menuInfo.MenuName + " 已加密!", "MainWindowGrowl");
}
}
}
private void AlterPassword(object sender, RoutedEventArgs e)
{
MainWindow.mainWindow.RightCard.PDDialog.Title.Text = "输入旧密码";
MainWindow.mainWindow.RightCard.PDDialog.type = PasswordType.ALTER;
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Visible;
//单独设置焦点
MainWindow.mainWindow.RightCard.PDDialog.SetFocus();
}
/// <summary>
/// 右键点击进行处理
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MyCard_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
RunTimeStatus.SHOW_RIGHT_BTN_MENU = true;
new Thread(() =>
{
Thread.Sleep(50);
RunTimeStatus.SHOW_RIGHT_BTN_MENU = false;
}).Start();
//在没有设置密码的情况下不弹出修改密码菜单
if (string.IsNullOrEmpty(appData.AppConfig.MenuPassword))
{
AlterPW1.Visibility = Visibility.Collapsed;
} else
{
AlterPW1.Visibility = Visibility.Visible;
}
}
private void ListBoxItem_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
ListBoxItem lbi = sender as ListBoxItem;
MenuInfo info = lbi.DataContext as MenuInfo;
ItemCollection ics = lbi.ContextMenu.Items;
foreach (object obj in ics)
{
MenuItem mi = (MenuItem)obj;
if (mi.Header.Equals("修改密码"))
{
if (string.IsNullOrEmpty(appData.AppConfig.MenuPassword))
{
mi.Visibility = Visibility.Collapsed;
}
else
{
mi.Visibility = Visibility.Visible;
}
break;
}
if (mi.Header.Equals("加密此列表") || mi.Header.Equals("取消加密此列表"))
{
if (info.IsEncrypt)
{
mi.Header = "取消加密此列表";
} else
{
mi.Header = "加密此列表";
}
}
}
}
}
}

View File

@@ -7,6 +7,8 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
xmlns:ot="clr-namespace:GeekDesk.Control.Other"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
>
@@ -19,15 +21,6 @@
</Trigger>
</Style.Triggers>
</Style>-->
<Storyboard x:Key="Custom1Transition" x:Shared="False">
<DoubleAnimation From="50" To="0" Duration="0:0:0.4" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
<DoubleAnimation.EasingFunction>
<ElasticEase Oscillations="1"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
<Style x:Key="ImageStyle" TargetType="Image">
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageWidth, Mode=OneWay}"/>
<Setter Property="Height" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"/>
@@ -46,6 +39,48 @@
</Setter>
</Style>
<Style x:Key="SearchListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border>
<Border.Style>
<Style TargetType="Border">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</Border.Style>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Storyboard x:Key="Custom1Transition1" x:Shared="False">
<DoubleAnimation From="50" To="0" Duration="0:0:0.4" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
<DoubleAnimation.EasingFunction>
<ElasticEase Oscillations="1"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
<Storyboard x:Key="Custom2Transition2" x:Shared="False">
<DoubleAnimation From="10" To="0" Duration="0:0:0.4" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<DoubleAnimation.EasingFunction>
<ElasticEase Oscillations="1"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
<Storyboard x:Key="Custom3Transition3" x:Shared="False">
<DoubleAnimation From=".8" To="1" Duration="0:0:0.4">
<DoubleAnimation.EasingFunction>
<ElasticEase Oscillations="1"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
<cvt:OpcityConvert x:Key="OpcityConvert"/>
<cvt:SearchResWidth x:Key="SearchResWidth"/>
<temp:SearchIconList x:Key="SearchIconList"/>
@@ -59,7 +94,9 @@
BorderThickness="1"
Effect="{DynamicResource EffectShadow2}"
Margin="5,0,5,5" Grid.ColumnSpan="2"
PreviewMouseRightButtonDown="WrapCard_PreviewMouseRightButtonDown">
PreviewMouseRightButtonDown="WrapCard_PreviewMouseRightButtonDown"
hc:Dialog.Token="RightWrapCardDialog"
>
<hc:Card.Background>
<SolidColorBrush Color="AliceBlue" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
</hc:Card.Background>
@@ -73,87 +110,100 @@
<MenuItem x:Name="CardLockCM" Header="锁定主面板" Click="LockAppPanel"/>
</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=OneWay}"
BorderThickness="0"
<hc:DialogContainer>
<Grid>
<ot:PasswordDialog xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndGrowHorizontally}, Event=Visibility, Duration=50, Delay=0}"
x:Name="PDDialog"
Panel.ZIndex="99"
IsVisibleChanged="PDDialog_IsVisibleChanged"
Margin="0,-100,0,0"/>
<StackPanel Panel.ZIndex="1" Margin="0,-10,-0,0"/>
<WrapPanel Orientation="Horizontal"
VirtualizingPanel.VirtualizationMode="Recycling"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.IsContainerVirtualizable="True"
>
<UniformGrid x:Name="WrapUFG" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndGrowHorizontally}, Event=Visibility}">
<!--<hc:TransitioningContentControl TransitionStoryboard="{StaticResource Custom3Transition3}">-->
<ListBox x:Name="IconListBox"
ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=OneWay}"
BorderThickness="0"
Padding="0,10,0,0"
>
<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>
>
<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}}}"/>-->
<WrapPanel />
</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="AddSystemIcon"/>
<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}"/>
</Style>
</ListBox.ItemContainerStyle>
<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.Content="{Binding Content}"
hc:Poptip.Placement="BottomLeft"
Background="#00FFFFFF"
MouseEnter="StackPanel_MouseEnter"
MouseLeave="StackPanel_MouseLeave"
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
>
<!--<StackPanel Background="#00FFFFFF"
MouseEnter="CursorPanel_MouseEnter"
MouseLeave="CursorPanel_MouseLeave"
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageWidth, Mode=OneWay}">-->
<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"
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
>
<!--<StackPanel Background="#00FFFFFF"
MouseEnter="CursorPanel_MouseEnter"
MouseLeave="CursorPanel_MouseLeave"
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageWidth, Mode=OneWay}">-->
<Image Style="{StaticResource ImageStyle}"
RenderOptions.BitmapScalingMode="HighQuality"/>
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}"/>
<!--</StackPanel>-->
</hc:SimpleStackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
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}"/>
<!--</StackPanel>-->
</WrapPanel>
</Grid>
</hc:SimpleStackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!--</hc:TransitioningContentControl>-->
</UniformGrid>
</WrapPanel>
</Grid>
</hc:DialogContainer>
</hc:Card>
<hc:Card x:Name="VerticalCard"
@@ -172,17 +222,18 @@
<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"
>
<UniformGrid x:Name="VerticalUFG">
<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">
<UniformGrid x:Name="VerticalUFG" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, OffsetY= -10, Event=Visibility}">
<!--<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">-->
<ListBox ItemsSource="{Binding Source={StaticResource SearchIconList},Path=IconList}"
BorderThickness="0"
Padding="0,10,0,0"
>
BorderThickness="0"
Padding="0,10,0,0"
x:Name="SearchListBox"
SelectionChanged="SearchListBox_SelectionChanged"
>
<ListBox.Background>
<SolidColorBrush Opacity="0"/>
</ListBox.Background>
@@ -199,7 +250,7 @@
</ListBox.Resources>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MyListBoxItemStyle}">
<Style TargetType="ListBoxItem" BasedOn="{StaticResource SearchListBoxItemStyle}">
<Setter Property="ContextMenu" Value="{StaticResource IconDialog}"/>
</Style>
</ListBox.ItemContainerStyle>
@@ -214,36 +265,54 @@
<ListBox.ItemTemplate>
<DataTemplate>
<Border CornerRadius="8">
<Border.Style>
<Style TargetType="Border">
<Setter Property="VerticalAlignment" Value="Center"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem }}}"
Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="White" Opacity="0.68"/>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<WrapPanel Tag="{Binding}"
Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.MenuCardWidth, Mode=OneWay, Converter={StaticResource SearchResWidth}, ConverterParameter=2}"
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"
>
Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.MenuCardWidth, Mode=OneWay, Converter={StaticResource SearchResWidth}, ConverterParameter=2}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
hc:Poptip.HitMode="None"
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
hc:Poptip.Content="{Binding Content}"
hc:Poptip.Placement="BottomLeft"
Background="#00FFFFFF"
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
Margin="25,10,0,10"
>
<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}"/>
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>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</hc:TransitioningContentControl>
<!--</hc:TransitioningContentControl>-->
</UniformGrid>
</WrapPanel>

View File

@@ -13,6 +13,7 @@ using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading;
@@ -25,68 +26,76 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
private AppData appData = MainWindow.appData;
private volatile static bool DROP_ICON = false;
private Thread dropCheckThread = null;
ListBoxDragDropManager<IconInfo> dragMgr;
//private Thread dropCheckThread = null;
public RightCardControl()
{
InitializeComponent();
this.Loaded += RightCardControl_Loaded;
}
#region
DelegateCommand<int[]> _swap;
public DelegateCommand<int[]> SwapCommand
private void RightCardControl_Loaded(object sender, RoutedEventArgs e)
{
get
{
if (_swap == null)
_swap = new DelegateCommand<int[]>(
(indexes) =>
{
DROP_ICON = true;
if (appData.AppConfig.IconSortType != SortType.CUSTOM
&& (dropCheckThread == null || !dropCheckThread.IsAlive))
{
dropCheckThread = new Thread(() =>
{
do
{
DROP_ICON = false;
Thread.Sleep(1000);
} while (DROP_ICON);
MainWindow.appData.AppConfig.IconSortType = SortType.CUSTOM;
App.Current.Dispatcher.Invoke(() =>
{
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed
|| MainWindow.mainWindow.Opacity != 1)
{
Growl.WarningGlobal("已将图标排序规则重置为自定义!");
}
else
{
Growl.Warning("已将图标排序规则重置为自定义!", "MainWindowGrowl");
}
});
});
dropCheckThread.Start();
}
int fromS = indexes[0];
int to = indexes[1];
ObservableCollection<IconInfo> iconList = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
var elementSource = iconList[to];
var dragged = iconList[fromS];
iconList.Remove(dragged);
iconList.Insert(to, dragged);
}
);
return _swap;
}
this.dragMgr = new ListBoxDragDropManager<IconInfo>(this.IconListBox);
}
#endregion
//#region 图标拖动
//DelegateCommand<int[]> _swap;
//public DelegateCommand<int[]> SwapCommand
//{
// get
// {
// if (_swap == null)
// _swap = new DelegateCommand<int[]>(
// (indexes) =>
// {
// DROP_ICON = true;
// if (appData.AppConfig.IconSortType != SortType.CUSTOM
// && (dropCheckThread == null || !dropCheckThread.IsAlive))
// {
// dropCheckThread = new Thread(() =>
// {
// do
// {
// DROP_ICON = false;
// Thread.Sleep(1000);
// } while (DROP_ICON);
// MainWindow.appData.AppConfig.IconSortType = SortType.CUSTOM;
// App.Current.Dispatcher.Invoke(() =>
// {
// if (MainWindow.mainWindow.Visibility == Visibility.Collapsed
// || MainWindow.mainWindow.Opacity != 1)
// {
// Growl.WarningGlobal("已将图标排序规则重置为自定义!");
// }
// else
// {
// Growl.Warning("已将图标排序规则重置为自定义!", "MainWindowGrowl");
// }
// });
// });
// dropCheckThread.Start();
// }
// int fromS = indexes[0];
// int to = indexes[1];
// ObservableCollection<IconInfo> iconList = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
// var elementSource = iconList[to];
// var dragged = iconList[fromS];
// iconList.Remove(dragged);
// iconList.Insert(to, dragged);
// }
// );
// return _swap;
// }
//}
//#endregion 图标拖动
@@ -163,33 +172,51 @@ namespace GeekDesk.Control.UserControls.PannelCard
StartIconApp(icon, IconStartType.SHOW_IN_EXPLORE);
}
private void StartIconApp(IconInfo icon, IconStartType type)
private void StartIconApp(IconInfo icon, IconStartType type, bool useRelativePath = false)
{
try
{
using (Process p = new Process())
{
string startArg = icon.StartArg;
if (startArg != null && Constants.SYSTEM_ICONS.ContainsKey(startArg))
{
StartSystemApp(startArg, type);
}
else
{
p.StartInfo.FileName = icon.Path;
string path;
if (useRelativePath)
{
string fullPath = Path.Combine(Constants.APP_DIR, icon.RelativePath);
path = Path.GetFullPath(fullPath);
} else
{
path = icon.Path;
}
p.StartInfo.FileName = path;
if (!StringUtil.IsEmpty(startArg))
{
p.StartInfo.Arguments = startArg;
}
if (icon.IconType == IconType.OTHER)
{
if (!File.Exists(icon.Path) && !Directory.Exists(icon.Path))
if (!File.Exists(path) && !Directory.Exists(path))
{
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
return;
//如果没有使用相对路径 那么使用相对路径启动一次
if (!useRelativePath)
{
StartIconApp(icon, type, true);
return;
} else
{
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
return;
}
}
p.StartInfo.WorkingDirectory = icon.Path.Substring(0, icon.Path.LastIndexOf("\\"));
p.StartInfo.WorkingDirectory = path.Substring(0, path.LastIndexOf("\\"));
switch (type)
{
case IconStartType.ADMIN_STARTUP:
@@ -257,6 +284,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
}
}
p.Start();
if (useRelativePath)
{
//如果使用相对路径启动成功 那么重新设置程序绝对路径
icon.Path = path;
}
}
}
icon.Count++;
@@ -269,8 +301,15 @@ namespace GeekDesk.Control.UserControls.PannelCard
}
catch (Exception e)
{
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(不支持的启动方式)!");
LogUtil.WriteErrorLog(e, "程序启动失败:path=" + icon.Path + ",type=" + type);
if (!useRelativePath)
{
StartIconApp(icon, type, true);
}
else
{
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(可能为不支持的启动方式)!");
LogUtil.WriteErrorLog(e, "程序启动失败:path=" + icon.Path + ",type=" + type);
}
}
}
@@ -368,7 +407,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
MainWindow.appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Add(iconInfo);
}
CommonCode.SortIconList();
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
/// <summary>
@@ -405,11 +444,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
case IconType.URL:
IconInfoUrlDialog urlDialog = new IconInfoUrlDialog(info);
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "IconInfoDialog");
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "MainWindowDialog");
break;
default:
IconInfoDialog dialog = new IconInfoDialog(info);
dialog.dialog = HandyControl.Controls.Dialog.Show(dialog, "IconInfoDialog");
dialog.dialog = HandyControl.Controls.Dialog.Show(dialog, "MainWindowDialog");
break;
}
}
@@ -636,7 +675,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
private void AddUrlIcon(object sender, RoutedEventArgs e)
{
IconInfoUrlDialog urlDialog = new IconInfoUrlDialog();
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "IconInfoDialog");
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "MainWindowDialog");
}
/// <summary>
@@ -716,5 +755,68 @@ namespace GeekDesk.Control.UserControls.PannelCard
CardLockCM.Header = "锁定主面板";
}
}
public void SearchListBoxIndexAdd()
{
if (SearchListBox.Items.Count > 0)
{
if (SearchListBox.SelectedIndex < SearchListBox.Items.Count - 1)
{
SearchListBox.SelectedIndex += 1;
}
}
}
public void SearchListBoxIndexSub()
{
if (SearchListBox.Items.Count > 0)
{
if (SearchListBox.SelectedIndex > 0)
{
SearchListBox.SelectedIndex -= 1;
}
}
}
public void StartupSelectionItem()
{
if (SearchListBox.SelectedItem != null)
{
IconInfo icon = SearchListBox.SelectedItem as IconInfo;
if (icon.AdminStartUp)
{
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
}
else
{
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
}
}
}
private void SearchListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
SearchListBox.ScrollIntoView(SearchListBox.SelectedItem);
}
private void PDDialog_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (PDDialog.Visibility == Visibility.Visible)
{
RunTimeStatus.SHOW_MENU_PASSWORDBOX = true;
PDDialog.ClearVal();
PDDialog.ErrorMsg.Visibility = Visibility.Collapsed;
PDDialog.PasswordGrid.Visibility = Visibility.Visible;
PDDialog.HintGrid.Visibility = Visibility.Collapsed;
PDDialog.count = 0;
PDDialog.SetFocus();
}
else
{
RunTimeStatus.SHOW_MENU_PASSWORDBOX = false;
PDDialog.ClearVal();
MainWindow.mainWindow.Focus();
}
}
}
}

View File

@@ -42,7 +42,7 @@ namespace GeekDesk.Control.UserControls.SystemItem
iconInfo = CommonCode.GetIconInfoByPath(thisInfo.LnkPath_NoWrite);
}
menuInfo.IconList.Add(iconInfo);
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
}
}

View File

@@ -6,7 +6,6 @@
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:ToDoInfo}"
mc:Ignorable="d"
xmlns:cst="clr-namespace:GeekDesk.Converts"
Background="Transparent"
>

View File

@@ -1,4 +1,5 @@
using GeekDesk.Control.Windows;
using GeekDesk.Constant;
using GeekDesk.Control.Windows;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Controls;
@@ -42,7 +43,7 @@ namespace GeekDesk.Control.UserControls.Backlog
{
MainWindow.appData.HiToDoList.Remove(info);
}
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
return true;
}, "DeleteConfirm");

View File

@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
xmlns:local="clr-namespace:GeekDesk"
Title="Setting"
mc:Ignorable="d"
@@ -109,14 +110,14 @@
</hc:SideMenu>
</hc:Card>
<hc:ScrollViewer Grid.Row="0" Grid.Column="1" BorderThickness="0" Margin="0,5,1,5">
<UniformGrid x:Name="UFG">
<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">
<UniformGrid x:Name="UFG" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, Event=Visibility, Delay=0}">
<!--<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">-->
<hc:Card x:Name="RightCard" BorderThickness="0" MouseDown="DragMove">
<hc:Card.Background>
<SolidColorBrush Opacity="0"/>
</hc:Card.Background>
</hc:Card>
</hc:TransitioningContentControl>
<!--</hc:TransitioningContentControl>-->
</UniformGrid>
</hc:ScrollViewer>

View File

@@ -36,6 +36,8 @@ namespace GeekDesk.Control.Windows
RightCard.Content = about;
this.Topmost = true;
this.mainWindow = mainWindow;
UFG.Visibility = Visibility.Collapsed;
UFG.Visibility = Visibility.Visible;
}

View File

@@ -81,15 +81,25 @@ namespace GeekDesk.Control.Windows
if (window == null || !window.Activate())
{
window = new GlobalColorPickerWindow();
window.Opacity = 0;
App.DoEvents();
window.Show();
}
window.Hide();
GlobalColorPickerWindow thisWindow = (GlobalColorPickerWindow)window;
if (thisWindow.colorPickerWindow == null || !thisWindow.colorPickerWindow.Activate())
new Thread(() =>
{
thisWindow.colorPickerWindow = new PixelColorPickerWindow(thisWindow.MyColorPicker);
}
thisWindow.colorPickerWindow.Show();
Thread.Sleep(200);
App.Current.Dispatcher.Invoke(() =>
{
GlobalColorPickerWindow thisWindow = (GlobalColorPickerWindow)window;
if (thisWindow.colorPickerWindow == null || !thisWindow.colorPickerWindow.Activate())
{
thisWindow.colorPickerWindow = new PixelColorPickerWindow(thisWindow.MyColorPicker);
}
thisWindow.colorPickerWindow.Show();
});
}).Start();
}
public static void Show()
@@ -98,6 +108,7 @@ namespace GeekDesk.Control.Windows
{
window = new GlobalColorPickerWindow();
}
window.Opacity = 1;
window.Show();
Keyboard.Focus(window);
}

View File

@@ -138,7 +138,7 @@ namespace GeekDesk.Control.Windows
}
window.Show();
Keyboard.Focus(window);
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0);
}
private void CustomButton_Click(object sender, RoutedEventArgs e)

View File

@@ -280,7 +280,7 @@ namespace GeekDesk.Control.Windows
}
window.Show();
Keyboard.Focus(window);
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0);
}

View File

@@ -178,7 +178,7 @@ namespace GeekDesk.Control.Windows
Growl.SuccessGlobal("设置待办任务成功, 系统将在 " + minutes + " 分钟后提醒您!");
}
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
this.Close();
}

View File

@@ -10,12 +10,21 @@ namespace GeekDesk.Converts
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int val = int.Parse(value.ToString());
var param = 0;
if (parameter != null)
{
param = int.Parse(parameter.ToString());
}
if (val + param > 0)
{
val += param;
}
return new CornerRadius(val);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
return null;
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace GeekDesk.Converts
{
internal class ReverseBoolConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null) return null;
bool val = (bool)value;
return !val;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -8,7 +8,10 @@ namespace GeekDesk.Converts
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null) return null;
if (value == null)
{
value = "";
}
if (parameter == null)
{
return value.ToString();
@@ -16,7 +19,14 @@ namespace GeekDesk.Converts
else
{
string val = value.ToString();
if (string.IsNullOrEmpty(val))
{
return parameter.ToString()
.Replace("\\n", "")
.Replace("{}", "");
}
string param = parameter.ToString();
param = param.Replace("\\n", "\n");
return param.Replace("{}", val);
}
}

View File

@@ -21,6 +21,7 @@ namespace DraggAnimatedPanel
#endregion
static DraggAnimatedPanel()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(DraggAnimatedPanel), new FrameworkPropertyMetadata(typeof(DraggAnimatedPanel)));
}

View File

@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props" Condition="Exists('packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props')" />
<Import Project="packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props" Condition="Exists('packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props')" />
<Import Project="packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props" Condition="Exists('packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -30,6 +33,8 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -44,7 +49,7 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
@@ -52,6 +57,8 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
</PropertyGroup>
<PropertyGroup>
<StartupObject>GeekDesk.App</StartupObject>
@@ -113,12 +120,19 @@
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Reactive, Version=5.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>packages\System.Reactive.5.0.0\lib\net472\System.Reactive.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
@@ -132,6 +146,9 @@
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="XamlFlair.WPF, Version=1.2.13.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\XamlFlair.WPF.1.2.13\lib\net472\XamlFlair.WPF.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
@@ -146,12 +163,16 @@
<Compile Include="Constant\IconType.cs" />
<Compile Include="Constant\CommonEnum.cs" />
<Compile Include="Constant\IconStartType.cs" />
<Compile Include="Constant\PasswordType.cs" />
<Compile Include="Constant\RunTimeStatus.cs" />
<Compile Include="Constant\SearchType.cs" />
<Compile Include="Constant\SortType.cs" />
<Compile Include="Constant\TodoTaskExecType.cs" />
<Compile Include="Constant\BGStyle.cs" />
<Compile Include="Constant\UpdateType.cs" />
<Compile Include="Control\Other\GlobalMsgNotification.xaml.cs">
<DependentUpon>GlobalMsgNotification.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Other\BacklogNotificatin.xaml.cs">
<DependentUpon>BacklogNotificatin.xaml</DependentUpon>
</Compile>
@@ -161,6 +182,9 @@
<Compile Include="Control\Other\GradientBGDialog.xaml.cs">
<DependentUpon>GradientBGDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Other\PasswordDialog.xaml.cs">
<DependentUpon>PasswordDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Other\MyColorPickerDialog.xaml.cs">
<DependentUpon>MyColorPickerDialog.xaml</DependentUpon>
</Compile>
@@ -234,30 +258,38 @@
<Compile Include="Converts\OpcityConvert.cs" />
<Compile Include="Converts\BGStyleConvert.cs" />
<Compile Include="Converts\UpdateTypeConvert.cs" />
<Compile Include="Converts\ReverseBoolConvert.cs" />
<Compile Include="Converts\Visibility2BooleanConverter.cs" />
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
<Compile Include="Converts\HideTypeConvert.cs" />
<Compile Include="Interface\IWindowCommon.cs" />
<Compile Include="MyThread\RelativePathThread.cs" />
<Compile Include="Task\ShowSecondTask.cs" />
<Compile Include="Task\ToDoTask.cs" />
<Compile Include="MyThread\MouseHookThread.cs" />
<Compile Include="MyThread\DispatcherBuild.cs" />
<Compile Include="MyThread\UpdateThread.cs" />
<Compile Include="Util\AeroGlassHelper.cs" />
<Compile Include="Util\BGSettingUtil.cs" />
<Compile Include="Util\BlurGlassUtil.cs" />
<Compile Include="Util\ColorUtil.cs" />
<Compile Include="Util\DragAdorner.cs" />
<Compile Include="Util\GlobalHotKey.cs" />
<Compile Include="Util\CommonCode.cs" />
<Compile Include="Util\FileIcon.cs" />
<Compile Include="Util\FileUtil.cs" />
<Compile Include="Util\KeyUtil.cs" />
<Compile Include="Util\ListBoxDragDropManager.cs" />
<Compile Include="Util\LogUtil.cs" />
<Compile Include="Util\MarginHide.cs" />
<Compile Include="Util\HttpUtil.cs" />
<Compile Include="Util\ImageUtil.cs" />
<Compile Include="Converts\MenuWidthConvert.cs" />
<Compile Include="Util\MD5Util.cs" />
<Compile Include="Util\MouseUtil.cs" />
<Compile Include="Util\RegisterUtil.cs" />
<Compile Include="Util\RelayCommand.cs" />
<Compile Include="Util\ShellContextMenu.cs" />
<Compile Include="Util\ShowWindowFollowMouse.cs" />
<Compile Include="Util\StringUtil.cs" />
@@ -272,6 +304,10 @@
<Compile Include="ViewModel\IconfontInfo.cs" />
<Compile Include="ViewModel\IconInfo.cs" />
<Compile Include="ViewModel\MenuInfo.cs" />
<Page Include="Control\Other\GlobalMsgNotification.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Control\Other\BacklogNotificatin.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -284,6 +320,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Control\Other\PasswordDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Control\Other\MyColorPickerDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -384,6 +424,11 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resource\Dictionary\XamlFlairSettings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
@@ -475,7 +520,30 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<UserProperties update_1json__JsonSchema="https://typedoc.org/schema.json" />
<UserProperties update_1json__JsonSchema="https://beaujs.com/schema.json" />
</VisualStudio>
</ProjectExtensions>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props'))" />
<Error Condition="!Exists('packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets'))" />
<Error Condition="!Exists('packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props'))" />
<Error Condition="!Exists('packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets'))" />
<Error Condition="!Exists('packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props'))" />
<Error Condition="!Exists('packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets'))" />
</Target>
<Import Project="packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets" Condition="Exists('packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets')" />
<Import Project="packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets" Condition="Exists('packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets')" />
<Import Project="packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets" Condition="Exists('packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets')" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>; Move all assemblies and related files to lib folder
ROBOCOPY "$(TargetDir) " "$(TargetDir)lib\ " /XF Data *.exe *.config *.manifest /XD lib logs bak /E /IS /MOVE
if %25errorlevel%25 leq 4 exit 0 else exit %25errorlevel%25</PostBuildEvent>
</PropertyGroup>
</Project>

View File

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

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
# Visual Studio Version 17
VisualStudioVersion = 17.1.32319.34
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeekDesk", "GeekDesk.csproj", "{B4983CEC-2281-413C-8ECF-92EE0E40A713}"

View File

@@ -4,6 +4,6 @@ namespace GeekDesk.Interface
{
public interface IWindowCommon
{
void OnKeyDown(object sender, KeyEventArgs e);
void OnKeyDown(object sender, KeyEventArgs e);
}
}

View File

@@ -1,2 +1,2 @@
- 这是个人开发的程序,任何人可任意修改和免费使用(未做较大功能性改动不允许修改赞赏码,重新修改发布需注明出处)
- 这是个人开发的程序,任何人可任意修改和免费使用(未做较大功能性改动不允许修改赞赏码,重新修改发布需注明出处)
- 商用需联系作者

View File

@@ -5,6 +5,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:cn="clr-namespace:GeekDesk.Constant"
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
xmlns:local="clr-namespace:GeekDesk"
mc:Ignorable="d"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
x:Name="AppWindow"
@@ -17,18 +19,17 @@
AllowsTransparency="True"
Background="Transparent"
ShowInTaskbar="False"
Opacity="0"
Opacity="1"
Deactivated="AppWindow_Deactivated"
SizeChanged="Window_SizeChanged"
KeyDown="OnKeyDown"
PreviewKeyDown="OnKeyDown"
Focusable="True"
MouseDown="MainWindow_MouseDown"
MouseEnter="MainWindow_MouseEnter"
GotFocus="Window_GotFocus"
Loaded="Window_Loaded"
>
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="0" ResizeBorderThickness="15"/>
</WindowChrome.WindowChrome>
<Window.Resources>
<RoutedUICommand x:Key="SearchHotKeyDown" Text="SearchHotKeyDown"/>
@@ -36,37 +37,38 @@
<cvt:OpcityConvert x:Key="OpcityConvert"/>
<cvt:IntToCornerRadius x:Key="IntToCornerRadius"/>
<cvt:DoubleToGridLength x:Key="DoubleToGridLength"/>
<Style x:Key="BorderBacStyle" TargetType="Border">
</Style>
<cvt:ReverseBoolConvert x:Key="ReverseBoolConvert"/>
</Window.Resources>
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="0" CornerRadius="30" ResizeBorderThickness="15"/>
</WindowChrome.WindowChrome>
<Window.InputBindings>
<KeyBinding Gesture="Ctrl+F" Key="F" Command="{StaticResource SearchHotKeyDown}"/>
</Window.InputBindings>
<Window.CommandBindings>
<CommandBinding Command="{StaticResource SearchHotKeyDown}" CanExecute="SearchHotKeyDown"/>
<!--<CommandBinding Command="ChangeImgBG" Executed="ChangeImgBG_Executed" CanExecute="ChangeImgBG_CanExecute" />-->
</Window.CommandBindings>
<Window.Effect>
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
RenderingBias="Quality" ShadowDepth="2"/>
</Window.Effect>
<Border Margin="20" CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}" BorderThickness="0"
Background="AliceBlue"
Opacity="{Binding AppConfig.PannelOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"
hc:Dialog.Token="IconInfoDialog"
<!--Opacity="{Binding AppConfig.PannelOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"-->
<Border Margin="20" CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}"
BorderThickness="0"
Focusable="True"
x:Name="BGBorder"
hc:Dialog.Token="MainWindowDialog"
xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndGrowHorizontally}, Event=None}"
xf:Animations.PrimaryBinding="{Binding AppConfig.IsShow, Mode=OneWay}"
xf:Animations.Secondary="{xf:Animate BasedOn={StaticResource FadeOut}, Event=None}"
xf:Animations.SecondaryBinding="{Binding AppConfig.IsShow, Mode=OneWay, Converter={StaticResource ReverseBoolConvert}}"
xf:Animations.SecondaryCompletionCommand="{Binding HideCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
xf:Animations.AllowOpacityReset="False"
>
<hc:DialogContainer Focusable="True">
<!-- -1是为了解决圆角白线的问题-->
<Border x:Name="BGBorder"
CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}"
BorderThickness="0"
Margin="-1"
>
<Border.Effect>
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
RenderingBias="Quality" ShadowDepth="2"/>
</Border.Effect>
<hc:DialogContainer Focusable="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" MouseMove="DragMove"></RowDefinition>
@@ -77,9 +79,10 @@
<ColumnDefinition x:Name="RightColumn" Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--获取焦点用-->
<TextBox x:Name="EmptyTextBox" Width="0"/>
<CheckBox x:Name="ShowBox" Visibility="Hidden" Panel.ZIndex="2"/>
<CheckBox x:Name="HideBox" Visibility="Hidden" Panel.ZIndex="2"/>
<StackPanel HorizontalAlignment="Right" Panel.ZIndex="99" hc:Growl.GrowlParent="False" hc:Growl.Token="MainWindowGrowl" Grid.Column="1" Grid.Row="1"/>
<DockPanel Grid.Row="0" Grid.Column="0" MouseMove="DragMove">
<DockPanel.Background>
@@ -94,38 +97,39 @@
</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"
hc:IconElement.Width="18"
HorizontalAlignment="Right"
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>
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"
hc:IconElement.Width="18"
HorizontalAlignment="Right"
Click="ConfigButtonClick"
Initialized="SettingButton_Initialized"
PreviewMouseLeftButtonDown="AppButton_PreviewMouseLeftButtonDown"
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"
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}"
/>
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"
PreviewMouseLeftButtonDown="AppButton_PreviewMouseLeftButtonDown"
FocusVisualStyle="{x:Null}"
/>
</hc:UniformSpacingPanel>
</DockPanel>
<uc:LeftCardControl Grid.Row="1" Grid.Column="0"/>
<uc:LeftCardControl x:Name="LeftCard" Grid.Row="1" Grid.Column="0"/>
<!--分割线-->
<GridSplitter Opacity="0" Grid.Row="1" Grid.Column="0" Width="1" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
@@ -141,15 +145,14 @@
TextChanged="SearchBox_TextChanged"
/>
<uc:RightCardControl x:Name="RightCard" Grid.Row="1" Grid.Column="1"/>
<hc:NotifyIcon Icon="/Taskbar.ico" Click="NotifyIcon_Click" x:Name="BarIcon"
MouseRightButtonDown="BarIcon_MouseRightButtonDown"
Visibility="{Binding AppConfig.ShowBarIcon, Mode=TwoWay, Converter={StaticResource Boolean2VisibilityConverter}}">
<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" x:Name="TaskbarContextMenu">
<MenuItem Header="打开面板" Click="ShowApp"/>
<MenuItem Header="拾色器" Click="ColorPicker"/>
<MenuItem Header="备份" Click="BakDataFile"/>
<MenuItem Header="隐藏图标" Click="CloseBarIcon"/>
<MenuItem Header="待办" Click="BacklogMenuClick"/>
<MenuItem Header="程序目录" Click="OpenThisDir"/>
@@ -158,12 +161,13 @@
<MenuItem Header="退出" Click="ExitApp"/>
</ContextMenu>
</hc:NotifyIcon.ContextMenu>
</hc:NotifyIcon>
<uc:RightCardControl x:Name="RightCard" Grid.Row="1" Grid.Column="1"/>
<StackPanel hc:Growl.GrowlParent="True" VerticalAlignment="Top" Margin="0,10,10,0"/>
</Grid>
</Border>
</hc:DialogContainer>
</hc:DialogContainer>
</Border>
</Window>

View File

@@ -1,5 +1,6 @@
using GeekDesk.Constant;
using GeekDesk.Control.UserControls.Config;
using GeekDesk.Control.UserControls.PannelCard;
using GeekDesk.Control.Windows;
using GeekDesk.Interface;
using GeekDesk.MyThread;
@@ -7,6 +8,7 @@ using GeekDesk.Task;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using GeekDesk.ViewModel.Temp;
using Microsoft.Win32;
using NPinyin;
using System;
using System.Collections.ObjectModel;
@@ -15,6 +17,7 @@ using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media.Animation;
using System.Windows.Threading;
using static GeekDesk.Util.ShowWindowFollowMouse;
@@ -36,14 +39,18 @@ namespace GeekDesk
public static MainWindow mainWindow;
public MainWindow()
{
//加载数据
LoadData();
InitializeComponent();
mainWindow = this;
this.Topmost = true;
this.Loaded += Window_Loaded;
this.SizeChanged += MainWindow_Resize;
ToDoTask.BackLogCheck();
//用于其他类访问
mainWindow = this;
//置于顶层
this.Topmost = true;
//执行待办提醒
ToDoTask.BackLogCheck();
////实例化隐藏 Hide类进行时间timer设置
MarginHide.ReadyHide(this);
@@ -51,11 +58,14 @@ namespace GeekDesk
{
MarginHide.StartHide();
}
}
/// <summary>
/// 显示搜索框
/// 搜索快捷键按下
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
@@ -67,6 +77,9 @@ namespace GeekDesk
}
}
/// <summary>
/// 显示搜索框
/// </summary>
private void ShowSearchBox()
{
RunTimeStatus.SEARCH_BOX_SHOW = true;
@@ -116,9 +129,16 @@ namespace GeekDesk
{
SearchIconList.IconList.Clear();
}
if (RightCard.SearchListBox.Items.Count > 0)
{
RightCard.SearchListBox.SelectedIndex = 0;
}
RightCard.VerticalUFG.Visibility = Visibility.Visible;
}
/// <summary>
/// 隐藏搜索框
/// </summary>
public void HidedSearchBox()
{
RunTimeStatus.SEARCH_BOX_SHOW = false;
@@ -159,20 +179,13 @@ namespace GeekDesk
BGSettingUtil.BGSetting();
if (!appData.AppConfig.StartedShowPanel)
{
if (appData.AppConfig.AppAnimation)
{
this.Opacity = 0;
}
else
{
this.Visibility = Visibility.Collapsed;
}
this.Visibility = Visibility.Collapsed;
}
else
{
ShowApp();
}
//ShowSecondTask.SHowSecond();
//给任务栏图标一个名字
BarIcon.Text = Constants.MY_NAME;
@@ -205,6 +218,12 @@ namespace GeekDesk
//更新线程开启 检测更新
UpdateThread.Update();
//建立相对路径
RelativePathThread.MakeRelativePath();
//毛玻璃 暂时未解决阴影问题
//BlurGlassUtil.EnableBlur(this);
}
/// <summary>
@@ -329,21 +348,6 @@ namespace GeekDesk
}
/// <summary>
/// 重置窗体大小 写入缓存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void MainWindow_Resize(object sender, System.EventArgs e)
{
if (this.DataContext != null)
{
AppData appData = this.DataContext as AppData;
appData.AppConfig.WindowWidth = this.Width;
appData.AppConfig.WindowHeight = this.Height;
}
}
/// <summary>
@@ -422,8 +426,6 @@ namespace GeekDesk
// return;
//}
MainWindow.mainWindow.Activate();
if (MarginHide.ON_HIDE)
{
//修改贴边隐藏状态为未隐藏
@@ -437,35 +439,65 @@ namespace GeekDesk
if (appData.AppConfig.FollowMouse)
{
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0, false);
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0);
}
FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
MainWindow.mainWindow.Activate();
mainWindow.Show();
//mainWindow.Visibility = Visibility.Visible;
if (appData.AppConfig.AppAnimation)
{
appData.AppConfig.IsShow = true;
}
else
{
appData.AppConfig.IsShow = null;
}
//FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
Keyboard.Focus(mainWindow);
Keyboard.Focus(mainWindow.SearchBox);
if (RunTimeStatus.SHOW_MENU_PASSWORDBOX)
{
mainWindow.RightCard.PDDialog.SetFocus();
} else
{
Keyboard.Focus(mainWindow.SearchBox);
}
}
public static void HideApp()
{
if (!MarginHide.IS_HIDE)
if (appData.AppConfig.AppAnimation)
{
//关闭锁定
RunTimeStatus.LOCK_APP_PANEL = false;
if (RunTimeStatus.SEARCH_BOX_SHOW)
{
mainWindow.HidedSearchBox();
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
}
else
{
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
}
appData.AppConfig.IsShow = false;
}
else
{
ShowApp();
appData.AppConfig.IsShow = null;
HideAppVis();
}
}
private static void HideAppVis()
{
//关闭锁定
RunTimeStatus.LOCK_APP_PANEL = false;
if (RunTimeStatus.SEARCH_BOX_SHOW)
{
mainWindow.HidedSearchBox();
}
mainWindow.Visibility = Visibility.Collapsed;
//if (!MarginHide.IS_HIDE)
//{
//}
//else
//{
// ShowApp();
//}
}
/// <summary>
@@ -676,16 +708,24 @@ namespace GeekDesk
{
HideApp();
}
//else if (
// appData.AppConfig.SearchType == SearchType.KEY_DOWN &&
// (
// (e.Key >= Key.D0 && e.Key <= Key.Z)
// || (e.Key >= Key.NumPad0 && e.Key < Key.NumPad9)
// )
// )
//{
// ShowSearchBox();
//}
if (RunTimeStatus.SEARCH_BOX_SHOW && (e.Key == Key.Up
|| e.Key == Key.Down
|| e.Key == Key.Tab
|| e.Key == Key.Enter
))
{
if (e.Key == Key.Down || e.Key == Key.Tab)
{
RightCard.SearchListBoxIndexAdd();
} else if (e.Key == Key.Up)
{
RightCard.SearchListBoxIndexSub();
} else if (e.Key == Key.Enter)
{
RightCard.StartupSelectionItem();
}
}
}
@@ -718,29 +758,87 @@ namespace GeekDesk
/// <param name="e"></param>
private void ColorPicker(object sender, RoutedEventArgs e)
{
TaskbarContextMenu.Visibility = Visibility.Collapsed;
App.DoEvents();
TaskbarContextMenu.IsOpen = false;
GlobalColorPickerWindow.CreateNoShow();
}
/// <summary>
/// 防止点击拾色器后无法显示菜单的问题
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BarIcon_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
TaskbarContextMenu.Visibility = Visibility.Visible;
}
private void Window_GotFocus(object sender, RoutedEventArgs e)
{
Keyboard.Focus(SearchBox);
// 如果没有在修改菜单 并且不是右键点击了面板
if (!RunTimeStatus.IS_MENU_EDIT
&& !RunTimeStatus.SHOW_RIGHT_BTN_MENU
&& !RunTimeStatus.APP_BTN_IS_DOWN)
{
if (RunTimeStatus.SHOW_MENU_PASSWORDBOX)
{
//必须在其它文本框没有工作的时候才给密码框焦点
RightCard.PDDialog.SetFocus();
}
else
{
//必须在其它文本框没有工作的时候才给搜索框焦点
Keyboard.Focus(SearchBox);
}
}
}
private void AppWindow_Deactivated(object sender, EventArgs e)
{
AppWindowLostFocus();
}
/// <summary>
/// 备份数据文件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[Obsolete]
private void BakDataFile(object sender, RoutedEventArgs e)
{
Thread t = new Thread(() =>
{
CommonCode.BakAppData();
});
t.ApartmentState = ApartmentState.STA;
t.Start();
}
private void AppButton_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//点击了面板
RunTimeStatus.APP_BTN_IS_DOWN = true;
new Thread(() =>
{
Thread.Sleep(50);
RunTimeStatus.APP_BTN_IS_DOWN = false;
}).Start();
}
private ICommand _hideCommand;
public ICommand HideCommand
{
get
{
if (_hideCommand == null)
{
_hideCommand = new RelayCommand(
p =>
{
return true;
},
p =>
{
HideAppVis();
});
}
return _hideCommand;
}
}
}
}

View File

@@ -1,3 +1,4 @@
# BookerLiu
diff a/MainWindow.xaml b/MainWindow.xaml (rejected hunks)
@@ -20,6 +20,7 @@
SizeChanged="Window_SizeChanged"

View File

@@ -0,0 +1,42 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace GeekDesk.MyThread
{
public class RelativePathThread
{
public static void MakeRelativePath()
{
new Thread(() =>
{
ObservableCollection<MenuInfo> menuList = MainWindow.appData.MenuList;
string myExePath = Constants.APP_DIR + "GeekDesk.exe";
foreach (MenuInfo mi in menuList)
{
ObservableCollection<IconInfo> iconList = mi.IconList;
foreach (IconInfo icon in iconList)
{
string relativePath = FileUtil.MakeRelativePath(myExePath, icon.Path);
if (File.Exists(icon.Path)
&& !string.IsNullOrEmpty(relativePath)
&& !relativePath.Equals(icon.Path)) {
icon.RelativePath_NoWrite = relativePath;
}
}
}
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_BAK_PATH);
}).Start();
}
}
}

View File

@@ -4,7 +4,7 @@ using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
// 与程序集关联的信息。
[assembly: AssemblyTitle("GeekDesk")]
[assembly: AssemblyDescription("小巧、美观的桌面快速启动工具")]
[assembly: AssemblyConfiguration("")]
@@ -49,5 +49,5 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.1.5")]
[assembly: AssemblyFileVersion("2.4.1.5")]
[assembly: AssemblyVersion("2.5.1.0")]
[assembly: AssemblyFileVersion("2.5.1.0")]

View File

@@ -1,77 +1,46 @@
# GeekDesk 极客桌面
小巧、**美观**的桌面快速启动管理工具
———— 大风, 雨夜...
「你来了」
「我来了」
谈一谈做GeekDesk的原因:
「你究竟想干什么!」
「我想做一款软件, 这个软件要Cool」
「什么软件?」
「从最常用的桌面开始吧」
目前的市场上也有一部分桌面图标管理工具, 但是**界面好点的收费**, **免费的界面差**
**windows11**都来了, 难道还要用界面停留在**win7时代**的软件吗
「哼!现在的软件多入牛毛, 会差你一个吗」
「我不知道, 但是我想做」
所以就萌生了做这款软件的想法, **免费 / 美观 / 高度定制化** 是从GeekDesk诞生开始就有的需求和方向, 未来也会向着这些方向发展
目前GeekDesk只有一个人在开发, 大家如果有好的建议也可以提Issue
「你以为凭你一个人的力量能在这大海里掀起什么波浪吗」
「但只要我想就够了, 这是我的梦想!」
「梦想? 可笑, 这世界哪有什么梦想. 不过是一日三餐, 车子和房!」
「我想...就够了...」
「...」
———— 雨停, 狂风仍在呼啸...
<img src="https://s4.ax1x.com/2021/12/15/TSrwfU.png" a border="0" width="800px"/>
**免费 / 美观 / 高度定制化** 是从GeekDesk诞生开始就有的需求和方向, 未来也会向着这些方向发展
目前GeekDesk只有一个人在开发所以想法有限, 大家如果有好的建议也可以提Issue
另外如果你喜欢 GeekDesk的话, 或许可以为作者购买防脱洗发水
当然, 点个**Star**也是对作者的激励哦~ 😊😊😊
### GitHub
[https://github.com/Demo-Liu/GeekDesk](https://github.com/Demo-Liu/GeekDesk)
### 码云
[https://gitee.com/demo_liu/GeekDesk](https://gitee.com/demo_liu/GeekDesk)
<img src="https://z3.ax1x.com/2021/07/20/WYdfmR.jpg" alt="WYdfmR.jpg" border="0" width="400px"/>
## 开发框架
- wpf
- .net 4.7.2
- [HandyControl](https://github.com/HandyOrg/HandyControl)
## 全局热键 一键呼出 鼠标跟随
- 自定义热键 设置并使用自己习惯的快捷键
- 一键呼出 使用鼠标中键呼出
- 鼠标跟随 自动追随鼠标位置
<img src="https://s4.ax1x.com/2021/12/15/TSlg8f.gif" alt="WJt4hQ.gif" border="0" width="800px"/>
## 全局热键 鼠标跟随 快速启动 随时随地
- 支持自定义热键
- 支持鼠标跟随
<img src="https://z3.ax1x.com/2021/07/19/WJt4hQ.gif" alt="WJt4hQ.gif" border="0" width="800px"/>
## 自定义壁纸
- 随意选择自己喜欢的壁纸
<img src="https://s4.ax1x.com/2021/12/15/TSNx4H.gif" alt="WJt4hQ.gif" border="0" width="800px"/>
[![WJlcIs.md.jpg](https://z3.ax1x.com/2021/07/19/WJlcIs.md.jpg)](https://imgtu.com/i/WJlcIs)
## 毛玻璃等界面效果
- 背景图片毛玻璃效果
- 界面透明度
- 界面圆角
<img src="https://s4.ax1x.com/2021/12/15/TSabTO.gif" alt="WGOYSU.gif" border="0" width="800px"/>
<img src="https://z3.ax1x.com/2021/07/19/WGOYSU.gif" alt="WGOYSU.gif" border="0" width="800px"/>
## 自定义菜单图标
- 80多个系统图标可供选择
- 另支持在线导入阿里巴巴icon图标
- ~~篇幅原因,公众号内回复 **自定义图标** 可以查看教程~~ 现在软件内已经贴上教程链接啦 也欢迎大家关注我的公众号:blush:
<img src="https://s4.ax1x.com/2021/12/15/TSd1NF.gif" border="0" width="800px"/>
- 篇幅原因,公众号内回复 **自定义图标** 可以查看教程
<img src="https://z3.ax1x.com/2021/07/19/WJ3fDU.png" alt="WJ3fDU.png" border="0" width="450px"/>
## 定时提醒 永不忘记
- 快捷键快速新建待办事项
<img src="https://s4.ax1x.com/2021/12/15/TSDCvj.gif" alt="WJU6df.gif" border="0" width="800px"/>
<img src="https://z3.ax1x.com/2021/07/19/WJU6df.gif" alt="WJU6df.gif" border="0" width="800px"/>
## 开发框架
- wpf
- .net 4.7.2
- [HandyControl](https://github.com/HandyOrg/HandyControl)
## Stargazers over time
[![Stargazers over time](https://starchart.cc/Demo-Liu/GeekDesk.svg)](https://starchart.cc/Demo-Liu/GeekDesk)
## LICENSE
- 这是个人开发的程序,任何人可任意修改和免费使用(未做较大功能性改动不允许修改赞赏码,重新修改发布需注明出处)
- 商用需联系作者

View File

@@ -0,0 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF">
<!--组合动画-->
</ResourceDictionary>

31
Task/ShowSecondTask.cs Normal file
View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace GeekDesk.Task
{
internal class ShowSecondTask
{
public static void SHowSecond()
{
System.Timers.Timer timer = new System.Timers.Timer
{
Enabled = true,
Interval = 5000
};
timer.Start();
timer.Elapsed += Timer_Elapsed;
}
private static void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Process[] pcArr = Process.GetProcessesByName("ShellExperienceHost.exe");
Thread.Sleep(1000);
}
}
}

View File

@@ -60,7 +60,7 @@ namespace GeekDesk.Task
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
}
}
}
#region

View File

@@ -1,9 +1,9 @@
{
"title": "GeekDesk版本更新",
"subTitle": "V2.4.15",
"subTitle": "V2.5.11",
"msgTitle": "本次更新内容如下",
"msg": "['PS:又一次的更新, 虽然还有很多需求没有完成, 但仍然耗费了我大量精力, 没有点Star的兄弟萌, 求个免费Star(GitHub国内某些用户可能进不去), 再给我一点更新的动力!','增加纯色/渐变色背景','增加/优化拾色器功能','增加主面板Logo开关','优化待办任务,现在待办任务快捷键不再是新建待办窗口','增加鼠标滚轮切换菜单功能(需要鼠标指针在菜单栏)','优化搜索功能,增加 快捷键搜索/按键即搜 可选操作','优化贴边隐藏动画, 纵享丝滑了属于是兄弟萌', '其它已知问题修复']",
"githubUrl": "https://github.com/Demo-Liu/GeekDesk/releases",
"msg": "['依旧耗费了我大量精力开发,希望大家去给我点个免费的Star', '这个版本有一些优化点, 大家可以自行探索, 另外征集新Logo的设计, 要求美观并能体现\\'极客\\'风格','本次重新打包了程序文件(文件目录更清爽了,注意,这次不要使用覆盖升级(2.5.10可覆盖)), 可以将旧版本根目录下的Data文件复制到新版本根目录, 然后使用新版本启动','修复了2.5.10版本部分相对路径创建导致启动崩溃的bug','增加可拖动图标到其它菜单的功能,取消了拖动时的动画','增加了列表展开动画的开关','增加了数据备份功能','优化大部分动画','优化搜索功能(达到了可只用键盘或只用鼠标启动所需目标)','增加了相对路径(实验性,可能有bug)','增加列表加密功能(实验性,可能有bug)','其它已知问题修复']",
"githubUrl": "https://github.com/BookerLiu/GeekDesk/releases",
"giteeUrl": "https://gitee.com/BookerLiu/GeekDesk/releases",
"version": "2.4.15"
"version": "2.5.11"
}

View File

@@ -45,7 +45,7 @@ namespace GeekDesk.Util
else
{
LinearGradientBrush lgb = new LinearGradientBrush();
lgb.Opacity = (double)(Math.Round((decimal)(appConfig.BgOpacity / 100.00), 2));
GradientStop gs = new GradientStop
{
Color = (Color)ColorConverter.ConvertFromString(appConfig.GradientBGParam.Color1),

77
Util/BlurGlassUtil.cs Normal file
View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interop;
namespace GeekDesk.Util
{
public class BlurGlassUtil
{
internal enum AccentState
{
ACCENT_DISABLED = 1,
ACCENT_ENABLE_GRADIENT = 0,
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
ACCENT_ENABLE_BLURBEHIND = 3,
ACCENT_INVALID_STATE = 4
}
[StructLayout(LayoutKind.Sequential)]
internal struct AccentPolicy
{
public AccentState AccentState;
public int AccentFlags;
public int GradientColor;
public int AnimationId;
}
[StructLayout(LayoutKind.Sequential)]
internal struct WindowCompositionAttributeData
{
public WindowCompositionAttribute Attribute;
public IntPtr Data;
public int SizeOfData;
}
internal enum WindowCompositionAttribute
{
// ...
WCA_ACCENT_POLICY = 19
// ...
}
[DllImport("user32.dll")]
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
public static void EnableBlur(Window window)
{
WindowInteropHelper windowHelper = new WindowInteropHelper(window);
AccentPolicy accent = new AccentPolicy
{
AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND
};
int accentStructSize = Marshal.SizeOf(accent);
IntPtr accentPtr = Marshal.AllocHGlobal(accentStructSize);
Marshal.StructureToPtr(accent, accentPtr, false);
WindowCompositionAttributeData data = new WindowCompositionAttributeData
{
Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
SizeOfData = accentStructSize,
Data = accentPtr
};
SetWindowCompositionAttribute(windowHelper.Handle, ref data);
Marshal.FreeHGlobal(accentPtr);
}
}
}

View File

@@ -1,5 +1,9 @@
using GeekDesk.Constant;
using GeekDesk.Control.Other;
using GeekDesk.ViewModel;
using HandyControl.Data;
using Microsoft.Win32;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -8,6 +12,7 @@ using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows;
using System.Windows.Media.Imaging;
using static GeekDesk.Control.Other.GlobalMsgNotification;
/// <summary>
/// 提取一些代码
@@ -28,30 +33,112 @@ namespace GeekDesk.Util
{
using (FileStream fs = File.Create(Constants.DATA_FILE_PATH)) { }
appData = new AppData();
SaveAppData(appData);
SaveAppData(appData, Constants.DATA_FILE_PATH);
}
else
{
using (FileStream fs = new FileStream(Constants.DATA_FILE_PATH, FileMode.Open))
try
{
BinaryFormatter bf = new BinaryFormatter();
appData = bf.Deserialize(fs) as AppData;
using (FileStream fs = new FileStream(Constants.DATA_FILE_PATH, FileMode.Open))
{
BinaryFormatter bf = new BinaryFormatter();
appData = bf.Deserialize(fs) as AppData;
}
}
catch
{
if (File.Exists(Constants.DATA_FILE_BAK_PATH))
{
try
{
using (FileStream fs = new FileStream(Constants.DATA_FILE_BAK_PATH, FileMode.Open))
{
BinaryFormatter bf = new BinaryFormatter();
appData = bf.Deserialize(fs) as AppData;
}
DialogMsg msg = new DialogMsg();
msg.msg = "不幸的是, GeekDesk当前的数据文件已经损坏, " +
"现在已经启用系统自动备份的数据\n\n" +
"如果你有较新的备份, " +
"请退出GeekDesk, " +
"将备份文件重命名为:Data, " +
"然后将Data覆盖到GeekDesk的根目录即可\n\n" +
"系统上次备份时间: \n" + appData.AppConfig.SysBakTime +
"\n\n如果当前数据就是你想要的数据, 那么请不用管它";
GlobalMsgNotification gm = new GlobalMsgNotification(msg);
HandyControl.Controls.Notification ntf = HandyControl.Controls.Notification.Show(gm, ShowAnimation.Fade, true);
gm.ntf = ntf;
} catch
{
MessageBox.Show("不幸的是, GeekDesk当前的数据文件已经损坏\n如果你有备份, 请将备份文件重命名为:Data 然后将Data覆盖到GeekDesk的根目录即可!");
Application.Current.Shutdown();
return null;
}
} else
{
MessageBox.Show("不幸的是, GeekDesk当前的数据文件已经损坏\n如果你有备份, 请将备份文件重命名为:Data 然后将Data覆盖到GeekDesk的根目录即可!");
Application.Current.Shutdown();
return null;
}
}
}
return appData;
}
private readonly static object _MyLock = new object();
/// <summary>
/// 保存app 数据
/// </summary>
/// <param name="appData"></param>
public static void SaveAppData(AppData appData)
public static void SaveAppData(AppData appData, string filePath)
{
using (FileStream fs = new FileStream(Constants.DATA_FILE_PATH, FileMode.Create))
lock (_MyLock)
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, appData);
if (filePath.Equals(Constants.DATA_FILE_BAK_PATH))
{
appData.AppConfig.SysBakTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
if (!Directory.Exists(filePath.Substring(0, filePath.LastIndexOf("\\"))))
{
Directory.CreateDirectory(filePath.Substring(0, filePath.LastIndexOf("\\")));
}
using (FileStream fs = new FileStream(filePath, FileMode.Create))
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, appData);
}
}
}
public static void SavePassword(string password)
{
using (StreamWriter sw = new StreamWriter(Constants.PW_FILE_BAK_PATH))
{
sw.Write(password);
}
}
public static void BakAppData()
{
SaveFileDialog sfd = new SaveFileDialog
{
Title = "备份文件",
Filter = "bak文件(*.bak)|*.bak",
FileName = "Data-GD-" + DateTime.Now.ToString("yyMMdd") + ".bak",
};
if (sfd.ShowDialog() == true)
{
using (FileStream fs = new FileStream(sfd.FileName, FileMode.Create))
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, MainWindow.appData);
}
}
}
@@ -92,7 +179,7 @@ namespace GeekDesk.Util
// ext = System.IO.Path.GetExtension(path).ToLower();
//}
string iconPath = null;
string iconPath;
//if (".lnk".Equals(ext))
//{
@@ -111,16 +198,21 @@ namespace GeekDesk.Util
BitmapImage bi = ImageUtil.GetBitmapIconByPath(iconPath);
IconInfo iconInfo = new IconInfo
{
Path = path,
LnkPath = tempPath,
BitmapImage = bi,
StartArg = FileUtil.GetArgByLnk(tempPath)
Path_NoWrite = path,
LnkPath_NoWrite = tempPath,
BitmapImage_NoWrite = bi,
StartArg_NoWrite = FileUtil.GetArgByLnk(tempPath)
};
iconInfo.DefaultImage = iconInfo.ImageByteArr;
iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(tempPath);
iconInfo.DefaultImage_NoWrite = iconInfo.ImageByteArr;
iconInfo.Name_NoWrite = System.IO.Path.GetFileNameWithoutExtension(tempPath);
if (StringUtil.IsEmpty(iconInfo.Name))
{
iconInfo.Name = path;
iconInfo.Name_NoWrite = path;
}
string relativePath = FileUtil.MakeRelativePath(Constants.APP_DIR + "GeekDesk.exe", iconInfo.Path);
if (!string.IsNullOrEmpty(relativePath) && !relativePath.Equals(iconInfo.Path))
{
iconInfo.RelativePath_NoWrite = relativePath;
}
return iconInfo;
}

175
Util/DragAdorner.cs Normal file
View File

@@ -0,0 +1,175 @@
// Copyright (C) Josh Smith - January 2007
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Documents;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Controls;
namespace GeekDesk.Util
{
/// <summary>
/// Renders a visual which can follow the mouse cursor,
/// such as during a drag-and-drop operation.
/// </summary>
public class DragAdorner : Adorner
{
#region Data
private Rectangle child = null;
private double offsetLeft = 0;
private double offsetTop = 0;
#endregion // Data
#region Constructor
/// <summary>
/// Initializes a new instance of DragVisualAdorner.
/// </summary>
/// <param name="adornedElement">The element being adorned.</param>
/// <param name="size">The size of the adorner.</param>
/// <param name="brush">A brush to with which to paint the adorner.</param>
public DragAdorner( UIElement adornedElement, Size size, Brush brush )
: base( adornedElement )
{
Rectangle rect = new Rectangle();
rect.Fill = brush;
rect.Width = size.Width;
rect.Height = size.Height;
rect.IsHitTestVisible = false;
this.child = rect;
}
#endregion // Constructor
#region Public Interface
#region GetDesiredTransform
/// <summary>
/// Override.
/// </summary>
/// <param name="transform"></param>
/// <returns></returns>
public override GeneralTransform GetDesiredTransform( GeneralTransform transform )
{
GeneralTransformGroup result = new GeneralTransformGroup();
result.Children.Add( base.GetDesiredTransform( transform ) );
result.Children.Add( new TranslateTransform( this.offsetLeft, this.offsetTop ) );
return result;
}
#endregion // GetDesiredTransform
#region OffsetLeft
/// <summary>
/// Gets/sets the horizontal offset of the adorner.
/// </summary>
public double OffsetLeft
{
get { return this.offsetLeft; }
set
{
this.offsetLeft = value;
UpdateLocation();
}
}
#endregion // OffsetLeft
#region SetOffsets
/// <summary>
/// Updates the location of the adorner in one atomic operation.
/// </summary>
/// <param name="left"></param>
/// <param name="top"></param>
public void SetOffsets( double left, double top )
{
this.offsetLeft = left;
this.offsetTop = top;
this.UpdateLocation();
}
#endregion // SetOffsets
#region OffsetTop
/// <summary>
/// Gets/sets the vertical offset of the adorner.
/// </summary>
public double OffsetTop
{
get { return this.offsetTop; }
set
{
this.offsetTop = value;
UpdateLocation();
}
}
#endregion // OffsetTop
#endregion // Public Interface
#region Protected Overrides
/// <summary>
/// Override.
/// </summary>
/// <param name="constraint"></param>
/// <returns></returns>
protected override Size MeasureOverride( Size constraint )
{
this.child.Measure( constraint );
return this.child.DesiredSize;
}
/// <summary>
/// Override.
/// </summary>
/// <param name="finalSize"></param>
/// <returns></returns>
protected override Size ArrangeOverride( Size finalSize )
{
this.child.Arrange( new Rect( finalSize ) );
return finalSize;
}
/// <summary>
/// Override.
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
protected override Visual GetVisualChild( int index )
{
return this.child;
}
/// <summary>
/// Override. Always returns 1.
/// </summary>
protected override int VisualChildrenCount
{
get { return 1; }
}
#endregion // Protected Overrides
#region Private Helpers
private void UpdateLocation()
{
AdornerLayer adornerLayer = this.Parent as AdornerLayer;
if( adornerLayer != null )
adornerLayer.Update( this.AdornedElement );
}
#endregion // Private Helpers
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
@@ -10,16 +11,31 @@ namespace GeekDesk.Util
{
public class FileIcon
{
private static List<string> GetBlurExts()
{
List<string> list = new List<string>();
list.Add(".exe");
list.Add(".cer");
list.Add(".lnk");
return list;
static List<string> blurExtsList;
static List<int[]> pixelList;
static FileIcon() {
blurExtsList = new List<string>
{
".exe",
".cer",
".lnk",
".chm"
};
pixelList = new List<int[]>
{
new int[]{ 256 / 4, 256 / 4 },
new int[]{ 256 / 2, 256 / 4 },
new int[]{ 256 / 4 * 3, 256 / 4 },
new int[]{ 256 / 4, 256 / 2 },
new int[]{ 256 / 4, 256 / 4 * 3 },
new int[]{ 256 / 4 * 3, 256 / 2 },
new int[]{ 256 / 4 * 3, 256 / 4 * 3 },
new int[]{ 256 / 2, 256 / 4 * 3 },
};
}
[DllImport("User32.dll")]
public static extern int PrivateExtractIcons(
string lpszFile, //文件名可以是exe,dll,ico,cur,ani,bmp
@@ -53,7 +69,7 @@ namespace GeekDesk.Util
ip = hIcons[0];
ico = Icon.FromHandle(ip);
}
else if (GetBlurExts().Contains(ext))
else if (blurExtsList.Contains(ext))
{
ico = Icon.ExtractAssociatedIcon(filePath);
}
@@ -61,8 +77,14 @@ namespace GeekDesk.Util
{
ip = GetJumboIcon(GetIconIndex(filePath));
ico = Icon.FromHandle(ip);
if (CheckIsSmallIco(ico.ToBitmap()))
{
ico = Icon.ExtractAssociatedIcon(filePath);
}
}
Bitmap bmp = ico.ToBitmap();
MemoryStream strm = new MemoryStream();
@@ -73,6 +95,7 @@ namespace GeekDesk.Util
myEncoderParameters.Param[0] = myEncoderParameter;
bmp.Save(strm, myImageCodecInfo, myEncoderParameters);
BitmapImage bmpImage = new BitmapImage();
bmpImage.BeginInit();
strm.Seek(0, SeekOrigin.Begin);
@@ -82,6 +105,7 @@ namespace GeekDesk.Util
{
Shell32.DestroyIcon(ip);
}
DeleteObject(bmp.GetHbitmap());
return bmpImage.Clone();
}
@@ -98,6 +122,30 @@ namespace GeekDesk.Util
return null;
}
private static bool CheckIsSmallIco(Bitmap bm)
{
Color color;
int count = 0;
foreach (int[] arr in pixelList)
{
color = bm.GetPixel(arr[0], arr[1]);
if (color.A == 0)
{
count++;
}
}
DeleteObject(bm.GetHbitmap());
if (count >= 6)
{
return true;
}
return false;
}
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr onj);
public static int GetIconIndex(string pszFile)

View File

@@ -1,5 +1,6 @@
using IWshRuntimeLibrary;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
@@ -156,5 +157,27 @@ namespace GeekDesk.Util
}
}
public static string MakeRelativePath(string fromPath, string toPath)
{
string relativePath = null;
try
{
if (string.IsNullOrEmpty(toPath) || string.IsNullOrEmpty(fromPath)) return null;
Uri file = new Uri(@toPath);
// Must end in a slash to indicate folder
Uri folder = new Uri(@fromPath);
relativePath =
Uri.UnescapeDataString(
folder.MakeRelativeUri(file)
.ToString()
.Replace('/', Path.DirectorySeparatorChar)
);
} catch (Exception ex)
{
LogUtil.WriteErrorLog(ex, "建立相对路径出错:fromPath:" + fromPath + ",toPath:" + toPath);
}
return relativePath;
}
}
}

View File

@@ -0,0 +1,892 @@
// Copyright (C) Josh Smith - January 2007
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Input;
using GeekDesk.Util;
using GeekDesk.Constant;
using HandyControl.Controls;
namespace GeekDesk.Util
{
#region ListBoxDragDropManager
/// <summary>
/// Manages the dragging and dropping of ListBoxItems in a ListBox.
/// The ItemType type parameter indicates the type of the objects in
/// the ListBox's items source. The ListBox's ItemsSource must be
/// set to an instance of ObservableCollection of ItemType, or an
/// Exception will be thrown.
/// </summary>
/// <typeparam name="ItemType">The type of the ListBox's items.</typeparam>
public class ListBoxDragDropManager<ItemType> where ItemType : class
{
#region Data
bool canInitiateDrag;
DragAdorner dragAdorner;
double dragAdornerOpacity;
int indexToSelect;
bool isDragInProgress;
ItemType itemUnderDragCursor;
ListBox listBox;
Point ptMouseDown;
bool showDragAdorner;
#endregion // Data
#region Constructors
/// <summary>
/// Initializes a new instance of ListBoxDragManager.
/// </summary>
public ListBoxDragDropManager()
{
this.canInitiateDrag = false;
this.dragAdornerOpacity = 0.7;
this.indexToSelect = -1;
this.showDragAdorner = true;
}
/// <summary>
/// Initializes a new instance of ListBoxDragManager.
/// </summary>
/// <param name="listBox"></param>
public ListBoxDragDropManager( ListBox listBox )
: this()
{
this.ListBox = listBox;
}
/// <summary>
/// Initializes a new instance of ListBoxDragManager.
/// </summary>
/// <param name="listBox"></param>
/// <param name="dragAdornerOpacity"></param>
public ListBoxDragDropManager( ListBox listBox, double dragAdornerOpacity )
: this( listBox )
{
this.DragAdornerOpacity = dragAdornerOpacity;
}
/// <summary>
/// Initializes a new instance of ListBoxDragManager.
/// </summary>
/// <param name="listBox"></param>
/// <param name="showDragAdorner"></param>
public ListBoxDragDropManager( ListBox listBox, bool showDragAdorner )
: this( listBox )
{
this.ShowDragAdorner = showDragAdorner;
}
#endregion // Constructors
#region Public Interface
#region DragAdornerOpacity
/// <summary>
/// Gets/sets the opacity of the drag adorner. This property has no
/// effect if ShowDragAdorner is false. The default value is 0.7
/// </summary>
public double DragAdornerOpacity
{
get { return this.dragAdornerOpacity; }
set
{
if( this.IsDragInProgress )
throw new InvalidOperationException( "Cannot set the DragAdornerOpacity property during a drag operation." );
if( value < 0.0 || value > 1.0 )
throw new ArgumentOutOfRangeException( "DragAdornerOpacity", value, "Must be between 0 and 1." );
this.dragAdornerOpacity = value;
}
}
#endregion // DragAdornerOpacity
#region IsDragInProgress
/// <summary>
/// Returns true if there is currently a drag operation being managed.
/// </summary>
public bool IsDragInProgress
{
get { return this.isDragInProgress; }
private set { this.isDragInProgress = value; }
}
#endregion // IsDragInProgress
#region ListBox
/// <summary>
/// Gets/sets the ListBox whose dragging is managed. This property
/// can be set to null, to prevent drag management from occuring. If
/// the ListBox's AllowDrop property is false, it will be set to true.
/// </summary>
public ListBox ListBox
{
get { return listBox; }
set
{
if( this.IsDragInProgress )
throw new InvalidOperationException( "Cannot set the ListBox property during a drag operation." );
if( this.listBox != null )
{
#region Unhook Events
this.listBox.PreviewMouseLeftButtonDown -= LIstBox_PreviewMouseLeftButtonDown;
this.listBox.PreviewMouseMove -= LIstBox_PreviewMouseMove;
this.listBox.DragOver -= LIstBox_DragOver;
this.listBox.DragLeave -= LIstBox_DragLeave;
this.listBox.DragEnter -= LIstBox_DragEnter;
this.listBox.Drop -= LIstBox_Drop;
#endregion // Unhook Events
}
this.listBox = value;
if( this.listBox != null )
{
if( !this.listBox.AllowDrop )
this.listBox.AllowDrop = true;
#region Hook Events
this.listBox.PreviewMouseLeftButtonDown += LIstBox_PreviewMouseLeftButtonDown;
this.listBox.PreviewMouseMove += LIstBox_PreviewMouseMove;
this.listBox.DragOver += LIstBox_DragOver;
this.listBox.DragLeave += LIstBox_DragLeave;
this.listBox.DragEnter += LIstBox_DragEnter;
this.listBox.Drop += LIstBox_Drop;
#endregion // Hook Events
}
}
}
#endregion // ListBox
#region ProcessDrop [event]
/// <summary>
/// Raised when a drop occurs. By default the dropped item will be moved
/// to the target index. Handle this event if relocating the dropped item
/// requires custom behavior. Note, if this event is handled the default
/// item dropping logic will not occur.
/// </summary>
public event EventHandler<ProcessDropEventArgs<ItemType>> ProcessDrop;
#endregion // ProcessDrop [event]
#region ShowDragAdorner
/// <summary>
/// Gets/sets whether a visual representation of the ListBoxItem being dragged
/// follows the mouse cursor during a drag operation. The default value is true.
/// </summary>
public bool ShowDragAdorner
{
get { return this.showDragAdorner; }
set
{
if( this.IsDragInProgress )
throw new InvalidOperationException( "Cannot set the ShowDragAdorner property during a drag operation." );
this.showDragAdorner = value;
}
}
#endregion // ShowDragAdorner
#endregion // Public Interface
#region Event Handling Methods
#region LIstBox_PreviewMouseLeftButtonDown
void LIstBox_PreviewMouseLeftButtonDown( object sender, MouseButtonEventArgs e )
{
if( this.IsMouseOverScrollbar )
{
// 4/13/2007 - Set the flag to false when cursor is over scrollbar.
this.canInitiateDrag = false;
return;
}
int index = this.IndexUnderDragCursor;
this.canInitiateDrag = index > -1;
if( this.canInitiateDrag )
{
// Remember the location and index of the ListBoxItem the user clicked on for later.
this.ptMouseDown = MouseUtil.GetMousePosition();
//this.ptMouseDown = MouseUtil.GetMousePosition( this.listBox );
this.indexToSelect = index;
}
else
{
this.ptMouseDown = new Point( -10000, -10000 );
this.indexToSelect = -1;
}
}
#endregion // LIstBox_PreviewMouseLeftButtonDown
#region LIstBox_PreviewMouseMove
void LIstBox_PreviewMouseMove( object sender, MouseEventArgs e )
{
if( !this.CanStartDragOperation )
return;
// Select the item the user clicked on.
if( this.listBox.SelectedIndex != this.indexToSelect )
this.listBox.SelectedIndex = this.indexToSelect;
// If the item at the selected index is null, there's nothing
// we can do, so just return;
if( this.listBox.SelectedItem == null )
return;
ListBoxItem itemToDrag = this.GetListBoxItem( this.listBox.SelectedIndex );
if( itemToDrag == null )
return;
AdornerLayer adornerLayer = this.ShowDragAdornerResolved ? this.InitializeAdornerLayer( itemToDrag ) : null;
this.InitializeDragOperation( itemToDrag );
this.PerformDragOperation();
this.FinishDragOperation( itemToDrag, adornerLayer );
}
#endregion // LIstBox_PreviewMouseMove
#region LIstBox_DragOver
void LIstBox_DragOver( object sender, DragEventArgs e )
{
e.Effects = DragDropEffects.Move;
if ( this.ShowDragAdornerResolved )
this.UpdateDragAdornerLocation();
// Update the item which is known to be currently under the drag cursor.
int index = this.IndexUnderDragCursor;
this.ItemUnderDragCursor = index < 0 ? null : this.ListBox.Items[index] as ItemType;
}
#endregion // LIstBox_DragOver
#region LIstBox_DragLeave
void LIstBox_DragLeave( object sender, DragEventArgs e )
{
if( !this.IsMouseOver( this.listBox ) )
{
if( this.ItemUnderDragCursor != null )
this.ItemUnderDragCursor = null;
if( this.dragAdorner != null )
this.dragAdorner.Visibility = Visibility.Collapsed;
}
}
#endregion // LIstBox_DragLeave
#region LIstBox_DragEnter
void LIstBox_DragEnter( object sender, DragEventArgs e )
{
if( this.dragAdorner != null && this.dragAdorner.Visibility != Visibility.Visible )
{
// Update the location of the adorner and then show it.
this.UpdateDragAdornerLocation();
this.dragAdorner.Visibility = Visibility.Visible;
}
}
#endregion // LIstBox_DragEnter
#region LIstBox_Drop
void LIstBox_Drop( object sender, DragEventArgs e )
{
if( this.ItemUnderDragCursor != null )
this.ItemUnderDragCursor = null;
e.Effects = DragDropEffects.None;
if( !e.Data.GetDataPresent( typeof( ItemType ) ) )
return;
// Get the data object which was dropped.
ItemType data = e.Data.GetData( typeof( ItemType ) ) as ItemType;
if( data == null )
return;
// Get the ObservableCollection<ItemType> which contains the dropped data object.
ObservableCollection<ItemType> itemsSource = this.listBox.ItemsSource as ObservableCollection<ItemType>;
if( itemsSource == null )
throw new Exception(
"A ListBox managed by ListBoxDragManager must have its ItemsSource set to an ObservableCollection<ItemType>." );
int oldIndex = itemsSource.IndexOf( data );
int newIndex = this.IndexUnderDragCursor;
if( newIndex < 0 )
{
// The drag started somewhere else, and our ListBox is empty
// so make the new item the first in the list.
if( itemsSource.Count == 0 )
newIndex = 0;
// The drag started somewhere else, but our ListBox has items
// so make the new item the last in the list.
else if( oldIndex < 0 )
newIndex = itemsSource.Count;
// The user is trying to drop an item from our ListBox into
// our ListBox, but the mouse is not over an item, so don't
// let them drop it.
else
return;
}
// Dropping an item back onto itself is not considered an actual 'drop'.
if( oldIndex == newIndex )
return;
if( this.ProcessDrop != null )
{
// Let the client code process the drop.
ProcessDropEventArgs<ItemType> args = new ProcessDropEventArgs<ItemType>( itemsSource, data, oldIndex, newIndex, e.AllowedEffects );
this.ProcessDrop( this, args );
e.Effects = args.Effects;
}
else
{
// Move the dragged data object from it's original index to the
// new index (according to where the mouse cursor is). If it was
// not previously in the ListBox, then insert the item.
if( oldIndex > -1 )
{
// <20>ⲿҵ<E2B2BF><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
itemsSource.Move(oldIndex, newIndex);
if (MainWindow.appData.AppConfig.IconSortType != SortType.CUSTOM)
{
MainWindow.appData.AppConfig.IconSortType = SortType.CUSTOM;
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed
|| MainWindow.mainWindow.Opacity != 1)
{
Growl.WarningGlobal("<22>ѽ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>!");
}
else
{
Growl.Warning("<22>ѽ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>!", "MainWindowGrowl");
}
}
}
else
{
itemsSource.Insert(newIndex, data);
}
// Set the Effects property so that the call to DoDragDrop will return 'Move'.
e.Effects = DragDropEffects.Move;
}
}
#endregion // LIstBox_Drop
#endregion // Event Handling Methods
#region Private Helpers
#region CanStartDragOperation
bool CanStartDragOperation
{
get
{
if( Mouse.LeftButton != MouseButtonState.Pressed )
return false;
if( !this.canInitiateDrag )
return false;
if( this.indexToSelect == -1 )
return false;
if( !this.HasCursorLeftDragThreshold )
return false;
return true;
}
}
#endregion // CanStartDragOperation
#region FinishDragOperation
void FinishDragOperation( ListBoxItem draggedItem, AdornerLayer adornerLayer )
{
// Let the ListBoxItem know that it is not being dragged anymore.
ListBoxItemDragState.SetIsBeingDragged( draggedItem, false );
this.IsDragInProgress = false;
if( this.ItemUnderDragCursor != null )
this.ItemUnderDragCursor = null;
// Remove the drag adorner from the adorner layer.
if( adornerLayer != null )
{
adornerLayer.Remove( this.dragAdorner );
this.dragAdorner = null;
}
}
#endregion // FinishDragOperation
#region GetListBoxItem
ListBoxItem GetListBoxItem( int index )
{
if( this.listBox.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated )
return null;
return this.listBox.ItemContainerGenerator.ContainerFromIndex( index ) as ListBoxItem;
}
ListBoxItem GetListBoxItem( ItemType dataItem )
{
if( this.listBox.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated )
return null;
return this.listBox.ItemContainerGenerator.ContainerFromItem( dataItem ) as ListBoxItem;
}
#endregion // GetListBoxItem
#region HasCursorLeftDragThreshold
bool HasCursorLeftDragThreshold
{
get
{
if( this.indexToSelect < 0 )
return false;
ListBoxItem item = this.GetListBoxItem( this.indexToSelect );
Rect bounds = VisualTreeHelper.GetDescendantBounds( item );
Point ptInItem = this.listBox.TranslatePoint( this.ptMouseDown, item );
// In case the cursor is at the very top or bottom of the ListBoxItem
// we want to make the vertical threshold very small so that dragging
// over an adjacent item does not select it.
double topOffset = Math.Abs( ptInItem.Y );
double btmOffset = Math.Abs( bounds.Height - ptInItem.Y );
double vertOffset = Math.Min( topOffset, btmOffset );
double width = SystemParameters.MinimumHorizontalDragDistance * 2;
double height = Math.Min( SystemParameters.MinimumVerticalDragDistance, vertOffset ) * 2;
Size szThreshold = new Size( width, height );
Rect rect = new Rect( this.ptMouseDown, szThreshold );
rect.Offset( szThreshold.Width / -2, szThreshold.Height / -2 );
//Point ptInListBox = MouseUtil.GetMousePosition(this.listBox);
Point ptInListBox = MouseUtil.GetMousePosition();
return !rect.Contains( ptInListBox );
}
}
#endregion // HasCursorLeftDragThreshold
#region IndexUnderDragCursor
/// <summary>
/// Returns the index of the ListBoxItem underneath the
/// drag cursor, or -1 if the cursor is not over an item.
/// </summary>
int IndexUnderDragCursor
{
get
{
int index = -1;
for( int i = 0; i < this.listBox.Items.Count; ++i )
{
ListBoxItem item = this.GetListBoxItem( i );
if( this.IsMouseOver( item ) )
{
index = i;
break;
}
}
return index;
}
}
#endregion // IndexUnderDragCursor
#region InitializeAdornerLayer
AdornerLayer InitializeAdornerLayer( ListBoxItem itemToDrag )
{
// Create a brush which will paint the ListBoxItem onto
// a visual in the adorner layer.
VisualBrush brush = new VisualBrush( itemToDrag );
// Create an element which displays the source item while it is dragged.
this.dragAdorner = new DragAdorner( this.listBox, itemToDrag.RenderSize, brush );
// Set the drag adorner's opacity.
this.dragAdorner.Opacity = this.DragAdornerOpacity;
AdornerLayer layer = AdornerLayer.GetAdornerLayer( this.listBox );
layer.Add( dragAdorner );
// Save the location of the cursor when the left mouse button was pressed.
this.ptMouseDown = MouseUtil.GetMousePosition(this.listBox);
//this.ptMouseDown = MouseUtil.GetMousePosition();
return layer;
}
#endregion // InitializeAdornerLayer
#region InitializeDragOperation
void InitializeDragOperation( ListBoxItem itemToDrag )
{
// Set some flags used during the drag operation.
this.IsDragInProgress = true;
this.canInitiateDrag = false;
// Let the ListBoxItem know that it is being dragged.
ListBoxItemDragState.SetIsBeingDragged( itemToDrag, true );
}
#endregion // InitializeDragOperation
#region IsMouseOver
bool IsMouseOver( Visual target )
{
// We need to use MouseUtil to figure out the cursor
// coordinates because, during a drag-drop operation, the WPF
// mechanisms for getting the coordinates behave strangely.
Rect bounds = VisualTreeHelper.GetDescendantBounds( target );
Point mousePos = MouseUtil.GetMousePosition( target );
return bounds.Contains( mousePos );
}
#endregion // IsMouseOver
#region IsMouseOverScrollbar
/// <summary>
/// Returns true if the mouse cursor is over a scrollbar in the ListBox.
/// </summary>
bool IsMouseOverScrollbar
{
get
{
Point ptMouse = MouseUtil.GetMousePosition( this.listBox );
HitTestResult res = VisualTreeHelper.HitTest( this.listBox, ptMouse );
if( res == null )
return false;
DependencyObject depObj = res.VisualHit;
while( depObj != null )
{
if( depObj is ScrollBar )
return true;
// VisualTreeHelper works with objects of type Visual or Visual3D.
// If the current object is not derived from Visual or Visual3D,
// then use the LogicalTreeHelper to find the parent element.
if( depObj is Visual || depObj is System.Windows.Media.Media3D.Visual3D )
depObj = VisualTreeHelper.GetParent( depObj );
else
depObj = LogicalTreeHelper.GetParent( depObj );
}
return false;
}
}
#endregion // IsMouseOverScrollbar
#region ItemUnderDragCursor
ItemType ItemUnderDragCursor
{
get { return this.itemUnderDragCursor; }
set
{
if( this.itemUnderDragCursor == value )
return;
// The first pass handles the previous item under the cursor.
// The second pass handles the new one.
for( int i = 0; i < 2; ++i )
{
if( i == 1 )
this.itemUnderDragCursor = value;
if( this.itemUnderDragCursor != null )
{
ListBoxItem listBoxItem = this.GetListBoxItem( this.itemUnderDragCursor );
if( listBoxItem != null )
ListBoxItemDragState.SetIsUnderDragCursor( listBoxItem, i == 1 );
}
}
}
}
#endregion // ItemUnderDragCursor
#region PerformDragOperation
void PerformDragOperation()
{
ItemType selectedItem = this.listBox.SelectedItem as ItemType;
DragDropEffects allowedEffects = DragDropEffects.Move | DragDropEffects.Move | DragDropEffects.Link;
if( DragDrop.DoDragDrop( this.listBox, selectedItem, allowedEffects ) != DragDropEffects.None )
{
// The item was dropped into a new location,
// so make it the new selected item.
this.listBox.SelectedItem = selectedItem;
}
}
#endregion // PerformDragOperation
#region ShowDragAdornerResolved
bool ShowDragAdornerResolved
{
get { return this.ShowDragAdorner && this.DragAdornerOpacity > 0.0; }
}
#endregion // ShowDragAdornerResolved
#region UpdateDragAdornerLocation
void UpdateDragAdornerLocation()
{
if( this.dragAdorner != null )
{
//Point ptCursor = MouseUtil.GetMousePosition(this.ListBox);
Point ptCursor = MouseUtil.GetMousePosition(this.ListBox);
//double left = ptCursor.X - this.ptMouseDown.X;
//double left2 = ptCursor.X;
ListBoxItem itemBeingDragged = this.GetListBoxItem(this.indexToSelect);
// 4/13/2007 - Made the top offset relative to the item being dragged.
Point itemLoc = itemBeingDragged.TranslatePoint( new Point( 0, 0 ), this.ListBox );
double top = itemLoc.Y + ptCursor.Y - this.ptMouseDown.Y;
double left = itemLoc.X + ptCursor.X - this.ptMouseDown.X;
this.dragAdorner.SetOffsets(left, top );
}
}
#endregion // UpdateDragAdornerLocation
#endregion // Private Helpers
}
#endregion // ListBoxDragDropManager
#region ListBoxItemDragState
/// <summary>
/// Exposes attached properties used in conjunction with the ListBoxDragDropManager class.
/// Those properties can be used to allow triggers to modify the appearance of ListBoxItems
/// in a ListBox during a drag-drop operation.
/// </summary>
public static class ListBoxItemDragState
{
#region IsBeingDragged
/// <summary>
/// Identifies the ListBoxItemDragState's IsBeingDragged attached property.
/// This field is read-only.
/// </summary>
public static readonly DependencyProperty IsBeingDraggedProperty =
DependencyProperty.RegisterAttached(
"IsBeingDragged",
typeof( bool ),
typeof( ListBoxItemDragState ),
new UIPropertyMetadata( false ) );
/// <summary>
/// Returns true if the specified ListBoxItem is being dragged, else false.
/// </summary>
/// <param name="item">The ListBoxItem to check.</param>
public static bool GetIsBeingDragged( ListBoxItem item )
{
return (bool)item.GetValue( IsBeingDraggedProperty );
}
/// <summary>
/// Sets the IsBeingDragged attached property for the specified ListBoxItem.
/// </summary>
/// <param name="item">The ListBoxItem to set the property on.</param>
/// <param name="value">Pass true if the element is being dragged, else false.</param>
internal static void SetIsBeingDragged( ListBoxItem item, bool value )
{
item.SetValue( IsBeingDraggedProperty, value );
}
#endregion // IsBeingDragged
#region IsUnderDragCursor
/// <summary>
/// Identifies the ListBoxItemDragState's IsUnderDragCursor attached property.
/// This field is read-only.
/// </summary>
public static readonly DependencyProperty IsUnderDragCursorProperty =
DependencyProperty.RegisterAttached(
"IsUnderDragCursor",
typeof( bool ),
typeof( ListBoxItemDragState ),
new UIPropertyMetadata( false ) );
/// <summary>
/// Returns true if the specified ListBoxItem is currently underneath the cursor
/// during a drag-drop operation, else false.
/// </summary>
/// <param name="item">The ListBoxItem to check.</param>
public static bool GetIsUnderDragCursor( ListBoxItem item )
{
return (bool)item.GetValue( IsUnderDragCursorProperty );
}
/// <summary>
/// Sets the IsUnderDragCursor attached property for the specified ListBoxItem.
/// </summary>
/// <param name="item">The ListBoxItem to set the property on.</param>
/// <param name="value">Pass true if the element is underneath the drag cursor, else false.</param>
internal static void SetIsUnderDragCursor( ListBoxItem item, bool value )
{
item.SetValue( IsUnderDragCursorProperty, value );
}
#endregion // IsUnderDragCursor
}
#endregion // ListBoxItemDragState
#region ProcessDropEventArgs
/// <summary>
/// Event arguments used by the ListBoxDragDropManager.ProcessDrop event.
/// </summary>
/// <typeparam name="ItemType">The type of data object being dropped.</typeparam>
public class ProcessDropEventArgs<ItemType> : EventArgs where ItemType : class
{
#region Data
ObservableCollection<ItemType> itemsSource;
ItemType dataItem;
int oldIndex;
int newIndex;
DragDropEffects allowedEffects = DragDropEffects.None;
DragDropEffects effects = DragDropEffects.None;
#endregion // Data
#region Constructor
internal ProcessDropEventArgs(
ObservableCollection<ItemType> itemsSource,
ItemType dataItem,
int oldIndex,
int newIndex,
DragDropEffects allowedEffects )
{
this.itemsSource = itemsSource;
this.dataItem = dataItem;
this.oldIndex = oldIndex;
this.newIndex = newIndex;
this.allowedEffects = allowedEffects;
}
#endregion // Constructor
#region Public Properties
/// <summary>
/// The items source of the ListBox where the drop occurred.
/// </summary>
public ObservableCollection<ItemType> ItemsSource
{
get { return this.itemsSource; }
}
/// <summary>
/// The data object which was dropped.
/// </summary>
public ItemType DataItem
{
get { return this.dataItem; }
}
/// <summary>
/// The current index of the data item being dropped, in the ItemsSource collection.
/// </summary>
public int OldIndex
{
get { return this.oldIndex; }
}
/// <summary>
/// The target index of the data item being dropped, in the ItemsSource collection.
/// </summary>
public int NewIndex
{
get { return this.newIndex; }
}
/// <summary>
/// The drag drop effects allowed to be performed.
/// </summary>
public DragDropEffects AllowedEffects
{
get { return allowedEffects; }
}
/// <summary>
/// The drag drop effect(s) performed on the dropped item.
/// </summary>
public DragDropEffects Effects
{
get { return effects; }
set { effects = value; }
}
#endregion // Public Properties
}
#endregion // ProcessDropEventArgs
}

View File

@@ -12,7 +12,10 @@ namespace GeekDesk.Util
try
{
Exception ex = exception as Exception;
if (!Directory.Exists(Constants.ERROR_FILE_PATH.Substring(0, Constants.ERROR_FILE_PATH.LastIndexOf("\\"))))
{
Directory.CreateDirectory(Constants.ERROR_FILE_PATH.Substring(0, Constants.ERROR_FILE_PATH.LastIndexOf("\\")));
}
using (FileStream fs = File.Open(Constants.ERROR_FILE_PATH, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
fs.Seek(0, SeekOrigin.End);
@@ -58,6 +61,10 @@ namespace GeekDesk.Util
{
try
{
if (!Directory.Exists(Constants.LOG_FILE_PATH.Substring(0, Constants.LOG_FILE_PATH.LastIndexOf("\\"))))
{
Directory.CreateDirectory(Constants.LOG_FILE_PATH.Substring(0, Constants.LOG_FILE_PATH.LastIndexOf("\\")));
}
using (FileStream fs = File.Open(Constants.LOG_FILE_PATH, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
fs.Seek(0, SeekOrigin.End);

32
Util/MD5Util.cs Normal file
View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Util
{
internal class MD5Util
{
public static string CreateMD5(string input)
{
// Use input string to calculate MD5 hash
using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
{
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
byte[] hashBytes = md5.ComputeHash(inputBytes);
//return Convert.ToHexString(hashBytes); // .NET 5 +
//Convert the byte array to hexadecimal string prior to.NET 5
StringBuilder sb = new System.Text.StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("X2"));
}
return sb.ToString();
}
}
}
}

View File

@@ -25,8 +25,8 @@ namespace GeekDesk.Util
{
private static Window window;//定义使用该方法的窗体
private static readonly int hideTime = 50;
private static readonly int showTime = 30;
private static readonly int hideTime = 65;
private static readonly int showTime = 15;
private static int animalTime;
@@ -77,8 +77,7 @@ namespace GeekDesk.Util
#region
private static void HideWindow(object o, EventArgs e)
{
if (window.Visibility != Visibility.Visible
|| RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW
if (RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW
|| RunTimeStatus.LOCK_APP_PANEL) return;
double screenLeft = SystemParameters.VirtualScreenLeft;
@@ -98,7 +97,7 @@ namespace GeekDesk.Util
//鼠标不在窗口上
if ((mouseX < windowLeft || mouseX > windowLeft + windowWidth
|| mouseY < windowTop || mouseY > windowTop + windowHeight) && !IS_HIDE)
|| mouseY < windowTop || mouseY > windowTop + windowHeight) && !IS_HIDE && window.Visibility == Visibility.Visible)
{
//上方隐藏条件
if (windowTop <= screenTop)
@@ -126,8 +125,9 @@ namespace GeekDesk.Util
}
}
else if (mouseX >= windowLeft && mouseX <= windowLeft + windowWidth
&& mouseY >= windowTop && mouseY <= windowTop + windowHeight && IS_HIDE)
&& mouseY >= windowTop && mouseY <= windowTop + windowHeight && IS_HIDE && window.Visibility != Visibility.Visible)
{
window.Show();
//上方显示
if (windowTop <= screenTop - showMarginWidth)
{
@@ -189,6 +189,7 @@ namespace GeekDesk.Util
double windowTop = window.Top;
double windowLeft = window.Left;
window.Visibility = Visibility.Visible;
//左侧显示
if (windowLeft <= screenLeft - showMarginWidth)
{
@@ -226,17 +227,30 @@ namespace GeekDesk.Util
{
App.Current.Dispatcher.Invoke(() =>
{
double abs = Math.Abs(Math.Abs(to) - Math.Abs(from));
double subLen = abs / hideTime;
if ((int)hideType <= 3)
switch (hideType)
{
case HideType.LEFT_SHOW:
to -= 20;
break;
case HideType.RIGHT_SHOW:
to += 20;
break;
case HideType.TOP_SHOW:
to -= 20;
break;
}
double abs = Math.Abs(Math.Abs(to) - Math.Abs(from));
if (hideType <= HideType.RIGHT_SHOW)
{
animalTime = showTime;
} else
{
animalTime = hideTime;
}
double subLen = abs / animalTime;
int count = 0;
while (count < animalTime)
{
@@ -267,81 +281,20 @@ namespace GeekDesk.Util
switch (hideType)
{
case HideType.LEFT_HIDE:
window.Left = to;
break;
case HideType.LEFT_SHOW:
window.Left = to - 20;
break;
case HideType.RIGHT_HIDE:
window.Left = to;
break;
case HideType.RIGHT_SHOW:
window.Left = to + 20;
break;
case HideType.TOP_HIDE:
window.Top = to;
break;
case HideType.TOP_SHOW:
window.Top = to - 20;
window.Top = to;
break;
default:
window.Left = to;
break;
}
if (hideType > HideType.RIGHT_SHOW)
{
window.Visibility = Visibility.Collapsed;
}
//double toTemp = to;
//double leftT = 0;
//double topT = 0;
//switch (hideType)
//{
// case HideType.LEFT_HIDE:
// to += leftT;
// break;
// case HideType.LEFT_SHOW:
// to -= leftT;
// break;
// case HideType.RIGHT_HIDE:
// to -= leftT;
// break;
// case HideType.RIGHT_SHOW:
// to += leftT;
// break;
// case HideType.TOP_HIDE:
// to += topT;
// break;
// case HideType.TOP_SHOW:
// to -= topT;
// break;
//}
//DoubleAnimation da = new DoubleAnimation
//{
// From = from,
// To = to,
// Duration = new Duration(TimeSpan.FromMilliseconds(hideTime))
//};
//// 如果是显示 则贴屏幕侧不显示阴影
//bool isShow = false;
//int shadowWidthTemp = Constants.SHADOW_WIDTH;
//if (hideType <= HideType.RIGHT_SHOW)
//{
// isShow = true;
// if (hideType == HideType.RIGHT_SHOW)
// {
// shadowWidthTemp = -shadowWidthTemp;
// }
//}
//da.Completed += (s, e) =>
//{
// if ("Top".Equals(property.Name))
// {
// window.Top = isShow ? toTemp - shadowWidthTemp : toTemp;
// }
// else
// {
// window.Left = isShow ? toTemp - shadowWidthTemp : toTemp;
// }
// window.BeginAnimation(property, null);
//};
//Timeline.SetDesiredFrameRate(da, 60);
//window.BeginAnimation(property, da);
});
}).Start();

View File

@@ -1,6 +1,7 @@
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media;
namespace GeekDesk.Util
{
@@ -27,5 +28,27 @@ namespace GeekDesk.Util
GetCursorPos(ref w32Mouse);
return new Point(w32Mouse.X, w32Mouse.Y);
}
public static Point GetMousePosition(Visual relativeTo)
{
Win32Point mouse = new Win32Point();
GetCursorPos(ref mouse);
// Using PointFromScreen instead of Dan Crevier's code (commented out below)
// is a bug fix created by William J. Roberts. Read his comments about the fix
// here: http://www.codeproject.com/useritems/ListViewDragDropManager.asp?msg=1911611#xx1911611xx
return relativeTo.PointFromScreen(new Point((double)mouse.X, (double)mouse.Y));
#region Commented Out
//System.Windows.Interop.HwndSource presentationSource =
// (System.Windows.Interop.HwndSource)PresentationSource.FromVisual( relativeTo );
//ScreenToClient( presentationSource.Handle, ref mouse );
//GeneralTransform transform = relativeTo.TransformToAncestor( presentationSource.RootVisual );
//Point offset = transform.Transform( new Point( 0, 0 ) );
//return new Point( mouse.X - offset.X, mouse.Y - offset.Y );
#endregion // Commented Out
}
}
}

37
Util/RelayCommand.cs Normal file
View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace GeekDesk.Util
{
public class RelayCommand : ICommand
{
private readonly Predicate<object> _canExecute;
private readonly Action<object> _execute;
public RelayCommand(Predicate<object> canExecute, Action<object> execute)
{
_canExecute = canExecute;
_execute = execute;
}
public event EventHandler CanExecuteChanged
{
add => CommandManager.RequerySuggested += value;
remove => CommandManager.RequerySuggested -= value;
}
public bool CanExecute(object parameter)
{
return _canExecute(parameter);
}
public void Execute(object parameter)
{
_execute(parameter);
}
}
}

View File

@@ -21,7 +21,7 @@ namespace GeekDesk.Util
/// <summary>
/// 随鼠标位置显示面板
/// </summary>
public static void Show(Window window, MousePosition position, double widthOffset = 0, double heightOffset = 0, bool visibility = true)
public static void Show(Window window, MousePosition position, double widthOffset = 0, double heightOffset = 0)
{
//获取鼠标位置
System.Windows.Point p = MouseUtil.GetMousePosition();
@@ -101,11 +101,6 @@ namespace GeekDesk.Util
{
window.Top = p.Y - afterHeight;
}
if (visibility)
{
window.Opacity = 0;
window.Visibility = Visibility.Visible;
}
}
}

View File

@@ -93,8 +93,79 @@ namespace GeekDesk.ViewModel
private SearchType searchType;
private string sysBakTime; //系统自动备份时间
private string menuPassword; //锁菜单密码
private string passwordHint; //密码提示
private bool? isShow;
private bool itemSpradeAnimation; //列表展开动画
#region GetSet
public bool ItemSpradeAnimation
{
get
{
return itemSpradeAnimation;
}
set
{
itemSpradeAnimation = value;
OnPropertyChanged("ItemSpradeAnimation");
}
}
public bool? IsShow
{
get
{
return isShow;
}
set
{
isShow = value;
OnPropertyChanged("IsShow");
}
}
public string PasswordHint
{
get
{
return passwordHint;
}
set
{
passwordHint = value;
OnPropertyChanged("PasswordHint");
}
}
public string MenuPassword
{
get
{
return menuPassword;
}
set
{
menuPassword = value;
OnPropertyChanged("MenuPassword");
}
}
public string SysBakTime
{
get
{
return sysBakTime;
}
set
{
sysBakTime = value;
}
}
public SearchType SearchType
{
@@ -898,7 +969,7 @@ namespace GeekDesk.ViewModel
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
#endregion

View File

@@ -1,4 +1,5 @@
using GeekDesk.Util;
using GeekDesk.Constant;
using GeekDesk.Util;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
@@ -88,7 +89,7 @@ namespace GeekDesk.ViewModel
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
}

View File

@@ -1,4 +1,5 @@
using GeekDesk.Util;
using GeekDesk.Constant;
using GeekDesk.Util;
using System;
using System.ComponentModel;
@@ -69,7 +70,7 @@ namespace GeekDesk.ViewModel
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
}

View File

@@ -24,9 +24,36 @@ namespace GeekDesk.ViewModel
private string startArg; //启动参数
private string lnkPath;
private string relativePath; //相对路径
private IconType iconType = IconType.OTHER;
public string RelativePath_NoWrite
{
get
{
return relativePath;
}
set
{
relativePath = value;
}
}
public string RelativePath
{
get
{
return relativePath;
}
set
{
relativePath = value;
OnPropertyChanged("RelativePath");
}
}
public string LnkPath_NoWrite
{
get
@@ -178,6 +205,14 @@ namespace GeekDesk.ViewModel
set
{
name = value;
if (StringUtil.IsEmpty(Path))
{
content = Name + "\n使用次数: " + Count;
}
else
{
content = Path + "\n" + Name + "\n使用次数: " + Count;
}
}
}
@@ -211,6 +246,14 @@ namespace GeekDesk.ViewModel
set
{
path = value;
if (StringUtil.IsEmpty(Path))
{
content = Name + "\n使用次数: " + Count;
}
else
{
content = Path + "\n" + Name + "\n使用次数: " + Count;
}
}
}
@@ -303,7 +346,7 @@ namespace GeekDesk.ViewModel
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}

View File

@@ -20,8 +20,22 @@ namespace GeekDesk.ViewModel
private string menuGeometry; //菜单几何图标
private string geometryColor; //几何图标颜色
private ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
private bool isEncrypt; //是否加密
public bool IsEncrypt
{
get
{
return isEncrypt;
}
set
{
isEncrypt = value;
OnPropertyChanged("IsEncrypt");
}
}
public string MenuGeometry
{
get
@@ -134,7 +148,7 @@ namespace GeekDesk.ViewModel
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
}
}

View File

@@ -133,7 +133,7 @@ namespace GeekDesk.ViewModel
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
CommonCode.SaveAppData(MainWindow.appData);
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
}
}
}

View File

@@ -3,7 +3,10 @@
<package id="CommonServiceLocator" version="2.0.6" targetFramework="net452" requireReinstallation="true" />
<package id="HandyControl" version="3.3.0" targetFramework="net472" />
<package id="KeyMouseHook" version="1.0.6" targetFramework="net472" developmentDependency="true" />
<package id="Microsoft.Build.Tasks.Git" version="1.0.0" targetFramework="net472" developmentDependency="true" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="2.1.1" targetFramework="net472" />
<package id="Microsoft.SourceLink.Common" version="1.0.0" targetFramework="net472" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="1.0.0" targetFramework="net472" developmentDependency="true" />
<package id="MouseKeyHook" version="5.6.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="NPinyin.Core" version="3.0.0" targetFramework="net472" />
@@ -13,5 +16,8 @@
<package id="System.Drawing.Common" version="6.0.0-preview.6.21352.12" targetFramework="net472" />
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Reactive" version="5.0.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="XamlFlair.WPF" version="1.2.13" targetFramework="net472" />
</packages>