public ShowPlaybackForm() { InitializeComponent(); var enumValues = Enum.GetValues(typeof(HeadSetTypes)).Cast <object>().Select(x => new { Value = x, Name = x.ToString() }).ToList(); this.Playback.DataSource = enumValues; this.Playback.ValueMember = "Value"; this.Playback.DisplayMember = "Name"; this.Playback.DrawMode = DrawMode.OwnerDrawFixed; this.Playback.ItemHeight = RadioButtonRenderer.GetGlyphSize( Graphics.FromHwnd(IntPtr.Zero), RadioButtonState.CheckedNormal).Height + 4; this.Playback.DrawItem += (obj, ea) => { var lb = (ListBox)obj; ea.DrawBackground(); var text = lb.GetItemText(lb.Items[ea.Index]); var r = ea.Bounds; r.Offset(ea.Bounds.Height, 0); RadioButtonRenderer.DrawRadioButton(ea.Graphics, new Point(ea.Bounds.Location.X, ea.Bounds.Location.Y + 2), r, text, lb.Font, TextFormatFlags.Left, false, (ea.State & DrawItemState.Selected) == DrawItemState.Selected ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal); }; }
private void PaintAnimatedButton(Graphics g, Rectangle bounds, RadioButtonState curState, RadioButtonListItem li) { Point gp = li.GlyphPosition; gp.Offset(bounds.Location); RadioButtonRenderer.DrawRadioButton(g, gp, curState); }
// Three state checkbox column cell //protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, // DataGridViewElementStates elementState, object value, object formattedValue, string errorText, // DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) //{ // // The checkBox cell is disabled, so paint the border, background, and disabled checkBox for the cell. // if (!this.Enabled) // { // // Draw the cell background, if specified. // if ((paintParts & DataGridViewPaintParts.Background) == DataGridViewPaintParts.Background) // { // SolidBrush cellBackground = new SolidBrush(cellStyle.BackColor); // graphics.FillRectangle(cellBackground, cellBounds); // cellBackground.Dispose(); // } // // Draw the cell borders, if specified. // if ((paintParts & DataGridViewPaintParts.Border) == DataGridViewPaintParts.Border) // { // PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle); // } // // Calculate the area in which to draw the checkBox. // CheckBoxState state = CheckBoxState.MixedDisabled;//value != null && (SelectedStatus)value != SelectedStatus.AlreadyInstalled ? CheckBoxState.UncheckedNormal : CheckBoxState.MixedDisabled;//.UncheckedDisabled; // Size size = CheckBoxRenderer.GetGlyphSize(graphics, state); // Point center = new Point(cellBounds.X, cellBounds.Y); // center.X += (cellBounds.Width - size.Width) / 2; // center.Y += (cellBounds.Height - size.Height) / 2; // // Draw the disabled checkBox. // CheckBoxRenderer.DrawCheckBox(graphics, center, state); // } // else // { // // The checkBox cell is enabled, so let the base class, handle the painting. // base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); // } //} // Radiobutton column cell protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { // Draw the cell background, if specified. if ((paintParts & DataGridViewPaintParts.Background) == DataGridViewPaintParts.Background) { SolidBrush cellBackground = new SolidBrush(cellStyle.BackColor); graphics.FillRectangle(cellBackground, cellBounds); cellBackground.Dispose(); } // Draw the cell borders, if specified. if ((paintParts & DataGridViewPaintParts.Border) == DataGridViewPaintParts.Border) { PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle); } // Calculate the area in which to draw the checkBox. RadioButtonState state = value != null && (SelectedStatus)value == SelectedStatus.Selected ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal; Size size = RadioButtonRenderer.GetGlyphSize(graphics, state); Point center = new Point(cellBounds.X, cellBounds.Y); center.X += (cellBounds.Width - size.Width) / 2; center.Y += (cellBounds.Height - size.Height) / 2; // Draw the disabled checkBox. RadioButtonRenderer.DrawRadioButton(graphics, center, state); }
protected override void OnOwnerDraw(Graphics g) { RadioButton radioButton = base.HostControl as RadioButton; RadioButtonState state = radioButton.Focused ? RadioButtonState.UncheckedHot : RadioButtonState.UncheckedNormal; System.Drawing.ContentAlignment checkAlign = radioButton.CheckAlign; Size glyphSize = RadioButtonRenderer.GetGlyphSize(g, state); Rectangle rectangle = base.CalculateCheckBounds(checkAlign, glyphSize); if (base["Checked"] == 3) { int num = LayoutHelper.IsRightToLeft(base.HostControl) ? 12 : 8; Rectangle targetRect = new Rectangle(rectangle.Left + rectangle.Width - num, rectangle.Top, 8, 8); Color color = radioButton.Enabled ? radioButton.BackColor : SystemColors.Control; using (new SolidBrush(color)) { g.DrawIcon(Icons.LockIcon, targetRect); } radioButton.Enabled = false; return; } if (Application.RenderWithVisualStyles) { RadioButtonRenderer.DrawRadioButton(g, rectangle.Location, state); return; } rectangle.X--; ControlPaint.DrawRadioButton(g, rectangle, ButtonState.Normal); }
/// <summary> /// Paints the button. /// </summary> /// <param name="g">A <see cref="Graphics" /> reference.</param> /// <param name="index">The index of the item.</param> /// <param name="bounds">The bounds in which to paint the item.</param> /// <param name="newState"></param> protected override void PaintButton(Graphics g, int index, Rectangle bounds, bool newState) { var li = BaseItems[index] as RadioButtonListItem; if (li == null) { throw new ArgumentOutOfRangeException(nameof(index)); } // Get current state var curState = li.Checked ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal; if (!Enabled || !li.Enabled) { curState += 3; } else if (index == PressingItem) { curState += 2; } else if (index == HoverItem) { curState++; } li.State = curState; // Draw glyph var gp = li.GlyphPosition; gp.Offset(bounds.Location); RadioButtonRenderer.DrawRadioButton(g, gp, newState ? li.State : li.PrevState); System.Diagnostics.Debug.WriteLine($"PaintRadioButton[{index}]: tx='{li.Text}'; r={bounds}; st[{newState}]={(newState ? li.State : li.PrevState)}"); }
protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates dataGridViewElementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { base.Paint(graphics, clipBounds, cellBounds, rowIndex, dataGridViewElementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); Point p = new Point(); Size s = RadioButtonRenderer.GetGlyphSize(graphics, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal); p.X = cellBounds.Location.X + (cellBounds.Width / 2) - (s.Width / 2); p.Y = cellBounds.Location.Y + (cellBounds.Height / 2) - (s.Height / 2); _cellLocation = cellBounds.Location; radioButtonLocation = p; radioButtonSize = s; if (_checked) { _cbState = System.Windows.Forms.VisualStyles.RadioButtonState.CheckedNormal; } else { _cbState = System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal; } RadioButtonRenderer.DrawRadioButton(graphics, radioButtonLocation, _cbState); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); float totalLength = e.ClipRectangle.Right - e.ClipRectangle.Left; float quaterLength = ((totalLength / 2) / 4); int startPoint = (int)(e.ClipRectangle.Left + 10); Rectangle rectAngle = new Rectangle(e.ClipRectangle.X, e.ClipRectangle.Y - 1, e.ClipRectangle.Width, e.ClipRectangle.Height); rectAngle.X = startPoint + CheckBoxRenderer.GetGlyphSize(e.Graphics, CheckBoxState.UncheckedNormal).Width; SizeF sizeF = e.Graphics.MeasureString(Text, this.Font); rectAngle.Width = (int)sizeF.Width + 2; rectAngle.Height = this.Font.Height; CheckBoxRenderer.RenderMatchingApplicationState = true; Rectangle rectAngleBack = new Rectangle(startPoint - 3, rectAngle.Y, (rectAngle.X - (startPoint - 3)) + rectAngle.Width, rectAngle.Height); RadioButtonRenderer.DrawParentBackground(e.Graphics, rectAngleBack, this); Font font = Font; RadioButtonRenderer.DrawRadioButton(e.Graphics, new System.Drawing.Point(startPoint, e.ClipRectangle.Y), rectAngle, Text, this.Font, TextFormatFlags.VerticalCenter, false, checkedStatus ? RadioButtonState.CheckedNormal: RadioButtonState.UncheckedNormal); }
private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { Rectangle bounds = e.SubItem.Bounds; if (e.ColumnIndex == 0) { bounds.Width = bounds.X + e.Item.SubItems[1].Bounds.X; } //toggle colors if the item is highlighted if (e.Item.Selected && e.Item.ListView.Focused) { e.SubItem.BackColor = SystemColors.Highlight; e.SubItem.ForeColor = e.Item.ListView.BackColor; } else if (e.Item.Selected && !e.Item.ListView.Focused) { e.SubItem.BackColor = SystemColors.Control; e.SubItem.ForeColor = e.Item.ListView.ForeColor; } else { e.SubItem.BackColor = e.Item.ListView.BackColor; e.SubItem.ForeColor = e.Item.ListView.ForeColor; } // Draw the standard header background. e.DrawBackground(); int xOffset = 0; if (e.ColumnIndex == 0) { Point glyphPoint = new Point(4, e.Item.Position.Y + 2); MyTask task = e.Item.Tag as MyTask; if (string.IsNullOrEmpty(task.TaskGroupName)) { CheckBoxState state = e.Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal; CheckBoxRenderer.DrawCheckBox(e.Graphics, glyphPoint, state); xOffset = CheckBoxRenderer.GetGlyphSize(e.Graphics, state).Width + 4; } else { RadioButtonState state = e.Item.Checked ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal; RadioButtonRenderer.DrawRadioButton(e.Graphics, glyphPoint, state); xOffset = RadioButtonRenderer.GetGlyphSize(e.Graphics, state).Width + 4; } } //add a 2 pixel buffer the match default behavior Rectangle rec = new Rectangle(e.Bounds.X + 2 + xOffset, e.Bounds.Y + 2, e.Bounds.Width - 4, e.Bounds.Height - 4); //TODO Confirm combination of TextFormatFlags.EndEllipsis and TextFormatFlags.ExpandTabs works on all systems. MSDN claims they're exclusive but on Win7-64 they work. TextFormatFlags flags = TextFormatFlags.Left | TextFormatFlags.EndEllipsis | TextFormatFlags.ExpandTabs | TextFormatFlags.SingleLine; //If a different tabstop than the default is needed, will have to p/invoke DrawTextEx from win32. TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.Item.ListView.Font, rec, e.SubItem.ForeColor, flags); }
public override void OnPaint(object sender, RibbonElementPaintEventArgs e) { if (Owner != null) { Owner.Renderer.OnRenderRibbonItem(new RibbonItemRenderEventArgs(Owner, e.Graphics, Bounds, this)); if (Style == CheckBoxStyle.CheckBox) { var CheckState = Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal; if (Selected) { CheckState += 1; } if (CheckBoxOrientation == CheckBoxOrientationEnum.Left) { CheckBoxRenderer.DrawCheckBox(e.Graphics, new Point(_checkboxBounds.Left, _checkboxBounds.Top), CheckState); } else { CheckBoxRenderer.DrawCheckBox(e.Graphics, new Point(_checkboxBounds.Left + spacing, _checkboxBounds.Top), CheckState); } } else { var RadioState = Checked ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal; if (Selected) { RadioState += 1; } if (CheckBoxOrientation == CheckBoxOrientationEnum.Left) { RadioButtonRenderer.DrawRadioButton(e.Graphics, new Point(_checkboxBounds.Left, _checkboxBounds.Top), RadioState); } else { RadioButtonRenderer.DrawRadioButton(e.Graphics, new Point(_checkboxBounds.Left + spacing, _checkboxBounds.Top), RadioState); } } if (LabelVisible) { var f = new StringFormat(); if (_CheckBoxOrientation == CheckBoxOrientationEnum.Left) { f.Alignment = StringAlignment.Near; } else { f.Alignment = StringAlignment.Far; } f.LineAlignment = StringAlignment.Far; //Top f.Trimming = StringTrimming.None; f.FormatFlags |= StringFormatFlags.NoWrap; Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs(Owner, e.Graphics, _labelBounds, this, LabelBounds, Text, f)); } } }
static void DrawRadioButton(Graphics g, Rectangle bounds, RadioButtonState state) { RadioButtonRenderer.DrawRadioButton( g, bounds.Location, state ); }
//</Snippet2> //<Snippet4> // Draw the radio button in the current state. protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); RadioButtonRenderer.DrawRadioButton(e.Graphics, ClientRectangle.Location, TextRectangle, this.Text, this.Font, clicked, state); }
// Let the item paint itself, and then paint the RadioButton // where the check mark is normally displayed. protected override void OnPaint(PaintEventArgs e) { if (Image != null) { // If the client sets the Image property, the selection behavior // remains unchanged, but the RadioButton is not displayed and the // selection is indicated only by the selection rectangle. base.OnPaint(e); return; } else { // If the Image property is not set, call the base OnPaint method // with the CheckState property temporarily cleared to prevent // the check mark from being painted. CheckState currentState = this.CheckState; this.CheckState = CheckState.Unchecked; base.OnPaint(e); this.CheckState = currentState; } // Determine the correct state of the RadioButton. RadioButtonState buttonState = RadioButtonState.UncheckedNormal; if (Enabled) { if (mouseDownState) { if (Checked) buttonState = RadioButtonState.CheckedPressed; else buttonState = RadioButtonState.UncheckedPressed; } else if (mouseHoverState) { if (Checked) buttonState = RadioButtonState.CheckedHot; else buttonState = RadioButtonState.UncheckedHot; } else { if (Checked) buttonState = RadioButtonState.CheckedNormal; } } else { if (Checked) buttonState = RadioButtonState.CheckedDisabled; else buttonState = RadioButtonState.UncheckedDisabled; } // Calculate the position at which to display the RadioButton. Int32 offset = (ContentRectangle.Height - RadioButtonRenderer.GetGlyphSize( e.Graphics, buttonState).Height) / 2; Point imageLocation = new Point( ContentRectangle.Location.X + 4, ContentRectangle.Location.Y + offset); // Paint the RadioButton. RadioButtonRenderer.DrawRadioButton( e.Graphics, imageLocation, buttonState); }
// Main paiting method protected override void OnDrawItem(DrawItemEventArgs e) { var maxItem = Items.Count - 1; if (e.Index < 0 || e.Index > maxItem) { // Erase all background if control has no items e.Graphics.FillRectangle(_backBrush, ClientRectangle); return; } // Calculate bounds for background, if last item paint up to bottom of control var backRect = e.Bounds; if (e.Index == maxItem) { backRect.Height = ClientRectangle.Top + ClientRectangle.Height - e.Bounds.Top; } e.Graphics.FillRectangle(_backBrush, backRect); // Determines text color/brush Brush textBrush; var isChecked = (e.State & DrawItemState.Selected) == DrawItemState.Selected; var state = isChecked ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal; if ((e.State & DrawItemState.Disabled) == DrawItemState.Disabled) { textBrush = SystemBrushes.GrayText; state = isChecked ? RadioButtonState.CheckedDisabled : RadioButtonState.UncheckedDisabled; } else if ((e.State & DrawItemState.Grayed) == DrawItemState.Grayed) { textBrush = SystemBrushes.GrayText; state = isChecked ? RadioButtonState.CheckedDisabled : RadioButtonState.UncheckedDisabled; } else { textBrush = SystemBrushes.FromSystemColor(ForeColor); } // Determines bounds for text and radio button var glyphSize = RadioButtonRenderer.GetGlyphSize(e.Graphics, state); var glyphLocation = e.Bounds.Location; glyphLocation.Y += (e.Bounds.Height - glyphSize.Height) / 2; var bounds = new Rectangle(e.Bounds.X + glyphSize.Width, e.Bounds.Y, e.Bounds.Width - glyphSize.Width, e.Bounds.Height); // Draws the radio button RadioButtonRenderer.DrawRadioButton(e.Graphics, glyphLocation, state); // Draws the text e.Graphics.DrawString(Items[e.Index].ToString(), e.Font, textBrush, bounds, _align); // If the ListBox has focus, draw a focus rectangle around the selected item. e.DrawFocusRectangle(); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (this.Image != null) { return; } RadioButtonState state = RadioButtonState.UncheckedNormal; if (this.Enabled) { if (this.m_mouseDownState) { state = this.Checked ? RadioButtonState.CheckedPressed : RadioButtonState.UncheckedPressed; } else if (this.m_mouseHoverState) { state = this.Checked ? RadioButtonState.CheckedHot : RadioButtonState.UncheckedHot; } else { state = this.Checked ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal; } } else { state = this.Checked ? RadioButtonState.CheckedDisabled : RadioButtonState.UncheckedDisabled; } Int32 offset = (ContentRectangle.Height - RadioButtonRenderer.GetGlyphSize(e.Graphics, state).Height) / 2; Point imageLocation = new Point(ContentRectangle.Location.X + 4, ContentRectangle.Location.Y + offset); if (this.Checked && RadioButtonRenderer.IsBackgroundPartiallyTransparent(state)) { Size glyphSize = RadioButtonRenderer.GetGlyphSize(e.Graphics, state); glyphSize.Width--; glyphSize.Height--; Rectangle backgroundRectangle = new Rectangle(imageLocation, glyphSize); e.Graphics.FillEllipse(SystemBrushes.Control, backgroundRectangle); } RadioButtonRenderer.DrawRadioButton(e.Graphics, imageLocation, state); }
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) { ToolStripMenuItem item = e.Item as ToolStripMenuItem; if (item != null && languages.Contains(item)) { RadioButtonRenderer.DrawRadioButton(e.Graphics, e.ImageRectangle.Location, System.Windows.Forms.VisualStyles.RadioButtonState.CheckedNormal); } else { base.OnRenderItemCheck(e); } }
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.ColumnIndex == 1 && e.RowIndex >= 0) { var value = (bool?)e.FormattedValue; e.Paint(e.CellBounds, DataGridViewPaintParts.All & ~DataGridViewPaintParts.ContentForeground); var state = value.HasValue && value.Value ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal; var size = RadioButtonRenderer.GetGlyphSize(e.Graphics, state); var location = new Point((e.CellBounds.Width - size.Width) / 2, (e.CellBounds.Height - size.Height) / 2); location.Offset(e.CellBounds.Location); RadioButtonRenderer.DrawRadioButton(e.Graphics, location, state); e.Handled = true; } }
private static void DrawCheckBox(DrawListViewSubItemEventArgs e, TaskSelection tasks, out int checkboxWidth) { Point glyphPoint = new Point(4, e.Item.Position.Y + 2); if (!string.IsNullOrEmpty(tasks.TaskGroupName)) { RadioButtonState state; if (tasks.Forbidden) { state = RadioButtonState.UncheckedDisabled; } else { state = e.Item.Checked ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal; } RadioButtonRenderer.DrawRadioButton(e.Graphics, glyphPoint, state); checkboxWidth = RadioButtonRenderer.GetGlyphSize(e.Graphics, state).Width + 4; } else if (tasks.DesignTime) { checkboxWidth = CheckBoxRenderer.GetGlyphSize(e.Graphics, CheckBoxState.UncheckedNormal).Width + 4; } else { CheckBoxState state; if (tasks.Forbidden) { state = CheckBoxState.UncheckedDisabled; } else { state = (tasks.Enabled3State == Enabled3State.AllEnabled) ? CheckBoxState.CheckedNormal : (tasks.Enabled3State == Enabled3State.AllDisabled) ? CheckBoxState.UncheckedNormal : CheckBoxState.MixedNormal; } CheckBoxRenderer.DrawCheckBox(e.Graphics, glyphPoint, state); checkboxWidth = CheckBoxRenderer.GetGlyphSize(e.Graphics, state).Width + 4; } }
protected void DrawCheckBox(PaintEventArgs e, ButtonBaseAdapter.LayoutData layout) { Graphics g = e.Graphics; Rectangle checkBounds = layout.checkBounds; if (!Application.RenderWithVisualStyles) { checkBounds.X--; } ButtonState state = this.GetState(); if (Application.RenderWithVisualStyles) { RadioButtonRenderer.DrawRadioButton(g, new Point(checkBounds.Left, checkBounds.Top), RadioButtonRenderer.ConvertFromButtonState(state, this.Control.MouseIsOver)); } else { ControlPaint.DrawRadioButton(g, checkBounds, state); } }
protected override void OnDrawItem(DrawItemEventArgs e) { var text = (Items.Count > 0) ? GetItemText(Items[e.Index]) : Name; Rectangle r = e.Bounds; Point p; var flags = TextFormatFlags.Default | TextFormatFlags.NoPrefix; var selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected; var state = selected ? (Enabled ? RadioButtonState.CheckedNormal : RadioButtonState.CheckedDisabled) : (Enabled ? RadioButtonState.UncheckedNormal : RadioButtonState.UncheckedDisabled); if (RightToLeft == System.Windows.Forms.RightToLeft.Yes) { p = new Point(r.Right - r.Height + (ItemHeight - s.Width) / 2, r.Top + (ItemHeight - s.Height) / 2); r = new Rectangle(r.Left, r.Top, r.Width - r.Height, r.Height); flags |= TextFormatFlags.RightToLeft | TextFormatFlags.Right; } else { p = new Point(r.Left + (ItemHeight - s.Width) / 2, r.Top + (ItemHeight - s.Height) / 2); r = new Rectangle(r.Left + r.Height, r.Top, r.Width - r.Height, r.Height); } var bc = selected ? (Enabled ? SystemColors.Highlight : SystemColors.InactiveBorder) : BackColor; var fc = selected ? (Enabled ? SystemColors.HighlightText : SystemColors.GrayText) : ForeColor; using (var b = new SolidBrush(bc)) { e.Graphics.FillRectangle(b, e.Bounds); } RadioButtonRenderer.DrawRadioButton(e.Graphics, p, state); TextRenderer.DrawText(e.Graphics, text, Font, r, fc, bc, flags); e.DrawFocusRectangle(); base.OnDrawItem(e); }
private void DoPaint(PaintEventArgs pevent) { CheckBoxRenderer.DrawParentBackground(pevent.Graphics, pevent.ClipRectangle, this); RadioButtonState radioButtonState; if (Checked) { radioButtonState = RadioButtonState.CheckedNormal; if (Focused) { radioButtonState = RadioButtonState.CheckedHot; } if (!Enabled) { radioButtonState = RadioButtonState.CheckedDisabled; } } else { radioButtonState = RadioButtonState.UncheckedNormal; if (Focused) { radioButtonState = RadioButtonState.UncheckedHot; } if (!Enabled) { radioButtonState = RadioButtonState.UncheckedDisabled; } } Size glyphSize = RadioButtonRenderer.GetGlyphSize(pevent.Graphics, radioButtonState); Rectangle rect = ClientRectangle; rect.Width -= glyphSize.Width; rect.Location = new Point(rect.Left + glyphSize.Width, 0); // rect.Top); //RadioButtonRenderer.DrawRadioButton(pevent.Graphics, new System.Drawing.Point(0, rect.Height / 2 - glyphSize.Height / 2), rect, this.Text, this.Font, this.Focused, radioButtonState); RadioButtonRenderer.DrawRadioButton(pevent.Graphics, new System.Drawing.Point(0, 2), rect, this.Text, this.Font, false, radioButtonState); }
/// <summary> /// Raises the <see cref="E:Paint"/> event. /// </summary> /// <param name="pevent">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param> protected override void OnPaint(PaintEventArgs pevent) { /*if (this.UseVisualStyleBackColor) * RadioButtonRenderer.DrawParentBackground(pevent.Graphics, pevent.ClipRectangle, this); * else*/ pevent.Graphics.Clear(this.BackColor); Rectangle glyphBounds, focusBounds, textBounds, subtextBounds; int h = GetElementBounds(pevent.Graphics, pevent.ClipRectangle, out glyphBounds, out textBounds, out subtextBounds, out focusBounds); if (this.AutoSize) { this.Size = new Size(Rectangle.Union(glyphBounds, focusBounds).Width, h); } RadioButtonRenderer.DrawRadioButton(pevent.Graphics, glyphBounds.Location, GetRadioButtonState()); TextRenderer.DrawText(pevent.Graphics, this.Text, this.Font, textBounds, this.ForeColor, this.TextFormatFlags); if (subtextBounds != Rectangle.Empty) { TextRenderer.DrawText(pevent.Graphics, Subtext, this.SubtextFont, subtextBounds, this.SubtextForeColor, this.TextFormatFlags); } //if (this.Focused) ControlPaint.DrawFocusRectangle(pevent.Graphics, focusBounds); }
protected void DrawCheckBox(PaintEventArgs e, LayoutData layout) { Graphics g = e.Graphics; Rectangle check = layout.checkBounds; if (!Application.RenderWithVisualStyles) { check.X--; // compensate for Windows drawing slightly offset to right } ButtonState style = GetState(); if (Application.RenderWithVisualStyles) { RadioButtonRenderer.DrawRadioButton(g, new Point(check.Left, check.Top), RadioButtonRenderer.ConvertFromButtonState(style, Control.MouseIsOver), Control.HandleInternal); } else { ControlPaint.DrawRadioButton(g, check, style); } }
private ImageList CrtRadBtnImg() { var lst = new ImageList(); for (int i = 0; i < 2; i++) { Bitmap bmp = new Bitmap(16, 16); Graphics chkGraphics = Graphics.FromImage(bmp); switch (i) { // 0,1 - offset the checkbox slightly so it positions in the correct place case 0: RadioButtonRenderer.DrawRadioButton(chkGraphics, new Point(0, 1), System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal); break; case 1: RadioButtonRenderer.DrawRadioButton(chkGraphics, new Point(0, 1), System.Windows.Forms.VisualStyles.RadioButtonState.CheckedNormal); break; } lst.Images.Add(bmp); } return(lst); }
// Let the item paint itself, and then paint the RadioButton // where the check mark is displayed, covering the check mark // if it is present. protected override void OnPaint(PaintEventArgs e) { // If the client sets the Image property, the selection behavior // remains unchanged, but the RadioButton is not displayed and the // selection is indicated only by the selection rectangle. if (Image != null) { base.OnPaint(e); return; } // Determine the correct state of the RadioButton. RadioButtonState buttonState = RadioButtonState.UncheckedNormal; if (Enabled) { if (mouseDownState) { if (Checked) { buttonState = RadioButtonState.CheckedPressed; } else { buttonState = RadioButtonState.UncheckedPressed; } } else if (mouseHoverState) { if (Checked) { buttonState = RadioButtonState.CheckedHot; } else { buttonState = RadioButtonState.UncheckedHot; } } else if (Checked) { buttonState = RadioButtonState.CheckedNormal; } } else if (Checked) { buttonState = RadioButtonState.CheckedDisabled; } else { buttonState = RadioButtonState.UncheckedDisabled; } // Calculate the rectangle at which to display the RadioButton. Size glyphSize = RadioButtonRenderer.GetGlyphSize(e.Graphics, buttonState); Rectangle contentRect = this.ContentRectangle; Point imageLocation = contentRect.Location; float scale = e.Graphics.DpiX / 96f; imageLocation.Offset((int)Math.Round(5f * scale, MidpointRounding.AwayFromZero), (contentRect.Height - glyphSize.Height) / 2); ToolStripRenderer renderer = Owner?.Renderer; if (renderer != null) { renderer.DrawMenuItemBackground(new ToolStripItemRenderEventArgs(e.Graphics, this)); int x = (int)(32 * scale); e.Graphics.SetClip(new Rectangle(x, contentRect.Y, Math.Max(contentRect.Width - x, 0), contentRect.Height)); base.OnPaint(e); e.Graphics.ResetClip(); } else { base.OnPaint(e); } // If the item is selected and the RadioButton paints with partial // transparency, such as when theming is enabled, the check mark // shows through the RadioButton image. In this case, paint a // non-transparent background first to cover the check mark. if (Checked && RadioButtonRenderer.IsBackgroundPartiallyTransparent(buttonState)) { e.Graphics.FillEllipse(SystemBrushes.Control, new Rectangle(imageLocation.X, imageLocation.Y, glyphSize.Width - 1, glyphSize.Height - 1)); } RadioButtonRenderer.DrawRadioButton(e.Graphics, imageLocation, buttonState); }
// Let the item paint itself, and then paint the RadioButton // where the check mark is displayed, covering the check mark // if it is present. protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); // If the client sets the Image property, the selection behavior // remains unchanged, but the RadioButton is not displayed and the // selection is indicated only by the selection rectangle. if (Image != null) { return; } // Determine the correct state of the RadioButton. RadioButtonState buttonState = RadioButtonState.UncheckedNormal; if (Enabled) { if (mouseDownState) { if (Checked) { buttonState = RadioButtonState.CheckedPressed; } else { buttonState = RadioButtonState.UncheckedPressed; } } else if (mouseHoverState) { if (Checked) { buttonState = RadioButtonState.CheckedHot; } else { buttonState = RadioButtonState.UncheckedHot; } } else { if (Checked) { buttonState = RadioButtonState.CheckedNormal; } } } else { if (Checked) { buttonState = RadioButtonState.CheckedDisabled; } else { buttonState = RadioButtonState.UncheckedDisabled; } } // Calculate the position at which to display the RadioButton. int offset = (ContentRectangle.Height - RadioButtonRenderer.GetGlyphSize(e.Graphics, buttonState).Height) / 2; Point imageLocation = new Point(ContentRectangle.Location.X + 4, ContentRectangle.Location.Y + offset); // If the item is selected and the RadioButton paints with partial // transparency, such as when theming is enabled, the check mark // shows through the RadioButton image. In this case, paint a // non-transparent background first to cover the check mark. if (Checked && RadioButtonRenderer.IsBackgroundPartiallyTransparent(buttonState)) { Size glyphSize = RadioButtonRenderer.GetGlyphSize(e.Graphics, buttonState); glyphSize.Height--; glyphSize.Width--; Rectangle backgroundRectangle = new Rectangle(imageLocation, glyphSize); e.Graphics.FillEllipse(SystemBrushes.Control, backgroundRectangle); } RadioButtonRenderer.DrawRadioButton(e.Graphics, imageLocation, buttonState); }
// Paint the RadioButton where the check mark is normally displayed. protected virtual void item_Paint(object sender, PaintEventArgs e) { ToolStripMenuItem item = sender as ToolStripMenuItem; bool bulleted = (item == this.SelectedItem); if (item.Image != null) { // If the client sets the Image property, the selection behavior remains unchanged, but the RadioButton is not // displayed and the selection is indicated only by the selection rectangle. return; } // Determine the correct state of the RadioButton. RadioButtonState buttonState = RadioButtonState.UncheckedNormal; // initial value if (item.Enabled) { if (item.Pressed) { if (bulleted) { buttonState = RadioButtonState.CheckedPressed; } else { buttonState = RadioButtonState.UncheckedPressed; } } else if (item.Selected) { if (bulleted) { buttonState = RadioButtonState.CheckedHot; } else { buttonState = RadioButtonState.UncheckedHot; } } else if (bulleted) { buttonState = RadioButtonState.CheckedNormal; } } else { if (bulleted) { buttonState = RadioButtonState.CheckedDisabled; } else { buttonState = RadioButtonState.UncheckedDisabled; } } // Calculate the position at which to display the RadioButton. int offset = (item.ContentRectangle.Height - RadioButtonRenderer.GetGlyphSize(e.Graphics, buttonState).Height) / 2; Point imageLocation = new Point(item.ContentRectangle.Location.X + 4, item.ContentRectangle.Location.Y + offset); // Paint the RadioButton. RadioButtonRenderer.DrawRadioButton(e.Graphics, imageLocation, buttonState); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); RadioButtonState state; TextFormatFlags flags = TextFormatFlags.VerticalCenter; for (int i = 0; i < Count; i++) { if (i == fSelectedIndex) { if (Enabled) { if (i == fDownedIndex) { state = RadioButtonState.CheckedPressed; } else if (i == fHoveredIndex) { state = RadioButtonState.CheckedHot; } else { state = RadioButtonState.CheckedNormal; } } else { state = RadioButtonState.CheckedDisabled; } } else { if (Enabled) { if (i == fDownedIndex) { state = RadioButtonState.UncheckedPressed; } else if (i == fHoveredIndex) { state = RadioButtonState.UncheckedHot; } else { state = RadioButtonState.UncheckedNormal; } } else { state = RadioButtonState.UncheckedDisabled; } } Rectangle r = fItems[i].Rect; r.X = r.X + 18; Point p = fItems[i].Rect.Location; p.Y = p.Y + r.Height / 2 - 6; RadioButtonRenderer.DrawRadioButton(e.Graphics, p, r, fItems[i].Text, this.Font, flags, this.Focused, state); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (comboBox1.SelectedItem == null) { return; } Graphics g = e.Graphics; Image i = Image.FromFile(@"accessories-character-map.png"); Font f = new Font("Microsoft Sans Serif", 8); switch (comboBox1.SelectedItem.ToString()) { case "ButtonRenderer": ButtonRenderer.DrawButton(g, new Rectangle(0, 125, 75, 23), System.Windows.Forms.VisualStyles.PushButtonState.Pressed); ButtonRenderer.DrawButton(g, new Rectangle(0, 25, 75, 23), System.Windows.Forms.VisualStyles.PushButtonState.Default); ButtonRenderer.DrawButton(g, new Rectangle(0, 50, 75, 23), System.Windows.Forms.VisualStyles.PushButtonState.Disabled); ButtonRenderer.DrawButton(g, new Rectangle(0, 75, 75, 23), System.Windows.Forms.VisualStyles.PushButtonState.Hot); ButtonRenderer.DrawButton(g, new Rectangle(0, 100, 75, 23), System.Windows.Forms.VisualStyles.PushButtonState.Normal); ButtonRenderer.DrawButton(g, new Rectangle(100, 125, 75, 23), true, System.Windows.Forms.VisualStyles.PushButtonState.Pressed); ButtonRenderer.DrawButton(g, new Rectangle(100, 25, 75, 23), true, System.Windows.Forms.VisualStyles.PushButtonState.Default); ButtonRenderer.DrawButton(g, new Rectangle(100, 50, 75, 23), true, System.Windows.Forms.VisualStyles.PushButtonState.Disabled); ButtonRenderer.DrawButton(g, new Rectangle(100, 75, 75, 23), true, System.Windows.Forms.VisualStyles.PushButtonState.Hot); ButtonRenderer.DrawButton(g, new Rectangle(100, 100, 75, 23), true, System.Windows.Forms.VisualStyles.PushButtonState.Normal); ButtonRenderer.DrawButton(g, new Rectangle(200, 125, 75, 23), i, new Rectangle(200, 128, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Pressed); ButtonRenderer.DrawButton(g, new Rectangle(200, 25, 75, 23), i, new Rectangle(203, 28, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Default); ButtonRenderer.DrawButton(g, new Rectangle(200, 50, 75, 23), i, new Rectangle(203, 53, 16, 16), false, System.Windows.Forms.VisualStyles.PushButtonState.Disabled); ButtonRenderer.DrawButton(g, new Rectangle(200, 75, 75, 23), i, new Rectangle(203, 78, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Hot); ButtonRenderer.DrawButton(g, new Rectangle(200, 100, 75, 23), i, new Rectangle(203, 103, 16, 16), false, System.Windows.Forms.VisualStyles.PushButtonState.Normal); ButtonRenderer.DrawButton(g, new Rectangle(300, 125, 75, 23), "Hi there button!", f, true, System.Windows.Forms.VisualStyles.PushButtonState.Pressed); ButtonRenderer.DrawButton(g, new Rectangle(300, 25, 75, 23), "Hi there button!", f, true, System.Windows.Forms.VisualStyles.PushButtonState.Default); ButtonRenderer.DrawButton(g, new Rectangle(300, 50, 75, 23), "Hi there button!", f, false, System.Windows.Forms.VisualStyles.PushButtonState.Disabled); ButtonRenderer.DrawButton(g, new Rectangle(300, 75, 75, 23), "Hi there button!", f, true, System.Windows.Forms.VisualStyles.PushButtonState.Hot); ButtonRenderer.DrawButton(g, new Rectangle(300, 100, 75, 23), "Hi there button!", f, false, System.Windows.Forms.VisualStyles.PushButtonState.Normal); ButtonRenderer.DrawButton(g, new Rectangle(400, 125, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, true, System.Windows.Forms.VisualStyles.PushButtonState.Pressed); ButtonRenderer.DrawButton(g, new Rectangle(400, 25, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, true, System.Windows.Forms.VisualStyles.PushButtonState.Default); ButtonRenderer.DrawButton(g, new Rectangle(400, 50, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, false, System.Windows.Forms.VisualStyles.PushButtonState.Disabled); ButtonRenderer.DrawButton(g, new Rectangle(400, 75, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, true, System.Windows.Forms.VisualStyles.PushButtonState.Hot); ButtonRenderer.DrawButton(g, new Rectangle(400, 100, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, false, System.Windows.Forms.VisualStyles.PushButtonState.Normal); ButtonRenderer.DrawButton(g, new Rectangle(500, 125, 75, 23), "Hi there button!", f, i, new Rectangle(500, 128, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Pressed); ButtonRenderer.DrawButton(g, new Rectangle(500, 25, 75, 23), "Hi there button!", f, i, new Rectangle(500, 28, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Default); ButtonRenderer.DrawButton(g, new Rectangle(500, 50, 75, 23), "Hi there button!", f, i, new Rectangle(500, 53, 16, 16), false, System.Windows.Forms.VisualStyles.PushButtonState.Disabled); ButtonRenderer.DrawButton(g, new Rectangle(500, 75, 75, 23), "Hi there button!", f, i, new Rectangle(500, 78, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Hot); ButtonRenderer.DrawButton(g, new Rectangle(500, 100, 75, 23), "Hi there button!", f, i, new Rectangle(500, 103, 16, 16), false, System.Windows.Forms.VisualStyles.PushButtonState.Normal); ButtonRenderer.DrawButton(g, new Rectangle(600, 125, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, i, new Rectangle(600, 128, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Pressed); ButtonRenderer.DrawButton(g, new Rectangle(600, 25, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, i, new Rectangle(600, 28, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Default); ButtonRenderer.DrawButton(g, new Rectangle(600, 50, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, i, new Rectangle(600, 53, 16, 16), false, System.Windows.Forms.VisualStyles.PushButtonState.Disabled); ButtonRenderer.DrawButton(g, new Rectangle(600, 75, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, i, new Rectangle(600, 78, 16, 16), true, System.Windows.Forms.VisualStyles.PushButtonState.Hot); ButtonRenderer.DrawButton(g, new Rectangle(600, 100, 75, 23), "Hi there button!", f, TextFormatFlags.Left & TextFormatFlags.WordEllipsis, i, new Rectangle(600, 103, 16, 16), false, System.Windows.Forms.VisualStyles.PushButtonState.Normal); break; case "CheckBoxRenderer": CheckBoxRenderer.DrawCheckBox(g, new Point(5, 5), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 5, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 4, 16, 16), false, System.Windows.Forms.VisualStyles.CheckBoxState.CheckedDisabled); CheckBoxRenderer.DrawCheckBox(g, new Point(5, 25), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 25, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 24, 16, 16), false, System.Windows.Forms.VisualStyles.CheckBoxState.CheckedHot); CheckBoxRenderer.DrawCheckBox(g, new Point(5, 45), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 45, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 44, 16, 16), true, System.Windows.Forms.VisualStyles.CheckBoxState.CheckedNormal); CheckBoxRenderer.DrawCheckBox(g, new Point(5, 65), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 65, 75, 14), "checkBox1", f, TextFormatFlags.Default, false, System.Windows.Forms.VisualStyles.CheckBoxState.CheckedPressed); CheckBoxRenderer.DrawCheckBox(g, new Point(5, 85), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 85, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 84, 16, 16), true, System.Windows.Forms.VisualStyles.CheckBoxState.MixedDisabled); CheckBoxRenderer.DrawCheckBox(g, new Point(5, 105), System.Windows.Forms.VisualStyles.CheckBoxState.MixedHot); CheckBoxRenderer.DrawCheckBox(g, new Point(5, 125), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 125, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 124, 16, 16), false, System.Windows.Forms.VisualStyles.CheckBoxState.MixedNormal); CheckBoxRenderer.DrawCheckBox(g, new Point(5, 145), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 145, 75, 14), "checkBox1", f, i, new Rectangle(90, 144, 16, 16), true, System.Windows.Forms.VisualStyles.CheckBoxState.MixedPressed); CheckBoxRenderer.DrawCheckBox(g, new Point(5, 165), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 165, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 164, 16, 16), false, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedDisabled); CheckBoxRenderer.DrawCheckBox(g, new Point(5, 185), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 185, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 184, 16, 16), false, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedHot); CheckBoxRenderer.DrawCheckBox(g, new Point(5, 205), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 205, 75, 14), "checkBox1", f, true, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal); CheckBoxRenderer.DrawCheckBox(g, new Point(5, 225), new Rectangle(8 + CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal).Width, 225, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 224, 16, 16), false, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedPressed); break; case "ComboBoxRenderer": if (!ComboBoxRenderer.IsSupported) { g.DrawString("Visual Styles not enabled", f, Brushes.Black, 0, 0); break; } ComboBoxRenderer.DrawTextBox(e.Graphics, new Rectangle(5, 5, 121, 21), System.Windows.Forms.VisualStyles.ComboBoxState.Normal); ComboBoxRenderer.DrawDropDownButton(e.Graphics, new Rectangle(109, 6, 16, 19), System.Windows.Forms.VisualStyles.ComboBoxState.Normal); ComboBoxRenderer.DrawTextBox(e.Graphics, new Rectangle(5, 35, 121, 21), this.Text, this.Font, System.Windows.Forms.VisualStyles.ComboBoxState.Hot); ComboBoxRenderer.DrawDropDownButton(e.Graphics, new Rectangle(109, 36, 16, 19), System.Windows.Forms.VisualStyles.ComboBoxState.Hot); ComboBoxRenderer.DrawTextBox(e.Graphics, new Rectangle(5, 65, 121, 21), this.Text, this.Font, new Rectangle(8, 65, 57, 21), System.Windows.Forms.VisualStyles.ComboBoxState.Disabled); ComboBoxRenderer.DrawDropDownButton(e.Graphics, new Rectangle(109, 66, 16, 19), System.Windows.Forms.VisualStyles.ComboBoxState.Disabled); ComboBoxRenderer.DrawTextBox(e.Graphics, new Rectangle(5, 95, 121, 21), this.Text, this.Font, TextFormatFlags.WordEllipsis, System.Windows.Forms.VisualStyles.ComboBoxState.Pressed); ComboBoxRenderer.DrawDropDownButton(e.Graphics, new Rectangle(109, 96, 16, 19), System.Windows.Forms.VisualStyles.ComboBoxState.Pressed); break; case "GroupBoxRenderer": Font f2 = new Font("Microsoft Sans Serif", 12); Font f3 = new Font("Microsoft Sans Serif", 14); Font f4 = new Font("Microsoft Sans Serif", 8); GroupBoxRenderer.DrawGroupBox(g, new Rectangle(5, 5, 150, 75), "My Group!", f, Color.Black, TextFormatFlags.Default, System.Windows.Forms.VisualStyles.GroupBoxState.Normal); GroupBoxRenderer.DrawGroupBox(g, new Rectangle(5, 105, 150, 75), "My Group!", f2, Color.Red, System.Windows.Forms.VisualStyles.GroupBoxState.Disabled); GroupBoxRenderer.DrawGroupBox(g, new Rectangle(5, 205, 150, 75), "My Group!", f3, TextFormatFlags.Default, System.Windows.Forms.VisualStyles.GroupBoxState.Normal); GroupBoxRenderer.DrawGroupBox(g, new Rectangle(5, 305, 150, 75), "My Group!", f4, System.Windows.Forms.VisualStyles.GroupBoxState.Disabled); GroupBoxRenderer.DrawGroupBox(g, new Rectangle(5, 405, 150, 75), System.Windows.Forms.VisualStyles.GroupBoxState.Normal); break; case "ProgressBarRenderer": if (!ProgressBarRenderer.IsSupported) { g.DrawString("Visual Styles not enabled", f, Brushes.Black, 0, 0); break; } g.DrawString("ChunkSpaceThickness: " + ProgressBarRenderer.ChunkSpaceThickness.ToString(), this.Font, Brushes.Black, 0, 0); g.DrawString("ChunkThickness: " + ProgressBarRenderer.ChunkThickness.ToString(), this.Font, Brushes.Black, 0, 20); ProgressBarRenderer.DrawHorizontalBar(g, new Rectangle(5, 40, 100, 20)); ProgressBarRenderer.DrawHorizontalChunks(g, new Rectangle(7, 42, 47, 16)); ProgressBarRenderer.DrawVerticalBar(g, new Rectangle(110, 40, 20, 100)); ProgressBarRenderer.DrawVerticalChunks(g, new Rectangle(112, 42, 16, 47)); break; case "RadioButtonRenderer": RadioButtonRenderer.DrawRadioButton(g, new Point(5, 5), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 5, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 4, 16, 16), false, System.Windows.Forms.VisualStyles.RadioButtonState.CheckedDisabled); RadioButtonRenderer.DrawRadioButton(g, new Point(5, 25), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 25, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 24, 16, 16), false, System.Windows.Forms.VisualStyles.RadioButtonState.CheckedHot); RadioButtonRenderer.DrawRadioButton(g, new Point(5, 45), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 45, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 44, 16, 16), true, System.Windows.Forms.VisualStyles.RadioButtonState.CheckedNormal); RadioButtonRenderer.DrawRadioButton(g, new Point(5, 65), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 65, 75, 14), "checkBox1", f, TextFormatFlags.Default, false, System.Windows.Forms.VisualStyles.RadioButtonState.CheckedPressed); RadioButtonRenderer.DrawRadioButton(g, new Point(5, 85), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 85, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 84, 16, 16), true, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedDisabled); RadioButtonRenderer.DrawRadioButton(g, new Point(5, 105), System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedHot); RadioButtonRenderer.DrawRadioButton(g, new Point(5, 125), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 125, 75, 14), "checkBox1", f, TextFormatFlags.Default, i, new Rectangle(90, 124, 16, 16), false, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal); RadioButtonRenderer.DrawRadioButton(g, new Point(5, 145), new Rectangle(8 + RadioButtonRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedNormal).Width, 145, 75, 14), "checkBox1", f, i, new Rectangle(90, 144, 16, 16), true, System.Windows.Forms.VisualStyles.RadioButtonState.UncheckedPressed); break; case "ScrollBarRenderer": if (!ScrollBarRenderer.IsSupported) { g.DrawString("Visual Styles not enabled", f, Brushes.Black, 0, 0); break; } ScrollBarRenderer.DrawArrowButton(g, new Rectangle(5, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.DownDisabled); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(25, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.DownHot); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(45, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.DownNormal); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(65, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.DownPressed); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(85, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.LeftDisabled); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(105, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.LeftHot); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(125, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.LeftNormal); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(145, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.LeftPressed); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(165, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.RightDisabled); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(185, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.RightHot); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(205, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.RightNormal); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(225, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.RightPressed); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(245, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.UpDisabled); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(265, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.UpHot); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(285, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.UpNormal); ScrollBarRenderer.DrawArrowButton(g, new Rectangle(305, 5, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState.UpPressed); ScrollBarRenderer.DrawHorizontalThumb(g, new Rectangle(5, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled); ScrollBarRenderer.DrawHorizontalThumb(g, new Rectangle(45, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Hot); ScrollBarRenderer.DrawHorizontalThumb(g, new Rectangle(85, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Normal); ScrollBarRenderer.DrawHorizontalThumb(g, new Rectangle(125, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed); ScrollBarRenderer.DrawHorizontalThumbGrip(g, new Rectangle(5, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled); ScrollBarRenderer.DrawHorizontalThumbGrip(g, new Rectangle(45, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Hot); ScrollBarRenderer.DrawHorizontalThumbGrip(g, new Rectangle(85, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Normal); ScrollBarRenderer.DrawHorizontalThumbGrip(g, new Rectangle(125, 25, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed); ScrollBarRenderer.DrawLeftHorizontalTrack(g, new Rectangle(5, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled); ScrollBarRenderer.DrawLeftHorizontalTrack(g, new Rectangle(45, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Hot); ScrollBarRenderer.DrawLeftHorizontalTrack(g, new Rectangle(85, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Normal); ScrollBarRenderer.DrawLeftHorizontalTrack(g, new Rectangle(125, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed); ScrollBarRenderer.DrawLowerVerticalTrack(g, new Rectangle(5, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled); ScrollBarRenderer.DrawLowerVerticalTrack(g, new Rectangle(25, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Hot); ScrollBarRenderer.DrawLowerVerticalTrack(g, new Rectangle(45, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Normal); ScrollBarRenderer.DrawLowerVerticalTrack(g, new Rectangle(65, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed); ScrollBarRenderer.DrawRightHorizontalTrack(g, new Rectangle(165, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled); ScrollBarRenderer.DrawRightHorizontalTrack(g, new Rectangle(205, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Hot); ScrollBarRenderer.DrawRightHorizontalTrack(g, new Rectangle(245, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Normal); ScrollBarRenderer.DrawRightHorizontalTrack(g, new Rectangle(285, 45, 38, 18), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed); ScrollBarRenderer.DrawSizeBox(g, new Rectangle(5, 105, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarSizeBoxState.LeftAlign); ScrollBarRenderer.DrawSizeBox(g, new Rectangle(25, 105, 18, 18), System.Windows.Forms.VisualStyles.ScrollBarSizeBoxState.RightAlign); ScrollBarRenderer.DrawUpperVerticalTrack(g, new Rectangle(85, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled); ScrollBarRenderer.DrawUpperVerticalTrack(g, new Rectangle(105, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Hot); ScrollBarRenderer.DrawUpperVerticalTrack(g, new Rectangle(125, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Normal); ScrollBarRenderer.DrawUpperVerticalTrack(g, new Rectangle(145, 65, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed); ScrollBarRenderer.DrawVerticalThumb(g, new Rectangle(5, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled); ScrollBarRenderer.DrawVerticalThumb(g, new Rectangle(25, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Hot); ScrollBarRenderer.DrawVerticalThumb(g, new Rectangle(45, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Normal); ScrollBarRenderer.DrawVerticalThumb(g, new Rectangle(65, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed); ScrollBarRenderer.DrawVerticalThumbGrip(g, new Rectangle(5, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Disabled); ScrollBarRenderer.DrawVerticalThumbGrip(g, new Rectangle(25, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Hot); ScrollBarRenderer.DrawVerticalThumbGrip(g, new Rectangle(45, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Normal); ScrollBarRenderer.DrawVerticalThumbGrip(g, new Rectangle(65, 105, 18, 38), System.Windows.Forms.VisualStyles.ScrollBarState.Pressed); g.DrawString(ScrollBarRenderer.GetSizeBoxSize(g, System.Windows.Forms.VisualStyles.ScrollBarState.Normal).ToString(), f, Brushes.Black, new PointF(5, 145)); g.DrawString(ScrollBarRenderer.GetThumbGripSize(g, System.Windows.Forms.VisualStyles.ScrollBarState.Normal).ToString(), f, Brushes.Black, new PointF(5, 165)); break; case "TabRenderer": if (!TabRenderer.IsSupported) { g.DrawString("Visual Styles not enabled", f, Brushes.Black, 0, 0); break; } TabRenderer.DrawTabPage(g, new Rectangle(5, 95, 700, 50)); TabRenderer.DrawTabItem(g, new Rectangle(5, 55, 70, 25), System.Windows.Forms.VisualStyles.TabItemState.Normal); TabRenderer.DrawTabItem(g, new Rectangle(95, 55, 70, 25), true, System.Windows.Forms.VisualStyles.TabItemState.Selected); TabRenderer.DrawTabItem(g, new Rectangle(185, 55, 70, 25), "Tab 1", f, System.Windows.Forms.VisualStyles.TabItemState.Normal); TabRenderer.DrawTabItem(g, new Rectangle(275, 55, 70, 25), i, new Rectangle(278, 58, 16, 16), false, System.Windows.Forms.VisualStyles.TabItemState.Hot); TabRenderer.DrawTabItem(g, new Rectangle(365, 55, 70, 25), "Tab 6 is too long", f, true, System.Windows.Forms.VisualStyles.TabItemState.Normal); TabRenderer.DrawTabItem(g, new Rectangle(455, 55, 70, 25), "My Tab Octopus", f, TextFormatFlags.WordEllipsis, false, System.Windows.Forms.VisualStyles.TabItemState.Disabled); TabRenderer.DrawTabItem(g, new Rectangle(545, 55, 70, 25), "Tab 7", f, i, new Rectangle(546, 56, 16, 16), true, System.Windows.Forms.VisualStyles.TabItemState.Normal); TabRenderer.DrawTabItem(g, new Rectangle(635, 55, 70, 25), "Tab 8", f, TextFormatFlags.WordEllipsis, i, new Rectangle(638, 58, 16, 16), false, System.Windows.Forms.VisualStyles.TabItemState.Disabled); break; case "TextBoxRenderer": if (!TextBoxRenderer.IsSupported) { g.DrawString("Visual Styles not enabled", f, Brushes.Black, 0, 0); break; } TextBoxRenderer.DrawTextBox(g, new Rectangle(5, 55, 95, 40), System.Windows.Forms.VisualStyles.TextBoxState.Assist); TextBoxRenderer.DrawTextBox(g, new Rectangle(105, 55, 95, 40), "This is my text box text!!!", f, System.Windows.Forms.VisualStyles.TextBoxState.Disabled); TextBoxRenderer.DrawTextBox(g, new Rectangle(205, 55, 95, 40), "This is my text box text!!!", f, new Rectangle(205, 55, 95, 40), System.Windows.Forms.VisualStyles.TextBoxState.Hot); TextBoxRenderer.DrawTextBox(g, new Rectangle(305, 55, 95, 40), "This is my text box text!!!", f, TextFormatFlags.WordEllipsis, System.Windows.Forms.VisualStyles.TextBoxState.Normal); TextBoxRenderer.DrawTextBox(g, new Rectangle(405, 55, 95, 40), "This is my text box text!!!", f, new Rectangle(405, 55, 95, 40), TextFormatFlags.WordEllipsis, System.Windows.Forms.VisualStyles.TextBoxState.Readonly); TextBoxRenderer.DrawTextBox(g, new Rectangle(505, 55, 95, 40), System.Windows.Forms.VisualStyles.TextBoxState.Selected); break; case "TrackBarRenderer": if (!TrackBarRenderer.IsSupported) { g.DrawString("Visual Styles not enabled", f, Brushes.Black, 0, 0); break; } TrackBarRenderer.DrawBottomPointingThumb(g, new Rectangle(5, 5, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled); TrackBarRenderer.DrawBottomPointingThumb(g, new Rectangle(20, 5, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot); TrackBarRenderer.DrawBottomPointingThumb(g, new Rectangle(35, 5, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal); TrackBarRenderer.DrawBottomPointingThumb(g, new Rectangle(50, 5, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed); TrackBarRenderer.DrawHorizontalThumb(g, new Rectangle(5, 45, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled); TrackBarRenderer.DrawHorizontalThumb(g, new Rectangle(20, 45, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot); TrackBarRenderer.DrawHorizontalThumb(g, new Rectangle(35, 45, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal); TrackBarRenderer.DrawHorizontalThumb(g, new Rectangle(50, 45, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed); TrackBarRenderer.DrawHorizontalTicks(g, new Rectangle(5, 75, 100, 20), 15, System.Windows.Forms.VisualStyles.EdgeStyle.Bump); TrackBarRenderer.DrawHorizontalTicks(g, new Rectangle(115, 75, 100, 20), 10, System.Windows.Forms.VisualStyles.EdgeStyle.Etched); TrackBarRenderer.DrawHorizontalTicks(g, new Rectangle(225, 75, 100, 20), 5, System.Windows.Forms.VisualStyles.EdgeStyle.Raised); TrackBarRenderer.DrawHorizontalTicks(g, new Rectangle(335, 75, 100, 20), 25, System.Windows.Forms.VisualStyles.EdgeStyle.Sunken); TrackBarRenderer.DrawHorizontalTrack(g, new Rectangle(5, 120, 100, 20)); TrackBarRenderer.DrawLeftPointingThumb(g, new Rectangle(5, 145, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled); TrackBarRenderer.DrawLeftPointingThumb(g, new Rectangle(25, 145, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot); TrackBarRenderer.DrawLeftPointingThumb(g, new Rectangle(45, 145, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal); TrackBarRenderer.DrawLeftPointingThumb(g, new Rectangle(65, 145, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed); TrackBarRenderer.DrawRightPointingThumb(g, new Rectangle(5, 165, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled); TrackBarRenderer.DrawRightPointingThumb(g, new Rectangle(25, 165, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot); TrackBarRenderer.DrawRightPointingThumb(g, new Rectangle(45, 165, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal); TrackBarRenderer.DrawRightPointingThumb(g, new Rectangle(65, 165, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed); TrackBarRenderer.DrawTopPointingThumb(g, new Rectangle(5, 185, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled); TrackBarRenderer.DrawTopPointingThumb(g, new Rectangle(20, 185, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot); TrackBarRenderer.DrawTopPointingThumb(g, new Rectangle(35, 185, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal); TrackBarRenderer.DrawTopPointingThumb(g, new Rectangle(50, 185, 12, 20), System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed); TrackBarRenderer.DrawVerticalThumb(g, new Rectangle(5, 215, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled); TrackBarRenderer.DrawVerticalThumb(g, new Rectangle(25, 215, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot); TrackBarRenderer.DrawVerticalThumb(g, new Rectangle(45, 215, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal); TrackBarRenderer.DrawVerticalThumb(g, new Rectangle(65, 215, 20, 12), System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed); TrackBarRenderer.DrawVerticalTicks(g, new Rectangle(5, 230, 20, 100), 15, System.Windows.Forms.VisualStyles.EdgeStyle.Bump); TrackBarRenderer.DrawVerticalTicks(g, new Rectangle(50, 230, 20, 100), 10, System.Windows.Forms.VisualStyles.EdgeStyle.Etched); TrackBarRenderer.DrawVerticalTicks(g, new Rectangle(95, 230, 20, 100), 5, System.Windows.Forms.VisualStyles.EdgeStyle.Raised); TrackBarRenderer.DrawVerticalTicks(g, new Rectangle(140, 230, 20, 100), 25, System.Windows.Forms.VisualStyles.EdgeStyle.Sunken); TrackBarRenderer.DrawVerticalTrack(g, new Rectangle(185, 230, 20, 100)); g.DrawString(TrackBarRenderer.GetBottomPointingThumbSize(g, System.Windows.Forms.VisualStyles.TrackBarThumbState.Normal).ToString(), f, Brushes.Black, new Point(5, 340)); g.DrawString(TrackBarRenderer.GetLeftPointingThumbSize(g, System.Windows.Forms.VisualStyles.TrackBarThumbState.Hot).ToString(), f, Brushes.Black, new Point(5, 370)); g.DrawString(TrackBarRenderer.GetRightPointingThumbSize(g, System.Windows.Forms.VisualStyles.TrackBarThumbState.Disabled).ToString(), f, Brushes.Black, new Point(5, 400)); g.DrawString(TrackBarRenderer.GetTopPointingThumbSize(g, System.Windows.Forms.VisualStyles.TrackBarThumbState.Pressed).ToString(), f, Brushes.Black, new Point(5, 430)); break; default: break; } }
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index < 0) { return; } if (e.Index > this.Items.Count - 1) { return; } int size = e.Font.Height; // button size depends on font height, not on item height if (IsTransparent && e.State != DrawItemState.Selected) { e.Graphics.FillRectangle(TransparentBrush, e.Bounds); } else { e.DrawBackground(); } Brush textBrush; bool isChecked = (e.State & DrawItemState.Selected) == DrawItemState.Selected; RadioButtonState state = isChecked ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal; if ((e.State & DrawItemState.Disabled) == DrawItemState.Disabled) { textBrush = SystemBrushes.GrayText; state = isChecked ? RadioButtonState.CheckedDisabled : RadioButtonState.UncheckedDisabled; } else if ((e.State & DrawItemState.Grayed) == DrawItemState.Grayed) { textBrush = SystemBrushes.GrayText; state = isChecked ? RadioButtonState.CheckedDisabled : RadioButtonState.UncheckedDisabled; } else if ((e.State & DrawItemState.Selected) == DrawItemState.Selected && !Transparent) { textBrush = SystemBrushes.HighlightText; } else { textBrush = SystemBrushes.FromSystemColor(this.ForeColor); } // Draw radio button Rectangle bounds = e.Bounds; bounds.Width = size; RadioButtonRenderer.DrawRadioButton(e.Graphics, bounds.Location, state); // Draw text bounds = new Rectangle(e.Bounds.X + size + 2, e.Bounds.Y, e.Bounds.Width - size - 2, e.Bounds.Height); if (!string.IsNullOrEmpty(DisplayMember)) // Bound Datatable? Then show the column written in Displaymember { e.Graphics.DrawString(((System.Data.DataRowView) this.Items[e.Index])[this.DisplayMember].ToString(), e.Font, textBrush, bounds, this.Align); } else { e.Graphics.DrawString(this.Items[e.Index].ToString(), e.Font, textBrush, bounds, this.Align); } // If the ListBox has focus, // draw a focus rectangle around the selected item. e.DrawFocusRectangle(); }
// Main paiting method protected override void OnDrawItem(DrawItemEventArgs e) { int maxItem = this.Items.Count - 1; if (e.Index < 0 || e.Index > maxItem) { // Erase all background if control has no items e.Graphics.FillRectangle(BackBrush, this.ClientRectangle); return; } int size = e.Font.Height; // button size depends on font height, not on item height // Calculate bounds for background, if last item paint up to bottom of control Rectangle backRect = e.Bounds; if (e.Index == maxItem) { backRect.Height = this.ClientRectangle.Top + this.ClientRectangle.Height - e.Bounds.Top; } e.Graphics.FillRectangle(BackBrush, backRect); // Determines text color/brush Brush textBrush; bool isChecked = (e.State & DrawItemState.Selected) == DrawItemState.Selected; RadioButtonState state = isChecked ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal; if ((e.State & DrawItemState.Disabled) == DrawItemState.Disabled) { textBrush = SystemBrushes.GrayText; state = isChecked ? RadioButtonState.CheckedDisabled : RadioButtonState.UncheckedDisabled; } else if ((e.State & DrawItemState.Grayed) == DrawItemState.Grayed) { textBrush = SystemBrushes.GrayText; state = isChecked ? RadioButtonState.CheckedDisabled : RadioButtonState.UncheckedDisabled; } else { textBrush = new SolidBrush(this.ForeColor);//jash modified textBrush = SystemBrushes.FromSystemColor(this.ForeColor); } // Determines bounds for text and radio button Size glyphSize = RadioButtonRenderer.GetGlyphSize(e.Graphics, state); Point glyphLocation = e.Bounds.Location; glyphLocation.Y += (e.Bounds.Height - glyphSize.Height) / 2; Rectangle bounds = new Rectangle(e.Bounds.X + glyphSize.Width, e.Bounds.Y, e.Bounds.Width - glyphSize.Width, e.Bounds.Height); // Draws the radio button RadioButtonRenderer.DrawRadioButton(e.Graphics, glyphLocation, state); // Draws the text if (!string.IsNullOrEmpty(DisplayMember)) // Bound Datatable? Then show the column written in Displaymember { e.Graphics.DrawString(((System.Data.DataRowView) this.Items[e.Index])[this.DisplayMember].ToString(), e.Font, textBrush, bounds, this.Align); } else { e.Graphics.DrawString(this.Items[e.Index].ToString(), e.Font, textBrush, bounds, this.Align); } // If the ListBox has focus, draw a focus rectangle around the selected item. e.DrawFocusRectangle(); }