✨ feture 增加关联实时文件夹
This commit is contained in:
@@ -222,59 +222,48 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
|
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
|
||||||
{
|
{
|
||||||
string menuId = System.Guid.NewGuid().ToString();
|
string menuId = System.Guid.NewGuid().ToString();
|
||||||
new Thread(() =>
|
|
||||||
|
string path = dialog.FileName;
|
||||||
|
|
||||||
|
MenuInfo menuInfo = new MenuInfo
|
||||||
{
|
{
|
||||||
this.Dispatcher.BeginInvoke(new Action(() =>
|
MenuName = Path.GetFileNameWithoutExtension(path),
|
||||||
{
|
MenuId = menuId,
|
||||||
string path = dialog.FileName;
|
MenuType = MenuType.LINK,
|
||||||
|
LinkPath = path,
|
||||||
|
IsEncrypt = false,
|
||||||
|
};
|
||||||
|
|
||||||
MenuInfo menuInfo = new MenuInfo
|
appData.MenuList.Add(menuInfo);
|
||||||
{
|
|
||||||
MenuName = Path.GetFileNameWithoutExtension(path),
|
|
||||||
MenuId = menuId,
|
|
||||||
MenuType = MenuType.LINK,
|
|
||||||
LinkPath = path,
|
|
||||||
IsEncrypt = false,
|
|
||||||
};
|
|
||||||
|
|
||||||
appData.MenuList.Add(menuInfo);
|
MenuListBox.SelectedIndex = appData.MenuList.Count - 1;
|
||||||
|
appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
|
||||||
MenuListBox.SelectedIndex = appData.MenuList.Count - 1;
|
appData.AppConfig.SelectedMenuIcons = menuInfo.IconList;
|
||||||
appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
|
//首次触发不了Selected事件
|
||||||
appData.AppConfig.SelectedMenuIcons = menuInfo.IconList;
|
object obj = MenuListBox.ItemContainerGenerator.ContainerFromIndex(MenuListBox.SelectedIndex);
|
||||||
//首次触发不了Selected事件
|
SetListBoxItemEvent((ListBoxItem)obj);
|
||||||
object obj = MenuListBox.ItemContainerGenerator.ContainerFromIndex(MenuListBox.SelectedIndex);
|
Lbi_Selected(obj, null);
|
||||||
SetListBoxItemEvent((ListBoxItem)obj);
|
HandyControl.Controls.Growl.Success("菜单关联成功, 后台加载列表!", "MainWindowGrowl");
|
||||||
Lbi_Selected(obj, null);
|
FileWatcher.LinkMenuWatcher(menuInfo);
|
||||||
|
|
||||||
HandyControl.Controls.Growl.Success("菜单关联成功, 后台加载列表!", "MainWindowGrowl");
|
|
||||||
|
|
||||||
FileWatcher.LinkMenuWatcher(menuInfo);
|
|
||||||
}));
|
|
||||||
}).Start();
|
|
||||||
|
|
||||||
new Thread(() =>
|
new Thread(() =>
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000);
|
DirectoryInfo dirInfo = new DirectoryInfo(menuInfo.LinkPath);
|
||||||
this.Dispatcher.BeginInvoke(new Action(() =>
|
FileSystemInfo[] fileInfos = dirInfo.GetFileSystemInfos();
|
||||||
{
|
|
||||||
MenuInfo info = null;
|
|
||||||
foreach (MenuInfo menuInfo in appData.MenuList)
|
|
||||||
{
|
|
||||||
if (menuInfo.MenuId.Equals(menuId))
|
|
||||||
{
|
|
||||||
info = menuInfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DirectoryInfo dirInfo = new DirectoryInfo(info.LinkPath);
|
ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
|
||||||
FileSystemInfo[] fileInfos = dirInfo.GetFileSystemInfos();
|
foreach (FileSystemInfo fileInfo in fileInfos)
|
||||||
foreach (FileSystemInfo fileInfo in fileInfos)
|
{
|
||||||
|
IconInfo iconInfo = CommonCode.GetIconInfoByPath_NoWrite(fileInfo.FullName);
|
||||||
|
iconList.Add(iconInfo);
|
||||||
|
}
|
||||||
|
this.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
foreach (IconInfo iconInfo in iconList)
|
||||||
{
|
{
|
||||||
IconInfo iconInfo = CommonCode.GetIconInfoByPath_NoWrite(fileInfo.FullName);
|
menuInfo.IconList.Add(iconInfo);
|
||||||
info.IconList.Add(iconInfo);
|
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
}).Start();
|
}).Start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace GeekDesk.MyThread
|
|||||||
foreach (MenuInfo mi in menuList)
|
foreach (MenuInfo mi in menuList)
|
||||||
{
|
{
|
||||||
ObservableCollection<IconInfo> iconList = mi.IconList;
|
ObservableCollection<IconInfo> iconList = mi.IconList;
|
||||||
|
if (iconList == null) continue;
|
||||||
foreach (IconInfo icon in iconList)
|
foreach (IconInfo icon in iconList)
|
||||||
{
|
{
|
||||||
if (icon == null) continue;
|
if (icon == null) continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user