本文整理汇总了C#中System.Windows.Media.StreamGeometryContext类的典型用法代码示例。如果您正苦于以下问题:C# StreamGeometryContext类的具体用法?C# StreamGeometryContext怎么用?C# StreamGeometryContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StreamGeometryContext类属于System.Windows.Media命名空间,在下文中一共展示了StreamGeometryContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InternalDrawGeometrys
private void InternalDrawGeometrys(StreamGeometryContext context, List<Point> listp)
{
bool first = true;
Point pre = new Point(0, 0);
foreach (Point ep in listp)
{
Point p1 = new Point(ep.X - Constants.CALACTION_TRACELEN, ep.Y);
Point p2 = new Point(ep.X, ep.Y - Constants.CALACTION_TRACELEN);
Point p3 = new Point(ep.X + Constants.CALACTION_TRACELEN, ep.Y);
Point p4 = new Point(ep.X, ep.Y + Constants.CALACTION_TRACELEN);
//draw cross
context.BeginFigure(p1, true, false);
context.LineTo(p3, true, true);
context.BeginFigure(p2, true, false);
context.LineTo(p4, true, true);
if (first)
{
first = false;
pre = ep;
}
else
{
context.BeginFigure(pre, true, false);
context.LineTo(ep, true, true);
pre = ep;
}
}
}
示例2: CreateArrows
private void CreateArrows(Path path, StreamGeometryContext gc)
{
double start;
if (path.PathType == PathType.Convex)
{
start = GeometryHelper.GetAngleFromPoint(path.StartPoint, path.Origin);
}
else
{
start = GeometryHelper.GetAngleFromPoint(path.EndPoint, path.Origin);
}
for(int i= 0; i < 10; i++)
{
start += 8;
var org = GeometryHelper.GetPointAtAngle(path.Origin, path.Radius, start);
var pt1 = GeometryHelper.GetPointAtAngle(path.Origin, path.Radius + 10, start);
var pt2 = GeometryHelper.GetPointAtAngle(path.Origin, path.Radius - 10, start);
var pt3 = GeometryHelper.GetPointAtAngle(org, 20, start + 90);
gc.BeginFigure(pt1, true, true);
gc.LineTo(pt2, true, true);
gc.LineTo(pt3, true, true);
gc.LineTo(pt1, true, true);
gc.BeginFigure(path.Origin, false, false);
gc.LineTo(pt1, true, true);
}
}
示例3: Draw
public override void Draw(StreamGeometryContext context, Point startPoint, Point endPoint)
{
Vector line = endPoint - startPoint;
Vector perpendicularLine = new Vector(line.Y, -line.X);
perpendicularLine.Normalize();
double halfLength = line.Length/2;
Point leftPoint = startPoint - (perpendicularLine*halfLength);
Point rightPoint = startPoint + (perpendicularLine * halfLength);
var norLine = new Vector(line.X, line.Y);
norLine.Normalize();
Point shortEndPoint = endPoint - (norLine * 4);
context.BeginFigure(startPoint, true, false);
context.LineTo(shortEndPoint, true, false);
context.LineTo(leftPoint, false, false);
context.LineTo(shortEndPoint, true, false);
context.LineTo(rightPoint, false, false);
context.LineTo(shortEndPoint, true, false);
context.LineTo(endPoint, true, false);
}
示例4: InternalDrawGeometry
/// <summary>
/// Draws the primitive geometric components of the wedge.
/// </summary>
/// <param name="context">The context.</param>
public void InternalDrawGeometry(StreamGeometryContext context)
{
Point startPoint = center;
Point innerArcStartPoint = ComputeCartesianCoordinate(rotationAngle, innerRadius);
innerArcStartPoint.Offset(center.X, center.Y);
Point innerArcEndPoint = ComputeCartesianCoordinate(rotationAngle + sweep, innerRadius);
innerArcEndPoint.Offset(center.X, center.Y);
Point outerArcStartPoint = ComputeCartesianCoordinate(rotationAngle, /*innerRadius +*/ outerRadius);
outerArcStartPoint.Offset(center.X, center.Y);
Point outerArcEndPoint = ComputeCartesianCoordinate(rotationAngle + sweep, /*innerRadius +*/ outerRadius);
outerArcEndPoint.Offset(center.X, center.Y);
bool largeArc = sweep > 180.0;
/*
Point offset = ComputeCartesianCoordinate(rotationAngle + sweep / 2, PushOut);
innerArcStartPoint.Offset(offset.X, offset.Y);
innerArcEndPoint.Offset(offset.X, offset.Y);
outerArcStartPoint.Offset(offset.X, offset.Y);
outerArcEndPoint.Offset(offset.X, offset.Y);
*/
Size outerArcSize = new Size(/*innerRadius +*/ outerRadius, /*innerRadius +*/ outerRadius);
Size innerArcSize = new Size(innerRadius, innerRadius);
context.BeginFigure(innerArcStartPoint, true, true);
context.LineTo(outerArcStartPoint, true, true);
context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true);
context.LineTo(innerArcEndPoint, true, true);
context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true);
}
示例5: DrawArrow
private static void DrawArrow(StreamGeometryContext streamGeometryContext, Point[] points, Vector sizeOffset, double thickness)
{
double headWidth = thickness;
double headHeight = thickness * 0.8;
Point pt1 = Point.Add(points[points.Length - 2], sizeOffset);
Point pt2 = Point.Add(points[points.Length - 1], sizeOffset);
double theta = Math.Atan2(pt1.Y - pt2.Y, pt1.X - pt2.X);
double sint = Math.Sin(theta);
double cost = Math.Cos(theta);
Point pt3 = new Point(
pt2.X + (headWidth * cost - headHeight * sint),
pt2.Y + (headWidth * sint + headHeight * cost));
Point pt4 = new Point(
pt2.X + (headWidth * cost + headHeight * sint),
pt2.Y - (headHeight * cost - headWidth * sint));
streamGeometryContext.BeginFigure(pt1, true, false);
streamGeometryContext.LineTo(pt2, true, true);
streamGeometryContext.LineTo(pt3, true, true);
streamGeometryContext.LineTo(pt2, true, true);
streamGeometryContext.LineTo(pt4, true, true);
}
示例6: Draw
public override void Draw(StreamGeometryContext context, Connection connection)
{
if (connection.SourceConnectionPoint == null || connection.TargetConnectionPoint == null)
{
context.BeginFigure(connection.StartPoint, true, false);
context.LineTo(connection.EndPoint, true, true);
}
else if(connection.Source == connection.Target)
{
Point startPoint = connection.SourceEndPoint.EndPoint;
Point midPoint = connection.SourceConnectionPoint.LineAwayFromThisTo(startPoint, 50);
context.BeginFigure(startPoint, true, true);
context.ArcTo(midPoint, new Size(50, 50), 180, false, SweepDirection.Clockwise, true, true);
context.ArcTo(startPoint, new Size(50, 50), 180, false, SweepDirection.Clockwise, true, true);
}
else
{
Point startPoint = connection.SourceEndPoint.EndPoint;
Point endPoint = connection.TargetEndPoint.EndPoint;
context.BeginFigure(startPoint, true, false);
context.LineTo(endPoint, true, true);
}
}
示例7: Polygon
static void Polygon(StreamGeometryContext ctx, Point point, double size, double startAngle, int steps)
{
var halfSize = size / 2;
var xOffset = halfSize * Math.Sin(startAngle);
var yOffset = halfSize * Math.Cos(startAngle);
ctx.BeginFigure(new Point(point.X + xOffset, point.Y - yOffset), true, true);
for (var angle = startAngle + (MoreMath.TwoPi / steps); angle < MoreMath.TwoPi; angle += MoreMath.TwoPi / steps) ctx.LineTo(new Point(point.X + (halfSize * Math.Sin(angle)), point.Y - (halfSize * Math.Cos(angle))), true, true);
}
示例8: Draw
public override void Draw(StreamGeometryContext context, Point startPoint, Point endPoint)
{
Vector mainLine = startPoint.To(endPoint);
mainLine.Normalize();
Vector mainPerpendicularLine = DrawingHelper.GetPerpendicularLine(startPoint, endPoint);
DrawingHelper.DrawTriangle(context, mainLine, mainPerpendicularLine, startPoint, 10, false);
}
示例9: Draw
public void Draw(StreamGeometryContext context, Connection connection)
{
Point startPoint = connection.SourceEndPoint.EndPoint;
Point endPoint = connection.TargetEndPoint.EndPoint;
context.BeginFigure(startPoint, true, false);
context.LineTo(endPoint, true, true);
}
示例10: DrawTriangle
public static void DrawTriangle(StreamGeometryContext context, Vector mainLine, Vector mainPerpendicularLine, Point point1, int size, bool isFilled)
{
int halfSize = size / 2;
context.BeginFigure(point1, isFilled, true);
var point2 = point1 + (mainPerpendicularLine * halfSize) + (mainLine * size);
var point3 = point1 - (mainPerpendicularLine * halfSize) + (mainLine * size);
context.LineTo(point2, true, true);
context.LineTo(point3, true, true);
}
示例11: AddRing
///<summary>
/// Adds a <see cref="PathFigure"/> representing a polygon ring
/// having the given coordinate sequence to the supplied <see cref="StreamGeometryContext"/>
///</summary>
///<param name="sgc">The stream geometry context.</param>
///<param name="coordinates">A coordinate sequence</param>
///<param name="filled">Starting paramter for </param>
///<returns>The path for the coordinate sequence</returns>
private static void AddRing(StreamGeometryContext sgc, Coordinate[] coordinates, bool filled)
{
if (coordinates.Length <= 0)
return;
sgc.BeginFigure(ToPoint(coordinates[0]), filled, true);
if (coordinates.Length > 0)
sgc.PolyLineTo(ToPoint(coordinates, 1), true, true);
}
示例12: AddCircleToGeometry
private static void AddCircleToGeometry(StreamGeometryContext streamGeometryContext, Point[] points, double pointSize)
{
foreach (Point point in points)
{
streamGeometryContext.BeginFigure(new Point(point.X - (pointSize / 2), point.Y - (pointSize / 2)), true, true);
streamGeometryContext.ArcTo(new Point(point.X - (pointSize / 2) - 0.0001, point.Y - (pointSize / 2)),
new Size(pointSize, pointSize), 360, true, SweepDirection.Clockwise, true, false);
}
}
示例13: InternalDrawGeometry
private void InternalDrawGeometry(StreamGeometryContext context)
{
generateGeometry();
context.BeginFigure(tips[0], true, true);
for (int x = 1; x < points.Count(); x++)
{
context.LineTo(points[x], true, true);
}
}
示例14: OpenFigure
static void OpenFigure(StreamGeometryContext ctx, Point point, double size, double startAngle, int steps)
{
var halfSize = size / 2;
for (var angle = startAngle; angle <= Math.PI; angle += Math.PI / steps)
{
var xOffset = halfSize * Math.Sin(angle);
var yOffset = halfSize * Math.Cos(angle);
ctx.BeginFigure(new Point(point.X + xOffset, point.Y - yOffset), false, false);
ctx.LineTo(new Point(point.X - xOffset, point.Y + yOffset), true, false);
}
}
示例15: DrawParallelLines
public static void DrawParallelLines(StreamGeometryContext context, Point startPoint, Point endPoint, int spacing)
{
Vector perpendicularLine = GetPerpendicularLine(startPoint, endPoint);
// Draw 1->2 line
context.BeginFigure(startPoint + (perpendicularLine * spacing), true, false);
context.LineTo(endPoint + (perpendicularLine * spacing), true, true);
// Draw 2->1 line
context.BeginFigure(startPoint - (perpendicularLine * spacing), true, false);
context.LineTo(endPoint - (perpendicularLine * spacing), true, true);
}