コード例 #1
0
ファイル: RibbonButton.cs プロジェクト: daywrite/EApp
 /// <summary>
 /// Creates a new button
 /// </summary>
 /// <param name="image">Image of the button (32 x 32 suggested)</param>
 /// <param name="smallImage">Image of the button when in medium of compact mode (16 x 16 suggested)</param>
 /// <param name="style">Style of the button</param>
 /// <param name="text">Text of the button</param>
 public RibbonButton()
 {
     _dropDownItems = new RibbonItemCollection();
     _dropDownArrowSize = new Size(5, 3);
     _dropDownMargin = new Padding(6);
     _DropDownArrowDirection = RibbonArrowDirection.Down;
     Image = CreateImage(32);
     SmallImage = CreateImage(16);
 }
コード例 #2
0
ファイル: RibbonButton.cs プロジェクト: rrossenbg/vprint
 /// <summary>
 /// Creates a new button
 /// </summary>
 /// <param name="image">Image of the button (32 x 32 suggested)</param>
 /// <param name="smallImage">Image of the button when in medium of compact mode (16 x 16 suggested)</param>
 /// <param name="style">Style of the button</param>
 /// <param name="text">Text of the button</param>
 public RibbonButton()
 {
     _dropDownItems          = new RibbonItemCollection();
     _dropDownArrowSize      = new Size(5, 3);
     _dropDownMargin         = new Padding(6);
     _DropDownArrowDirection = RibbonArrowDirection.Down;
     Image      = CreateImage(32);
     SmallImage = CreateImage(16);
 }
コード例 #3
0
 /// <summary>
 /// Creates a new button
 /// </summary>
 /// <param name="image">Image of the button (32 x 32 suggested)</param>
 /// <param name="smallImage">Image of the button when in medium of compact mode (16 x 16 suggested)</param>
 /// <param name="style">Style of the button</param>
 /// <param name="text">Text of the button</param>
 public RibbonButton()
 {
     _style = RibbonButtonStyle.Normal;
     _dropDownArrowDirection = RibbonArrowDirection.Down;
     _assignedHandlers       = new Set <RibbonItem>();
     DropDownItems           = new RibbonItemCollection();
     DropDownItems.SetOwnerItem(this);
     _dropDownArrowSize = new Size(5, 3);
     _dropDownMargin    = new Padding(6);
     Image                = CreateImage(32);
     SmallImage           = CreateImage(16);
     DrawDropDownIconsBar = true;
 }
        /// <summary>
        /// Draws the pair of arrows that make a shadded arrow, centered on the specified bounds
        /// </summary>
        /// <param name="g"></param>
        /// <param name="b"></param>
        /// <param name="d"></param>
        /// <param name="enabled"></param>
        public void DrawArrowShaded(Graphics g, Rectangle b, RibbonArrowDirection d, bool enabled)
        {
            Size arrSize = arrowSize;

            if (d == RibbonArrowDirection.Left || d == RibbonArrowDirection.Right)
            {
                //Invert size
                arrSize = new Size(arrowSize.Height, arrowSize.Width);
            }

            Point arrowP = new Point(
                 b.Left + (b.Width - arrSize.Width) / 2,
                 b.Top + (b.Height - arrSize.Height) / 2
                 );

            Rectangle bounds = new Rectangle(arrowP, arrSize);
            Rectangle boundsLight = bounds; boundsLight.Offset(0, 1);

            Color lt = ColorTable.ArrowLight;
            Color dk = ColorTable.Arrow;

            if (!enabled)
            {
                lt = Color.Transparent;
                dk = ColorTable.ArrowDisabled;
            }

            DrawArrow(g, boundsLight, lt, d);
            DrawArrow(g, bounds, dk, d);
        }
        /// <summary>
        /// Draws an arrow on the specified bounds
        /// </summary>
        /// <param name="g"></param>
        /// <param name="bounds"></param>
        /// <param name="c"></param>
        public void DrawArrow(Graphics g, Rectangle b, Color c, RibbonArrowDirection d)
        {
            GraphicsPath path = new GraphicsPath();
            Rectangle bounds = b;

            if (b.Width % 2 != 0 && (d == RibbonArrowDirection.Up))
                bounds = new Rectangle(new Point(b.Left - 1, b.Top - 1), new Size(b.Width + 1, b.Height + 1));

            if (d == RibbonArrowDirection.Up)
            {
                path.AddLine(bounds.Left, bounds.Bottom, bounds.Right, bounds.Bottom);
                path.AddLine(bounds.Right, bounds.Bottom, bounds.Left + bounds.Width / 2, bounds.Top);
            }
            else if (d == RibbonArrowDirection.Down)
            {
                path.AddLine(bounds.Left, bounds.Top, bounds.Right, bounds.Top);
                path.AddLine(bounds.Right, bounds.Top, bounds.Left + bounds.Width / 2, bounds.Bottom);
            }
            else if (d == RibbonArrowDirection.Left)
            {
                path.AddLine(bounds.Left, bounds.Top, bounds.Right, bounds.Top + bounds.Height / 2);
                path.AddLine(bounds.Right, bounds.Top + bounds.Height / 2, bounds.Left, bounds.Bottom);
            }
            else
            {
                path.AddLine(bounds.Right, bounds.Top, bounds.Left, bounds.Top + bounds.Height / 2);
                path.AddLine(bounds.Left, bounds.Top + bounds.Height / 2, bounds.Right, bounds.Bottom);
            }

            path.CloseFigure();

            using (SolidBrush bb = new SolidBrush(c))
            {
                SmoothingMode sm = g.SmoothingMode;
                g.SmoothingMode = SmoothingMode.None;
                g.FillPath(bb, path);
                g.SmoothingMode = sm;
            }

            path.Dispose();
        }