新增关联文件夹菜单功能

This commit is contained in:
huangcan
2023-01-29 15:03:38 +08:00
parent 2fd078f722
commit ce17e7174e
9 changed files with 154 additions and 2 deletions

View File

@@ -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

View File

@@ -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<IconInfo> iconList = new ObservableCollection<IconInfo>();
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<IconInfo> relationIconInfo = new ObservableCollection<IconInfo>();
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