|
|
@@ -39,9 +39,13 @@ namespace System.Windows.Forms
|
|
|
private bool rounded_edges;
|
|
|
|
|
|
#region Public Constructor
|
|
|
- public ToolStripProfessionalRenderer () : base ()
|
|
|
+ public ToolStripProfessionalRenderer () : this (new ProfessionalColorTable ())
|
|
|
{
|
|
|
- color_table = new ProfessionalColorTable ();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ToolStripProfessionalRenderer (ProfessionalColorTable professionalColorTable) : base ()
|
|
|
+ {
|
|
|
+ color_table = professionalColorTable;
|
|
|
rounded_edges = true;
|
|
|
}
|
|
|
#endregion
|
|
|
@@ -49,7 +53,6 @@ namespace System.Windows.Forms
|
|
|
#region Public Properties
|
|
|
public ProfessionalColorTable ColorTable {
|
|
|
get { return this.color_table; }
|
|
|
- set { this.color_table = value; }
|
|
|
}
|
|
|
|
|
|
public bool RoundedEdges {
|
|
|
@@ -61,15 +64,32 @@ namespace System.Windows.Forms
|
|
|
#region Protected Methods
|
|
|
protected override void OnRenderArrow (ToolStripArrowRenderEventArgs e)
|
|
|
{
|
|
|
- base.OnRenderArrow (e);
|
|
|
-
|
|
|
- using (Pen p = new Pen (e.ArrowColor)) {
|
|
|
- int x = e.ArrowRectangle.Left + (e.ArrowRectangle.Width / 2) - 3;
|
|
|
- int y = e.ArrowRectangle.Top + (e.ArrowRectangle.Height / 2) - 2;
|
|
|
-
|
|
|
- e.Graphics.DrawLine (p, x + 1, y, x + 5, y);
|
|
|
- e.Graphics.DrawLine (p, x + 2, y + 1, x + 4, y + 1);
|
|
|
- e.Graphics.DrawLine (p, x + 3, y + 1, x + 3, y + 2);
|
|
|
+ switch (e.Direction) {
|
|
|
+ case ArrowDirection.Down:
|
|
|
+ using (Pen p = new Pen (e.ArrowColor)) {
|
|
|
+ int x = e.ArrowRectangle.Left + (e.ArrowRectangle.Width / 2) - 3;
|
|
|
+ int y = e.ArrowRectangle.Top + (e.ArrowRectangle.Height / 2) - 2;
|
|
|
+
|
|
|
+ e.Graphics.DrawLine (p, x + 1, y, x + 5, y);
|
|
|
+ e.Graphics.DrawLine (p, x + 2, y + 1, x + 4, y + 1);
|
|
|
+ e.Graphics.DrawLine (p, x + 3, y + 1, x + 3, y + 2);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ArrowDirection.Left:
|
|
|
+ break;
|
|
|
+ case ArrowDirection.Right:
|
|
|
+ using (Pen p = new Pen (e.ArrowColor)) {
|
|
|
+ int x = e.ArrowRectangle.Left + (e.ArrowRectangle.Width / 2) - 3;
|
|
|
+ int y = e.ArrowRectangle.Top + (e.ArrowRectangle.Height / 2) - 4;
|
|
|
+
|
|
|
+ e.Graphics.DrawLine (p, x, y, x, y + 6);
|
|
|
+ e.Graphics.DrawLine (p, x + 1, y + 1, x + 1, y + 5);
|
|
|
+ e.Graphics.DrawLine (p, x + 2, y + 2, x + 2, y + 4);
|
|
|
+ e.Graphics.DrawLine (p, x + 2, y + 3, x + 3, y + 3);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ArrowDirection.Up:
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -86,8 +106,11 @@ namespace System.Windows.Forms
|
|
|
if (e.Item is ToolStripButton && (e.Item as ToolStripButton).Checked && !e.Item.Selected)
|
|
|
using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ButtonCheckedGradientBegin, this.ColorTable.ButtonCheckedGradientEnd, LinearGradientMode.Vertical))
|
|
|
e.Graphics.FillRectangle (b, paint_here);
|
|
|
- else
|
|
|
- if (e.Item.Pressed || (e.Item is ToolStripButton && (e.Item as ToolStripButton).Checked))
|
|
|
+ else
|
|
|
+ if (e.Item is ToolStripMenuItem && (e.Item.Pressed || (e.Item as ToolStripMenuItem).DropDown.Visible == true))
|
|
|
+ using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ToolStripGradientBegin, this.ColorTable.ToolStripGradientEnd, LinearGradientMode.Vertical))
|
|
|
+ e.Graphics.FillRectangle (b, paint_here);
|
|
|
+ else if (e.Item.Pressed || (e.Item is ToolStripButton && (e.Item as ToolStripButton).Checked))
|
|
|
using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ButtonPressedGradientBegin, this.ColorTable.ButtonPressedGradientEnd, LinearGradientMode.Vertical))
|
|
|
e.Graphics.FillRectangle (b, paint_here);
|
|
|
else if (e.Item.Selected && !e.Item.Pressed)
|
|
|
@@ -101,7 +124,7 @@ namespace System.Windows.Forms
|
|
|
if (e.Item.Selected && !e.Item.Pressed)
|
|
|
using (Pen p = new Pen (this.ColorTable.ButtonSelectedBorder))
|
|
|
e.Graphics.DrawRectangle (p, paint_here);
|
|
|
- else if (e.Item.Pressed) // || (e.Item.Owner is MenuStrip && (e.Item as ToolStripMenuItem).DropDown.Visible == true))
|
|
|
+ else if (e.Item.Pressed || (e.Item.Owner is MenuStrip && (e.Item as ToolStripMenuItem).DropDown.Visible == true))
|
|
|
using (Pen p = new Pen (this.ColorTable.ButtonPressedBorder))
|
|
|
e.Graphics.DrawRectangle (p, paint_here);
|
|
|
else if (e.Item is ToolStripButton && (e.Item as ToolStripButton).Checked)
|
|
|
@@ -143,41 +166,33 @@ namespace System.Windows.Forms
|
|
|
return;
|
|
|
|
|
|
if (e.GripDisplayStyle == ToolStripGripDisplayStyle.Vertical) {
|
|
|
- using (Brush light_brush = new SolidBrush (this.ColorTable.GripLight)) {
|
|
|
- Rectangle r = new Rectangle (e.GripBounds.Left, e.GripBounds.Top + 5, 2, 2);
|
|
|
+ Rectangle r = new Rectangle (e.GripBounds.Left, e.GripBounds.Top + 5, 2, 2);
|
|
|
|
|
|
- for (int i = 0; i < e.GripBounds.Height - 11; i += 4) {
|
|
|
- e.Graphics.FillRectangle (light_brush, r);
|
|
|
- r.Offset (0, 4);
|
|
|
- }
|
|
|
- }
|
|
|
+ for (int i = 0; i < e.GripBounds.Height - 12; i += 4) {
|
|
|
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.GripLight), r);
|
|
|
+ r.Offset (0, 4);
|
|
|
+ }
|
|
|
|
|
|
- using (Brush dark_brush = new SolidBrush (this.ColorTable.GripDark)) {
|
|
|
- Rectangle r = new Rectangle (e.GripBounds.Left - 1, e.GripBounds.Top + 4, 2, 2);
|
|
|
+ Rectangle r2 = new Rectangle (e.GripBounds.Left - 1, e.GripBounds.Top + 4, 2, 2);
|
|
|
|
|
|
- for (int i = 0; i < e.GripBounds.Height - 11; i += 4) {
|
|
|
- e.Graphics.FillRectangle (dark_brush, r);
|
|
|
- r.Offset (0, 4);
|
|
|
- }
|
|
|
+ for (int i = 0; i < e.GripBounds.Height - 12; i += 4) {
|
|
|
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.GripDark), r2);
|
|
|
+ r2.Offset (0, 4);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- using (Brush light_brush = new SolidBrush (this.ColorTable.GripLight)) {
|
|
|
- Rectangle r = new Rectangle (e.GripBounds.Left + 5, e.GripBounds.Top, 2, 2);
|
|
|
+ Rectangle r = new Rectangle (e.GripBounds.Left + 5, e.GripBounds.Top, 2, 2);
|
|
|
|
|
|
- for (int i = 0; i < e.GripBounds.Width - 11; i += 4) {
|
|
|
- e.Graphics.FillRectangle (light_brush, r);
|
|
|
- r.Offset (4, 0);
|
|
|
- }
|
|
|
+ for (int i = 0; i < e.GripBounds.Width - 11; i += 4) {
|
|
|
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.GripLight), r);
|
|
|
+ r.Offset (4, 0);
|
|
|
}
|
|
|
|
|
|
- using (Brush dark_brush = new SolidBrush (this.ColorTable.GripDark)) {
|
|
|
- Rectangle r = new Rectangle (e.GripBounds.Left + 4, e.GripBounds.Top - 1, 2, 2);
|
|
|
+ Rectangle r2 = new Rectangle (e.GripBounds.Left + 4, e.GripBounds.Top - 1, 2, 2);
|
|
|
|
|
|
- for (int i = 0; i < e.GripBounds.Width - 11; i += 4) {
|
|
|
- e.Graphics.FillRectangle (dark_brush, r);
|
|
|
- r.Offset (4, 0);
|
|
|
- }
|
|
|
+ for (int i = 0; i < e.GripBounds.Width - 11; i += 4) {
|
|
|
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.GripDark), r2);
|
|
|
+ r2.Offset (4, 0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -190,6 +205,24 @@ namespace System.Windows.Forms
|
|
|
protected override void OnRenderItemCheck (ToolStripItemImageRenderEventArgs e)
|
|
|
{
|
|
|
base.OnRenderItemCheck (e);
|
|
|
+
|
|
|
+ if (e.Item.Selected)
|
|
|
+ {
|
|
|
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.CheckPressedBackground), e.ImageRectangle);
|
|
|
+ e.Graphics.DrawRectangle (ThemeEngine.Current.ResPool.GetPen (this.ColorTable.ButtonPressedBorder), e.ImageRectangle);
|
|
|
+ }
|
|
|
+ else if (e.Item.Pressed)
|
|
|
+ {
|
|
|
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.CheckSelectedBackground), e.ImageRectangle);
|
|
|
+ e.Graphics.DrawRectangle (ThemeEngine.Current.ResPool.GetPen (this.ColorTable.ButtonSelectedBorder), e.ImageRectangle);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.CheckBackground), e.ImageRectangle);
|
|
|
+ e.Graphics.DrawRectangle (ThemeEngine.Current.ResPool.GetPen (this.ColorTable.ButtonSelectedBorder), e.ImageRectangle);
|
|
|
+ }
|
|
|
+ if (e.Item.Image == null)
|
|
|
+ ControlPaint.DrawMenuGlyph(e.Graphics, new Rectangle (6,5,7,6), MenuGlyph.Checkmark);
|
|
|
}
|
|
|
|
|
|
protected override void OnRenderItemImage (ToolStripItemImageRenderEventArgs e)
|
|
|
@@ -215,11 +248,10 @@ namespace System.Windows.Forms
|
|
|
{
|
|
|
base.OnRenderMenuItemBackground (e);
|
|
|
|
|
|
- Rectangle paint_here = new Rectangle (2, 0, e.Item.Width - 4, e.Item.Height - 1);
|
|
|
+ Rectangle paint_here = new Rectangle (1, 0, e.Item.Width - 3, e.Item.Height - 1);
|
|
|
|
|
|
- if (e.Item.Selected) {
|
|
|
- using (Brush b = new SolidBrush (this.ColorTable.MenuItemSelected))
|
|
|
- e.Graphics.FillRectangle (b, paint_here);
|
|
|
+ if (e.Item.Selected || (e.Item is ToolStripMenuItem && (e.Item as ToolStripMenuItem).DropDown.Visible)) {
|
|
|
+ if (e.Item.Enabled) e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.MenuItemSelected), paint_here);
|
|
|
|
|
|
using (Pen p = new Pen (this.ColorTable.MenuItemBorder))
|
|
|
e.Graphics.DrawRectangle (p, paint_here);
|
|
|
@@ -236,31 +268,24 @@ namespace System.Windows.Forms
|
|
|
base.OnRenderSeparator (e);
|
|
|
|
|
|
if (e.Vertical) {
|
|
|
- using (Brush light_brush = new SolidBrush (this.ColorTable.SeparatorLight)) {
|
|
|
- Rectangle r = new Rectangle (4, 6, 1, e.Item.Height - 10);
|
|
|
- e.Graphics.FillRectangle (light_brush, r);
|
|
|
- }
|
|
|
+ Rectangle r = new Rectangle (4, 6, 1, e.Item.Height - 10);
|
|
|
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.SeparatorLight), r);
|
|
|
|
|
|
- using (Brush dark_brush = new SolidBrush (this.ColorTable.SeparatorDark)) {
|
|
|
- Rectangle r = new Rectangle (3, 5, 1, e.Item.Height - 10);
|
|
|
- e.Graphics.FillRectangle (dark_brush, r);
|
|
|
- }
|
|
|
+ Rectangle r2 = new Rectangle (3, 5, 1, e.Item.Height - 10);
|
|
|
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.SeparatorDark), r2);
|
|
|
}
|
|
|
else {
|
|
|
- if (!e.Item.IsOnDropDown)
|
|
|
- using (Brush light_brush = new SolidBrush (this.ColorTable.SeparatorLight)) {
|
|
|
+ if (!e.Item.IsOnDropDown) {
|
|
|
Rectangle r = new Rectangle (6, 4, e.Item.Width - 10, 1);
|
|
|
- e.Graphics.FillRectangle (light_brush, r);
|
|
|
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.SeparatorLight), r);
|
|
|
}
|
|
|
|
|
|
- using (Brush dark_brush = new SolidBrush (this.ColorTable.SeparatorDark)) {
|
|
|
- Rectangle r;
|
|
|
- if (e.Item.IsOnDropDown)
|
|
|
- r = new Rectangle (35, 3, e.Item.Width - 36, 1);
|
|
|
- else
|
|
|
- r = new Rectangle (5, 3, e.Item.Width - 10, 1);
|
|
|
- e.Graphics.FillRectangle (dark_brush, r);
|
|
|
- }
|
|
|
+ Rectangle r3;
|
|
|
+ if (e.Item.IsOnDropDown)
|
|
|
+ r3 = new Rectangle (35, 3, e.Item.Width - 36, 1);
|
|
|
+ else
|
|
|
+ r3 = new Rectangle (5, 3, e.Item.Width - 10, 1);
|
|
|
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.SeparatorDark), r3);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -273,21 +298,21 @@ namespace System.Windows.Forms
|
|
|
{
|
|
|
base.OnRenderToolStripBackground (e);
|
|
|
|
|
|
- //if (e.ToolStrip is ToolStripDropDown) {
|
|
|
- //e.Graphics.Clear (this.ColorTable.ToolStripDropDownBackground);
|
|
|
- //Rectangle side_gradient = new Rectangle (2, 2, 22, e.ToolStrip.Height - 4);
|
|
|
- //using (LinearGradientBrush b = new LinearGradientBrush (side_gradient, this.ColorTable.ToolStripGradientBegin, this.ColorTable.ToolStripGradientEnd, LinearGradientMode.Horizontal))
|
|
|
- //e.Graphics.FillRectangle (b, side_gradient);
|
|
|
- //return;
|
|
|
- //}
|
|
|
+ if (e.ToolStrip is ToolStripDropDown) {
|
|
|
+ e.Graphics.Clear (this.ColorTable.ToolStripDropDownBackground);
|
|
|
+ Rectangle side_gradient = new Rectangle (1, 2, 24, e.ToolStrip.Height - 3);
|
|
|
+ using (LinearGradientBrush b = new LinearGradientBrush (side_gradient, this.ColorTable.ToolStripGradientBegin, this.ColorTable.ToolStripGradientEnd, LinearGradientMode.Horizontal))
|
|
|
+ e.Graphics.FillRectangle (b, side_gradient);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- //if (e.ToolStrip is MenuStrip)
|
|
|
- //{
|
|
|
- //using (LinearGradientBrush b = new LinearGradientBrush (e.AffectedBounds, this.ColorTable.MenuStripGradientBegin, this.ColorTable.MenuStripGradientEnd, e.ToolStrip.Orientation == Orientation.Horizontal ? LinearGradientMode.Horizontal : LinearGradientMode.Vertical))
|
|
|
- //e.Graphics.FillRectangle (b, e.AffectedBounds);
|
|
|
+ if (e.ToolStrip is MenuStrip)
|
|
|
+ {
|
|
|
+ using (LinearGradientBrush b = new LinearGradientBrush (e.AffectedBounds, this.ColorTable.MenuStripGradientBegin, this.ColorTable.MenuStripGradientEnd, e.ToolStrip.Orientation == Orientation.Horizontal ? LinearGradientMode.Horizontal : LinearGradientMode.Vertical))
|
|
|
+ e.Graphics.FillRectangle (b, e.AffectedBounds);
|
|
|
|
|
|
- //}
|
|
|
- //else
|
|
|
+ }
|
|
|
+ else
|
|
|
using (LinearGradientBrush b = new LinearGradientBrush (e.AffectedBounds, this.ColorTable.ToolStripGradientBegin, this.ColorTable.ToolStripGradientEnd, e.ToolStrip.Orientation == Orientation.Vertical ? LinearGradientMode.Horizontal : LinearGradientMode.Vertical))
|
|
|
e.Graphics.FillRectangle (b, e.AffectedBounds);
|
|
|
}
|
|
|
@@ -296,13 +321,13 @@ namespace System.Windows.Forms
|
|
|
{
|
|
|
base.OnRenderToolStripBorder (e);
|
|
|
|
|
|
- //if (e.ToolStrip is ToolStripDropDown) {
|
|
|
- //e.Graphics.DrawLines (new Pen (this.ColorTable.ToolStripBorder), new Point[] { e.AffectedBounds.Location, new Point (e.AffectedBounds.Left, e.AffectedBounds.Bottom - 1), new Point (e.AffectedBounds.Right - 1, e.AffectedBounds.Bottom - 1), new Point (e.AffectedBounds.Right - 1, e.AffectedBounds.Top), new Point (e.AffectedBounds.Left + e.ConnectedArea.Right, e.AffectedBounds.Top) });
|
|
|
- //return;
|
|
|
- //}
|
|
|
+ if (e.ToolStrip is ToolStripDropDown) {
|
|
|
+ e.Graphics.DrawLines (new Pen (this.ColorTable.ToolStripBorder), new Point[] { e.AffectedBounds.Location, new Point (e.AffectedBounds.Left, e.AffectedBounds.Bottom - 1), new Point (e.AffectedBounds.Right - 1, e.AffectedBounds.Bottom - 1), new Point (e.AffectedBounds.Right - 1, e.AffectedBounds.Top), new Point (e.AffectedBounds.Left + e.ConnectedArea.Right, e.AffectedBounds.Top) });
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- //if (e.ToolStrip is MenuStrip)
|
|
|
- // return;
|
|
|
+ if (e.ToolStrip is MenuStrip)
|
|
|
+ return;
|
|
|
|
|
|
using (Pen p = new Pen (this.ColorTable.ToolStripBorder)) {
|
|
|
if (this.RoundedEdges == true) {
|