本文整理汇总了C#中IGraphics.DrawLines方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphics.DrawLines方法的具体用法?C# IGraphics.DrawLines怎么用?C# IGraphics.DrawLines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphics
的用法示例。
在下文中一共展示了IGraphics.DrawLines方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawArrow
public static void DrawArrow(IGraphics g, Coordinates startingLoc, Coordinates direction, double len, double headSize, Color lineColor, WorldTransform wt)
{
Coordinates endingLoc = startingLoc + direction.Normalize(len);
Coordinates headPt0 = endingLoc + direction.Rotate(135*Math.PI/180.0).Normalize(headSize);
Coordinates headPt1 = endingLoc + direction.Rotate(-135*Math.PI/180.0).Normalize(headSize);
IPen pen = g.CreatePen();
pen.Width = 3/wt.Scale;
pen.Color = Color.White;
PointF ptfStart = Utility.ToPointF(startingLoc);
PointF ptfEnd = Utility.ToPointF(endingLoc);
PointF ptfHeadPt0 = Utility.ToPointF(headPt0);
PointF ptfHeadPt1 = Utility.ToPointF(headPt1);
PointF[] headPts = new PointF[] { ptfHeadPt0, ptfEnd, ptfHeadPt1 };
g.DrawLine(pen, ptfStart, ptfEnd);
g.DrawLines(pen, headPts);
pen.Width = 1/wt.Scale;
pen.Color = lineColor;
g.DrawLine(pen, ptfStart, ptfEnd);
g.DrawLines(pen, headPts);
}
示例2: DrawLine
private void DrawLine(IGraphics g, bool onScreen, Style style)
{
if (!IsSelected || !onScreen)
{
linePen.Width = style.RelationshipWidth;
linePen.Color = style.RelationshipColor;
if (IsDashed)
{
dashPattern[0] = style.RelationshipDashSize;
dashPattern[1] = style.RelationshipDashSize;
linePen.DashPattern = dashPattern;
}
else
{
linePen.DashStyle = DashStyle.Solid;
}
g.DrawLines(linePen, routeCacheArray);
}
}
示例3: Render
//.........这里部分代码省略.........
else if (s == "Lines")
{
ig.SmoothingMode = SmoothingMode.AntiAlias;
Pen ow = new Pen(Color.Purple, 12);
ow.EndCap = LineCap.Round;
ow.StartCap = LineCap.Round;
ow.MiterLimit = 6f;
ow.LineJoin = LineJoin.Miter;
ig.SmoothingMode = SmoothingMode.None;
Pen tp = new Pen(Color.Red, 2);
tp.DashStyle = DashStyle.DashDot;
ig.DrawLine(tp, 70,20,190,20);
tp.DashStyle = DashStyle.Dash;
ig.DrawLine(tp, 70,30,190,30);
tp.DashStyle = DashStyle.Custom;
tp.DashPattern = new float[] {1,8,2,2};
ig.DrawLine(tp, 70,40,190,40);
ig.SmoothingMode = SmoothingMode.AntiAlias;
PointF[] pts = new PointF[4];
pts[0] = new PointF(20,50);
pts[1] = new PointF(30,90);
pts[2] = new PointF(65,60);
pts[3] = new PointF(50,40);
ig.DrawLines(ow, pts);
Point[] polly = new Point[]
{
new Point(200, 40),
new Point(220, 140),
new Point(240, 100),
new Point(290, 70),
new Point(230, 10)
};
ig.DrawPolygon(tp, polly);
//arrows
Pen arr = new Pen(Color.DarkGoldenrod, 5);
AdjustableArrowCap aac = new AdjustableArrowCap(5,3, false);
arr.EndCap = LineCap.Custom;
arr.CustomEndCap = aac;
arr.StartCap = LineCap.ArrowAnchor;
ig.DrawLine(arr, 50,120, 150,200);
arr.Width = 7f;
arr.EndCap = LineCap.RoundAnchor;
arr.StartCap = LineCap.SquareAnchor;
ig.DrawLine(arr, 100,120, 200,200);
arr.Width = 9;
arr.EndCap = LineCap.DiamondAnchor;
arr.StartCap = LineCap.ArrowAnchor;
ig.DrawLine(arr, 150,120, 250,200);
Point[] al = new Point[]
{
示例4: RenderTicLine
/// <summary>
/// Render just the tic line
/// </summary>
/// <param name="g">The graphics object</param>
/// <param name="nNumTics">The number of tics</param>
/// <param name="crBar1">The first bar color</param>
/// <param name="crBar2">The second bar color</param>
/// <param name="nTicLength">The length of each tic</param>
/// <param name="xOrigin">The x-origin</param>
/// <param name="yOrigin">The y-origin</param>
private static void RenderTicLine(IGraphics g, int nNumTics, Color crBar1, Color crBar2, int nTicLength,
int xOrigin, int yOrigin)
{
var pen1 = new Pen(crBar1, 1);
var pen2 = new Pen(crBar2, 1);
int x = xOrigin;
int y = yOrigin;
for (int i = 0; i < nNumTics; i++)
{
Pen pen = i % 2 != 0 ? pen2 : pen1;
PointF[] pts = new []
{
new PointF(x, y),
new PointF(x + nTicLength, y)
};
g.DrawLines(pen, pts);
x += nTicLength;
}
}
示例5: DrawEndCap
protected override void DrawEndCap(IGraphics g, bool onScreen, Style style)
{
if (association.Direction == Direction.Unidirectional)
{
linePen.Color = style.RelationshipColor;
linePen.Width = style.RelationshipWidth;
g.DrawLines(linePen, Arrowhead.OpenArrowPoints);
}
}
示例6: DrawLines
void DrawLines(IGraphics g, List<PointF> points, DrawingMode mode)
{
const int count = 5;
const float offsetY = 40;
if (points != null)
{
using (Pen pen = new Pen(_signalColor, 0.0f))
{
switch (mode)
{
case DrawingMode.DrawLines:
{
var pointsArray = points.ToArray();
for (int j = 0; j < count; j++)
{
g.TranslateTransform(0, offsetY);
g.DrawLines(pen, pointsArray);
}
} break;
case DrawingMode.GdiPlusDrawLine:
{
var gdip = ((GDIGraphics)g).Graphics;
for (int j = 0; j < count; j++)
{
g.TranslateTransform(0, offsetY);
for (int i = 1; i < points.Count; i++)
gdip.DrawLine(pen, points[i - 1], points[i]);
}
} break;
case DrawingMode.Gdi32:
{
var gdip = ((GDIGraphics)g).Graphics;
for (int j = 0; j < count; j++)
{
g.TranslateTransform(0, offsetY);
gdip.DrawLinesGdi32(pen, points);
}
} break;
default:
break;
}
}
}
}
示例7: DrawPolygons
private void DrawPolygons(IGraphics g, int width, int height)
{
if (GetPolygonCount == null || GetPolygon == null){
return;
}
for (int i = 0; i < GetPolygonCount(); i++){
PolygonData pol = GetPolygon(i);
PolygonProperties lp = GetPolygonProperties(i);
double[] xc = pol.x;
double[] yc = pol.y;
Pen linePen = new Pen(lp.LineColor, lp.LineWidth){DashStyle = lp.LineDashStyle};
List<Point> ps = new List<Point>();
for (int j = 0; j < xc.Length; j++){
if (double.IsNaN(xc[j]) || double.IsNaN(yc[j]) || double.IsInfinity(xc[j]) || double.IsInfinity(yc[j])){
continue;
}
int xi1 = ModelToViewX(xc[j], width);
int yi1 = ModelToViewY(yc[j], height);
ps.Add(new Point(xi1, yi1));
}
if (lp.LineWidth > 0){
g.DrawLines(linePen, ps.ToArray());
}
SymbolType symbolType = SymbolType.allSymbols[lp.SymbolType];
int symbolSize = lp.SymbolSize;
Pen p = new Pen(lp.SymbolColor);
Brush b = new SolidBrush(lp.SymbolColor);
if (symbolSize > 0){
foreach (Point t in ps){
symbolType.Draw(symbolSize, t.X, t.Y, g, p, b);
}
}
int w2 = lp.ErrorSize/2;
if (lp.HorizErrors){
Pen errorPen = new Pen(lp.SymbolColor, lp.ErrorLineWidth){DashStyle = DashStyle.Solid};
for (int j = 0; j < xc.Length; j++){
double x = xc[j];
double y = yc[j];
if (double.IsNaN(x) || double.IsNaN(y) || double.IsInfinity(x) || double.IsInfinity(y)){
continue;
}
int xi = ModelToViewX(x, width);
int yi = ModelToViewY(y, height);
double ed = pol.xErrDown[j];
if (!double.IsNaN(ed) && !double.IsInfinity(ed) && ed >= 0){
int xi2 = ModelToViewX(x - ed, width);
g.DrawLine(errorPen, xi, yi, xi2, yi);
if (w2 > 0){
g.DrawLine(errorPen, xi2, yi - w2, xi2, yi + w2);
}
}
double eu = pol.xErrUp[j];
if (!double.IsNaN(eu) && !double.IsInfinity(eu) && eu >= 0){
int xi3 = ModelToViewX(x + eu, width);
g.DrawLine(errorPen, xi, yi, xi3, yi);
if (w2 > 0){
g.DrawLine(errorPen, xi3, yi - w2, xi3, yi + w2);
}
}
}
}
if (lp.VertErrors){
Pen errorPen = new Pen(lp.SymbolColor, lp.ErrorLineWidth){DashStyle = DashStyle.Solid};
for (int j = 0; j < xc.Length; j++){
double x = xc[j];
double y = yc[j];
if (double.IsNaN(x) || double.IsNaN(y) || double.IsInfinity(x) || double.IsInfinity(y)){
continue;
}
int xi = ModelToViewX(x, width);
int yi = ModelToViewY(y, height);
double ed = pol.yErrDown[j];
if (!double.IsNaN(ed) && !double.IsInfinity(ed) && ed >= 0){
int yi2 = ModelToViewY(y - ed, height);
g.DrawLine(errorPen, xi, yi, xi, yi2);
if (w2 > 0){
g.DrawLine(errorPen, xi - w2, yi2, xi + w2, yi2);
}
}
double eu = pol.yErrUp[j];
if (!double.IsNaN(eu) && !double.IsInfinity(eu) && eu >= 0){
int yi3 = ModelToViewY(y + eu, height);
g.DrawLine(errorPen, xi, yi, xi, yi3);
if (w2 > 0){
g.DrawLine(errorPen, xi - w2, yi3, xi + w2, yi3);
}
}
}
}
}
}
示例8: Draw
void Draw(IGraphics g)
{
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
g.SmoothingMode = SmoothingMode.HighQuality;
//g.SetClip(new Rectangle(50, 50, 200, 400));
if (gridBrush == null)
{
gridBrush = new TextureBrush(Images.Grid_37px);
}
//gridBrush.ResetTransform();
//gridBrush.TranslateTransform(100, 100);
g.CompositingMode = CompositingMode.SourceCopy;
gridBrush.ResetTransform();
g.FillRectangle(gridBrush, glView1.ClientRectangle);
g.CompositingMode = CompositingMode.SourceOver;
g.HintTextBackgroundAction(HintBackground);
//g.PageUnit = GraphicsUnit.Millimeter;
//g.SmoothingMode = SmoothingMode.AntiAlias;
string text = "12.5% 2/5 (1) + ms test...";
g.DrawString(g.DpiX.ToString(), font1, Brushes.Black, new PointF(2, 2));
StringFormat sf = new StringFormat();
Rectangle rect = new Rectangle(100, 50, 400, 150);
g.DrawRectangle(Pens.Black, rect);
g.DrawString(text, font2, Brushes.Red, rect, sf);
sf.Alignment = StringAlignment.Center;
g.FillRectangle(Brushes.Black, new Rectangle(230, 50, 140, 40));
g.DrawString(text, font1, Brushes.Yellow, rect, sf);
sf.Alignment = StringAlignment.Far;
g.DrawString(text, font2, Brushes.Green, rect, sf);
sf.Alignment = StringAlignment.Near;
sf.LineAlignment = StringAlignment.Center;
g.DrawString(text, font1, Brushes.Blue, rect, sf);
sf = new StringFormat();
sf.Alignment = StringAlignment.Far;
sf.LineAlignment = StringAlignment.Far;
g.DrawString("Far, Far, PointF", font2, Brushes.Green, new PointF(100.0f, 150.0f), sf);
sf = new StringFormat();
sf.LineAlignment = StringAlignment.Far;
g.DrawString(text, font1, Brushes.DarkCyan, rect, sf);
List<PointF> points = new List<PointF>();
for (float x = 0.0f; x < (float)Math.PI * 6.0f; x += 0.01f)
{
points.Add(new PointF(x * (float)Math.Cos(x), x * (float)Math.Sin(x)));
}
Matrix m = new Matrix();
for (int y = 0; y < 5; y++)
{
for (int x = 0; x < 5; x++)
{
m.Reset();
m.Translate(x * 50.0f + 200.0f, y * 50.0f + 300.0f);
g.Transform = m;
g.DrawLines(new Pen(Color.Blue, 0.0f), points.ToArray());
}
}
g.ResetTransform();
g.DrawRectangle(new Pen(Color.Red, 0), new Rectangle(50, 150, 24, 24));
g.DrawImage(Images.NavigateDown_48px, new Rectangle(50, 150, 24, 24));
if (transparentBitmap == null)
{
ColorMatrix matrix = new ColorMatrix();
matrix.Matrix33 = 0.4f; //opacity 0 = completely transparent, 1 = completely opaque
transparentBitmap = GraphicsHelpers.BitmapFromImageAndColorMatrix(Images.NavigateDown_48px, matrix);
}
g.DrawRectangle(new Pen(Color.Red, 0), new Rectangle(100, 150, 24, 24));
g.DrawImage(transparentBitmap, new Rectangle(100, 150, 24, 24));
using (HatchBrush hatchBrush = new HatchBrush(HatchStyle.LightUpwardDiagonal, Color.Black, Color.Transparent))
{
g.FillRectangle(hatchBrush, new Rectangle(10, 10, 100, 20));
}
//.........这里部分代码省略.........
示例9: OnRenderInternal
/// <summary>
/// Method that does the actual rendering of individual features.
/// </summary>
/// <param name="map">The map</param>
/// <param name="lineString">The linestring</param>
/// <param name="graphics">The graphics object</param>
protected override void OnRenderInternal(Map map, ILineString lineString, IGraphics graphics)
{
var pts = /*LimitValues(*/ RendererHelper.OffsetRight(lineString.TransformToImage(map), Offset) /*)*/;
graphics.DrawLines(Line, pts);
}
示例10: Draw
/// <summary>
/// Draws this object to the <see cref="IGraphics" /> provided.
/// </summary>
/// <param name="graphics">The graphics object to use to draw this object.</param>
public override void Draw(IGraphics graphics)
{
base.Draw(graphics);
graphics.LineWidth = Controller.StyleManager.LineStyle.Width;
SelectedLine selectedLine = _selectedLine;
SelectedLine hoverLine = _hoverLine;
if (hoverLine != null)
{
graphics.LineStyle = SolidColourStyle.CornflowerBlue;
hoverLine.Line.Draw(
graphics,
hoverLine.EdgePart.GetLineTransform() * hoverLine.Tile.Transform);
}
if (selectedLine != null)
{
float radius = Controller.StyleManager.LineStyle.Width * 2;
Matrix3x2 transform = selectedLine.EdgePart.GetLineTransform() * selectedLine.Tile.Transform;
graphics.LineStyle = SolidColourStyle.CornflowerBlue;
selectedLine.Line.Draw(graphics, transform);
graphics.LineStyle = SolidColourStyle.Black;
foreach (ILine line in selectedLine.EdgePart.Lines)
{
QuadraticBezierCurve quadCurve;
CubicBezierCurve cubicCurve;
if ((quadCurve = line as QuadraticBezierCurve) != null)
{
graphics.LineStyle = TransparentBlue;
graphics.DrawLines(
Vector2.Transform(quadCurve.Start, transform),
Vector2.Transform(quadCurve.ControlPoint, transform),
Vector2.Transform(quadCurve.End, transform));
graphics.LineStyle = SolidColourStyle.Black;
}
else if ((cubicCurve = line as CubicBezierCurve) != null)
{
graphics.LineStyle = TransparentBlue;
graphics.DrawLines(
Vector2.Transform(cubicCurve.Start, transform),
Vector2.Transform(cubicCurve.ControlPointA, transform),
Vector2.Transform(cubicCurve.ControlPointB, transform),
Vector2.Transform(cubicCurve.End, transform));
graphics.LineStyle = SolidColourStyle.Black;
}
foreach (LineVector point in line.Points)
{
if (point.IsFixed) graphics.FillStyle = SolidColourStyle.Gray;
else if (point == _selectedVector) graphics.FillStyle = SolidColourStyle.CornflowerBlue;
else graphics.FillStyle = SolidColourStyle.White;
DrawControl(graphics, Vector2.Transform(point, transform), radius);
}
}
}
}