Reputation: 12204
I want to mimick drawing of default border based on value of property BorderStyle
.
Instead of single border around the control, my control is visualised as four adjacent custom-drawn boxes (2×2), each having standard border drawn individually. So for example, if Control.Border
is set to FixedSingle
value I want to draw single border around each box. Simplified example:
I have two related problems:
System.Windows.Forms.BorderStyle
?Fixed3D
) so I can use it in layout calculations?Upvotes: 1
Views: 1125
Reputation: 54453
If you want to get results that reliably look like the BorderStyles
on the machine you should make use of the methods of the ControlPaint
object.
For testing let's do it ouside of a Paint
event:
Panel somePanel = panel1;
using (Graphics G = somePanel.CreateGraphics())
{
G.FillRectangle(SystemBrushes.Window, new Rectangle(11, 11, 22, 22));
G.FillRectangle(SystemBrushes.Window, new Rectangle(44, 44, 66, 66));
G.FillRectangle(SystemBrushes.Window, new Rectangle(11, 44, 22, 66));
G.FillRectangle(SystemBrushes.Window, new Rectangle(44, 11, 66, 22));
ControlPaint.DrawBorder3D(G, new Rectangle(11, 11, 22, 22));
ControlPaint.DrawBorder3D(G, new Rectangle(44, 44, 66, 66));
ControlPaint.DrawBorder3D(G, new Rectangle(11, 44, 22, 66));
ControlPaint.DrawBorder3D(G, new Rectangle(44, 11, 66, 22));
}
Console.WriteLine("BorderSize.Width = " + SystemInformation.BorderSize.Width);
Console.WriteLine("Border3DSize.Width = " + SystemInformation.Border3DSize.Width);
On my machine this results in a screenshot similar to yours..:
..and these lines in the output:
BorderSize.Width = 1
Border3DSize.Width = 2
Upvotes: 1