本文整理汇总了C#中PointCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# PointCollection.Add方法的具体用法?C# PointCollection.Add怎么用?C# PointCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointCollection
的用法示例。
在下文中一共展示了PointCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: envelopeToPolygon
Polygon envelopeToPolygon(Envelope env)
{
PointCollection points = new PointCollection();
points.Add(new MapPoint(env.XMin, env.YMin, env.SpatialReference));
points.Add(new MapPoint(env.XMin, env.YMax, env.SpatialReference));
points.Add(new MapPoint(env.XMax, env.YMax, env.SpatialReference));
points.Add(new MapPoint(env.XMax, env.YMin, env.SpatialReference));
points.Add(new MapPoint(env.XMin, env.YMin, env.SpatialReference));
Polygon polygon = new Polygon();
polygon.Rings.Add(points);
return polygon;
}
示例2: CreatePolylineX
// Creates a polyline with two paths in the shape of an 'X' centered at the given point
private Polyline CreatePolylineX(MapPoint center, double length)
{
var halfLen = length / 2.0;
PointCollection coords1 = new PointCollection();
coords1.Add(new MapPoint(center.X - halfLen, center.Y + halfLen));
coords1.Add(new MapPoint(center.X + halfLen, center.Y - halfLen));
PointCollection coords2 = new PointCollection();
coords2.Add(new MapPoint(center.X + halfLen, center.Y + halfLen));
coords2.Add(new MapPoint(center.X - halfLen, center.Y - halfLen));
return new Polyline(new List<PointCollection> { coords1, coords2 }, MyMapView.SpatialReference);
}
示例3: OnPointerPressed
public void OnPointerPressed(InqCanvas inqCanvas, PointerRoutedEventArgs e)
{
Debug.WriteLine(e.Pointer.PointerDeviceType);
_currentStroke = new PointCollection();
_polyline = new Polyline
{
Stroke = new SolidColorBrush(StrokeColor),
StrokeThickness = 3,
StrokeLineJoin = PenLineJoin.Round
};
inqCanvas.Children.Add(_polyline);
_polyline.Points = _currentStroke;
var point = e.GetCurrentPoint(inqCanvas);
_strokeBuilder.BeginStroke(point);
_currentStroke.Add(point.Position);
//_inkManager.
/*
//TODO: add data binding for thickness and color
_currentStroke.StrokeThickness = Math.Max(4.0 * e.GetCurrentPoint(inqCanvas).Properties.Pressure, 2);
_currentInqLineView.StrokeThickness = _currentStroke.StrokeThickness;
inqCanvas.Children.Add(_currentInqLineView);
var currentPoint = e.GetCurrentPoint(inqCanvas);
_currentStroke.AddPoint(new Point(currentPoint.Position.X, currentPoint.Position.Y));
*/
}
示例4: MultiPolygonWktToPolygon
private static Polygon MultiPolygonWktToPolygon(string wkt)
{
var polygon = new Polygon();
var pointCollection = new PointCollection();
var removed = wkt.Replace("MULTIPOLYGON (", "");
var preSplit = removed.Replace(")), ((", "|");
var rings = preSplit.Split('|');
foreach (var r in rings)
{
PointCollection pc = new PointCollection();
var r1 = r.Replace("(", "");
var r2 = r1.Replace(")", "");
var r3 = r2.Trim();
var coords = r3.Split(',');
foreach(var coord in coords)
{
coord.Trim();
var xy = coord.Trim().Split(' ');
if (xy.Length != 2)
continue;
pc.Add(new MapPoint(double.Parse(xy[0], CultureInfo.InvariantCulture), double.Parse(xy[1], CultureInfo.InvariantCulture)));
}
polygon.Rings.Add(pc);
}
return polygon;
}
示例5: UpdateShape
/// <summary>
/// Updates the Shape for the series.
/// </summary>
/// <param name="definitionPoints">Locations of the points of each SeriesDefinition in the series.</param>
protected override void UpdateShape(IList<IEnumerable<Point>> definitionPoints)
{
for (int i = SeriesDefinitions.Count - 1; 0 < i; i--)
{
PointCollection pointCollection = new PointCollection();
IEnumerable<Point> topPoints = (ActualIndependentAxis is ICategoryAxis) ? definitionPoints[i].OrderBy(p => p.X) : definitionPoints[i];
foreach (Point p in topPoints)
{
pointCollection.Add(p);
}
IEnumerable<Point> bottomPoints = (ActualIndependentAxis is ICategoryAxis) ? definitionPoints[i - 1].OrderByDescending(p => p.X) : definitionPoints[i - 1].Reverse();
foreach (Point p in bottomPoints)
{
pointCollection.Add(p);
}
SetPolygonPointsProperty((Polygon)SeriesDefinitionShapes[SeriesDefinitions[i]], pointCollection);
}
if (1 <= SeriesDefinitions.Count)
{
double plotAreaMaximumDependentCoordinate = ActualDependentAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum).Value;
IComparable zeroValue = ActualDependentRangeAxis.Origin ?? 0.0;
if (zeroValue.CompareTo(ActualDependentRangeAxis.Range.Minimum) < 0)
{
zeroValue = ActualDependentRangeAxis.Range.Minimum;
}
if (0 < zeroValue.CompareTo(ActualDependentRangeAxis.Range.Maximum))
{
zeroValue = ActualDependentRangeAxis.Range.Maximum;
}
double zeroCoordinate = ActualDependentAxis.GetPlotAreaCoordinate(zeroValue).Value;
PointCollection pointCollection = new PointCollection();
Point[] topPoints = ((ActualIndependentAxis is ICategoryAxis) ? definitionPoints[0].OrderBy(p => p.X) : definitionPoints[0]).ToArray();
foreach (Point p in topPoints)
{
pointCollection.Add(p);
}
if (0 < topPoints.Length)
{
Point firstPoint = topPoints[0];
Point lastPoint = topPoints[topPoints.Length - 1];
pointCollection.Add(new Point(lastPoint.X, plotAreaMaximumDependentCoordinate - zeroCoordinate));
pointCollection.Add(new Point(firstPoint.X, plotAreaMaximumDependentCoordinate - zeroCoordinate));
}
SetPolygonPointsProperty((Polygon)SeriesDefinitionShapes[SeriesDefinitions[0]], pointCollection);
}
}
示例6: FromArray
// Helper method
private static PointCollection FromArray(params double[] parameters)
{
PointCollection coll = new PointCollection();
for (int i = 0; i < parameters.Length - 1; i+=2)
{
coll.Add(new MapPoint(parameters[i], parameters[i + 1]));
}
return coll;
}
示例7: ToPointCollectionList
/// <summary>
/// Convert a collection of points into a <see cref="PointCollectionList"/> that can be used as paths in <see cref="Polyline"/> types
/// or rings in <see cref="Polygon"/> types
/// </summary>
/// <param name="points"></param>
/// <returns></returns>
public static PointCollectionList ToPointCollectionList(this IEnumerable<Point> points)
{
var result = new PointCollectionList();
var pointCollection = new PointCollection();
foreach (var point in points)
pointCollection.Add(point.ToPointCollectionEntry());
result.Add(pointCollection);
return result;
}
示例8: FromArray
// Helper method
private static PointCollection FromArray(params double[] parameters)
{
PointCollection coll = new PointCollection(SpatialReferences.Wgs84);
var mapPointBuilder = new MapPointBuilder(SpatialReferences.Wgs84);
for (int i = 0; i < parameters.Length - 1; i+=2)
{
mapPointBuilder.SetValues(parameters[i], parameters[i + 1]);
coll.Add(mapPointBuilder.ToGeometry());
}
return coll;
}
示例9: UpdateShape
/// <summary>
/// Updates the shape for the series.
/// </summary>
/// <param name="definitionPoints">Locations of the points of each SeriesDefinition in the series.</param>
protected override void UpdateShape(IList<IEnumerable<Point>> definitionPoints)
{
for (int i = 0; i < SeriesDefinitions.Count; i++)
{
PointCollection pointCollection = new PointCollection();
foreach (Point p in ((ActualIndependentAxis is ICategoryAxis) ? definitionPoints[i].OrderBy(p => p.X) : definitionPoints[i]))
{
pointCollection.Add(p);
}
SetPolylinePointsProperty((Polyline)SeriesDefinitionShapes[SeriesDefinitions[i]], pointCollection);
}
}
示例10: Convert
public object Convert(object value, Type targetType, object parameter, string language)
{
double valueAsDouble = DebugHelper.CastAndAssert<double>(value);
double LeftBase = 20;
double RightBase = 20;
if (BaseShape == null)
{
BaseShape = new Polygon();
BaseShape.Points.Add(new Point(-20,25));
BaseShape.Points.Add(new Point(-20,20));
BaseShape.Points.Add(new Point(0,0));
BaseShape.Points.Add(new Point(20,20));
BaseShape.Points.Add(new Point(20,25));
}
PointCollection newShape = new PointCollection();
double maxValue = Windows.UI.Xaml.Window.Current.Bounds.Width;
if (BaseShape != null)
{
foreach (Point j in BaseShape.Points)
{
double shiftX = j.X;
if (valueAsDouble < LeftBase)
{
if (j.X < 0)
{
shiftX = j.X * valueAsDouble / LeftBase;
}
}
if ((maxValue - valueAsDouble) < RightBase)
{
if (j.X > 0)
{
shiftX = j.X * (maxValue - valueAsDouble) / RightBase;
}
}
newShape.Add(new Point(shiftX, j.Y));
}
}
return newShape;
}
示例11: CreatePolygonBox
// Creates a square polygon with a hole centered at the given point
private Polygon CreatePolygonBox(MapPoint center, double length)
{
var halfLen = length / 2.0;
PointCollection coords = new PointCollection();
coords.Add(new MapPoint(center.X - halfLen, center.Y + halfLen));
coords.Add(new MapPoint(center.X + halfLen, center.Y + halfLen));
coords.Add(new MapPoint(center.X + halfLen, center.Y - halfLen));
coords.Add(new MapPoint(center.X - halfLen, center.Y - halfLen));
coords.Add(new MapPoint(center.X - halfLen, center.Y + halfLen));
halfLen /= 3;
PointCollection coordsHole = new PointCollection();
coordsHole.Add(new MapPoint(center.X - halfLen, center.Y + halfLen));
coordsHole.Add(new MapPoint(center.X - halfLen, center.Y - halfLen));
coordsHole.Add(new MapPoint(center.X + halfLen, center.Y - halfLen));
coordsHole.Add(new MapPoint(center.X + halfLen, center.Y + halfLen));
coordsHole.Add(new MapPoint(center.X - halfLen, center.Y + halfLen));
return new Polygon(
new List<PointCollection> { coords, coordsHole },
MyMapView.SpatialReference);
}
示例12: EnvelopeToPolygon
public static Geometry EnvelopeToPolygon(Geometry geometry)
{
if (!(geometry is Envelope))
return null;
Envelope envelope = geometry as Envelope;
Polygon polygon = new Polygon();
polygon.SpatialReference = envelope.SpatialReference;
PointCollection pointCollection = new PointCollection();
MapPoint topLeft = new MapPoint();
topLeft.X = envelope.XMin;
topLeft.Y = envelope.YMax;
pointCollection.Add(topLeft);
MapPoint topRight = new MapPoint();
topRight.X = envelope.XMax;
topRight.Y = envelope.YMax;
pointCollection.Add(topRight);
MapPoint bottomRight = new MapPoint();
bottomRight.X = envelope.XMax;
bottomRight.Y = envelope.YMin;
pointCollection.Add(bottomRight);
MapPoint bottomLeft = new MapPoint();
bottomLeft.X = envelope.XMin;
bottomLeft.Y = envelope.YMin;
pointCollection.Add(bottomLeft);
pointCollection.Add(topLeft);
polygon.Rings.Add(pointCollection);
return polygon as Geometry;
}
示例13: GetRadiusAsPolygonGeodesic
public static Polygon GetRadiusAsPolygonGeodesic(MapPoint center, double distance, int pointCount)
{
Polyline line = GetRadiusGeodesicAsPolyline(center, distance, pointCount);
Polygon poly = new Polygon() { SpatialReference = new SpatialReference(4326) };
if (line.Paths.Count > 1)
{
PointCollection ring = line.Paths[0];
MapPoint last = ring[ring.Count - 1];
for (int i = 1; i < line.Paths.Count; i++)
{
PointCollection pnts = line.Paths[i];
ring.Add(new MapPoint(180 * Math.Sign(last.X), 90 * Math.Sign(center.Y)));
last = pnts[0];
ring.Add(new MapPoint(180 * Math.Sign(last.X), 90 * Math.Sign(center.Y)));
foreach (MapPoint p in pnts)
ring.Add(p);
last = pnts[pnts.Count - 1];
}
poly.Rings.Add(ring);
}
else
{
poly.Rings.Add(line.Paths[0]);
}
if (distance > _EARTHCIRCUMFERENCE_ * Math.PI / 2 && line.Paths.Count != 2)
{
PointCollection pnts = new PointCollection();
pnts.Add(new MapPoint(-180, -90));
pnts.Add(new MapPoint(180, -90));
pnts.Add(new MapPoint(180, 90));
pnts.Add(new MapPoint(-180, 90));
pnts.Add(new MapPoint(-180, -90));
poly.Rings.Add(pnts); //Exterior
}
return poly;
}
示例14: Convert
public object Convert(object value, Type targetType, object parameter, string language)
{
var sw = Window.Current.Bounds.Width;
var sh = Window.Current.Bounds.Height;
var input = (PointCollection) value;
var pc = new PointCollection();
foreach (var p in input)
{
pc.Add(new Point(p.X * sw * 0.08, p.Y * sh * 0.08));
}
return pc;
}
示例15: CalculateWheels
private PointCollection CalculateWheels(WheelsData CurrentData,
double inc)
{
PointCollection pts = new PointCollection();
var maxAngle = CurrentData.SuggestedMaxTurns * 2 * Math.PI;
for (double t = 0; t < maxAngle; t += inc)
{
Complex c = new Complex();
foreach (WheelStageData sd in CurrentData.Stages)
{
c += sd.Amplitude * Complex.Exp(new Complex(0,sd.Frequency * t ));
}
pts.Add(new Point(c.Real, c.Imaginary));
}
return pts;
}