Beispiel #1
0
        private InternalComboColors GetComboColors()
        {
            InternalComboColors c = new InternalComboColors();

            bool bFocus = (m_MouseOverThumb || this.Focused || this.DroppedDownInternal && this.DropDownStyle != ComboBoxStyle.Simple);
            if (bFocus && !this.Enabled)
                bFocus = false;

            if (BarFunctions.IsOffice2007Style(this.Style) && GlobalManager.Renderer is Office2007Renderer)
            {
                Office2007ComboBoxColorTable colorTable = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.ComboBox;
                Office2007ComboBoxStateColorTable stateColors = (IsToolbarStyle && !m_MouseOver ? colorTable.Default : colorTable.DefaultStandalone);
                if (bFocus)
                {
                    if (this.DroppedDown)
                        stateColors = colorTable.DroppedDown;
                    else if (bFocus)
                        stateColors = colorTable.MouseOver;
                }

                c.Background = stateColors.Background;
                c.Border = stateColors.Border;
                c.ThumbBackground = stateColors.ExpandBackground;
                c.ThumbText = stateColors.ExpandText;
                c.ThumbBorderOuter = stateColors.ExpandBorderOuter;
                c.ThumbBorderInner = stateColors.ExpandBorderInner;
            }
            else
            {
                ColorScheme cs = new ColorScheme(this.Style);
                if (bFocus)
                {
                    if (DroppedDownInternal)
                    {
                        c.ThumbBackground = new LinearGradientColorTable(cs.ItemPressedBackground, cs.ItemPressedBackground2, cs.ItemPressedBackgroundGradientAngle);
                        c.Border = cs.ItemPressedBorder;
                        c.ThumbText = cs.ItemPressedText;
                    }
                    else
                    {
                        if (m_MouseOverThumb)
                            c.ThumbBackground = new LinearGradientColorTable(cs.ItemHotBackground, cs.ItemHotBackground2, cs.ItemHotBackgroundGradientAngle);
                        else
                            c.ThumbBackground = new LinearGradientColorTable(cs.BarBackground, cs.BarBackground2, cs.BarBackgroundGradientAngle);
                        c.Border = cs.ItemHotBorder;
                        c.ThumbText = cs.ItemHotText;
                    }
                }
                else
                {
                    c.ThumbBackground = new LinearGradientColorTable(cs.BarBackground, cs.BarBackground2, cs.BarBackgroundGradientAngle);
                    if (m_MouseOver || !IsToolbarStyle)
                    {
                        c.Border = cs.ItemHotBorder;
                    }
                }
            }

            if (_FocusHighlightEnabled && this.Enabled && this.Focused)
                c.Background = _FocusHighlightColor;
            else if (!this.Enabled)
            {
                c.Background = _DisabledBackColor.IsEmpty ? SystemColors.Control : _DisabledBackColor;
                c.ThumbText = _DisabledForeColor.IsEmpty ? SystemColors.ControlDark : _DisabledForeColor; ;
            }

            return c;
        }
Beispiel #2
0
 private void PaintComboBorder(Graphics g, Rectangle controlBounds, InternalComboColors colors)
 {
     if (!_RenderBorder) return;
     DisplayHelp.DrawRectangle(g, colors.Border, controlBounds);
 }
Beispiel #3
0
 private void PaintComboBackground(Graphics g, Rectangle controlBounds, InternalComboColors colors)
 {
     DisplayHelp.FillRectangle(g, controlBounds, colors.Background);
 }
Beispiel #4
0
        private Rectangle PaintComboThumb(Graphics g, Rectangle r, InternalComboColors colors)
        {
            Rectangle contentRect = r;
            contentRect.Inflate(-2, -2);

            if (this.DropDownStyle == ComboBoxStyle.Simple || !_RenderThumb) return contentRect;

            int thumbWidth = SystemInformation.HorizontalScrollBarThumbWidth;
            Rectangle thumbRect = new Rectangle(r.Width - thumbWidth, r.Y, thumbWidth, r.Height);
            if (RightToLeft == RightToLeft.Yes)
                thumbRect = new Rectangle(r.X + 1, r.Y + 1, thumbWidth, r.Height - 2);
            if (!this.IsToolbarStyle)
            {
                thumbRect.Y += 2;
                thumbRect.Height -= 4;
                thumbRect.Width -= 2; ;
                if (RightToLeft == RightToLeft.Yes)
                    thumbRect.X += 2;
            }
            else if (!BarFunctions.IsOffice2007Style(this.Style))
                thumbRect.Inflate(-1, -1);

            if (RightToLeft == RightToLeft.Yes)
            {
                int diff = thumbRect.Right - contentRect.X + 2;
                contentRect.Width -= diff;
                contentRect.X += diff;
            }
            else
            {
                int diff = contentRect.Right - thumbRect.X + 2;
                contentRect.Width -= diff;
            }
            //contentRect.Y++;
            //contentRect.Height--;

            if (!this.IsToolbarStyle && BarFunctions.IsOffice2007Style(this.Style))
            {
                Office2007ButtonItemPainter.PaintBackground(g, GetOffice2007StateColorTable(), thumbRect, RoundRectangleShapeDescriptor.RectangleShape);
            }
            else
            {
                if (colors.ThumbBackground != null)
                    DisplayHelp.FillRectangle(g, thumbRect, colors.ThumbBackground);
                if (colors.ThumbBorderOuter != null)
                    DisplayHelp.DrawGradientRectangle(g, thumbRect, colors.ThumbBorderOuter, 1);
                Rectangle innerBorder = thumbRect;
                innerBorder.Inflate(-1, -1);
                if (colors.ThumbBorderInner != null)
                    DisplayHelp.DrawGradientRectangle(g, innerBorder, colors.ThumbBorderInner, 1);
            }

            using (SolidBrush brush = new SolidBrush(colors.ThumbText))
                DrawArrow(thumbRect, g, brush);

            m_ThumbRect = thumbRect;
            return contentRect;
        }