public void Paint(ButtonItem item, ItemPaintArgs pa, CrumbBarItemViewColorTable itemColorTable)
        {
            Graphics g =pa.Graphics;

            CrumbBarItemViewStateColorTable stateTable = itemColorTable.Default;
            CrumbBarItemViewStateColorTable stateTable2 = null;
            bool isPressed = false;
            if (item.IsMouseDown || item.Expanded)
            {
                stateTable = itemColorTable.Pressed;
                isPressed = true;
            }
            else if (item.IsMouseOverExpand)
            {
                stateTable = itemColorTable.MouseOverInactive;
                stateTable2 = itemColorTable.MouseOver;
            }
            else if (item.IsMouseOver)
                stateTable = itemColorTable.MouseOver;
            
            Rectangle rect = item.DisplayRectangle;
            rect.Width--;
            rect.Height--;
            Rectangle expandRect = item.GetTotalSubItemsRect();
            if (!expandRect.IsEmpty)
            {
                expandRect.Offset(rect.Location);
                expandRect.Width--;
                expandRect.Height--;
            }

            PaintBackground(item, g, stateTable, stateTable2, isPressed, ref rect, ref expandRect);

            Color textColor = stateTable.Foreground;
            if (!item.ForeColor.IsEmpty)
                textColor = item.ForeColor;
            if (!textColor.IsEmpty)
            {
                // Render text
                Font font = item.GetFont(pa, false);
                bool rightToLeft = pa.RightToLeft;
                rect = GetTextRectangle(item);
                eTextFormat stringFormat = eTextFormat.Left | eTextFormat.VerticalCenter | eTextFormat.HidePrefix;
                if (item.TextMarkupBody == null)
                {
                    TextDrawing.DrawString(g, ButtonItemPainter.GetDrawText(item.Text), font, textColor, rect, stringFormat);
                }
                else
                {
                    TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, textColor, rightToLeft);
                    d.HotKeyPrefixVisible = !((stringFormat & eTextFormat.HidePrefix) == eTextFormat.HidePrefix);
                    d.ContextObject = item;
                    Rectangle mr = new Rectangle(rect.X, rect.Y + (rect.Height - item.TextMarkupBody.Bounds.Height) / 2 + 1, item.TextMarkupBody.Bounds.Width, item.TextMarkupBody.Bounds.Height);
                    item.TextMarkupBody.Bounds = mr;
                    item.TextMarkupBody.Render(d);
                }

                if ((item.SubItems.Count > 0 || item.PopupType == ePopupType.Container) && item.ShowSubItems)
                {
                    // Render expand sign
                    GraphicsPath path = GetExpandPath(item, expandRect);
                    if (path != null)
                    {
                        SmoothingMode sm = g.SmoothingMode;
                        g.SmoothingMode = SmoothingMode.Default;
                        using(Brush brush=new SolidBrush(stateTable.Foreground))
                            g.FillPath(brush, path);
                        g.SmoothingMode = sm;
                    }
                }
            }
        }
Exemple #2
0
        internal static CrumbBarItemViewColorTable GetCrumbBarVistaColorTable(ColorFactory factory)
        {
            CrumbBarItemViewColorTable viewColorTable = new CrumbBarItemViewColorTable();
            CrumbBarItemViewStateColorTable crumbBarViewTable = new CrumbBarItemViewStateColorTable();
            viewColorTable.Default = crumbBarViewTable;
            crumbBarViewTable.Foreground = Color.Black;
            crumbBarViewTable = new CrumbBarItemViewStateColorTable();
            viewColorTable.MouseOver = crumbBarViewTable;
            crumbBarViewTable.Foreground = Color.Black;
            crumbBarViewTable.Background = new BackgroundColorBlendCollection();
            crumbBarViewTable.Background.AddRange(new BackgroundColorBlend[]{
                new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("EAF6FD")), 0f),
                new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("D7EFFC")), .5f),
                new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("BDE6FD")), .5f),
                new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("A6D9F4")), 1f)});
            crumbBarViewTable.Border = factory.GetColor(ColorScheme.GetColor("3C7FB1"));
            crumbBarViewTable.BorderLight = factory.GetColor(ColorScheme.GetColor("E0FFFFFF"));
            crumbBarViewTable = new CrumbBarItemViewStateColorTable();
            viewColorTable.MouseOverInactive = crumbBarViewTable;
            crumbBarViewTable.Foreground = Color.Black;
            crumbBarViewTable.Background = new BackgroundColorBlendCollection();
            crumbBarViewTable.Background.AddRange(new BackgroundColorBlend[]{
                new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFF2F2F2")), 0f),
                new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFEAEAEA")), .5f),
                new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFDCDCDC")), .5f),
                new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFCFCFCF")), 1f)});
            crumbBarViewTable.Border = factory.GetColor(ColorScheme.GetColor("FF8E8F8F"));
            crumbBarViewTable.BorderLight = factory.GetColor(ColorScheme.GetColor("E0FFFFFF"));
            crumbBarViewTable = new CrumbBarItemViewStateColorTable();
            viewColorTable.Pressed = crumbBarViewTable;
            crumbBarViewTable.Foreground = Color.Black;
            crumbBarViewTable.Background = new BackgroundColorBlendCollection();
            crumbBarViewTable.Background.AddRange(new BackgroundColorBlend[]{
                new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFC2E4F6")), 0f),
                new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFC2E4F6")), .5f),
                new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FFA9D9F2")), .5f),
                new BackgroundColorBlend(factory.GetColor(ColorScheme.GetColor("FF90CBEB")), 1f)});
            crumbBarViewTable.Border = factory.GetColor(ColorScheme.GetColor("FF6E8D9F"));
            crumbBarViewTable.BorderLight = factory.GetColor(ColorScheme.GetColor("906E8D9F"));

            return viewColorTable;
        }
        public void PaintOverflowButton(ButtonItem item, ItemPaintArgs pa, CrumbBarItemViewColorTable itemColorTable)
        {
            Graphics g =pa.Graphics;

            CrumbBarItemViewStateColorTable stateTable = itemColorTable.Default;
            CrumbBarItemViewStateColorTable stateTable2 = null;
            bool isPressed = false;
            if (item.IsMouseDown || item.Expanded)
            {
                stateTable = itemColorTable.Pressed;
                isPressed = true;
            }
            else if (item.IsMouseOver)
                stateTable = itemColorTable.MouseOver;
            
            Rectangle rect = item.DisplayRectangle;
            rect.Width--;
            rect.Height--;
            Rectangle expandRect = Rectangle.Empty;

            PaintBackground(item, g, stateTable, stateTable2, isPressed, ref rect, ref expandRect);

            Color textColor = stateTable.Foreground;
            if (!textColor.IsEmpty)
            {
                SmoothingMode sm = g.SmoothingMode;
                Point p = new Point(rect.X + (rect.Width - 7) / 2, rect.Y + (rect.Height - 5) / 2);
                if (isPressed)
                    p.Offset(1, 1);
                using (Pen pen = new Pen(textColor, 1))
                {
                    for (int i = 0; i < 2; i++)
                    {
                        g.DrawLine(pen, p.X + 3, p.Y, p.X, p.Y + 2);
                        g.DrawLine(pen, p.X, p.Y + 2, p.X + 3, p.Y + 4);
                        p.X += 4;
                    }
                }
            }
        }