我找不到任何關于如何繪制第一張圖片中所示的幾個點(用于拆分分隔符滑塊)的信息。
我試圖畫出這個:
現在,我的自定義控件代碼正在繪制帶陰影的直線
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);
}
}
如何實現這一目標?我在互聯網上嘗試了不同的Point[]方法,但沒有一種接近我想要達到的目標。
即使是指定繪制“點數”的參數也是一個加號。
感謝您的任何幫助!
我只是把它畫在面板上,但你可以用同樣的方法。