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;
                    }
                }
            }
        }
Esempio n. 2
0
 protected virtual Rectangle GetTotalSubItemsRect(ButtonItem button)
 {
     return button.GetTotalSubItemsRect();
 }