👥 菜单删除增加询问确认

This commit is contained in:
BookerLiu
2023-03-20 14:38:36 +08:00
parent 80a9975140
commit 32adce1815
2 changed files with 27 additions and 19 deletions

View File

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

View File

@@ -83,6 +83,7 @@
<CheckBox x:Name="HideBox" Visibility="Hidden" Panel.ZIndex="2"/> <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="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 Grid.Row="0" Grid.Column="0" MouseMove="DragMove">
<DockPanel.Background> <DockPanel.Background>