I can not find any information on how to draw a few dots (for Split separator slider) as shown in the first picture.
I am trying to draw this:
Right now, my custom control code is drawing a straight line with a shadow
public class CustomPaintSplitter : SplitContainer {
...
protected override void OnPaint(PaintEventArgs pe)
{
Graphics g = pe.Graphics;
Rectangle r = ClientRectangle;
g.FillRectangle(new SolidBrush(BackColor), r);
if (Orientation == Orientation.Horizontal)
{
SplitterWidth = 9;
int recWidth = SplitterRectangle.Width / 3;
Rectangle split_rect = new(SplitterRectangle.X recWidth, SplitterRectangle.Y, SplitterRectangle.Width - recWidth, SplitterRectangle.Height);
int x = split_rect.X;
int y = split_rect.Y 3;
g.DrawLine(new Pen(SystemColors.ControlLightLight), x, y, x, y 2);
g.DrawLine(new Pen(SystemColors.ControlLightLight), x, y, x recWidth, y);
g.DrawLine(new Pen(SystemColors.ControlDark), x, y 2, x recWidth, y 2);
g.DrawLine(new Pen(SystemColors.ControlDark), x recWidth, y, x recWidth, y 2);
}
// Calling the base class OnPaint
base.OnPaint(pe);
}
}
How can this be achieved? I tried different Point[] methods on the internet, but none of them draw anything near what I am trying to achieve.
Even a parameter to specify the number of "dots" drawn would be a plus.
Any help is appreciated!
CodePudding user response:
I just draw it on a panel but you can use it the same way.
private void panel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
Brush b = new SolidBrush(Color.Gray);
e.Graphics.FillEllipse(b, new Rectangle(10, 5, 5, 5));
e.Graphics.FillEllipse(b, new Rectangle(20, 5, 5, 5));
e.Graphics.FillEllipse(b, new Rectangle(30, 5, 5, 5));
}