Beispiel #1
0
        public virtual int UpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue)
        {
            Command command = ParentCommandManager.Get((CommandId)commandId);

            if (command == null)
            {
                return(NullCommandUpdateProperty(commandId, ref key, currentValue, out newValue));
            }

            try
            {
                newValue = new PropVariant();
                command.GetPropVariant(key, currentValue, ref newValue);

                if (newValue.IsNull())
                {
                    Trace.Fail("Didn't property update property for " + PropertyKeys.GetName(key) + " on command " + ((CommandId)commandId).ToString());

                    newValue = PropVariant.FromObject(currentValue.PropVariant.Value);
                }
            }
            catch (Exception ex)
            {
                Trace.Fail("Exception in UpdateProperty for " + PropertyKeys.GetName(key) + " on command " + commandId + ": " + ex);
                newValue = PropVariant.FromObject(currentValue.PropVariant.Value);
            }

            return(HRESULT.S_OK);
        }
        public static Bitmap GetGalleryItemImageFromCommand(CommandManager commandManager, CommandId commandId)
        {
            // @RIBBON TODO: Deal with high constrast appropriately
            Command command = commandManager.Get(commandId);
            if (command != null)
                return command.LargeImage;

            return Images.Missing_LargeImage;
        }
Beispiel #3
0
        public static Bitmap GetGalleryItemImageFromCommand(CommandManager commandManager, CommandId commandId)
        {
            // @RIBBON TODO: Deal with high contrast appropriately
            Command command = commandManager.Get(commandId);

            if (command != null)
            {
                return(command.LargeImage);
            }

            return(Images.Missing_LargeImage);
        }
        public void Dispatch(PropertyKey key, ExecuteEventHandlerArgs args)
        {
            ExecuteWithArgsDelegate executeWithArgsDelegate = commands[key] as ExecuteWithArgsDelegate;

            if (executeWithArgsDelegate != null)
            {
                executeWithArgsDelegate(args);
                return;
            }

            CommandId commandId = (CommandId)commands[key];
            Command   command   = CommandManager.Get(commandId);

            command.PerformExecuteWithArgs(args);
        }
        /// <summary>
        /// Gets the MenuItem for this MenuDefinitionEntry.
        /// </summary>
        /// <param name="commandManager">The CommandManager to use.</param>
        /// <param name="menuType">The MenuType.</param>
        /// <returns>The menu item for this MenuDefinitionEntry.</returns>
        protected override MenuItem GetMenuItem(CommandManager commandManager, MenuType menuType)
        {
            Command command = commandManager.Get(commandIdentifier);

            if (command == null || !command.On)
            {
                return(null);
            }
            if ((menuType == MenuType.Context || menuType == MenuType.CommandBarContext) && !command.VisibleOnContextMenu)
            {
                return(null);
            }

            //	Instantiate and initialize the CommandOwnerDrawMenuItem.
            CommandOwnerDrawMenuItem commandOwnerDrawMenuItem = new CommandOwnerDrawMenuItem(menuType, command, command.MenuText);

            return(commandOwnerDrawMenuItem);
        }
        public HtmlMarginEditor(CommandManager commandManager)
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            marginCommand = (MarginCommand)commandManager.Get(CommandId.MarginsGroup);

            this.label3.Text = Res.Get(StringId.ImgSBMarginTop);
            this.label4.Text = Res.Get(StringId.ImgSBMarginRight);
            this.label5.Text = Res.Get(StringId.ImgSBMarginLeft);
            this.label6.Text = Res.Get(StringId.ImgSBMarginBottom);

            comboBoxMargins.Initialize();
            comboBoxMargins.SelectedIndexChanged += new EventHandler(comboBoxMargins_SelectedIndexChanged);
            comboBoxMargins.SelectedIndex = 0;
            panelCustomMargin.VisibleChanged += new EventHandler(panelCustomMargin_VisibleChanged);

            comboBoxMargins.AccessibleName = ControlHelper.ToAccessibleName(Res.Get(StringId.ImgSBMargins));

            marginCommand.MarginChanged += new EventHandler(marginCommand_MarginChanged);
        }
        /// <summary>
        /// Gets the MenuItem for this MenuDefinitionEntry.
        /// </summary>
        /// <param name="commandManager">The CommandManager to use.</param>
        /// <param name="menuType">The MenuType.</param>
        /// <returns>The menu item for this MenuDefinitionEntry.</returns>
        protected override MenuItem GetMenuItem(CommandManager commandManager, MenuType menuType)
        {
            Command command = commandManager.Get(commandIdentifier);
            if (command == null || !command.On)
                return null;
            if ((menuType == MenuType.Context || menuType == MenuType.CommandBarContext) && !command.VisibleOnContextMenu)
                return null;

            //	Instantiate and initialize the CommandOwnerDrawMenuItem.
            CommandOwnerDrawMenuItem commandOwnerDrawMenuItem = new CommandOwnerDrawMenuItem(menuType, command, command.MenuText);
            return commandOwnerDrawMenuItem;
        }
 /// <summary>
 /// Must be called by inheriting classes to avoid null references!
 /// </summary>
 /// <param name="commandManager"></param>
 protected void InitializeAlignmentMarginCommands(CommandManager commandManager)
 {
     _marginCommand = (MarginCommand)commandManager.Get(CommandId.MarginsGroup);
     _alignmentCommand = (AlignmentCommand)commandManager.Get(CommandId.AlignmentGallery);
 }