private void DelayOrExecuteCommand(Commands.ICommand cmd) { if (!this.CheckDelayedCommand(cmd)) { //Util.DebugOut(cmd.ToString()); cmd.Execute(this); } }
private static MenuItem GetMenuItem([NotNull] Commands.ICommand command, [NotNull] object context) { Debug.ArgumentNotNull(command, nameof(command)); Debug.ArgumentNotNull(context, nameof(context)); var text = command.Text; if (AppHost.Settings.Options.ShowGroupAndSortingValue) { text = string.Format(@"[{0} {1}] {2}", command.SortingValue, command.Group, text); } var menuItem = new MenuItem { Header = text, Icon = command.Icon, IsChecked = command.IsChecked, Tag = command // InputGestureText = command.InputGestureText, }; if (!string.IsNullOrEmpty(command.ToolTip)) { menuItem.ToolTip = command.ToolTip; } var commandFullName = command.GetType().FullName; var shortcut = KeyboardManager.Shortcuts.FirstOrDefault(s => s.CommandName == commandFullName); if (shortcut != null) { menuItem.InputGestureText = shortcut.FormattedKeys; } menuItem.Click += delegate { AppHost.Usage.ReportCommand(command, context); command.Execute(context); }; if (command.Icon != null) { menuItem.Icon = new Image { Source = command.Icon.GetSource(), Width = 16, Height = 16 }; } if (command.SubmenuOpened != null) { var loading = new MenuItem { Header = Resources.Loading, Tag = @"loading", Foreground = SystemColors.GrayTextBrush }; menuItem.Items.Add(loading); menuItem.SubmenuOpened += command.SubmenuOpened; } return(menuItem); }
static bool EXE_exe(Commands.ICommand cmd) { Console.Clear(); cmd.Execute(); return(true); }