Skip to content

Instantly share code, notes, and snippets.

@superlucky8848
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superlucky8848/0e33199f5f59a501ed86 to your computer and use it in GitHub Desktop.
Save superlucky8848/0e33199f5f59a501ed86 to your computer and use it in GitHub Desktop.
Give .NET Winform splitContainer Control a visible paddle for movable splitter
private void splitContainer_Splitter_Paint(object sender, PaintEventArgs e)
{
SplitContainer control = sender as SplitContainer;
if(control == null) return;
//paint the three dots'
Point[] points = new Point[3];
int w = control.Width;
int h = control.Height;
int d = control.SplitterDistance;
int sW = control.SplitterWidth;
//calculate the position of the points'
if (control.Orientation == Orientation.Horizontal)
{
points[0] = new Point((w / 2), d + (sW / 2));
points[1] = new Point(points[0].X - 10, points[0].Y);
points[2] = new Point(points[0].X + 10, points[0].Y);
e.Graphics.FillRectangle(new SolidBrush(SystemColors.ControlDarkDark), 0, d + sW / 2 - 1, w / 2 - 20, 2);
e.Graphics.FillRectangle(new SolidBrush(SystemColors.ControlLightLight), 0, d + sW / 2 - 1, w / 2 - 21, 1);
e.Graphics.FillRectangle(new SolidBrush(SystemColors.ControlDarkDark), w / 2 + 20, d + sW / 2 - 1, w / 2 - 20, 2);
e.Graphics.FillRectangle(new SolidBrush(SystemColors.ControlLightLight), w / 2 + 20, d + sW / 2 - 1, w / 2 - 21, 1);
}
else
{
points[0] = new Point(d + (sW / 2), (h / 2));
points[1] = new Point(points[0].X, points[0].Y - 10);
points[2] = new Point(points[0].X, points[0].Y + 10);
e.Graphics.FillRectangle(new SolidBrush(SystemColors.ControlDarkDark), d + sW / 2 - 1, 0, 2, h / 2 - 20);
e.Graphics.FillRectangle(new SolidBrush(SystemColors.ControlLightLight), d + sW / 2 - 1, 0, 1, h / 2 - 21);
e.Graphics.FillRectangle(new SolidBrush(SystemColors.ControlDarkDark), d + sW / 2 - 1, h / 2 + 20, 2, h / 2 - 20);
e.Graphics.FillRectangle(new SolidBrush(SystemColors.ControlLightLight), d + sW / 2 - 1, h / 2 + 20, 1, h / 2 - 21);
}
foreach (Point p in points)
{
p.Offset(-2, -2);
e.Graphics.FillEllipse(SystemBrushes.ControlDark,
new Rectangle(p, new Size(3, 3)));
p.Offset(1, 1);
e.Graphics.FillEllipse(SystemBrushes.ControlLight,
new Rectangle(p, new Size(3, 3)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment