From 753a4e4fa2c5d53b8ee44d99649a40a7c97b717a Mon Sep 17 00:00:00 2001 From: Hsxxxxxx <568397119@qq.com> Date: Fri, 14 Oct 2022 15:46:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=9B=B4=E6=8E=A5=E6=8B=96?= =?UTF-8?q?=E5=8A=A8=E6=96=B0=E5=9B=BE=E6=A0=87=E5=88=B0=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PannelCard/LeftCardControl.xaml.cs | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs index d28516b..6a8a89d 100644 --- a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs +++ b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs @@ -487,15 +487,44 @@ namespace GeekDesk.Control.UserControls.PannelCard 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)); + if (iconInfo != null) + { + // 将已有图标移动到该菜单 + appData.MenuList[MenuListBox.SelectedIndex].IconList.Remove(iconInfo); + appData.MenuList[MenuListBox.Items.IndexOf(mi)].IconList.Add(iconInfo); - appData.MenuList[MenuListBox.SelectedIndex].IconList.Remove(iconInfo); - appData.MenuList[MenuListBox.Items.IndexOf(mi)].IconList.Add(iconInfo); + } + else + { + // 直接将新图标移动到该菜单 + Array dropObject = (System.Array)e.Data.GetData(DataFormats.FileDrop); + if (dropObject == null) return; + foreach (object obj in dropObject) + { + string path = (string)obj; + iconInfo = CommonCode.GetIconInfoByPath(path); + if (iconInfo == null) + { + LogUtil.WriteErrorLog("添加项目失败,未能获取到项目图标:" + path); + break; + + } + appData.MenuList[MenuListBox.Items.IndexOf(mi)].IconList.Add(iconInfo); + } + CommonCode.SortIconList(); + CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH); + } } private void EncryptMenu(object sender, RoutedEventArgs e)