Esempio n. 1
0
        public string GetText(CommandViewContext context)
        {
            if (this.CommonCommand == CommonCommand.None)
            {
                switch (context)
                {
                case CommandViewContext.ContextMenu:
                case CommandViewContext.Toolbar:
                    string[] parts = this.GetNameParts();
                    if (parts == null)
                    {
                        throw new InvalidOperationException("'parts' is null.");
                    }
                    if (parts.Length == 0)
                    {
                        throw new InvalidOperationException("'parts' is zero-length.");
                    }
                    return(parts[0]);

                case CommandViewContext.PopupMenu:
                    return(this.FullName);

                default:
                    throw new NotSupportedException(string.Format("Cannot handle '{0}' ({1}).", context, context.GetType()));
                }
            }
            else
            {
                bool shortName = true;
                if (context == CommandViewContext.PopupMenu)
                {
                    shortName = false;
                }

                // defer...
                return(this.GetCommonCommandName(shortName));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="command"></param>
        internal CommandMenuItem(DesktopCommandClickContext ClickContext, Command command, CommandViewContext viewContext)
            : base(command.GetText(viewContext))
        {
            if (ClickContext == null)
            {
                throw new ArgumentNullException("ClickContext");
            }
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            // set...
            _context = ClickContext;
            _command = command;

            // mbr - 2009-02-01 - added image support...
            if (command is DesktopCommand)
            {
                this.ImageResourceAssembly = ((DesktopCommand)command).ImageResourceAssembly;
                this.ImageResourceName     = ((DesktopCommand)command).ImageResourceName;
            }
        }