コード例 #1
0
        /// <summary>
        /// Adds the specified item to the collection
        /// </summary>
        public new void Add(RibbonButton item)
        {
            CheckRestrictions(item);

            item.SetOwner(Owner);
            item.SetOwnerPanel(OwnerPanel);
            item.SetOwnerTab(OwnerTab);
            item.SetOwnerItem(OwnerList);

            base.Add(item);
        }
コード例 #2
0
        private void InitializeStructurePanel()
        {
            Text = text;
            ButtonMoreVisible = false;
            FlowsTo = RibbonPanelFlowDirection.Bottom;

            addItemButton = RibbonHelper.AddButton(this, new AddItem());
            addItemButton.Style = RibbonButtonStyle.DropDown;
            addItemButton.DropDownShowing += addItemButton_DropDownShowing;
            RibbonHelper.AddSeparator(this);

            // POSTPONE: Реализовать.
            //var b = RibbonHelper.AddButton(this, new CopyItem());
            //b.MaxSizeMode = RibbonElementSizeMode.Medium;
            //b = RibbonHelper.AddButton(this, new PasteItem());
            //b.MaxSizeMode = RibbonElementSizeMode.Medium;
            var b = RibbonHelper.AddButton(this, new DeleteItem());
            b.MaxSizeMode = RibbonElementSizeMode.Medium;
            RibbonHelper.AddSeparator(this);
            RibbonHelper.AddButton(this, new ItemOptions());
        }
コード例 #3
0
 /// <summary>
 /// Draws the button as a selected button
 /// </summary>
 /// <param name="g"></param>
 /// <param name="button"></param>
 public void DrawButtonSelected(Graphics g, RibbonButton button)
 {
     DrawButtonSelected(g, button.Bounds, ButtonCorners(button));
 }
コード例 #4
0
        /// <summary>
        /// Draws the arrow of buttons
        /// </summary>
        /// <param name="g"></param>
        /// <param name="button"></param>
        public void DrawButtonDropDownArrow(Graphics g, RibbonButton button, Rectangle textLayout)
        {
            var bounds = Rectangle.Empty;

            if (button.SizeMode == RibbonElementSizeMode.Large || button.SizeMode == RibbonElementSizeMode.Overflow)
            {

                bounds = LargeButtonDropDownArrowBounds(g, button.Owner.Font, button.Text, textLayout);

            }
            else
            {
                bounds = textLayout;
            }

            DrawArrowShaded(g, bounds, button.DropDownArrowDirection, button.Enabled);
        }
コード例 #5
0
        /// <summary>
        /// Determines buttonface corners
        /// </summary>
        /// <param name="button"></param>
        /// <returns></returns>
        private Corners ButtonFaceRounding(RibbonButton button)
        {
            if (!(button.OwnerItem is RibbonItemGroup))
            {
                return button.SizeMode == RibbonElementSizeMode.Large ? Corners.North : Corners.West;
            }

            var c = Corners.None;
            var g = button.OwnerItem as RibbonItemGroup;
            if (button == g.FirstItem)
            {
                c |= Corners.West;
            }

            return c;
        }
コード例 #6
0
        /// <summary>
        /// Gets the corners to round on the specified button
        /// </summary>
        /// <param name="button"></param>
        /// <returns></returns>
        private Corners ButtonCorners(RibbonButton button)
        {
            if (!(button.OwnerItem is RibbonItemGroup))
            {
                return Corners.All;
            }

            var g = button.OwnerItem as RibbonItemGroup;
            var c = Corners.None;
            if (button == g.FirstItem)
            {
                c |= Corners.West;
            }

            if (button == g.LastItem)
            {
                c |= Corners.East;
            }

            return c;
        }
コード例 #7
0
        /// <summary>
        /// Draws a SplitDropDown button in selected state
        /// </summary>
        /// <param name="e"></param>
        /// <param name="button"></param>
        public void DrawSplitButtonSelected(RibbonItemRenderEventArgs e, RibbonButton button)
        {
            var outerR = Rectangle.FromLTRB(
                button.DropDownBounds.Left,
                button.DropDownBounds.Top,
                button.DropDownBounds.Right - 1,
                button.DropDownBounds.Bottom - 1);

            var innerR = Rectangle.FromLTRB(
                outerR.Left + 1,
                outerR.Top + 1,
                outerR.Right - 1,
                outerR.Bottom - 1);

            var faceOuterR = Rectangle.FromLTRB(
                button.ButtonFaceBounds.Left,
                button.ButtonFaceBounds.Top,
                button.ButtonFaceBounds.Right - 1,
                button.ButtonFaceBounds.Bottom - 1);

            var faceInnerR = Rectangle.FromLTRB(
                faceOuterR.Left + 1,
                faceOuterR.Top + 1,
                faceOuterR.Right + (button.SizeMode == RibbonElementSizeMode.Large ? -1 : 0),
                faceOuterR.Bottom + (button.SizeMode == RibbonElementSizeMode.Large ? 0 : -1));

            var faceCorners = ButtonFaceRounding(button);
            var ddCorners = ButtonDdRounding(button);

            var outer = RoundRectangle(outerR, 3, ddCorners);
            var inner = RoundRectangle(innerR, 2, ddCorners);
            var faceOuter = RoundRectangle(faceOuterR, 3, faceCorners);
            var faceInner = RoundRectangle(faceInnerR, 2, faceCorners);

            using (var b = new SolidBrush(Color.FromArgb(150, Color.White)))
            {
                e.Graphics.FillPath(b, inner);
            }

            using (var p = new Pen(button.Pressed && button.SizeMode != RibbonElementSizeMode.DropDown ? ColorTable.ButtonPressedBorderOut : ColorTable.ButtonSelectedBorderOut))
            {
                e.Graphics.DrawPath(p, outer);
            }

            using (var p = new Pen(button.Pressed && button.SizeMode != RibbonElementSizeMode.DropDown ? ColorTable.ButtonPressedBorderIn : ColorTable.ButtonSelectedBorderIn))
            {
                e.Graphics.DrawPath(p, faceInner);
            }

            outer.Dispose(); inner.Dispose(); faceOuter.Dispose(); faceInner.Dispose();
        }
コード例 #8
0
 /// <summary>
 /// Draws a SplitDropDown button with the dropdown area pressed
 /// </summary>
 /// <param name="e"></param>
 /// <param name="button"></param>
 public void DrawSplitButtonDropDownPressed(RibbonItemRenderEventArgs e, RibbonButton button)
 {
 }
コード例 #9
0
        /// <summary>
        /// Checks for the restrictions that buttons should have on the RibbonButton List
        /// </summary>
        /// <param name="button"></param>
        private void CheckRestrictions(RibbonButton button)
        {
            if (button == null)
                throw new ApplicationException("The RibbonButtonList only accepts button in the Buttons collection");

            if (button.Style != RibbonButtonStyle.Normal)
                throw new ApplicationException("The only style supported by the RibbonButtonList is Normal");
        }