internal RibbonButtonCollection(RibbonButtonList list)
 {
     _ownerList = list;
 }
        public void DrawButtonList(Graphics g, RibbonButtonList list, Ribbon ribbon)
        {
            Rectangle outerR = Rectangle.FromLTRB(
                 list.Bounds.Left,
                 list.Bounds.Top,
                 list.Bounds.Right - 1,
                 list.Bounds.Bottom);

            using (GraphicsPath path = RoundRectangle(outerR, 3, Corners.East))
            {
                Color bgcolor = list.Selected ? ColorTable.ButtonListBgSelected : ColorTable.ButtonListBg;

                if (list.Canvas is RibbonDropDown) bgcolor = ColorTable.DropDownBg;

                using (SolidBrush b = new SolidBrush(bgcolor))
                {
                    g.FillPath(b, path);
                }

                using (Pen p = new Pen(ColorTable.ButtonListBorder))
                {
                    g.DrawPath(p, path);
                }
            }

            if (list.ScrollType == RibbonButtonList.ListScrollType.Scrollbar && ScrollBarRenderer.IsSupported)
            {

                ScrollBarRenderer.DrawUpperVerticalTrack(g, list.ScrollBarBounds, ScrollBarState.Normal);

                if (list.ThumbPressed)
                {
                    ScrollBarRenderer.DrawVerticalThumb(g, list.ThumbBounds, ScrollBarState.Pressed);
                    ScrollBarRenderer.DrawVerticalThumbGrip(g, list.ThumbBounds, ScrollBarState.Pressed);
                }
                else if (list.ThumbSelected)
                {
                    ScrollBarRenderer.DrawVerticalThumb(g, list.ThumbBounds, ScrollBarState.Hot);
                    ScrollBarRenderer.DrawVerticalThumbGrip(g, list.ThumbBounds, ScrollBarState.Hot);
                }
                else
                {
                    ScrollBarRenderer.DrawVerticalThumb(g, list.ThumbBounds, ScrollBarState.Normal);
                    ScrollBarRenderer.DrawVerticalThumbGrip(g, list.ThumbBounds, ScrollBarState.Normal);
                }

                if (list.ButtonUpPressed)
                {
                    ScrollBarRenderer.DrawArrowButton(g, list.ButtonUpBounds, ScrollBarArrowButtonState.UpPressed);
                }
                else if (list.ButtonUpSelected)
                {
                    ScrollBarRenderer.DrawArrowButton(g, list.ButtonUpBounds, ScrollBarArrowButtonState.UpHot);
                }
                else
                {
                    ScrollBarRenderer.DrawArrowButton(g, list.ButtonUpBounds, ScrollBarArrowButtonState.UpNormal);
                }

                if (list.ButtonDownPressed)
                {
                    ScrollBarRenderer.DrawArrowButton(g, list.ButtonDownBounds, ScrollBarArrowButtonState.DownPressed);
                }
                else if (list.ButtonDownSelected)
                {
                    ScrollBarRenderer.DrawArrowButton(g, list.ButtonDownBounds, ScrollBarArrowButtonState.DownHot);
                }
                else
                {
                    ScrollBarRenderer.DrawArrowButton(g, list.ButtonDownBounds, ScrollBarArrowButtonState.DownNormal);
                }
            }
            else
            {
                #region Control Buttons

                if (list.ScrollType == RibbonButtonList.ListScrollType.Scrollbar)
                {
                    using (SolidBrush b = new SolidBrush(ColorTable.ButtonGlossyNorth))
                    {
                        g.FillRectangle(b, list.ScrollBarBounds);
                    }
                }

                if (!list.ButtonDownEnabled)
                {
					DrawButtonDisabled(g, list.ButtonDownBounds, list.ButtonDropDownPresent?Corners.None:Corners.SouthEast);
                }
                else if (list.ButtonDownPressed)
                {
                    DrawButtonPressed(g, list.ButtonDownBounds, list.ButtonDropDownPresent ? Corners.None : Corners.SouthEast, ribbon);
                }
                else if (list.ButtonDownSelected)
                {
                    DrawButtonSelected(g, list.ButtonDownBounds, list.ButtonDropDownPresent ? Corners.None : Corners.SouthEast, ribbon);
                }
                else
                {
                    DrawButton(g, list.ButtonDownBounds, Corners.None);
                }

                if (!list.ButtonUpEnabled)
                {
					DrawButtonDisabled(g, list.ButtonUpBounds, Corners.NorthEast);
                }
                else if (list.ButtonUpPressed)
                {
                    DrawButtonPressed(g, list.ButtonUpBounds, Corners.NorthEast, ribbon);
                }
                else if (list.ButtonUpSelected)
                {
                    DrawButtonSelected(g, list.ButtonUpBounds, Corners.NorthEast, ribbon);
                }
                else
                {
                    DrawButton(g, list.ButtonUpBounds, Corners.NorthEast);
                }

                if (list.ButtonDropDownPresent)
                {
                    if (list.ButtonDropDownPressed)
                    {
                        DrawButtonPressed(g, list.ButtonDropDownBounds, Corners.SouthEast, ribbon);
                    }
                    else if (list.ButtonDropDownSelected)
                    {
                        DrawButtonSelected(g, list.ButtonDropDownBounds, Corners.SouthEast, ribbon);
                    }
                    else
                    {
                        DrawButton(g, list.ButtonDropDownBounds, Corners.SouthEast);
                    }
                }

                if (list.ScrollType == RibbonButtonList.ListScrollType.Scrollbar && list.ScrollBarEnabled)
                {
                    if (list.ThumbPressed)
                    {
                        DrawButtonPressed(g, list.ThumbBounds, Corners.All, ribbon);
                    }
                    else if (list.ThumbSelected)
                    {
                        DrawButtonSelected(g, list.ThumbBounds, Corners.All, ribbon);
                    }
                    else
                    {
                        DrawButton(g, list.ThumbBounds, Corners.All);
                    }

                }

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

                Rectangle arrUp = CenterOn(list.ButtonUpBounds, new Rectangle(Point.Empty, arrowSize)); arrUp.Offset(0, 1);
                Rectangle arrD = CenterOn(list.ButtonDownBounds, new Rectangle(Point.Empty, arrowSize)); arrD.Offset(0, 1);
                Rectangle arrdd = CenterOn(list.ButtonDropDownBounds, new Rectangle(Point.Empty, arrowSize)); arrdd.Offset(0, 3);

                DrawArrow(g, arrUp, list.ButtonUpEnabled ? lt : Color.Transparent, RibbonArrowDirection.Up); arrUp.Offset(0, -1);
                DrawArrow(g, arrUp, list.ButtonUpEnabled ? dk : ds, RibbonArrowDirection.Up);

                DrawArrow(g, arrD, list.ButtonDownEnabled ? lt : Color.Transparent, RibbonArrowDirection.Down); arrD.Offset(0, -1);
                DrawArrow(g, arrD, list.ButtonDownEnabled ? dk : ds, RibbonArrowDirection.Down);

                if (list.ButtonDropDownPresent)
                {


                    using (SolidBrush b = new SolidBrush(ColorTable.Arrow))
                    {
                        SmoothingMode sm = g.SmoothingMode;
                        g.SmoothingMode = SmoothingMode.None;
                        g.FillRectangle(b, new Rectangle(new Point(arrdd.Left - 1, arrdd.Top - 4), new Size(arrowSize.Width + 2, 1)));
                        g.SmoothingMode = sm;
                    }

                    DrawArrow(g, arrdd, lt, RibbonArrowDirection.Down); arrdd.Offset(0, -1);
                    DrawArrow(g, arrdd, dk, RibbonArrowDirection.Down);
                }
                #endregion
            }
        }
Esempio n. 3
0
        private void InitLists()
        {
            Image[] images = new Image[255];
            RibbonProfessionalRenderer rend = new RibbonProfessionalRenderer();
            BackColor = Theme.ColorTable.RibbonBackground;
            Random r = new Random();

            #region Color Squares
            using (GraphicsPath path = RibbonProfessionalRenderer.RoundRectangle(new Rectangle(3, 3, 26, 26), 4))
            {
                using (GraphicsPath outer = RibbonProfessionalRenderer.RoundRectangle(new Rectangle(0, 0, 32, 32), 4))
                {
                    for (int i = 0; i < images.Length; i++)
                    {
                        Bitmap b = new Bitmap(32, 32);

                        using (Graphics g = Graphics.FromImage(b))
                        {
                            g.SmoothingMode = SmoothingMode.AntiAlias;

                            using (SolidBrush br = new SolidBrush(Color.FromArgb(255, i * (255 / images.Length), 0)))
                            {
                                g.FillPath(br, path);
                            }

                            using (Pen p = new Pen(Color.White, 3))
                            {
                                g.DrawPath(p, path);
                            }

                            g.DrawPath(Pens.Wheat, path);

                            g.DrawString(Convert.ToString(i + 1), Font, Brushes.White, new Point(10, 10));
                        }

                        images[i] = b;

                        RibbonButton btn = new RibbonButton();
                        btn.Image = b;
                        lst.Buttons.Add(btn);
                    }
                }
            }

            //lst.DropDownItems.Add(new RibbonSeparator("Available styles"));
            RibbonButtonList lst2 = new RibbonButtonList();

            for (int i = 0; i < images.Length; i++)
            {
                RibbonButton btn = new RibbonButton();
                btn.Image = images[i];
                lst2.Buttons.Add(btn);
            }
            lst.DropDownItems.Add(lst2);
            lst.DropDownItems.Add(new RibbonButton("Save selection as a new quick style..."));
            lst.DropDownItems.Add(new RibbonButton("Erase Format"));
            lst.DropDownItems.Add(new RibbonButton("Apply style...")); 
            #endregion

            #region Theme Colors

            RibbonButton[] buttons = new RibbonButton[30];
            int square = 16;
            int squares = 4;
            int sqspace = 2;

            for (int i = 0; i < buttons.Length; i++)
            {
                #region Create color squares
                Bitmap colors = new Bitmap((square + sqspace) * squares, square + 1);
                string[] colorss = new string[squares];
                using (Graphics g = Graphics.FromImage(colors))
                {
                    for (int j = 0; j < 4; j++)
                    {
                        Color sqcolor = GetRandomColor(r);
                        colorss[j] = sqcolor.Name;
                        using (SolidBrush b = new SolidBrush(sqcolor))
                        {
                            g.FillRectangle(b, new Rectangle(j * (square + sqspace), 0, square, square));
                        }
                        g.DrawRectangle(Pens.Gray, new Rectangle(j * (square + sqspace), 0, square, square));
                    }
                } 
                #endregion

                buttons[i] = new RibbonButton(colors);
                buttons[i].Text = string.Join(", ", colorss); ;
                buttons[i].MaxSizeMode = RibbonElementSizeMode.Medium;
                buttons[i].MinSizeMode = RibbonElementSizeMode.Medium;
            }
            RibbonButtonList blst = new RibbonButtonList(buttons);
            blst.FlowToBottom = false;
            blst.ItemsSizeInDropwDownMode = new Size(1, 10);
            itemColors.DropDownItems.Insert(0, blst);
            itemColors.DropDownResizable = true;

            #endregion

        }
 public void DrawButtonListButtonUp(Graphics g, RibbonButtonList list)
 {
 }
 public void DrawButtonListButtonDropDown(Graphics g, RibbonButtonList list)
 {
 }
        public void DrawButtonList(Graphics g, RibbonButtonList list)
        {
            Rectangle outerR = Rectangle.FromLTRB(
                list.Bounds.Left,
                list.Bounds.Top,
                list.Bounds.Right - 1,
                list.Bounds.Bottom);

            using (GraphicsPath path = RoundRectangle(outerR, 3, Corners.East))
            {
                Color bgcolor = list.Selected ? ColorTable.ButtonListBgSelected : ColorTable.ButtonListBg;

                if (list.Canvas is RibbonDropDown) bgcolor = ColorTable.DropDownBg;

                using (SolidBrush b = new SolidBrush(bgcolor))
                {
                    g.FillPath(b, path);
                }

                using (Pen p = new Pen(ColorTable.ButtonListBorder))
                {
                    g.DrawPath(p, path);
                }
            }

            #region Control Buttons

            if (!list.ButtonDownEnabled)
            {
                DrawButtonDisabled(g, list.ButtonDownBounds,  list.ButtonDropDownPresent ? Corners.None : Corners.SouthEast);
            }
            else if (list.ButtonDownPressed)
            {
                DrawButtonPressed(g, list.ButtonDownBounds, list.ButtonDropDownPresent ? Corners.None : Corners.SouthEast);
            }
            else if (list.ButtonDownSelected)
            {
                DrawButtonSelected(g, list.ButtonDownBounds, list.ButtonDropDownPresent ? Corners.None : Corners.SouthEast);
            }
            else
            {
                DrawButton(g, list.ButtonDownBounds, Corners.None);
            }

            if (!list.ButtonUpEnabled)
            {
                DrawButtonDisabled(g, list.ButtonUpBounds, Corners.NorthEast);
            }
            else if (list.ButtonUpPressed)
            {
                DrawButtonPressed(g, list.ButtonUpBounds, Corners.NorthEast);
            }
            else if (list.ButtonUpSelected)
            {
                DrawButtonSelected(g, list.ButtonUpBounds, Corners.NorthEast);
            }
            else
            {
                DrawButton(g, list.ButtonUpBounds, Corners.NorthEast);
            }

            if (list.ButtonDropDownPresent)
            {
                if (list.ButtonDropDownPressed)
                {
                    DrawButtonPressed(g, list.ButtonDropDownBounds, Corners.SouthEast);
                }
                else if (list.ButtonDropDownSelected)
                {
                    DrawButtonSelected(g, list.ButtonDropDownBounds, Corners.SouthEast);
                }
                else
                {
                    DrawButton(g, list.ButtonDropDownBounds, Corners.SouthEast);
                }
            }

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

            Rectangle arrUp = CenterOn(list.ButtonUpBounds, new Rectangle(Point.Empty, arrowSize)); arrUp.Offset(0, 1);
            Rectangle arrD = CenterOn(list.ButtonDownBounds, new Rectangle(Point.Empty, arrowSize)); arrD.Offset(0, 1);
            Rectangle arrdd = CenterOn(list.ButtonDropDownBounds, new Rectangle(Point.Empty, arrowSize)); arrdd.Offset(0, 3);

            DrawArrow(g, arrUp, list.ButtonUpEnabled ? lt : Color.Transparent, Direction.Up); arrUp.Offset(0, -1);
            DrawArrow(g, arrUp, list.ButtonUpEnabled ? dk : ds, Direction.Up);

            DrawArrow(g, arrD, list.ButtonDownEnabled ? lt : Color.Transparent, Direction.Down); arrD.Offset(0, -1);
            DrawArrow(g, arrD, list.ButtonDownEnabled ? dk : ds, Direction.Down);

            if (list.ButtonDropDownPresent)
            {

                using (SolidBrush b = new SolidBrush(ColorTable.Arrow))
                {
                    SmoothingMode sm = g.SmoothingMode;
                    g.SmoothingMode = SmoothingMode.None;
                    g.FillRectangle(b, new Rectangle(new Point(arrdd.Left - 1, arrdd.Top - 4), new Size(arrowSize.Width + 2, 1)));
                    g.SmoothingMode = sm;
                }

                DrawArrow(g, arrdd, lt, Direction.Down); arrdd.Offset(0, -1);
                DrawArrow(g, arrdd, dk, Direction.Down);
            }
            #endregion
        }
 internal RibbonButtonCollection(RibbonButtonList list)
 {
     _ownerList = list;
 }