Fix logic & Improve code quality

This commit is contained in:
Jack251970 2025-05-14 11:37:55 +08:00
parent 204d1d285a
commit da77085508

View file

@ -298,15 +298,7 @@ namespace Flow.Launcher.Plugin.Program.Views
if (selectedItems.Count == 0) if (selectedItems.Count == 0)
{ {
var msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source"); context.API.ShowMsgBox(context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source"));
context.API.ShowMsgBox(msg);
return;
}
if (IsAllItemsUserAdded(selectedItems))
{
var msg1 = context.API.GetTranslation("flowlauncher_plugin_program_delete_program_source_select_not_user_added");
context.API.ShowMsgBox(msg1);
return; return;
} }
@ -376,7 +368,7 @@ namespace Flow.Launcher.Plugin.Program.Views
var dataView = CollectionViewSource.GetDefaultView(programSourceView.ItemsSource); var dataView = CollectionViewSource.GetDefaultView(programSourceView.ItemsSource);
dataView.SortDescriptions.Clear(); dataView.SortDescriptions.Clear();
SortDescription sd = new SortDescription(sortBy, direction); var sd = new SortDescription(sortBy, direction);
dataView.SortDescriptions.Add(sd); dataView.SortDescriptions.Add(sd);
dataView.Refresh(); dataView.Refresh();
} }
@ -421,20 +413,18 @@ namespace Flow.Launcher.Plugin.Program.Views
if (selectedItems.Count == 0) if (selectedItems.Count == 0)
{ {
var msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source"); context.API.ShowMsgBox(context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source"));
context.API.ShowMsgBox(msg);
return; return;
} }
if (!IsAllItemsUserAdded(selectedItems)) if (!IsAllItemsUserAdded(selectedItems))
{ {
var msg1 = context.API.GetTranslation("flowlauncher_plugin_program_delete_program_source_select_user_added"); context.API.ShowMsgBox(context.API.GetTranslation("flowlauncher_plugin_program_delete_program_source_select_user_added"));
context.API.ShowMsgBox(msg1);
return; return;
} }
var msg2 = context.API.GetTranslation("flowlauncher_plugin_program_delete_program_source"); if (context.API.ShowMsgBox(context.API.GetTranslation("flowlauncher_plugin_program_delete_program_source"),
if (context.API.ShowMsgBox(msg2, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No) string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
{ {
return; return;
} }