瀏覽代碼

:busts_in_silhouette: 菜单删除增加询问确认

BookerLiu 2 年之前
父節點
當前提交
32adce1815
共有 2 個文件被更改,包括 27 次插入19 次删除
  1. 26 19
      Control/UserControls/PannelCard/LeftCardControl.xaml.cs
  2. 1 0
      MainWindow.xaml

+ 26 - 19
Control/UserControls/PannelCard/LeftCardControl.xaml.cs

@@ -220,27 +220,34 @@ namespace GeekDesk.Control.UserControls.PannelCard
         /// <param name="e"></param>
         private void DeleteMenu(object sender, RoutedEventArgs e)
         {
-            MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
-            if (appData.MenuList.Count == 1)
-            {
-                //如果删除以后没有菜单的话 先创建一个
-                CreateMenu(null, null);
-            }
-            int index = appData.MenuList.IndexOf(menuInfo);
-            if (index == 0)
-            {
-                index = 0;
-            }
-            else
+            HandyControl.Controls.Growl.Ask("确认删除此菜单吗?", isConfirmed =>
             {
-                index--;
-            }
+                if (isConfirmed)
+                {
+                    MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
+                    if (appData.MenuList.Count == 1)
+                    {
+                        //如果删除以后没有菜单的话 先创建一个
+                        CreateMenu(null, null);
+                    }
+                    int index = appData.MenuList.IndexOf(menuInfo);
+                    if (index == 0)
+                    {
+                        index = 0;
+                    }
+                    else
+                    {
+                        index--;
+                    }
 
-            appData.MenuList.Remove(menuInfo);
-            // 选中下一个菜单
-            MenuListBox.SelectedIndex = index;
-            appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
-            appData.AppConfig.SelectedMenuIcons = appData.MenuList[index].IconList;
+                    appData.MenuList.Remove(menuInfo);
+                    // 选中下一个菜单
+                    MenuListBox.SelectedIndex = index;
+                    appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
+                    appData.AppConfig.SelectedMenuIcons = appData.MenuList[index].IconList;
+                }
+                return true;
+            }, "MainWindowAskGrowl");
         }
 
         /// <summary>

+ 1 - 0
MainWindow.xaml

@@ -83,6 +83,7 @@
                 <CheckBox x:Name="HideBox" Visibility="Hidden" Panel.ZIndex="2"/>
 
                 <StackPanel HorizontalAlignment="Right" Panel.ZIndex="99" hc:Growl.GrowlParent="False" hc:Growl.Token="MainWindowGrowl" Grid.Column="1" Grid.Row="1"/>
+                <StackPanel HorizontalAlignment="Center" Panel.ZIndex="99" hc:Growl.GrowlParent="False" hc:Growl.Token="MainWindowAskGrowl" Grid.Column="1" Grid.Row="1"/>
 
                 <DockPanel Grid.Row="0" Grid.Column="0" MouseMove="DragMove">
                     <DockPanel.Background>