private CommandBarControl InitializeChildControl(ICommandMenuItem item)
        {
            if (item == null)
            {
                return(null);
            }

            var child = (CommandBarButton)Item.Controls.Add(MsoControlType.msoControlButton, Temporary: true);

            SetButtonImage(child, item.Image, item.Mask);

            child.BeginGroup = item.BeginGroup;
            child.Tag        = item.GetType().FullName;
            child.Caption    = item.Caption.Invoke();
            var command = item.Command as CommandBase; // todo: add 'ShortcutText' to a new 'interface ICommand : System.Windows.Input.ICommand'

            child.ShortcutText = command != null
                ? command.ShortcutText
                : string.Empty;

            Debug.WriteLine("Menu item '{0}' created; hash code: {1} (command hash code {2})", child.Caption, child.GetHashCode(), item.Command.GetHashCode());

            child.Click += child_Click;
            return(child);
        }
示例#2
0
        private ICommandBarControl InitializeChildControl(ICommandMenuItem item)
        {
            if (item == null)
            {
                return(null);
            }

            ICommandBarButton child;

            using (var controls = Item.Controls)
            {
                child = CommandBarButtonFactory.Create(controls);
            }
            child.Style   = item.ButtonStyle;
            child.Picture = item.Image;
            child.Mask    = item.Mask;
            child.ApplyIcon();

            child.IsVisible   = item.IsVisible;
            child.BeginsGroup = item.BeginGroup;
            child.Tag         = item.GetType().FullName;
            child.Caption     = item.Caption.Invoke();
            child.TooltipText = item.ToolTipText.Invoke();

            if (item.Command != null)
            {
                child.Click += child_Click;
            }
            return(child);
        }
示例#3
0
        private ICommandBarControl InitializeChildControl(ICommandMenuItem item)
        {
            if (item == null)
            {
                return(null);
            }

            ICommandBarButton child;

            using (var controls = Item.Controls)
            {
                child = CommandBarButtonFactory.Create(controls);
            }
            child.Picture = item.Image;
            child.Mask    = item.Mask;
            child.ApplyIcon();

            child.BeginsGroup = item.BeginGroup;
            using (var itemParent = Item.Parent)
            {
                child.Tag = $"{itemParent.Name}::{Item.Tag}::{item.GetType().Name}";
            }
            child.Caption = item.Caption.Invoke();
            var command = item.Command; // todo: add 'ShortcutText' to a new 'interface CommandBase : System.Windows.Input.CommandBase'

            child.ShortcutText = command != null
                ? command.ShortcutText
                : string.Empty;

            child.Click += child_Click;
            return(child);
        }
        private CommandBarControl InitializeChildControl(ICommandMenuItem item)
        {
            if (item == null)
            {
                return null;
            }

            var child = (CommandBarButton)Item.Controls.Add(MsoControlType.msoControlButton, Temporary: true);
            SetButtonImage(child, item.Image, item.Mask);

            child.BeginGroup = item.BeginGroup;
            child.Tag = item.GetType().FullName;
            child.Caption = item.Caption.Invoke();
            var command = item.Command as CommandBase; // todo: add 'ShortcutText' to a new 'interface CommandBase : System.Windows.Input.CommandBase'
            child.ShortcutText = command != null
                ? command.ShortcutText
                : string.Empty;

            child.Click += child_Click;
            return child;
        }