本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.GetLastPoint方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.GetLastPoint方法的具体用法?C# GraphicsPath.GetLastPoint怎么用?C# GraphicsPath.GetLastPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath.GetLastPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Path
public override GraphicsPath Path(SvgRenderer renderer)
{
if (_Path == null || this.IsPathDirty)
{
_Path = new GraphicsPath();
try
{
for (int i = 0; i < Points.Count; i += 2)
{
PointF endPoint = new PointF(Points[i].ToDeviceValue(renderer, UnitRenderingType.Horizontal, this),
Points[i + 1].ToDeviceValue(renderer, UnitRenderingType.Vertical, this));
// TODO: Remove unrequired first line
if (_Path.PointCount == 0)
{
_Path.AddLine(endPoint, endPoint);
}
else
{
_Path.AddLine(_Path.GetLastPoint(), endPoint);
}
}
}
catch (Exception exc)
{
Trace.TraceError("Error rendering points: " + exc.Message);
}
this.IsPathDirty = false;
}
return _Path;
}
示例2: Path
public override GraphicsPath Path(ISvgRenderer renderer)
{
if ((_Path == null || this.IsPathDirty) && base.StrokeWidth > 0)
{
_Path = new GraphicsPath();
try
{
for (int i = 0; (i + 1) < Points.Count; i += 2)
{
PointF endPoint = new PointF(Points[i].ToDeviceValue(renderer, UnitRenderingType.Horizontal, this),
Points[i + 1].ToDeviceValue(renderer, UnitRenderingType.Vertical, this));
if (renderer == null)
{
var radius = base.StrokeWidth / 2;
_Path.AddEllipse(endPoint.X - radius, endPoint.Y - radius, 2 * radius, 2 * radius);
continue;
}
// TODO: Remove unrequired first line
if (_Path.PointCount == 0)
{
_Path.AddLine(endPoint, endPoint);
}
else
{
_Path.AddLine(_Path.GetLastPoint(), endPoint);
}
}
}
catch (Exception exc)
{
Trace.TraceError("Error rendering points: " + exc.Message);
}
if (renderer != null)
this.IsPathDirty = false;
}
return _Path;
}
示例3: Get3DShinePath
private const double ROUNDED_RECT_RAD_PERCENT = .05d; //5 percent
#endregion Fields
#region Methods
public static GraphicsPath Get3DShinePath(Rectangle container, ControlShape shape)
{
GraphicsPath path = new GraphicsPath();
Rectangle pathRect = container;
pathRect.Width -= 1;
pathRect.Height -= 1;
RectangleF halfRect = new RectangleF(pathRect.X, pathRect.Y,
pathRect.Width, pathRect.Height / 2f);
if (pathRect.Height > 0 && pathRect.Width > 0)
{
switch (shape)
{
case ControlShape.Rect:
path.AddRectangle(halfRect);
break;
case ControlShape.RoundedRect:
//radius is 10% of smallest side
int rad = (int)(Math.Min(halfRect.Height, halfRect.Width) * ROUNDED_RECT_RAD_PERCENT);
path.AddRoundedRectangle(halfRect, rad);
break;
case ControlShape.Circular:
path.AddArc(pathRect, 180, 142);
PointF[] pts = new PointF[]
{
path.GetLastPoint(),
new PointF(container.Width * .70f, container.Height * .33f),
new PointF(container.Width * .25f, container.Height * .5f),
path.PathPoints[0]
};
path.AddCurve(pts);
path.CloseFigure();
break;
}
}
return path;
}
示例4: SyntaxToPath
public GraphicsPath SyntaxToPath(string PathSyntax)
{
List<string> t = Tokenize(PathSyntax);
if (t.Count < 2) return new GraphicsPath();
GraphicsPath p = new GraphicsPath();
int i = 0;
if (t[0] == "F1") {
p.FillMode = FillMode.Winding;
i++;
} else if (t[0] == "F0") {
p.FillMode = FillMode.Alternate;
i++;
}
PointF last_point = new PointF(0, 0);
for (; i < t.Count; i++) {
switch (t[i]) { // doesn't handle a lot of short-cuts yet. Doesn't support Hh or Vv
case "M":
p.StartFigure();
last_point = GetPointStr(t[i + 1], t[i + 2]);
i += 2;
break;
case "m":
p.StartFigure();
last_point = GetPointStrOff(t[i + 1], t[i + 2], last_point);
i += 2;
break;
case "L":
p.AddLine(last_point, GetPointStr(t[i + 1], t[i + 2]));
last_point = p.GetLastPoint();
i += 2;
break;
case "l":
p.AddLine(last_point, GetPointStrOff(t[i + 1], t[i + 2], last_point));
last_point = p.GetLastPoint();
i += 2;
break;
case "C":
p.AddBezier(last_point, GetPointStr(t[i + 1], t[i + 2]), GetPointStr(t[i + 3], t[i + 4]), GetPointStr(t[i + 5], t[i + 6]));
last_point = p.GetLastPoint();
i += 6;
break;
case "Z":
case "z":
p.CloseFigure();
break;
default:
throw new Exception("Unsupported symbol: " + t[i]);
}
}
p.CloseAllFigures();
return p;
}
示例5: bg_DoWork
void bg_DoWork(object sender, DoWorkEventArgs e)
{
MapInfo info = (MapInfo)e.Argument;
if(!info.Area.IsEmpty)
{
//var types = GMaps.Instance.GetAllLayersOfType(info.Type);
string bigImage = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + Path.DirectorySeparatorChar + "GMap at zoom " + info.Zoom + " - " + info.Type + "-" + DateTime.Now.Ticks + ".png";
e.Result = bigImage;
// current area
GPoint topLeftPx = info.Type.Projection.FromLatLngToPixel(info.Area.LocationTopLeft, info.Zoom);
GPoint rightButtomPx = info.Type.Projection.FromLatLngToPixel(info.Area.Bottom, info.Area.Right, info.Zoom);
GPoint pxDelta = new GPoint(rightButtomPx.X - topLeftPx.X, rightButtomPx.Y - topLeftPx.Y);
GMap.NET.GSize maxOfTiles = info.Type.Projection.GetTileMatrixMaxXY(info.Zoom);
int padding = info.MakeWorldFile ? 0 : 22;
{
using(Bitmap bmpDestination = new Bitmap((int)(pxDelta.X + padding * 2), (int)(pxDelta.Y + padding * 2)))
{
using(Graphics gfx = Graphics.FromImage(bmpDestination))
{
gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
gfx.SmoothingMode = SmoothingMode.HighQuality;
int i = 0;
// get tiles & combine into one
lock(tileArea)
{
foreach(var p in tileArea)
{
if(bg.CancellationPending)
{
e.Cancel = true;
return;
}
int pc = (int)(((double)++i / tileArea.Count) * 100);
bg.ReportProgress(pc, p);
foreach(var tp in info.Type.Overlays)
{
Exception ex;
GMapImage tile;
// tile number inversion(BottomLeft -> TopLeft) for pergo maps
if(tp.InvertedAxisY)
{
tile = GMaps.Instance.GetImageFrom(tp, new GPoint(p.X, maxOfTiles.Height - p.Y), info.Zoom, out ex) as GMapImage;
}
else // ok
{
tile = GMaps.Instance.GetImageFrom(tp, p, info.Zoom, out ex) as GMapImage;
}
if(tile != null)
{
using(tile)
{
long x = p.X * info.Type.Projection.TileSize.Width - topLeftPx.X + padding;
long y = p.Y * info.Type.Projection.TileSize.Width - topLeftPx.Y + padding;
{
gfx.DrawImage(tile.Img, x, y, info.Type.Projection.TileSize.Width, info.Type.Projection.TileSize.Height);
}
}
}
}
}
}
// draw routes
{
foreach(GMapRoute r in Main.routes.Routes)
{
if(r.IsVisible)
{
using(GraphicsPath rp = new GraphicsPath())
{
for(int j = 0; j < r.Points.Count; j++)
{
var pr = r.Points[j];
GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);
px.Offset(padding, padding);
px.Offset(-topLeftPx.X, -topLeftPx.Y);
GPoint p2 = px;
if(j == 0)
{
rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
}
else
{
System.Drawing.PointF p = rp.GetLastPoint();
rp.AddLine(p.X, p.Y, p2.X, p2.Y);
}
}
//.........这里部分代码省略.........
示例6: GetLastPoint2
private void GetLastPoint2(Graphics g)
{
GraphicsPath myPath = new GraphicsPath();
try
{
PointF lastPoint = myPath.GetLastPoint();
if(!lastPoint.IsEmpty)
{
string lastPointXString = lastPoint.X.ToString();
string lastPointYString = lastPoint.Y.ToString();
Console.WriteLine(lastPointXString + ", " + lastPointYString);
}
else
Console.WriteLine("lastPoint is empty");
}
catch (ArgumentException ae)
{
Console.WriteLine (ae.Message);
}
// Draw the path to the screen.
g.DrawPath(new Pen(Color.Black, 2), myPath);
}
示例7: GetLastPoint1
private void GetLastPoint1(Graphics g)
{
GraphicsPath myPath = new GraphicsPath();
myPath.AddLine(100, 100, 300, 100);
PointF lastPoint = myPath.GetLastPoint();
if(!lastPoint.IsEmpty)
{
string lastPointXString = lastPoint.X.ToString();
string lastPointYString = lastPoint.Y.ToString();
Console.WriteLine(lastPointXString + ", " + lastPointYString);
}
else
Console.WriteLine("lastPoint is empty");
// Draw the path to the screen.
g.DrawPath(new Pen(Color.Black, 2), myPath);
}
示例8: bg_DoWork
void bg_DoWork(object sender, DoWorkEventArgs e)
{
MapInfo info = (MapInfo)e.Argument;
if(!info.Area.IsEmpty)
{
string bigImage = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + Path.DirectorySeparatorChar + "GMap at zoom " + info.Zoom + " - " + info.Type + "-" + DateTime.Now.Ticks + ".jpg";
e.Result = bigImage;
// current area
GPoint topLeftPx = info.Type.Projection.FromLatLngToPixel(info.Area.LocationTopLeft, info.Zoom);
GPoint rightButtomPx = info.Type.Projection.FromLatLngToPixel(info.Area.Bottom, info.Area.Right, info.Zoom);
GPoint pxDelta = new GPoint(rightButtomPx.X - topLeftPx.X, rightButtomPx.Y - topLeftPx.Y);
GMap.NET.GSize maxOfTiles = info.Type.Projection.GetTileMatrixMaxXY(info.Zoom);
int padding = info.MakeWorldFile || info.MakeKmz ? 0 : 22;
{
using(Bitmap bmpDestination = new Bitmap((int)(pxDelta.X + padding * 2), (int)(pxDelta.Y + padding * 2)))
{
using(Graphics gfx = Graphics.FromImage(bmpDestination))
{
gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
gfx.SmoothingMode = SmoothingMode.HighQuality;
int i = 0;
// get tiles & combine into one
lock(tileArea)
{
foreach(var p in tileArea)
{
if(bg.CancellationPending)
{
e.Cancel = true;
return;
}
int pc = (int)(((double)++i / tileArea.Count) * 100);
bg.ReportProgress(pc, p);
foreach(var tp in info.Type.Overlays)
{
Exception ex;
GMapImage tile;
// tile number inversion(BottomLeft -> TopLeft) for pergo maps
if(tp.InvertedAxisY)
{
tile = GMaps.Instance.GetImageFrom(tp, new GPoint(p.X, maxOfTiles.Height - p.Y), info.Zoom, out ex) as GMapImage;
}
else // ok
{
tile = GMaps.Instance.GetImageFrom(tp, p, info.Zoom, out ex) as GMapImage;
}
if(tile != null)
{
using(tile)
{
long x = p.X * info.Type.Projection.TileSize.Width - topLeftPx.X + padding;
long y = p.Y * info.Type.Projection.TileSize.Width - topLeftPx.Y + padding;
{
gfx.DrawImage(tile.Img, x, y, info.Type.Projection.TileSize.Width, info.Type.Projection.TileSize.Height);
}
}
}
}
}
}
// draw routes
{
foreach(GMapRoute r in Main.routes.Routes)
{
if(r.IsVisible)
{
using(GraphicsPath rp = new GraphicsPath())
{
for(int j = 0; j < r.Points.Count; j++)
{
var pr = r.Points[j];
GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);
px.Offset(padding, padding);
px.Offset(-topLeftPx.X, -topLeftPx.Y);
GPoint p2 = px;
if(j == 0)
{
rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
}
else
{
System.Drawing.PointF p = rp.GetLastPoint();
rp.AddLine(p.X, p.Y, p2.X, p2.Y);
}
}
if(rp.PointCount > 0)
{
//.........这里部分代码省略.........
示例9: DrawPolygons
/// <summary>
/// draw polygons, override to draw custom
/// </summary>
/// <param name="g"></param>
protected virtual void DrawPolygons(Graphics g)
{
#if !PocketPC
foreach(GMapPolygon r in Polygons)
{
if(r.IsVisible)
{
using(GraphicsPath rp = new GraphicsPath())
{
for(int i = 0; i < r.LocalPoints.Count; i++)
{
GPoint p2 = r.LocalPoints[i];
if(i == 0)
{
rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
}
else
{
System.Drawing.PointF p = rp.GetLastPoint();
rp.AddLine(p.X, p.Y, p2.X, p2.Y);
}
}
if(rp.PointCount > 0)
{
rp.CloseFigure();
if (!(((SolidBrush)r.Fill).Color.A == 155 && ((SolidBrush)r.Fill).Color.B == 255 && ((SolidBrush)r.Fill).Color.G == 248 && ((SolidBrush)r.Fill).Color.R == 240))
g.FillPath(r.Fill, rp);
g.DrawPath(r.Stroke, rp);
}
}
}
}
#else
foreach(GMapPolygon r in Polygons)
{
if(r.IsVisible)
{
Point[] pnts = new Point[r.LocalPoints.Count];
for(int i = 0; i < r.LocalPoints.Count; i++)
{
Point p2 = new Point(r.LocalPoints[i].X, r.LocalPoints[i].Y);
pnts[pnts.Length - 1 - i] = p2;
}
if(pnts.Length > 0)
{
g.FillPolygon(r.Fill, pnts);
g.DrawPolygon(r.Stroke, pnts);
}
}
}
#endif
}
示例10: DrawRoutes
/// <summary>
/// draw routes, override to draw custom
/// </summary>
/// <param name="g"></param>
protected virtual void DrawRoutes(Graphics g)
{
#if !PocketPC
foreach(GMapRoute r in Routes)
{
if(r.IsVisible)
{
using(GraphicsPath rp = new GraphicsPath())
{
for(int i = 0; i < r.LocalPoints.Count; i++)
{
GPoint p2 = r.LocalPoints[i];
if(i == 0)
{
rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
}
else
{
System.Drawing.PointF p = rp.GetLastPoint();
rp.AddLine(p.X, p.Y, p2.X, p2.Y);
}
}
if(rp.PointCount > 0)
{
g.DrawPath(r.Stroke, rp);
}
}
}
}
#else
foreach(GMapRoute r in Routes)
{
if(r.IsVisible)
{
Point[] pnts = new Point[r.LocalPoints.Count];
for(int i = 0; i < r.LocalPoints.Count; i++)
{
Point p2 = new Point(r.LocalPoints[i].X, r.LocalPoints[i].Y);
pnts[pnts.Length - 1 - i] = p2;
}
if(pnts.Length > 0)
{
g.DrawLines(r.Stroke, pnts);
}
}
}
#endif
}
示例11: PathDataParse
//.........这里部分代码省略.........
Label_049B:
tf2 = new PointF(tf2.X, singleArray1[0] + tf2.Y);
info2 = new PointInfo(tf2, text1);
goto Label_1001;
Label_0579:
tf1 = new PointF(single3, single4);
tf2 = new PointF(singleArray1[2], singleArray1[3]);
info2 = new PointInfo(tf2, new PointF(single1, single2), new PointF(single3, single4), text1);
goto Label_1001;
Label_05D2:
single5 = (2f * tf2.X) - tf1.X;
single6 = (2f * tf2.Y) - tf1.Y;
Label_0600:
single1 = tf2.X + (((single5 - tf2.X) * 2f) / 3f);
single2 = tf2.Y + (((single6 - tf2.Y) * 2f) / 3f);
single3 = single5 + ((singleArray1[0] - single5) / 3f);
single4 = single6 + ((singleArray1[1] - single6) / 3f);
if (singleArray1.Length != 2)
{
throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidpathformat") + text1);
}
path1.AddBezier(tf2.X, tf2.Y, single1, single2, single3, single4, singleArray1[0], singleArray1[1]);
tf1 = new PointF(single3, single4);
tf2 = new PointF(singleArray1[0], singleArray1[1]);
info2 = new PointInfo(tf2, new PointF(single1, single2), new PointF(single3, single4), text1);
goto Label_1001;
Label_0755:
single1 = (2f * tf2.X) - tf1.X;
single2 = (2f * tf2.Y) - tf1.Y;
path1.AddBezier(tf2.X, tf2.Y, single1, single2, singleArray1[0], singleArray1[1], singleArray1[2], singleArray1[3]);
Label_07C4:
tf1 = new PointF(singleArray1[0], singleArray1[1]);
tf2 = new PointF(singleArray1[2], singleArray1[3]);
info2 = new PointInfo(path1.GetLastPoint(), path1.PathPoints[path1.PointCount - 3], path1.PathPoints[path1.PointCount - 2], text1);
goto Label_1001;
Label_0872:
tf1 = new PointF(singleArray1[2], singleArray1[3]);
tf2 = new PointF(singleArray1[4], singleArray1[5]);
info2 = new PointInfo(new PointF(singleArray1[4], singleArray1[5]), new PointF(singleArray1[0], singleArray1[1]), new PointF(singleArray1[2], singleArray1[3]), text1);
goto Label_1001;
Label_092D://A
tf1 = PointF.Empty;
tf2 = path1.GetLastPoint();//, path1.PathPoints[path1.PointCount - 3], path1.PathPoints[path1.PointCount - 2]
info2 = new PointInfo(tf2,PointF.Empty,new PointF(tf2.X+singleArray1[0],tf2.Y), text1);
info2.NextControl=new PointF(tf2.X,tf2.Y+singleArray1[1]);
info2.Rx=singleArray1[0];
info2.Ry=singleArray1[1];
info2.Angle=singleArray1[2];
info2.LargeArcFlage=(int)singleArray1[3];
info2.SweepFlage=(int)singleArray1[4];
goto Label_1001;
Label_09F7:
tf1 = PointF.Empty;
tf2 = path1.GetLastPoint();
info2 = new PointInfo(path1.GetLastPoint(), path1.PathPoints[path1.PointCount - 3], path1.PathPoints[path1.PointCount - 2], text1);
goto Label_1001;
Label_0B0D:
tf1 = new PointF(single3, single4);
tf2 = new PointF(singleArray1[2] + tf2.X, tf2.Y + singleArray1[3]);
info2 = new PointInfo(path1.GetLastPoint(), path1.PathPoints[path1.PointCount - 3], path1.PathPoints[path1.PointCount - 2], text1);
goto Label_1001;
Label_0B98:
single5 = (2f * tf2.X) - tf1.X;
single6 = (2f * tf2.Y) - tf1.Y;
Label_0BC6:
single1 = tf2.X + (((single5 - tf2.X) * 2f) / 3f);
示例12: EvaluateParameters
public void EvaluateParameters()
{
Rectangle outerRectangle = new Rectangle(
(int)(_owner.Center.X - _owner.OuterRadius * _outerFactor),
(int)(_owner.Center.Y - _owner.OuterRadius * _outerFactor),
(int)(2 * _owner.OuterRadius * _outerFactor),
(int)(2 * _owner.OuterRadius * _outerFactor)
);
Rectangle innerRectangle = new Rectangle(
(int)(_owner.Center.X - _owner.InnerRadius * _innerFactor),
(int)(_owner.Center.Y - _owner.InnerRadius * _innerFactor),
(int)(2 * _owner.InnerRadius * _innerFactor),
(int)(2 * _owner.InnerRadius * _innerFactor)
);
// Внешняя дуга.
GraphicsPath outerArc = new GraphicsPath();
outerArc.AddArc(outerRectangle, _startAngle, _sweepAngle);
// Внутренняя дуга сектора.
GraphicsPath innerArc = new GraphicsPath();
innerArc.AddArc(innerRectangle, _startAngle, _sweepAngle);
// Вычисляем границу сектора.
_diagSectorPath.Dispose();
_diagSectorPath = new GraphicsPath();
_diagSectorPath.AddPath(outerArc, true);
_diagSectorPath.AddLine(
outerArc.GetLastPoint(),
innerArc.GetLastPoint()
);
innerArc.Reverse();
_diagSectorPath.AddPath(innerArc, true);
outerArc.Reverse();
_diagSectorPath.AddLine(
outerArc.GetLastPoint(),
innerArc.GetLastPoint()
);
_region.Dispose();
_region = new Region(_diagSectorPath);
_owner.Invalidate();
}
示例13: OnRender
public override void OnRender(System.Drawing.Graphics g)
{
if (IsVisible)
{
List<Point> points = new List<Point>();
using (GraphicsPath rp = new GraphicsPath())
{
for (int i = 0; i < LocalPoints.Count; i++)
{
GPoint p2 = LocalPoints[i];
points.Add(new Point(LocalPoints[i].X, LocalPoints[i].Y));
if (i == 0)
{
rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
}
else
{
System.Drawing.PointF p = rp.GetLastPoint();
rp.AddLine(p.X, p.Y, p2.X, p2.Y);
}
Pen pen = new Pen(Color.FromArgb(100, 255, 0, 0));
pen.Width = 1.5F;
if (_showNode)
g.DrawArc(pen, (float)LocalPoints[i].X - 3, (float)LocalPoints[i].Y - 3, 6, 6, (float)360, (float)360);
}
if (rp.PointCount > 0)
{
g.DrawPath(Stroke, rp);
}
}
}
}
示例14: GetLastPoint2
public void GetLastPoint2()
{
path = new GraphicsPath ();
PointF actual = path.GetLastPoint ();
}
示例15: GetLastPoint
public void GetLastPoint()
{
path = new GraphicsPath ();
path.AddLine (new Point (100, 100), new Point (400, 100));
path.AddLine (new Point (400, 200), new Point (10, 100));
PointF expected = new PointF (10f, 100f);
PointF actual = path.GetLastPoint ();
DrawingTest.AssertAlmostEqual(expected, actual);
path.StartFigure ();
path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
path.StartFigure ();
path.AddRectangle (new Rectangle (10, 20, 300, 400));
expected = new PointF (10f, 420f);
actual = path.GetLastPoint ();
DrawingTest.AssertAlmostEqual(expected, actual);
path.StartFigure ();
path.AddLine (new Point (400, 400), new Point (400, 10));
expected = new PointF (400f, 10f);
actual = path.GetLastPoint ();
DrawingTest.AssertAlmostEqual(expected, actual);
//t.AssertCompare ();
}