public CommandBarControl(CommandBarLightweightControl commandBar, CommandBarDefinition commandBarDefinition)
        {
            // It's important that the commandBarDefinition not be set
            // on the command bar until after the command bar has a heavyweight parent.
            // Otherwise, command bar entries that have heavyweight controls will never
            // be parented properly and therefore never show up.

            Debug.Assert(commandBar.CommandBarDefinition == null,
                         "Don't set the command bar definition before creating CommandBarControl!");

            InitializeComponent();

            _commandBar = commandBar;

            _commandBar.LightweightControlContainerControl = this;
            _commandBar.CommandBarDefinition = commandBarDefinition;

            _commandBar.VirtualBounds = new Rectangle(new Point(0, 0), _commandBar.DefaultVirtualSize);
            Height       = _commandBar.VirtualHeight;
            SizeChanged += new EventHandler(CommandBarControl_SizeChanged);

            AccessibleRole = System.Windows.Forms.AccessibleRole.ToolBar;
            AccessibleName = commandBar.AccessibleName;
            InitFocusAndAccessibility();
        }
        public CommandBarControl(CommandBarLightweightControl commandBar, CommandBarDefinition commandBarDefinition)
        {
            // It's important that the commandBarDefinition not be set
            // on the command bar until after the command bar has a heavyweight parent.
            // Otherwise, command bar entries that have heavyweight controls will never
            // be parented properly and therefore never show up.

            Debug.Assert(commandBar.CommandBarDefinition == null,
                         "Don't set the command bar definition before creating CommandBarControl!");

            InitializeComponent();

            _commandBar = commandBar;

            _commandBar.LightweightControlContainerControl = this;
            _commandBar.CommandBarDefinition = commandBarDefinition;

            _commandBar.VirtualBounds = new Rectangle(new Point(0, 0), _commandBar.DefaultVirtualSize);
            Height = _commandBar.VirtualHeight;
            SizeChanged += new EventHandler(CommandBarControl_SizeChanged);

            AccessibleRole = System.Windows.Forms.AccessibleRole.ToolBar;
            AccessibleName = commandBar.AccessibleName;
            InitFocusAndAccessibility();
        }
 /// <summary>
 /// Gets the control for this entry.
 /// </summary>
 /// <returns>Lightweight control.</returns>
 public override LightweightControl GetLightweightControl(CommandBarLightweightControl commandBarLightweightControl, bool rightAligned)
 {
     if (commandBarButtonLightweightControl == null)
     {
         commandBarButtonLightweightControl = new CommandBarButtonLightweightControl(commandBarLightweightControl, commandIdentifier, rightAligned);
     }
     return(commandBarButtonLightweightControl);
 }
 /// <summary>
 /// Gets the lightweight control for this entry.
 /// </summary>
 /// <returns>Lightweight control.</returns>
 public override LightweightControl GetLightweightControl(CommandBarLightweightControl commandBarLightweightControl, bool rightAligned)
 {
     if (commandBarControlLightweightControl == null)
     {
         commandBarControlLightweightControl = new CommandBarControlLightweightControl(control);
     }
     return(commandBarControlLightweightControl);
 }
 /// <summary>
 /// Gets the command bar lightweight control for this command bar entry.
 /// </summary>
 /// <returns>Lightweight control.</returns>
 public virtual LightweightControl GetLightweightControl(CommandBarLightweightControl commandBarLightweightControl, bool rightAligned)
 {
     return(null);
 }
 /// <summary>
 /// Gets the lightweight control for this entry.
 /// </summary>
 /// <returns>Lightweight control.</returns>
 public override LightweightControl GetLightweightControl(CommandBarLightweightControl commandBarLightweightControl, bool rightAligned)
 {
     if (commandBarLabelLightweightControl == null)
         commandBarLabelLightweightControl = new CommandBarLabelLightweightControl(text);
     return commandBarLabelLightweightControl;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Raises the Layout event.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLayout(EventArgs e)
        {
            //	Call the base class's method so that registered delegates receive the event.
            base.OnLayout(e);

            //	Obtain our CommandBarLightweightControl.  Must have one.
            CommandBarLightweightControl commandBarLightweightControl = LightweightControlContainerControl as CommandBarLightweightControl;

            if (commandBarLightweightControl == null)
            {
                return;
            }

            //	Layout the lightweight controls on the command bar lightweight control.
            int      xOffset  = 0;
            Previous previous = Previous.None;

            foreach (LightweightControl lightweightControl in LightweightControls)
            {
                //	Have the lightweight control perform its layout logic.
                lightweightControl.PerformLayout();

                //	Skip the lightweight control if it's not visible.
                if (!lightweightControl.Visible)
                {
                    continue;
                }

                //	Handle separators.
                if (lightweightControl is CommandBarSeparatorLightweightControl)
                {
                    lightweightControl.VirtualHeight = VirtualHeight;
                    xOffset += commandBarLightweightControl.SeparatorLayoutMargin;
                }

                if (previous == Previous.None)
                {
                    xOffset += 5;
                }

                if ((previous == Previous.Button || previous == Previous.Separator) && lightweightControl is CommandBarButtonLightweightControl)
                {
                    xOffset += OffsetSpacing;
                }

                if (lightweightControl is CommandBarButtonLightweightControl)
                {
                    xOffset += ((CommandBarButtonLightweightControl)lightweightControl).MarginLeft;
                }

                //	Set the location of this control.
                lightweightControl.VirtualLocation = new Point(xOffset, Utility.CenterMinZero(lightweightControl.VirtualHeight, VirtualHeight));

                //	Have the lightweight control perform its layout logic.
                //lightweightControl.PerformLayout();

                //	Adjust the x offset for the next loop iteration.
                xOffset += lightweightControl.VirtualWidth;

                if (lightweightControl is CommandBarButtonLightweightControl)
                {
                    xOffset += ((CommandBarButtonLightweightControl)lightweightControl).MarginRight;
                }

                previous = Previous.Other;

                //	Handle separators.
                if (lightweightControl is CommandBarSeparatorLightweightControl)
                {
                    xOffset += commandBarLightweightControl.SeparatorLayoutMargin;
                    previous = Previous.Separator;
                }


                if (lightweightControl is CommandBarButtonLightweightControl)
                {
                    //if (((CommandBarButtonLightweightControl)lightweightControl).DropDownContextMenuUserInterface)
                    //    xOffset += 15;

                    previous = Previous.Button;
                }
            }

            VirtualWidth = xOffset;

            RtlLayoutFixup(false);
        }
 /// <summary>
 /// Gets the command bar lightweight control for this command bar entry.
 /// </summary>
 /// <returns>Lightweight control.</returns>
 public virtual LightweightControl GetLightweightControl(CommandBarLightweightControl commandBarLightweightControl, bool rightAligned)
 {
     return null;
 }
 public void ForceLayout()
 {
     CommandBarLightweightControl.PerformLayout();
 }
 /// <summary>
 /// Gets the lightweight control for this entry.
 /// </summary>
 /// <returns>Lightweight control.</returns>
 public override LightweightControl GetLightweightControl(CommandBarLightweightControl commandBarLightweightControl, bool rightAligned)
 {
     return new CommandBarSpacerLightweightControl();
 }
 /// <summary>
 /// Gets the control for this entry.
 /// </summary>
 /// <returns>Lightweight control.</returns>
 public override LightweightControl GetLightweightControl(CommandBarLightweightControl commandBarLightweightControl, bool rightAligned)
 {
     lightweightControl.LightweightControlContainerControl = commandBarLightweightControl;
     return(lightweightControl);
 }
        public CommandBarButtonLightweightControl(CommandBarLightweightControl commandBarLightweightControl, string commandIdentifier, bool rightAligned)
        {
            /// <summary>
            /// Required for Windows.Forms Class Composition Designer support
            /// </summary>
            InitializeComponent();
            InitializeObject();

            //	Set the command bar lightweight control.
            this.commandBarLightweightControl = commandBarLightweightControl;
            commandBarLightweightControl.CommandManagerChanged += new EventHandler(commandBarLightweightControl_CommandManagerChanged);

            //	Set the command identifier.
            this.commandIdentifier = commandIdentifier;

            this.rightAligned = rightAligned;

            this.contextMenuArrowBitmap = commandBarLightweightControl.ContextMenuArrowBitmap;
            this.contextMenuArrowBitmapDisabled = commandBarLightweightControl.ContextMenuArrowBitmapDisabled;

            //	Update the command.
            UpdateCommand();
        }
 /// <summary>
 /// Gets the control for this entry.
 /// </summary>
 /// <returns>Lightweight control.</returns>
 public override LightweightControl GetLightweightControl(CommandBarLightweightControl commandBarLightweightControl, bool rightAligned)
 {
     if (commandBarButtonLightweightControl == null)
         commandBarButtonLightweightControl = new CommandBarButtonLightweightControl(commandBarLightweightControl, commandIdentifier, rightAligned);
     return commandBarButtonLightweightControl;
 }
 public TransparentCommandBarControl(CommandBarLightweightControl commandBar, CommandBarDefinition commandBarDefinition) : base(commandBar, commandBarDefinition)
 {
 }
 /// <summary>
 /// Gets the control for this entry.
 /// </summary>
 /// <returns>Lightweight control.</returns>
 public override LightweightControl GetLightweightControl(CommandBarLightweightControl commandBarLightweightControl, bool rightAligned)
 {
     lightweightControl.LightweightControlContainerControl = commandBarLightweightControl;
     return lightweightControl;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Gets the lightweight control for this entry.
 /// </summary>
 /// <returns>Lightweight control.</returns>
 public override LightweightControl GetLightweightControl(CommandBarLightweightControl commandBarLightweightControl, bool rightAligned)
 {
     return(new CommandBarSpacerLightweightControl());
 }
 public TransparentCommandBarControl(CommandBarLightweightControl commandBar, CommandBarDefinition commandBarDefinition) : base(commandBar, commandBarDefinition)
 {
 }