private void InitializeCommand(RoutedUICommand command, Func <bool> isVisibleHandler, Func <bool> isEnabledHandler, Func <bool> isCheckedHandler, Action commandHandler)
 {
     CommandList.Add(command);
     MenuHeaderTable.Add(command, command.Text);
     MenuIsVisibleTable.Add(command, isVisibleHandler);
     MenuIsEnabledTable.Add(command, isEnabledHandler);
     MenuIsCheckedTable.Add(command, isCheckedHandler);
     MenuHandlerTable.Add(command, commandHandler);
 }
Example #2
0
        private ICommand InitMenuCommand(string commandName, string header, ExecutedRoutedEventHandler executed)
        {
            ICommand Command = (ICommand)FindResource(commandName);

            MenuHeaderTable.Add(Command, header);

            // Bind the command to the corresponding handler. Requires the menu to be the target of notifications in TaskbarIcon.
            CommandManager.RegisterClassCommandBinding(typeof(ContextMenu), new CommandBinding(Command, executed));

            return(Command);
        }
        private void InitializeCommand(string header, Func <bool> isVisibleHandler, Func <bool> isEnabledHandler, Func <bool> isCheckedHandler, Action commandHandler)
        {
            ICommand Command = new RoutedUICommand();

            CommandList.Add(Command);
            MenuHeaderTable.Add(Command, header);
            MenuIsVisibleTable.Add(Command, isVisibleHandler);
            MenuIsEnabledTable.Add(Command, isEnabledHandler);
            MenuIsCheckedTable.Add(Command, isCheckedHandler);
            MenuHandlerTable.Add(Command, commandHandler);
        }
        private void InitializeCommand(string header, Func <bool> isVisibleHandler, Func <bool> isEnabledHandler, Func <bool> isCheckedHandler, Action commandHandler)
        {
            string   LocalizedText = Properties.Resources.ResourceManager.GetString(header, CultureInfo.CurrentCulture) !;
            ICommand Command       = new RoutedUICommand(LocalizedText, header, GetType());

            CommandList.Add(Command);
            MenuHeaderTable.Add(Command, LocalizedText);
            MenuIsVisibleTable.Add(Command, isVisibleHandler);
            MenuIsEnabledTable.Add(Command, isEnabledHandler);
            MenuIsCheckedTable.Add(Command, isCheckedHandler);
            MenuHandlerTable.Add(Command, commandHandler);
        }