diff --git a/NAPS2.Lib.WinForms/EtoForms/Ui/WinFormsDesktopForm.cs b/NAPS2.Lib.WinForms/EtoForms/Ui/WinFormsDesktopForm.cs index 1e54c509c..a0de4e80a 100644 --- a/NAPS2.Lib.WinForms/EtoForms/Ui/WinFormsDesktopForm.cs +++ b/NAPS2.Lib.WinForms/EtoForms/Ui/WinFormsDesktopForm.cs @@ -206,8 +206,13 @@ public class WinFormsDesktopForm : DesktopForm private wf.ToolStripItem ApplyCommand(wf.ToolStripItem item, Command command) { + void SetItemText() => item.Text = item is wf.ToolStripMenuItem ? command.MenuText : command.ToolBarText; item.Image = command.Image.ToSD(); - item.Text = item is wf.ToolStripMenuItem ? command.MenuText : command.ToolBarText; + SetItemText(); + if (command is ActionCommand actionCommand) + { + actionCommand.TextChanged += (_, _) => SetItemText(); + } if (item is wf.ToolStripMenuItem menuItem) { menuItem.ShortcutKeys = command.Shortcut.ToSWF(); diff --git a/NAPS2.Lib/EtoForms/ActionCommand.cs b/NAPS2.Lib/EtoForms/ActionCommand.cs index 2595bfcbf..e103e5ee3 100644 --- a/NAPS2.Lib/EtoForms/ActionCommand.cs +++ b/NAPS2.Lib/EtoForms/ActionCommand.cs @@ -23,6 +23,9 @@ public class ActionCommand : Command { ToolBarText = value; MenuText = value; + TextChanged?.Invoke(this, EventArgs.Empty); } } + + public event EventHandler? TextChanged; } \ No newline at end of file diff --git a/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs b/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs index 9847d4234..fb9ab2e1c 100644 --- a/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs @@ -424,16 +424,15 @@ public abstract class DesktopForm : EtoFormBase Commands.ReorderMenu.Enabled = Commands.EmailPdf.Enabled = Commands.Print.Enabled = ImageList.Images.Any(); - // TODO: Changing the text on the command doesn't actually propagate to the widget // "All" dropdown items - Commands.SaveAllPdf.MenuText = Commands.SaveAllImages.MenuText = Commands.EmailAll.MenuText = - Commands.ReverseAll.MenuText = string.Format(MiscResources.AllCount, ImageList.Images.Count); + Commands.SaveAllPdf.Text = Commands.SaveAllImages.Text = Commands.EmailAll.Text = + Commands.ReverseAll.Text = string.Format(MiscResources.AllCount, ImageList.Images.Count); Commands.SaveAllPdf.Enabled = Commands.SaveAllImages.Enabled = Commands.EmailAll.Enabled = Commands.ReverseAll.Enabled = ImageList.Images.Any(); // "Selected" dropdown items - Commands.SaveSelectedPdf.MenuText = Commands.SaveSelectedImages.MenuText = Commands.EmailSelected.MenuText = - Commands.ReverseSelected.MenuText = string.Format(MiscResources.SelectedCount, ImageList.Selection.Count); + Commands.SaveSelectedPdf.Text = Commands.SaveSelectedImages.Text = Commands.EmailSelected.Text = + Commands.ReverseSelected.Text = string.Format(MiscResources.SelectedCount, ImageList.Selection.Count); Commands.SaveSelectedPdf.Enabled = Commands.SaveSelectedImages.Enabled = Commands.EmailSelected.Enabled = Commands.ReverseSelected.Enabled = ImageList.Selection.Any();