diff --git a/Constant/MenuTypeEnum.cs b/Constant/MenuTypeEnum.cs
new file mode 100644
index 0000000..f0c43b9
--- /dev/null
+++ b/Constant/MenuTypeEnum.cs
@@ -0,0 +1,8 @@
+namespace GeekDesk.Constant
+{
+ public enum MenuTypeEnum
+ {
+ NORMAL = 0,
+ RELATION_FOLDER = 1
+ }
+}
\ No newline at end of file
diff --git a/Control/Other/PasswordDialog.xaml.cs b/Control/Other/PasswordDialog.xaml.cs
index c6139ac..27c2437 100644
--- a/Control/Other/PasswordDialog.xaml.cs
+++ b/Control/Other/PasswordDialog.xaml.cs
@@ -90,6 +90,7 @@ namespace GeekDesk.Control.Other
= appData.MenuList[
MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex
].IconList;
+ MainWindow.mainWindow.LeftCard.BuildWatcher();
//显示数据托盘
MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Visible;
//取消加密操作
diff --git a/Control/UserControls/Config/ThemeControl.xaml b/Control/UserControls/Config/ThemeControl.xaml
index 0159ffc..7114026 100644
--- a/Control/UserControls/Config/ThemeControl.xaml
+++ b/Control/UserControls/Config/ThemeControl.xaml
@@ -234,6 +234,20 @@
+
+
+
+
+
+
+
+
diff --git a/Control/UserControls/PannelCard/LeftCardControl.xaml b/Control/UserControls/PannelCard/LeftCardControl.xaml
index 4d2a4df..fd47701 100644
--- a/Control/UserControls/PannelCard/LeftCardControl.xaml
+++ b/Control/UserControls/PannelCard/LeftCardControl.xaml
@@ -139,6 +139,7 @@
+
@@ -158,6 +159,7 @@
+
diff --git a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs
index d28516b..faad6af 100644
--- a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs
+++ b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs
@@ -7,11 +7,19 @@ using GeekDesk.ViewModel;
using System;
using System.Collections.ObjectModel;
+using System.IO;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
+using DragEventArgs = System.Windows.DragEventArgs;
+using KeyEventArgs = System.Windows.Input.KeyEventArgs;
+using MenuItem = System.Windows.Controls.MenuItem;
+using MouseEventArgs = System.Windows.Input.MouseEventArgs;
+using TextBox = System.Windows.Controls.TextBox;
+using UserControl = System.Windows.Controls.UserControl;
namespace GeekDesk.Control.UserControls.PannelCard
{
@@ -23,6 +31,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
private int menuSelectIndexTemp = -1;
private AppData appData = MainWindow.appData;
private SolidColorBrush bac = new SolidColorBrush(Color.FromRgb(236, 236, 236));
+ private FileSystemWatcher Watcher = new FileSystemWatcher();
public LeftCardControl()
@@ -34,9 +43,33 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
SelectLastMenu();
SetMenuListBoxItemEvent();
+ BindWatcherEvent();
+ BuildWatcher();
};
}
+ private void BindWatcherEvent()
+ {
+ Watcher.Created += WatcherEvent;
+ Watcher.Renamed += WatcherEvent;
+ Watcher.Deleted += WatcherEvent;
+ }
+
+ public void BuildWatcher()
+ {
+ MenuInfo menuInfo = appData.MenuList[appData.AppConfig.SelectedMenuIndex];
+ if (menuInfo.MenuType == MenuTypeEnum.RELATION_FOLDER)
+ {
+ Watcher.Path = menuInfo.RelationPath;
+ }
+ Watcher.EnableRaisingEvents = menuInfo.MenuType == MenuTypeEnum.RELATION_FOLDER;
+ }
+
+ private void WatcherEvent(object sender, EventArgs e)
+ {
+ MenuInfo menuInfo = appData.MenuList[appData.AppConfig.SelectedMenuIndex];
+ appData.AppConfig.SelectedMenuIcons = menuInfo.IconList;
+ }
private void SetMenuListBoxItemEvent()
{
@@ -189,7 +222,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
///
private void CreateMenu(object sender, RoutedEventArgs e)
{
- MenuInfo info = new MenuInfo() { MenuEdit = Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewMenu" };
+ MenuInfo info = new MenuInfo() { MenuEdit = Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewMenu", MenuType = MenuTypeEnum.NORMAL};
appData.MenuList.Add(info);
MenuListBox.SelectedIndex = appData.MenuList.Count - 1;
appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
@@ -341,6 +374,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Collapsed;
appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList;
+ BuildWatcher();
}
}
MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Visible;
@@ -599,5 +633,34 @@ namespace GeekDesk.Control.UserControls.PannelCard
}
}
+
+ ///
+ /// 创建关联文件夹的菜单
+ ///
+ ///
+ ///
+ private void CreateFolderMenu(object sender, RoutedEventArgs e)
+ {
+ FolderBrowserDialog dialog = new FolderBrowserDialog();
+ dialog.RootFolder = Environment.SpecialFolder.Desktop;
+ if (dialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(dialog.SelectedPath))
+ {
+ MenuInfo info = new MenuInfo()
+ {
+ MenuEdit = Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = new DirectoryInfo(dialog.SelectedPath).Name,
+
+ MenuType = MenuTypeEnum.RELATION_FOLDER, RelationPath = dialog.SelectedPath
+ };
+
+ appData.MenuList.Add(info);
+ MenuListBox.SelectedIndex = appData.MenuList.Count - 1;
+ appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
+ appData.AppConfig.SelectedMenuIcons = info.IconList;
+ //首次触发不了Selected事件
+ object obj = MenuListBox.ItemContainerGenerator.ContainerFromIndex(MenuListBox.SelectedIndex);
+ SetListBoxItemEvent((ListBoxItem)obj);
+ Lbi_Selected(obj, null);
+ }
+ }
}
}
diff --git a/Control/UserControls/PannelCard/RightCardControl.xaml b/Control/UserControls/PannelCard/RightCardControl.xaml
index 480bd9f..488f781 100644
--- a/Control/UserControls/PannelCard/RightCardControl.xaml
+++ b/Control/UserControls/PannelCard/RightCardControl.xaml
@@ -207,7 +207,7 @@
-
+
diff --git a/GeekDesk.csproj b/GeekDesk.csproj
index bb2cde1..29a9e63 100644
--- a/GeekDesk.csproj
+++ b/GeekDesk.csproj
@@ -167,6 +167,7 @@
+
diff --git a/ViewModel/AppConfig.cs b/ViewModel/AppConfig.cs
index c547050..94c7dc5 100644
--- a/ViewModel/AppConfig.cs
+++ b/ViewModel/AppConfig.cs
@@ -105,8 +105,27 @@ namespace GeekDesk.ViewModel
private bool? secondsWindow; //秒数窗口 默认打开
+ private string filterExt = "lnk|exe|cmd|vbs|bat|xls|xlsx|doc|docx|txt|pdf";
+
#region GetSet
+ public string FilterExt
+ {
+ get
+ {
+ if (string.IsNullOrEmpty(filterExt))
+ {
+ FilterExt = "lnk|exe|cmd|vbs|bat|xls|xlsx|doc|docx|txt|pdf";
+ }
+ return filterExt;
+ }
+ set
+ {
+ filterExt = value;
+ OnPropertyChanged("FilterExt");
+ }
+ }
+
public bool? SecondsWindow
{
get
diff --git a/ViewModel/MenuInfo.cs b/ViewModel/MenuInfo.cs
index 243604b..5585b42 100644
--- a/ViewModel/MenuInfo.cs
+++ b/ViewModel/MenuInfo.cs
@@ -3,6 +3,8 @@ using GeekDesk.Util;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
+using System.IO;
+using System.Linq;
using System.Windows;
namespace GeekDesk.ViewModel
@@ -15,6 +17,8 @@ namespace GeekDesk.ViewModel
private string menuName;
private string menuId;
+ private MenuTypeEnum menuType = MenuTypeEnum.NORMAL;
+ private string relationPath;
private Visibility menuEdit = Visibility.Collapsed;
private Visibility notMenuEdit = Visibility.Visible;
private string menuGeometry; //菜单几何图标
@@ -22,6 +26,25 @@ namespace GeekDesk.ViewModel
private ObservableCollection iconList = new ObservableCollection();
private bool isEncrypt; //是否加密
+ public string RelationPath
+ {
+ get => relationPath;
+ set
+ {
+ relationPath = value;
+ OnPropertyChanged("RelationPath");
+ }
+ }
+
+ public MenuTypeEnum MenuType
+ {
+ get => menuType;
+ set
+ {
+ menuType = value;
+ OnPropertyChanged("MenuType");
+ }
+ }
public bool IsEncrypt
{
@@ -134,6 +157,27 @@ namespace GeekDesk.ViewModel
{
get
{
+ //如果是关联文件夹类型,实时读取
+ if (menuType == MenuTypeEnum.RELATION_FOLDER)
+ {
+ DirectoryInfo dir = new DirectoryInfo(RelationPath);
+ if (dir.Exists)
+ {
+ ObservableCollection relationIconInfo = new ObservableCollection();
+ var folders = dir.GetDirectories();
+ foreach (var directoryInfo in folders)
+ {
+ relationIconInfo.Add(CommonCode.GetIconInfoByPath(directoryInfo.FullName));
+ }
+ var files = dir.EnumerateFiles().Where(f => MainWindow.appData.AppConfig.FilterExt.Contains(f.Extension.Replace(".", "")));
+ foreach (var fileInfo in files)
+ {
+ relationIconInfo.Add(CommonCode.GetIconInfoByPath(fileInfo.FullName));
+ }
+
+ return relationIconInfo;
+ }
+ }
return iconList;
}
set