diff --git a/App.config b/App.config
index 617ade3..2a204ef 100644
--- a/App.config
+++ b/App.config
@@ -19,13 +19,14 @@
-
+
+
@@ -46,17 +47,21 @@
+
+
+
+
-
+
-
+
-
+
diff --git a/App.xaml b/App.xaml
index 1e6f819..4042ddb 100644
--- a/App.xaml
+++ b/App.xaml
@@ -13,6 +13,8 @@
+
+
diff --git a/Constant/Constants.cs b/Constant/Constants.cs
index 18889d7..544262d 100644
--- a/Constant/Constants.cs
+++ b/Constant/Constants.cs
@@ -13,14 +13,22 @@ namespace GeekDesk.Constant
public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk";
+
///
/// app数据文件路径
///
public static string DATA_FILE_PATH = APP_DIR + "Data"; //app数据文件路径
- public static string LOG_FILE_PATH = APP_DIR + "Log.log";
+ ///
+ /// 备份文件路径
+ ///
+ 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;
diff --git a/Constant/PasswordType.cs b/Constant/PasswordType.cs
new file mode 100644
index 0000000..3c97bc8
--- /dev/null
+++ b/Constant/PasswordType.cs
@@ -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, //取消密码
+ }
+}
diff --git a/Constant/RunTimeStatus.cs b/Constant/RunTimeStatus.cs
index ba82f5a..82df63b 100644
--- a/Constant/RunTimeStatus.cs
+++ b/Constant/RunTimeStatus.cs
@@ -20,7 +20,25 @@
public static bool LOCK_APP_PANEL = false;
+ ///
+ /// 是否弹出了菜单密码框
+ ///
+ public static bool SHOW_MENU_PASSWORDBOX = false;
+ ///
+ /// 是否弹出了右键菜单
+ ///
+ public static bool SHOW_RIGHT_BTN_MENU = false;
+
+ ///
+ /// 是否点击了面板功能按钮
+ ///
+ public static bool APP_BTN_IS_DOWN = false;
+
+ ///
+ /// 是否正在编辑菜单
+ ///
+ public static bool IS_MENU_EDIT = false;
}
}
diff --git a/Control/Other/BacklogNotificatin.xaml.cs b/Control/Other/BacklogNotificatin.xaml.cs
index 28b64c9..46fc210 100644
--- a/Control/Other/BacklogNotificatin.xaml.cs
+++ b/Control/Other/BacklogNotificatin.xaml.cs
@@ -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);
}
diff --git a/Control/Other/GlobalMsgNotification.xaml b/Control/Other/GlobalMsgNotification.xaml
new file mode 100644
index 0000000..c421ea3
--- /dev/null
+++ b/Control/Other/GlobalMsgNotification.xaml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Control/Other/GlobalMsgNotification.xaml.cs b/Control/Other/GlobalMsgNotification.xaml.cs
new file mode 100644
index 0000000..b64a686
--- /dev/null
+++ b/Control/Other/GlobalMsgNotification.xaml.cs
@@ -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
+{
+ ///
+ /// BacklogNotificatin.xaml 的交互逻辑
+ ///
+ 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();
+ }
+ }
+}
diff --git a/Control/Other/IconInfoDialog.xaml b/Control/Other/IconInfoDialog.xaml
index 7d75221..f094620 100644
--- a/Control/Other/IconInfoDialog.xaml
+++ b/Control/Other/IconInfoDialog.xaml
@@ -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 @@
+
-
+
-
-
+
+
+
+
+
-
-
+
@@ -41,12 +52,11 @@
-
-
+
-
+
diff --git a/Control/Other/IconInfoDialog.xaml.cs b/Control/Other/IconInfoDialog.xaml.cs
index 13a0855..a087d6f 100644
--- a/Control/Other/IconInfoDialog.xaml.cs
+++ b/Control/Other/IconInfoDialog.xaml.cs
@@ -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);
}
///
@@ -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)
diff --git a/Control/Other/IconInfoUrlDialog.xaml.cs b/Control/Other/IconInfoUrlDialog.xaml.cs
index 2ecb6f1..2e3847f 100644
--- a/Control/Other/IconInfoUrlDialog.xaml.cs
+++ b/Control/Other/IconInfoUrlDialog.xaml.cs
@@ -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);
}
///
@@ -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)
diff --git a/Control/Other/PasswordDialog.xaml b/Control/Other/PasswordDialog.xaml
new file mode 100644
index 0000000..39dca05
--- /dev/null
+++ b/Control/Other/PasswordDialog.xaml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Control/Other/PasswordDialog.xaml.cs b/Control/Other/PasswordDialog.xaml.cs
new file mode 100644
index 0000000..c6139ac
--- /dev/null
+++ b/Control/Other/PasswordDialog.xaml.cs
@@ -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
+{
+ ///
+ /// TextDialog.xaml 的交互逻辑
+ ///
+ 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();
+ }
+
+ ///
+ /// 跳过设置密码提示
+ ///
+ ///
+ ///
+ 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);
+ }
+ }
+}
diff --git a/Control/UserControls/Config/AboutControl.xaml b/Control/UserControls/Config/AboutControl.xaml
index a963f48..6bb384a 100644
--- a/Control/UserControls/Config/AboutControl.xaml
+++ b/Control/UserControls/Config/AboutControl.xaml
@@ -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 @@
-
+
diff --git a/Control/UserControls/Config/MotionControl.xaml b/Control/UserControls/Config/MotionControl.xaml
index 02e0a8b..cd272b5 100644
--- a/Control/UserControls/Config/MotionControl.xaml
+++ b/Control/UserControls/Config/MotionControl.xaml
@@ -84,15 +84,7 @@
-
-
-
-
-
-
-
-
-
+
diff --git a/Control/UserControls/Config/MotionControl.xaml.cs b/Control/UserControls/Config/MotionControl.xaml.cs
index 944ff11..da521c3 100644
--- a/Control/UserControls/Config/MotionControl.xaml.cs
+++ b/Control/UserControls/Config/MotionControl.xaml.cs
@@ -35,8 +35,6 @@ namespace GeekDesk.Control.UserControls.Config
///
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);
- }
- }
///
diff --git a/Control/UserControls/Config/OtherControl.xaml b/Control/UserControls/Config/OtherControl.xaml
index ca5c35e..989f205 100644
--- a/Control/UserControls/Config/OtherControl.xaml
+++ b/Control/UserControls/Config/OtherControl.xaml
@@ -93,6 +93,16 @@
Foreground="Black"
IsChecked="{Binding UpdateType, Mode=TwoWay, Converter={StaticResource UpdateTypeConvert}, ConverterParameter=2}"/>
+
+
+
+
+
diff --git a/Control/UserControls/Config/OtherControl.xaml.cs b/Control/UserControls/Config/OtherControl.xaml.cs
index 7c3aba1..a70b079 100644
--- a/Control/UserControls/Config/OtherControl.xaml.cs
+++ b/Control/UserControls/Config/OtherControl.xaml.cs
@@ -107,5 +107,10 @@ namespace GeekDesk.Control.UserControls.Config
CountLowSort.Visibility = Visibility.Visible;
}
}
+
+ private void BakDataFile(object sender, RoutedEventArgs e)
+ {
+ CommonCode.BakAppData();
+ }
}
}
diff --git a/Control/UserControls/Config/ThemeControl.xaml b/Control/UserControls/Config/ThemeControl.xaml
index 72a38da..0159ffc 100644
--- a/Control/UserControls/Config/ThemeControl.xaml
+++ b/Control/UserControls/Config/ThemeControl.xaml
@@ -110,7 +110,25 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -120,7 +138,7 @@
-
+
@@ -149,7 +167,7 @@
-
+
-
+
diff --git a/Control/UserControls/Config/ThemeControl.xaml.cs b/Control/UserControls/Config/ThemeControl.xaml.cs
index d1209bc..1f6ccad 100644
--- a/Control/UserControls/Config/ThemeControl.xaml.cs
+++ b/Control/UserControls/Config/ThemeControl.xaml.cs
@@ -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;
+ }
+
}
}
diff --git a/Control/UserControls/PannelCard/LeftCardControl.xaml b/Control/UserControls/PannelCard/LeftCardControl.xaml
index e6df174..4d2a4df 100644
--- a/Control/UserControls/PannelCard/LeftCardControl.xaml
+++ b/Control/UserControls/PannelCard/LeftCardControl.xaml
@@ -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"
@@ -21,9 +22,15 @@
+
+
+
+
+
+
@@ -71,110 +78,149 @@
-->
-
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs
index 095af92..ece408c 100644
--- a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs
+++ b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs
@@ -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));
- //是否正在修改菜单
- public bool IS_EDIT = false;
-
public LeftCardControl()
{
InitializeComponent();
@@ -205,7 +203,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
///
private void RenameMenu(object sender, RoutedEventArgs e)
{
- IS_EDIT = true;
+ RunTimeStatus.IS_MENU_EDIT = true;
MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
menuInfo.MenuEdit = (int)Visibility.Visible;
}
@@ -275,7 +273,7 @@ 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;
@@ -311,7 +309,14 @@ namespace GeekDesk.Control.UserControls.PannelCard
private void Menu_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
- if (IS_EDIT) return;
+ if (RunTimeStatus.IS_MENU_EDIT) return;
+
+ if (appData.AppConfig.ItemSpradeAnimation)
+ {
+ //是否启用列表展开动画
+ MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Collapsed;
+ }
+
//设置对应菜单的图标列表
if (MenuListBox.SelectedIndex == -1)
{
@@ -319,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;
}
@@ -331,7 +348,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
///
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(() =>
{
@@ -402,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;
@@ -427,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();
+ }
+
+ ///
+ /// 右键点击进行处理
+ ///
+ ///
+ ///
+ 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 = "加密此列表";
+ }
+ }
+ }
+
+ }
}
}
diff --git a/Control/UserControls/PannelCard/RightCardControl.xaml b/Control/UserControls/PannelCard/RightCardControl.xaml
index 8974f54..ae9d41a 100644
--- a/Control/UserControls/PannelCard/RightCardControl.xaml
+++ b/Control/UserControls/PannelCard/RightCardControl.xaml
@@ -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 @@
-->
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -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"
+ >
@@ -73,87 +110,100 @@
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+ >
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+ RenderOptions.BitmapScalingMode="HighQuality"/>
-
-
-
-
-
-
+ 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}"/>
+
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+ BorderThickness="0"
+ Padding="0,10,0,0"
+ x:Name="SearchListBox"
+ SelectionChanged="SearchListBox_SelectionChanged"
+ >
@@ -199,7 +250,7 @@
-
@@ -214,36 +265,54 @@
+
+
+
+
+ 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"
+ >
+ 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}"/>
+
-
+
diff --git a/Control/UserControls/PannelCard/RightCardControl.xaml.cs b/Control/UserControls/PannelCard/RightCardControl.xaml.cs
index 6570357..8de7128 100644
--- a/Control/UserControls/PannelCard/RightCardControl.xaml.cs
+++ b/Control/UserControls/PannelCard/RightCardControl.xaml.cs
@@ -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 dragMgr;
+
+ //private Thread dropCheckThread = null;
public RightCardControl()
{
InitializeComponent();
+ this.Loaded += RightCardControl_Loaded;
+
}
-
- #region 图标拖动
- DelegateCommand _swap;
- public DelegateCommand SwapCommand
+ private void RightCardControl_Loaded(object sender, RoutedEventArgs e)
{
- get
- {
- if (_swap == null)
- _swap = new DelegateCommand(
- (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 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(this.IconListBox);
}
- #endregion 图标拖动
+
+ //#region 图标拖动
+ //DelegateCommand _swap;
+ //public DelegateCommand SwapCommand
+ //{
+ // get
+ // {
+ // if (_swap == null)
+ // _swap = new DelegateCommand(
+ // (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 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);
}
///
@@ -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");
}
///
@@ -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();
+ }
+ }
}
}
diff --git a/Control/UserControls/SystemItem/SystemItem.xaml.cs b/Control/UserControls/SystemItem/SystemItem.xaml.cs
index a5d787d..7cc22ab 100644
--- a/Control/UserControls/SystemItem/SystemItem.xaml.cs
+++ b/Control/UserControls/SystemItem/SystemItem.xaml.cs
@@ -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);
}
}
}
diff --git a/Control/UserControls/ToDo/TodoControl.xaml b/Control/UserControls/ToDo/TodoControl.xaml
index 657799d..97fbd84 100644
--- a/Control/UserControls/ToDo/TodoControl.xaml
+++ b/Control/UserControls/ToDo/TodoControl.xaml
@@ -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"
>
diff --git a/Control/UserControls/ToDo/TodoControl.xaml.cs b/Control/UserControls/ToDo/TodoControl.xaml.cs
index 5e97e15..59de7a6 100644
--- a/Control/UserControls/ToDo/TodoControl.xaml.cs
+++ b/Control/UserControls/ToDo/TodoControl.xaml.cs
@@ -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");
diff --git a/Control/Windows/ConfigWindow.xaml b/Control/Windows/ConfigWindow.xaml
index f3f62ef..02e7063 100644
--- a/Control/Windows/ConfigWindow.xaml
+++ b/Control/Windows/ConfigWindow.xaml
@@ -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 @@
-
-
+
+
-
+
diff --git a/Control/Windows/ConfigWindow.xaml.cs b/Control/Windows/ConfigWindow.xaml.cs
index 8b20e93..636d6c9 100644
--- a/Control/Windows/ConfigWindow.xaml.cs
+++ b/Control/Windows/ConfigWindow.xaml.cs
@@ -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;
}
diff --git a/Control/Windows/IconfontWindow.xaml.cs b/Control/Windows/IconfontWindow.xaml.cs
index 22000cf..67df36a 100644
--- a/Control/Windows/IconfontWindow.xaml.cs
+++ b/Control/Windows/IconfontWindow.xaml.cs
@@ -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)
diff --git a/Control/Windows/SystemItemWindow.xaml.cs b/Control/Windows/SystemItemWindow.xaml.cs
index 0f79d65..ec8b6c1 100644
--- a/Control/Windows/SystemItemWindow.xaml.cs
+++ b/Control/Windows/SystemItemWindow.xaml.cs
@@ -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);
}
diff --git a/Control/Windows/ToDoInfoWindow.xaml.cs b/Control/Windows/ToDoInfoWindow.xaml.cs
index 5df9841..992615b 100644
--- a/Control/Windows/ToDoInfoWindow.xaml.cs
+++ b/Control/Windows/ToDoInfoWindow.xaml.cs
@@ -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();
}
diff --git a/Converts/IntToCornerRadius.cs b/Converts/IntToCornerRadius.cs
index ff8dd69..3048ad2 100644
--- a/Converts/IntToCornerRadius.cs
+++ b/Converts/IntToCornerRadius.cs
@@ -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;
}
}
}
diff --git a/Converts/ReverseBoolConvert.cs b/Converts/ReverseBoolConvert.cs
new file mode 100644
index 0000000..dfb9c6b
--- /dev/null
+++ b/Converts/ReverseBoolConvert.cs
@@ -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();
+ }
+ }
+}
diff --git a/Converts/StringAppendConvert.cs b/Converts/StringAppendConvert.cs
index e769f2e..1e046fd 100644
--- a/Converts/StringAppendConvert.cs
+++ b/Converts/StringAppendConvert.cs
@@ -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);
}
}
diff --git a/DraggAnimatedPanel/DraggAnimatedPanel.cs b/DraggAnimatedPanel/DraggAnimatedPanel.cs
index 53ad471..542ca80 100644
--- a/DraggAnimatedPanel/DraggAnimatedPanel.cs
+++ b/DraggAnimatedPanel/DraggAnimatedPanel.cs
@@ -21,6 +21,7 @@ namespace DraggAnimatedPanel
#endregion
static DraggAnimatedPanel()
{
+
DefaultStyleKeyProperty.OverrideMetadata(typeof(DraggAnimatedPanel), new FrameworkPropertyMetadata(typeof(DraggAnimatedPanel)));
}
diff --git a/GeekDesk.csproj b/GeekDesk.csproj
index f7e4628..6721d3b 100644
--- a/GeekDesk.csproj
+++ b/GeekDesk.csproj
@@ -1,5 +1,8 @@
+
+
+
Debug
@@ -30,6 +33,8 @@
false
false
true
+
+
AnyCPU
@@ -44,7 +49,7 @@
false
- AnyCPU
+ x64
pdbonly
true
bin\Release\
@@ -52,6 +57,8 @@
prompt
4
true
+ false
+ Auto
GeekDesk.App
@@ -113,12 +120,19 @@
packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
+
+ packages\System.Reactive.5.0.0\lib\net472\System.Reactive.dll
+
packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
+
+ packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
+
+
@@ -132,6 +146,9 @@
+
+ packages\XamlFlair.WPF.1.2.13\lib\net472\XamlFlair.WPF.dll
+
@@ -146,12 +163,16 @@
+
+
+ GlobalMsgNotification.xaml
+
BacklogNotificatin.xaml
@@ -161,6 +182,9 @@
GradientBGDialog.xaml
+
+ PasswordDialog.xaml
+
MyColorPickerDialog.xaml
@@ -234,30 +258,37 @@
+
+
+
+
+
+
+
@@ -272,6 +303,10 @@
+
+ MSBuild:Compile
+ Designer
+
Designer
MSBuild:Compile
@@ -284,6 +319,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
@@ -384,6 +423,11 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+ Always
+
@@ -475,7 +519,30 @@
-
+
+
+
+ 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ; 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
+
\ No newline at end of file
diff --git a/GeekDesk.sln b/GeekDesk.sln
index b21eaf0..f80a082 100644
--- a/GeekDesk.sln
+++ b/GeekDesk.sln
@@ -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}"
diff --git a/Interface/IWindowCommon.cs b/Interface/IWindowCommon.cs
index b74eba7..675d450 100644
--- a/Interface/IWindowCommon.cs
+++ b/Interface/IWindowCommon.cs
@@ -4,6 +4,6 @@ namespace GeekDesk.Interface
{
public interface IWindowCommon
{
- void OnKeyDown(object sender, KeyEventArgs e);
+ void OnKeyDown(object sender, KeyEventArgs e);
}
}
diff --git a/LICENSE.md b/LICENSE.md
index b60e487..aadd86c 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,2 +1,2 @@
-- 这是个人开发的程序,任何人可任意修改和免费使用(未做较大功能性改动不允许修改赞赏码,重新修改发布需注明出处)
+- 这是个人开发的程序,任何人可任意修改和免费使用(未做较大功能性改动不允许修改赞赏码,重新修改发布需注明出处)
- 商用需联系作者
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 1f8733d..c3db11f 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -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"
>
-
-
-
+
@@ -36,37 +37,38 @@
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
-
-
-
+
+
+
+
@@ -77,9 +79,10 @@
-
-
+
+
+
@@ -94,34 +97,35 @@
+ 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}"
+ />
-
@@ -148,6 +152,7 @@
+
@@ -162,8 +167,7 @@
-
-
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index fa95683..4b690e9 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -8,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;
@@ -16,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;
@@ -37,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);
@@ -52,11 +58,14 @@ namespace GeekDesk
{
MarginHide.StartHide();
}
+
}
+
+
///
- /// 显示搜索框
+ /// 搜索快捷键按下
///
///
///
@@ -68,6 +77,9 @@ namespace GeekDesk
}
}
+ ///
+ /// 显示搜索框
+ ///
private void ShowSearchBox()
{
RunTimeStatus.SEARCH_BOX_SHOW = true;
@@ -117,9 +129,16 @@ namespace GeekDesk
{
SearchIconList.IconList.Clear();
}
+ if (RightCard.SearchListBox.Items.Count > 0)
+ {
+ RightCard.SearchListBox.SelectedIndex = 0;
+ }
RightCard.VerticalUFG.Visibility = Visibility.Visible;
}
+ ///
+ /// 隐藏搜索框
+ ///
public void HidedSearchBox()
{
RunTimeStatus.SEARCH_BOX_SHOW = false;
@@ -160,14 +179,7 @@ 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
{
@@ -206,6 +218,12 @@ namespace GeekDesk
//更新线程开启 检测更新
UpdateThread.Update();
+
+ //建立相对路径
+ RelativePathThread.MakeRelativePath();
+
+ //毛玻璃 暂时未解决阴影问题
+ //BlurGlassUtil.EnableBlur(this);
}
///
@@ -330,21 +348,6 @@ namespace GeekDesk
}
- ///
- /// 重置窗体大小 写入缓存
- ///
- ///
- ///
- 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;
- }
- }
-
///
@@ -424,6 +427,15 @@ namespace GeekDesk
//}
MainWindow.mainWindow.Activate();
+ mainWindow.Show();
+ //mainWindow.Visibility = Visibility.Visible;
+ if (appData.AppConfig.AppAnimation)
+ {
+ appData.AppConfig.IsShow = true;
+ } else
+ {
+ appData.AppConfig.IsShow = null;
+ }
if (MarginHide.ON_HIDE)
{
@@ -438,35 +450,53 @@ 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);
- 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();
+ //}
}
///
@@ -677,16 +707,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();
+ }
+ }
}
@@ -723,14 +761,26 @@ namespace GeekDesk
GlobalColorPickerWindow.CreateNoShow();
}
-
private void Window_GotFocus(object sender, RoutedEventArgs e)
{
- if (!LeftCard.IS_EDIT)
+ // 如果没有在修改菜单 并且不是右键点击了面板
+ if (!RunTimeStatus.IS_MENU_EDIT
+ && !RunTimeStatus.SHOW_RIGHT_BTN_MENU
+ && !RunTimeStatus.APP_BTN_IS_DOWN)
{
- //if判断是为了能够使修改菜单时 菜单能够获得焦点
- Keyboard.Focus(SearchBox);
+ if (RunTimeStatus.SHOW_MENU_PASSWORDBOX)
+ {
+ //必须在其它文本框没有工作的时候才给密码框焦点
+ RightCard.PDDialog.SetFocus();
+ }
+ else
+ {
+ //必须在其它文本框没有工作的时候才给搜索框焦点
+ Keyboard.Focus(SearchBox);
+ }
+
}
+
}
private void AppWindow_Deactivated(object sender, EventArgs e)
@@ -738,5 +788,56 @@ namespace GeekDesk
AppWindowLostFocus();
}
+ ///
+ /// 备份数据文件
+ ///
+ ///
+ ///
+ [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;
+ }
+ }
+
+
+
}
}
diff --git a/MainWindow.xaml.rej b/MainWindow.xaml.rej
index 1b27959..ed84323 100644
--- a/MainWindow.xaml.rej
+++ b/MainWindow.xaml.rej
@@ -1,3 +1,4 @@
+# BookerLiu
diff a/MainWindow.xaml b/MainWindow.xaml (rejected hunks)
@@ -20,6 +20,7 @@
SizeChanged="Window_SizeChanged"
diff --git a/MyThread/RelativePathThread.cs b/MyThread/RelativePathThread.cs
new file mode 100644
index 0000000..3d79893
--- /dev/null
+++ b/MyThread/RelativePathThread.cs
@@ -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 menuList = MainWindow.appData.MenuList;
+
+ string myExePath = Constants.APP_DIR + "GeekDesk.exe";
+ foreach (MenuInfo mi in menuList)
+ {
+ ObservableCollection 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();
+ }
+ }
+}
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index afc1cf3..906a7ca 100644
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -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.6")]
-[assembly: AssemblyFileVersion("2.4.1.6")]
+[assembly: AssemblyVersion("2.5.1.0")]
+[assembly: AssemblyFileVersion("2.5.1.0")]
diff --git a/Resource/Dictionary/XamlFlairSettings.xaml b/Resource/Dictionary/XamlFlairSettings.xaml
new file mode 100644
index 0000000..bf7af56
--- /dev/null
+++ b/Resource/Dictionary/XamlFlairSettings.xaml
@@ -0,0 +1,7 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/Task/ToDoTask.cs b/Task/ToDoTask.cs
index 03d31e5..d5c2b50 100644
--- a/Task/ToDoTask.cs
+++ b/Task/ToDoTask.cs
@@ -60,7 +60,7 @@ namespace GeekDesk.Task
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
- }
+ }
}
#region 内存回收
diff --git a/Update.json b/Update.json
index 3470734..5e7cd9c 100644
--- a/Update.json
+++ b/Update.json
@@ -1,9 +1,9 @@
{
"title": "GeekDesk版本更新",
- "subTitle": "V2.4.16",
+ "subTitle": "V2.5.10",
"msgTitle": "本次更新内容如下",
- "msg": "['兄弟萌求Star, 求Star, 由于功能越来越多, 之后的更新我会测试一周再发布, 尽量做到没有BUG, 见谅', '这个版本没有功能性改变, 主要是为了修复上个版本的bug', '修复无法修改菜单名称的问题', '修复通过任务栏图标打开拾色器, 图标菜单消失问题']",
+ "msg": "['依旧耗费了我大量精力开发,希望大家去给我点个免费的Star', '这个版本有一些优化点, 大家可以自行探索, 另外征集新Logo的设计, 要求美观并能体现\\'极客\\'风格','本次重新打包了程序文件(文件目录更清爽了), 可以将旧版本根目录下的Data文件复制到新版本根目录, 然后使用新版本启动','增加可拖动图标到其它菜单的功能,取消了拖动时的动画','增加了列表展开动画的开关','增加了数据备份功能','优化大部分动画','优化搜索功能(达到了可只用键盘或只用鼠标启动所需目标)','增加了相对路径(实验性,可能有bug)','增加列表加密功能(实验性,可能有bug)','其它已知问题修复']",
"githubUrl": "https://github.com/BookerLiu/GeekDesk/releases",
"giteeUrl": "https://gitee.com/BookerLiu/GeekDesk/releases",
- "version": "2.4.16"
+ "version": "2.5.10"
}
\ No newline at end of file
diff --git a/Util/BGSettingUtil.cs b/Util/BGSettingUtil.cs
index b851f11..f7fcdf6 100644
--- a/Util/BGSettingUtil.cs
+++ b/Util/BGSettingUtil.cs
@@ -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),
diff --git a/Util/BlurGlassUtil.cs b/Util/BlurGlassUtil.cs
new file mode 100644
index 0000000..4faaafc
--- /dev/null
+++ b/Util/BlurGlassUtil.cs
@@ -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);
+ }
+ }
+}
diff --git a/Util/CommonCode.cs b/Util/CommonCode.cs
index 65f2b1c..040ff82 100644
--- a/Util/CommonCode.cs
+++ b/Util/CommonCode.cs
@@ -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;
///
/// 提取一些代码
@@ -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();
///
/// 保存app 数据
///
///
- 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;
}
diff --git a/Util/DragAdorner.cs b/Util/DragAdorner.cs
new file mode 100644
index 0000000..432007b
--- /dev/null
+++ b/Util/DragAdorner.cs
@@ -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
+{
+ ///
+ /// Renders a visual which can follow the mouse cursor,
+ /// such as during a drag-and-drop operation.
+ ///
+ public class DragAdorner : Adorner
+ {
+ #region Data
+
+ private Rectangle child = null;
+ private double offsetLeft = 0;
+ private double offsetTop = 0;
+
+ #endregion // Data
+
+ #region Constructor
+
+ ///
+ /// Initializes a new instance of DragVisualAdorner.
+ ///
+ /// The element being adorned.
+ /// The size of the adorner.
+ /// A brush to with which to paint the adorner.
+ 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
+
+ ///
+ /// Override.
+ ///
+ ///
+ ///
+ 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
+
+ ///
+ /// Gets/sets the horizontal offset of the adorner.
+ ///
+ public double OffsetLeft
+ {
+ get { return this.offsetLeft; }
+ set
+ {
+ this.offsetLeft = value;
+ UpdateLocation();
+ }
+ }
+
+ #endregion // OffsetLeft
+
+ #region SetOffsets
+
+ ///
+ /// Updates the location of the adorner in one atomic operation.
+ ///
+ ///
+ ///
+ public void SetOffsets( double left, double top )
+ {
+ this.offsetLeft = left;
+ this.offsetTop = top;
+ this.UpdateLocation();
+ }
+
+ #endregion // SetOffsets
+
+ #region OffsetTop
+
+ ///
+ /// Gets/sets the vertical offset of the adorner.
+ ///
+ public double OffsetTop
+ {
+ get { return this.offsetTop; }
+ set
+ {
+ this.offsetTop = value;
+ UpdateLocation();
+ }
+ }
+
+ #endregion // OffsetTop
+
+ #endregion // Public Interface
+
+ #region Protected Overrides
+
+ ///
+ /// Override.
+ ///
+ ///
+ ///
+ protected override Size MeasureOverride( Size constraint )
+ {
+ this.child.Measure( constraint );
+ return this.child.DesiredSize;
+ }
+
+ ///
+ /// Override.
+ ///
+ ///
+ ///
+ protected override Size ArrangeOverride( Size finalSize )
+ {
+ this.child.Arrange( new Rect( finalSize ) );
+ return finalSize;
+ }
+
+ ///
+ /// Override.
+ ///
+ ///
+ ///
+ protected override Visual GetVisualChild( int index )
+ {
+ return this.child;
+ }
+
+ ///
+ /// Override. Always returns 1.
+ ///
+ 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
+ }
+}
\ No newline at end of file
diff --git a/Util/FileIcon.cs b/Util/FileIcon.cs
index f0d5c60..55cd22a 100644
--- a/Util/FileIcon.cs
+++ b/Util/FileIcon.cs
@@ -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 GetBlurExts()
- {
- List list = new List();
- list.Add(".exe");
- list.Add(".cer");
- list.Add(".lnk");
- return list;
+ static List blurExtsList;
+ static List pixelList;
+ static FileIcon() {
+ blurExtsList = new List
+ {
+ ".exe",
+ ".cer",
+ ".lnk",
+ ".chm"
+ };
+ pixelList = new List
+ {
+ 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)
diff --git a/Util/FileUtil.cs b/Util/FileUtil.cs
index eb5a180..cf05976 100644
--- a/Util/FileUtil.cs
+++ b/Util/FileUtil.cs
@@ -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,20 @@ namespace GeekDesk.Util
}
}
+ public static string MakeRelativePath(string fromPath, string toPath)
+ {
+ 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);
+ string relativePath =
+ Uri.UnescapeDataString(
+ folder.MakeRelativeUri(file)
+ .ToString()
+ .Replace('/', Path.DirectorySeparatorChar)
+ );
+ return relativePath;
+ }
+
}
}
diff --git a/Util/ListBoxDragDropManager.cs b/Util/ListBoxDragDropManager.cs
new file mode 100644
index 0000000..5772529
--- /dev/null
+++ b/Util/ListBoxDragDropManager.cs
@@ -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
+
+ ///
+ /// 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.
+ ///
+ /// The type of the ListBox's items.
+ public class ListBoxDragDropManager 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
+
+ ///
+ /// Initializes a new instance of ListBoxDragManager.
+ ///
+ public ListBoxDragDropManager()
+ {
+ this.canInitiateDrag = false;
+ this.dragAdornerOpacity = 0.7;
+ this.indexToSelect = -1;
+ this.showDragAdorner = true;
+ }
+
+ ///
+ /// Initializes a new instance of ListBoxDragManager.
+ ///
+ ///
+ public ListBoxDragDropManager( ListBox listBox )
+ : this()
+ {
+ this.ListBox = listBox;
+ }
+
+ ///
+ /// Initializes a new instance of ListBoxDragManager.
+ ///
+ ///
+ ///
+ public ListBoxDragDropManager( ListBox listBox, double dragAdornerOpacity )
+ : this( listBox )
+ {
+ this.DragAdornerOpacity = dragAdornerOpacity;
+ }
+
+ ///
+ /// Initializes a new instance of ListBoxDragManager.
+ ///
+ ///
+ ///
+ public ListBoxDragDropManager( ListBox listBox, bool showDragAdorner )
+ : this( listBox )
+ {
+ this.ShowDragAdorner = showDragAdorner;
+ }
+
+ #endregion // Constructors
+
+ #region Public Interface
+
+ #region DragAdornerOpacity
+
+ ///
+ /// Gets/sets the opacity of the drag adorner. This property has no
+ /// effect if ShowDragAdorner is false. The default value is 0.7
+ ///
+ 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
+
+ ///
+ /// Returns true if there is currently a drag operation being managed.
+ ///
+ public bool IsDragInProgress
+ {
+ get { return this.isDragInProgress; }
+ private set { this.isDragInProgress = value; }
+ }
+
+ #endregion // IsDragInProgress
+
+ #region ListBox
+
+ ///
+ /// 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.
+ ///
+ 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]
+
+ ///
+ /// 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.
+ ///
+ public event EventHandler> ProcessDrop;
+
+ #endregion // ProcessDrop [event]
+
+ #region ShowDragAdorner
+
+ ///
+ /// Gets/sets whether a visual representation of the ListBoxItem being dragged
+ /// follows the mouse cursor during a drag operation. The default value is true.
+ ///
+ 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 which contains the dropped data object.
+ ObservableCollection itemsSource = this.listBox.ItemsSource as ObservableCollection;
+ if( itemsSource == null )
+ throw new Exception(
+ "A ListBox managed by ListBoxDragManager must have its ItemsSource set to an ObservableCollection." );
+
+ 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 args = new ProcessDropEventArgs( 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 )
+ {
+ // ⲿҵ
+ 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("ѽͼΪԶ!");
+ }
+ else
+ {
+ Growl.Warning("ѽͼΪԶ!", "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
+
+ ///
+ /// Returns the index of the ListBoxItem underneath the
+ /// drag cursor, or -1 if the cursor is not over an item.
+ ///
+ 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
+
+ ///
+ /// Returns true if the mouse cursor is over a scrollbar in the ListBox.
+ ///
+ 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
+
+ ///
+ /// 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.
+ ///
+ public static class ListBoxItemDragState
+ {
+ #region IsBeingDragged
+
+ ///
+ /// Identifies the ListBoxItemDragState's IsBeingDragged attached property.
+ /// This field is read-only.
+ ///
+ public static readonly DependencyProperty IsBeingDraggedProperty =
+ DependencyProperty.RegisterAttached(
+ "IsBeingDragged",
+ typeof( bool ),
+ typeof( ListBoxItemDragState ),
+ new UIPropertyMetadata( false ) );
+
+ ///
+ /// Returns true if the specified ListBoxItem is being dragged, else false.
+ ///
+ /// The ListBoxItem to check.
+ public static bool GetIsBeingDragged( ListBoxItem item )
+ {
+ return (bool)item.GetValue( IsBeingDraggedProperty );
+ }
+
+ ///
+ /// Sets the IsBeingDragged attached property for the specified ListBoxItem.
+ ///
+ /// The ListBoxItem to set the property on.
+ /// Pass true if the element is being dragged, else false.
+ internal static void SetIsBeingDragged( ListBoxItem item, bool value )
+ {
+ item.SetValue( IsBeingDraggedProperty, value );
+ }
+
+ #endregion // IsBeingDragged
+
+ #region IsUnderDragCursor
+
+ ///
+ /// Identifies the ListBoxItemDragState's IsUnderDragCursor attached property.
+ /// This field is read-only.
+ ///
+ public static readonly DependencyProperty IsUnderDragCursorProperty =
+ DependencyProperty.RegisterAttached(
+ "IsUnderDragCursor",
+ typeof( bool ),
+ typeof( ListBoxItemDragState ),
+ new UIPropertyMetadata( false ) );
+
+ ///
+ /// Returns true if the specified ListBoxItem is currently underneath the cursor
+ /// during a drag-drop operation, else false.
+ ///
+ /// The ListBoxItem to check.
+ public static bool GetIsUnderDragCursor( ListBoxItem item )
+ {
+ return (bool)item.GetValue( IsUnderDragCursorProperty );
+ }
+
+ ///
+ /// Sets the IsUnderDragCursor attached property for the specified ListBoxItem.
+ ///
+ /// The ListBoxItem to set the property on.
+ /// Pass true if the element is underneath the drag cursor, else false.
+ internal static void SetIsUnderDragCursor( ListBoxItem item, bool value )
+ {
+ item.SetValue( IsUnderDragCursorProperty, value );
+ }
+
+ #endregion // IsUnderDragCursor
+ }
+
+ #endregion // ListBoxItemDragState
+
+ #region ProcessDropEventArgs
+
+ ///
+ /// Event arguments used by the ListBoxDragDropManager.ProcessDrop event.
+ ///
+ /// The type of data object being dropped.
+ public class ProcessDropEventArgs : EventArgs where ItemType : class
+ {
+ #region Data
+
+ ObservableCollection itemsSource;
+ ItemType dataItem;
+ int oldIndex;
+ int newIndex;
+ DragDropEffects allowedEffects = DragDropEffects.None;
+ DragDropEffects effects = DragDropEffects.None;
+
+ #endregion // Data
+
+ #region Constructor
+
+ internal ProcessDropEventArgs(
+ ObservableCollection 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
+
+ ///
+ /// The items source of the ListBox where the drop occurred.
+ ///
+ public ObservableCollection ItemsSource
+ {
+ get { return this.itemsSource; }
+ }
+
+ ///
+ /// The data object which was dropped.
+ ///
+ public ItemType DataItem
+ {
+ get { return this.dataItem; }
+ }
+
+ ///
+ /// The current index of the data item being dropped, in the ItemsSource collection.
+ ///
+ public int OldIndex
+ {
+ get { return this.oldIndex; }
+ }
+
+ ///
+ /// The target index of the data item being dropped, in the ItemsSource collection.
+ ///
+ public int NewIndex
+ {
+ get { return this.newIndex; }
+ }
+
+ ///
+ /// The drag drop effects allowed to be performed.
+ ///
+ public DragDropEffects AllowedEffects
+ {
+ get { return allowedEffects; }
+ }
+
+ ///
+ /// The drag drop effect(s) performed on the dropped item.
+ ///
+ public DragDropEffects Effects
+ {
+ get { return effects; }
+ set { effects = value; }
+ }
+
+ #endregion // Public Properties
+ }
+
+ #endregion // ProcessDropEventArgs
+}
\ No newline at end of file
diff --git a/Util/LogUtil.cs b/Util/LogUtil.cs
index 627c61f..a78f8d5 100644
--- a/Util/LogUtil.cs
+++ b/Util/LogUtil.cs
@@ -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);
diff --git a/Util/MD5Util.cs b/Util/MD5Util.cs
new file mode 100644
index 0000000..de9df9b
--- /dev/null
+++ b/Util/MD5Util.cs
@@ -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();
+ }
+ }
+ }
+}
diff --git a/Util/MarginHide.cs b/Util/MarginHide.cs
index ca73440..c502d86 100644
--- a/Util/MarginHide.cs
+++ b/Util/MarginHide.cs
@@ -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();
diff --git a/Util/MouseUtil.cs b/Util/MouseUtil.cs
index 6197053..cd9716b 100644
--- a/Util/MouseUtil.cs
+++ b/Util/MouseUtil.cs
@@ -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
+ }
+
}
}
diff --git a/Util/RelayCommand.cs b/Util/RelayCommand.cs
new file mode 100644
index 0000000..383b0ae
--- /dev/null
+++ b/Util/RelayCommand.cs
@@ -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