public override void DrawCheckBoxItem(CheckBoxItemRenderEventArgs e) { CheckBoxItemPainter painter = PainterFactory.CreateCheckBoxItemPainter(e.CheckBoxItem); if (painter == null) return; if (painter is IOffice2007Painter) ((IOffice2007Painter)painter).ColorTable = m_ColorTable; painter.Paint(e); base.DrawCheckBoxItem(e); }
private Office2007CheckBoxStateColorTable GetCheckBoxStateColorTable(CheckBoxItemRenderEventArgs e) { CheckBoxItem item = e.CheckBoxItem; if (m_ColorTable != null && BarFunctions.IsOffice2007Style(e.CheckBoxItem.EffectiveStyle)) { Office2007CheckBoxColorTable ct = GetColorTable(e.CheckBoxItem, e.ItemPaintArgs.ContainerControl); // m_ColorTable.CheckBoxItem; if (!item.GetEnabled()) return ct.Disabled; else if (item.IsMouseDown) return ct.Pressed; else if (item.IsMouseOver) return ct.MouseOver; return ct.Default; } else { ColorScheme cs = e.ColorScheme; // Create color table based on the ColorScheme object... Office2007CheckBoxStateColorTable ct = new Office2007CheckBoxStateColorTable(); if (!item.GetEnabled()) { ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty); ct.CheckBorder = cs.ItemDisabledText; ct.CheckInnerBorder = cs.ItemDisabledText; ct.CheckInnerBackground = new LinearGradientColorTable(); ct.CheckSign = new LinearGradientColorTable(cs.ItemDisabledText, Color.Empty); ct.Text = cs.ItemDisabledText; } else if (item.IsMouseDown) { ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty); ct.CheckBorder = cs.ItemPressedBorder; ct.CheckInnerBorder = cs.ItemPressedBorder; ct.CheckInnerBackground = new LinearGradientColorTable(cs.ItemPressedBackground, cs.ItemPressedBackground2); ct.CheckSign = new LinearGradientColorTable(cs.ItemPressedText, Color.Empty); ct.Text = cs.ItemPressedText; } else if (item.IsMouseOver) { ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty); ct.CheckBorder = cs.ItemHotBorder; ct.CheckInnerBorder = cs.ItemHotBorder; ct.CheckInnerBackground = new LinearGradientColorTable(cs.ItemHotBackground, cs.ItemHotBackground2); ct.CheckSign = new LinearGradientColorTable(cs.ItemHotText, Color.Empty); ct.Text = cs.ItemHotText; } else { ct.CheckBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty); ct.CheckBorder = cs.PanelBorder; ct.CheckInnerBorder = ColorBlendFactory.SoftLight(cs.PanelBorder, Color.White); ct.CheckInnerBackground = new LinearGradientColorTable(cs.MenuBackground, Color.Empty); ct.CheckSign = new LinearGradientColorTable(cs.ItemText, Color.Empty); ct.Text = cs.ItemText; } return ct; } }
public override void Paint(CheckBoxItemRenderEventArgs e) { Graphics g = e.Graphics; CheckBoxItem item = e.CheckBoxItem; bool rtl = e.RightToLeft; Font font = e.Font; Office2007CheckBoxStateColorTable ct = this.GetCheckBoxStateColorTable(e); Rectangle checkBoxPosition = Rectangle.Empty; Rectangle textRect = Rectangle.Empty; eTextFormat tf = eTextFormat.Default; if (!(e.ItemPaintArgs != null && e.ItemPaintArgs.ContainerControl is DevComponents.DotNetBar.Controls.CheckBoxX || (e.ItemPaintArgs != null && e.ItemPaintArgs.ContainerControl is ItemControl) || (e.ItemPaintArgs != null && e.ItemPaintArgs.ContainerControl is Bar) || (e.ItemPaintArgs != null && e.ItemPaintArgs.ContainerControl is MenuPanel))) { tf |= eTextFormat.NoPrefix; } Size checkSignSize = item.GetCheckSignSize(); float baselineOffsetPixels = g.DpiY / 72f * (font.SizeInPoints / font.FontFamily.GetEmHeight(font.Style) * font.FontFamily.GetCellAscent(font.Style)) + .5f; //float fontDescentPixels = g.DpiY / 72f * (font.SizeInPoints / font.FontFamily.GetEmHeight(font.Style) * font.FontFamily.GetCellDescent(font.Style)); if (item.CheckBoxPosition == eCheckBoxPosition.Left && !rtl || item.CheckBoxPosition == eCheckBoxPosition.Right && rtl) { checkBoxPosition = new Rectangle(item.DisplayRectangle.X + item.CheckTextSpacing / 2, item.DisplayRectangle.Y + (item.DisplayRectangle.Height - checkSignSize.Height) / 2, checkSignSize.Width, checkSignSize.Height); textRect = new Rectangle(checkBoxPosition.Right + item.CheckTextSpacing / 2, item.DisplayRectangle.Y, item.DisplayRectangle.Right - (checkBoxPosition.Right + item.CheckTextSpacing / 2), item.DisplayRectangle.Height); if (item.TextMarkupBody == null) textRect.Y = checkBoxPosition.Bottom - (int)baselineOffsetPixels - 2; } else if (item.CheckBoxPosition == eCheckBoxPosition.Right && !rtl || item.CheckBoxPosition == eCheckBoxPosition.Left && rtl) { checkBoxPosition = new Rectangle(item.DisplayRectangle.Right - item.CheckTextSpacing / 2 - checkSignSize.Width, item.DisplayRectangle.Y + (item.DisplayRectangle.Height - checkSignSize.Height) / 2, checkSignSize.Width, checkSignSize.Height); textRect = new Rectangle(item.DisplayRectangle.X, item.DisplayRectangle.Y, checkBoxPosition.X - (item.DisplayRectangle.X + item.CheckTextSpacing / 2), item.DisplayRectangle.Height); if (item.TextMarkupBody == null) textRect.Y = checkBoxPosition.Bottom - (int)baselineOffsetPixels - 2; tf |= eTextFormat.Right; } else if (item.CheckBoxPosition == eCheckBoxPosition.Top) { checkBoxPosition = new Rectangle(item.DisplayRectangle.X + (item.DisplayRectangle.Width - checkSignSize.Width) / 2, item.DisplayRectangle.Y + item.VerticalPadding, checkSignSize.Width, checkSignSize.Height); textRect = new Rectangle(item.DisplayRectangle.X, checkBoxPosition.Bottom, item.DisplayRectangle.Width, item.DisplayRectangle.Bottom - checkBoxPosition.Bottom); tf |= eTextFormat.VerticalCenter | eTextFormat.HorizontalCenter; } else if (item.CheckBoxPosition == eCheckBoxPosition.Bottom) { checkBoxPosition = new Rectangle(item.DisplayRectangle.X + (item.DisplayRectangle.Width - checkSignSize.Width) / 2, item.DisplayRectangle.Bottom - item.VerticalPadding - checkSignSize.Height - 1, checkSignSize.Width, checkSignSize.Height); textRect = new Rectangle(item.DisplayRectangle.X, item.DisplayRectangle.Y, item.DisplayRectangle.Width, checkBoxPosition.Y - (item.DisplayRectangle.Y + item.VerticalPadding)); tf |= eTextFormat.VerticalCenter | eTextFormat.HorizontalCenter; } if (item.CheckState == CheckState.Unchecked && item.CheckBoxImageUnChecked != null) g.DrawImage(item.CheckBoxImageUnChecked, checkBoxPosition); else if (item.CheckState == CheckState.Checked && item.CheckBoxImageChecked != null) g.DrawImage(item.CheckBoxImageChecked, checkBoxPosition); else if (item.CheckState == CheckState.Indeterminate && item.CheckBoxImageIndeterminate != null) g.DrawImage(item.CheckBoxImageIndeterminate, checkBoxPosition); else { if (item.CheckBoxStyle == eCheckBoxStyle.CheckBox) { PaintCheckBox(g, checkBoxPosition, ct, item.CheckState); } else { PaintRadioButton(g, checkBoxPosition, ct, item.Checked); } } Color textColor = ct.Text; if (!item.TextColor.IsEmpty) textColor = item.TextColor; if (item.Text != "" && !textRect.IsEmpty && !textColor.IsEmpty && item.Orientation != eOrientation.Vertical && item.TextVisible) { if (item.TextMarkupBody != null) { TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, textColor, rtl); d.HotKeyPrefixVisible = !((tf & eTextFormat.HidePrefix) == eTextFormat.HidePrefix); if ((tf & eTextFormat.VerticalCenter) == eTextFormat.VerticalCenter) textRect.Y = item.TopInternal + (item.Bounds.Height - textRect.Height) / 2; else if ((tf & eTextFormat.Bottom) == eTextFormat.Bottom) textRect.Y += (item.Bounds.Height - textRect.Height) + 1; item.TextMarkupBody.Bounds = textRect; item.TextMarkupBody.Render(d); } else { #if FRAMEWORK20 if (e.ItemPaintArgs != null && e.ItemPaintArgs.GlassEnabled && item.Parent is CaptionItemContainer && !(e.ItemPaintArgs.ContainerControl is QatToolbar)) { if (!e.ItemPaintArgs.CachedPaint) Office2007RibbonControlPainter.PaintTextOnGlass(g, item.Text, font, textRect, TextDrawing.GetTextFormat(tf)); } else #endif TextDrawing.DrawString(g, item.Text, font, textColor, textRect, tf); } } if (item.Focused && item.DesignMode) { Rectangle r = item.DisplayRectangle; r.Inflate(-1, -1); DesignTime.DrawDesignTimeSelection(g, r, e.ColorScheme.ItemDesignTimeBorder); } }
/// <summary> /// Draws the CheckBoxItem. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you /// do not want default rendering to occur do not call the base implementation. You can call OnRenderCheckBoxItem method so events can occur. /// </summary> /// <param name="e">Provides context information.</param> public virtual void DrawCheckBoxItem(CheckBoxItemRenderEventArgs e) { OnRenderCheckBoxItem(e); }
/// <summary> /// Raises RenderCheckBoxItem event. /// </summary> /// <param name="e">Provides context information.</param> protected virtual void OnRenderCheckBoxItem(CheckBoxItemRenderEventArgs e) { if (RenderCheckBoxItem != null) RenderCheckBoxItem(this, e); }
/// <summary> /// Paints CheckBoxItem. /// </summary> /// <param name="e">Provides arguments for the operation.</param> public virtual void Paint(CheckBoxItemRenderEventArgs e) { }