Bis Pike also Pike
reference:
"10 basic skills of GDI programming"
"Rubber band"
Picture with a pen to draw a broken line on the canvas
To draw a dotted line on the Graphics object, as well as the geometry of the dashed border, the key is all on the PEN object.
Pen.dashStyle - Used to set the dotted line style. This attribute receives a Dashstyle enumeration.
Dash point line Dashdot Pictorial Picture Dashdotdot Pictorial Line Object Dot Point Solid Solid Cable Custom User Custom Line Type
Protected Override Void Onpaint (Painteventargs E)
{
Base.onpaint (e);
Pen P = New Pen (Color.RED);
p.dashstyle = dashstyle.dash;
E.Graphics.drawline (P, New Point (10, 10), New Point (300, 300));
}
Pen.dashcap - Linear pattern of the short line end point. This attribute accepts a Dash enumeration.
The FLAT is square in square. Both ends of ROUND are rounded phases. Triangle is both a triangular phase with a triangle.
Protected Override Void Onpaint (Painteventargs E)
{
Base.onpaint (e);
// set the smoothingmode property to smooth the line.
E.Graphics.smoothingMode =
System.drawing.drawing2d.smoothingmode.ntialias;
// CREATE A New Pen Object.
Pen Greenpen = New Pen (Color.green);
// set the width to 6.
Greenpen.width = 6.0f;
// set the dashcap to round.
Greenpen.dashcap = system.drawing.drawing2d.dashcap.Round;
// CREATE A CUSTOM DASH PATTERN.
Greenpen.dashpattern = new float [] {4.0F, 2.0F, 1.0F, 3.0F};
// Draw a line.
E.Graphics.drawline (Greenpen, 20.0F, 20.0F, 100.0F, 240.0F);
// Change the smoothingmode to none.
E.Graphics.smoothingMode =
System.drawing.drawing2d.smoothingmode.none;
// Draw ANother Line.
E.Graphics.drawline (Greenpen, 100.0F, 240.0F, 160.0F, 20.0F);
// Dispose of the custom pen.
Greenpen.dispose ();
}
Pen.dashoffset - The starting point of the straight line to the distance of the short-stroke pattern.
Pen.dashpattern - A set of arrays in a custom shortline and blank area.
Painting the arrow line
Pen.startCap - line phase style of the straight line starting point.
Pen.endcap - Linear pattern of straight line endpoint.
Both attributes accept LineCap enumeration.
Protected Override Void Onpaint (Painteventargs E)
{
Base.onpaint (e);
Pen P = New Pen (Color.RED);
p.Width = 20;
P.StartCap = linecap.RoundAnchor;
p.Endcap = linecap.diamondanchor; E.Graphics.drawline (P, 50, 50, 250, 250);
}
Pen.customstartCap - Custom line segment starting line phase pattern.
Pen.customedcap - Custom line segment end line phases.
These two attributes accept CustomLineCap objects.
Protected Override Void Onpaint (Painteventargs E)
{
Base.onpaint (e);
Graphicspath hpath = new graphicspath ();
// Create The Outline for Our Custom End Cap.
HPath.Addline (New Point (0, 0), New Point (0, 5));
HPath.Addline (New Point (0, 5), New Point (5, 1));
Hpath.Addline (New Point (5, 1), New Point (3, 1));
// Construct the hook-shaped end cap.
CustomLineCap Hookcap = New CustomLinecap (NULL, HPATH);
// set the start card and end cap of the hookcap to be rounded.
Hookcap.setstrokecaps (linecap.Round, linecap.Round);
// Create a pen and set End Custom Start and End
// Caps to the hook cap.
Pen Customcappen = New Pen (Color.Black, 5);
Customcappen.customstartcap = hookcap;
Customcappen.customendcap = hookcap;
// Create a Second Pen Using the start and end caps from
// The hook cap.
Pen Cappen = New Pen (Color.Red, 10);
LineCap Startcap;
LINECAP ENDCAP;
Hookcap.getstrokecaps (Out Startcap, Out EndCap);
Cappen.startcap = startcap;
Cappen.endcap = endcap;
// Create a line to draw.
Point [] Points = {New Point (100, 100), New Point (200, 50),
New Point (250, 300)};
// Draw the lines.
E.Graphics.drawlines (Cappen, Points);
E.Graphics.drawlines (Customcappen, Points);
}
reference:
"10 basic skills of GDI programming"
"Rubber band"