本文整理汇总了C#中System.Windows.Media.StreamGeometryContext.ArcTo方法的典型用法代码示例。如果您正苦于以下问题:C# StreamGeometryContext.ArcTo方法的具体用法?C# StreamGeometryContext.ArcTo怎么用?C# StreamGeometryContext.ArcTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.StreamGeometryContext
的用法示例。
在下文中一共展示了StreamGeometryContext.ArcTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: DrawGeometry
private void DrawGeometry(StreamGeometryContext context)
{
Size WaveSize = new Size(WaveHeight, WaveHeight);
Point StartPoint;
Point EndPoint;
StartPoint = new Point(StartPointX, (PlayfieldHeight-50) * (RemainingLives / Game.STARTING_LIVES ));
EndPoint = new Point(EndPointX, (PlayfieldHeight - 50) * (RemainingLives / Game.STARTING_LIVES));
if (RemainingLives == 0)
{
StartPoint = new Point(StartPointX, (PlayfieldHeight - 50));
EndPoint = new Point(EndPointX, (PlayfieldHeight - 50));
}
Point BottomRight = new Point(EndPointX, PlayfieldHeight);
Point BottomLeft = new Point(StartPointX, PlayfieldHeight);
Point waveEndPoint = EndPoint;
context.BeginFigure(BottomLeft, true, true);
context.LineTo(StartPoint, true, true);
for (int i = 1; i <= NUM_OF_WAVES; i++)
{
waveEndPoint.X = ((EndPoint.X - StartPoint.X) * ((double)i / NUM_OF_WAVES));
context.ArcTo(waveEndPoint, WaveSize, 0, false, SweepDirection.Counterclockwise, true, true);
}
context.LineTo(BottomRight, false, true);
}
示例4: DrawGeometry
private void DrawGeometry(StreamGeometryContext context, Point centre, float RotationAngle, float WedgeAngle, float Radius, float InnerRadius)
{
var innerArcStartPoint = ComputeCartesianCoordinate(RotationAngle, InnerRadius);
innerArcStartPoint.Offset(centre.X, centre.Y);
var innerArcEndPoint = ComputeCartesianCoordinate(RotationAngle + WedgeAngle, InnerRadius);
innerArcEndPoint.Offset(centre.X, centre.Y);
var outerArcStartPoint = ComputeCartesianCoordinate(RotationAngle, Radius);
outerArcStartPoint.Offset(centre.X, centre.Y);
var outerArcEndPoint = ComputeCartesianCoordinate(RotationAngle + WedgeAngle, Radius);
outerArcEndPoint.Offset(centre.X, centre.Y);
var largeArc = WedgeAngle > 180.0;
var outerArcSize = new Size(Radius, Radius);
var 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: SerializeData
/// <summary>
/// SerializeData - Serialize the contents of this Segment to the provided context.
/// </summary>
internal override void SerializeData(StreamGeometryContext ctx)
{
ctx.ArcTo(Point, Size, RotationAngle, IsLargeArc, SweepDirection, IsStroked, IsSmoothJoin);
}
示例6: ParseToGeometryContext
//.........这里部分代码省略.........
else
{
p = ReadPoint(cmd, ! AllowComma);
_secondLastPoint = ReadPoint(cmd, AllowComma);
}
_lastPoint = ReadPoint(cmd, AllowComma);
context.BezierTo(p, _secondLastPoint, _lastPoint, IsStroked, ! IsSmoothJoin);
last_cmd = 'C';
}
while (IsNumber(AllowComma));
break;
case 'q': case 'Q': // quadratic Bezier
case 't': case 'T': // smooth quadratic Bezier
EnsureFigure();
do
{
if ((cmd == 't') || (cmd == 'T'))
{
if (last_cmd == 'Q')
{
_secondLastPoint = Reflect();
}
else
{
_secondLastPoint = _lastPoint;
}
_lastPoint = ReadPoint(cmd, ! AllowComma);
}
else
{
_secondLastPoint = ReadPoint(cmd, ! AllowComma);
_lastPoint = ReadPoint(cmd, AllowComma);
}
context.QuadraticBezierTo(_secondLastPoint, _lastPoint, IsStroked, ! IsSmoothJoin);
last_cmd = 'Q';
}
while (IsNumber(AllowComma));
break;
case 'a': case 'A':
EnsureFigure();
do
{
// A 3,4 5, 0, 0, 6,7
double w = ReadNumber(! AllowComma);
double h = ReadNumber(AllowComma);
double rotation = ReadNumber(AllowComma);
bool large = ReadBool();
bool sweep = ReadBool();
_lastPoint = ReadPoint(cmd, AllowComma);
context.ArcTo(
_lastPoint,
new Size(w, h),
rotation,
large,
#if PBTCOMPILER
sweep,
#else
sweep ? SweepDirection.Clockwise : SweepDirection.Counterclockwise,
#endif
IsStroked,
! IsSmoothJoin
);
}
while (IsNumber(AllowComma));
last_cmd = 'A';
break;
case 'z':
case 'Z':
EnsureFigure();
context.SetClosedState(IsClosed);
_figureStarted = false;
last_cmd = 'Z';
_lastPoint = _lastStart; // Set reference point to be first point of current figure
break;
default:
ThrowBadToken();
break;
}
}
}
示例7: FillContexForCurve
static void FillContexForCurve(StreamGeometryContext context,Curve c) {
foreach(ICurve seg in c.Segments) {
var bezSeg = seg as CubicBezierSegment;
if(bezSeg != null) {
context.BezierTo(Common.WpfPoint(bezSeg.B(1)),
Common.WpfPoint(bezSeg.B(2)),Common.WpfPoint(bezSeg.B(3)),true,false);
} else {
var ls = seg as LineSegment;
if(ls != null)
context.LineTo(Common.WpfPoint(ls.End),true,false);
else {
var ellipse = seg as Ellipse;
if(ellipse != null) {
// context.LineTo(Common.WpfPoint(ellipse.End),true,false);
double sweepAngle = EllipseSweepAngle(ellipse);
bool largeArc = Math.Abs(sweepAngle) >= Math.PI;
Rectangle box = ellipse.FullBox();
context.ArcTo(Common.WpfPoint(ellipse.End),
new Size(box.Width / 2,box.Height / 2),
sweepAngle,
largeArc,
sweepAngle < 0
? SweepDirection.Counterclockwise
: SweepDirection.Clockwise,
true,true);
} else
throw new NotImplementedException();
}
}
}
}
示例8: DrawGeometry
/// <summary>
///
/// </summary>
/// <param name="context"></param>
protected void DrawGeometry(StreamGeometryContext context)
{
Point offset = new Point(
(double.IsNaN(CenterX)) ? Width / 2.0 : CenterX,
(double.IsNaN(CenterY)) ? Height / 2.0 : CenterY);
double angleSpan = Math.Abs(EndAngle - StartAngle);
Point thrustPoint = PolarToCartesian(StartAngle + angleSpan/2.0, RadiusThrust, offset);
Point outerArcStartPoint = PolarToCartesian(StartAngle, OuterRadius, offset);
Point outerArcEndPoint = PolarToCartesian(EndAngle, OuterRadius, offset);
//using LERP, calculate the innerArc points, sadly we shall be short changing
Point innerArcStartPoint = PolarToCartesian(StartAngle, InnerRadius - RadiusThrust, thrustPoint);
Point innerArcEndPoint = PolarToCartesian(EndAngle, InnerRadius - RadiusThrust, thrustPoint);
bool largeArc = angleSpan > 180.0;
double innerArcDim = Math.Max(0.0, InnerRadius - RadiusThrust);
Size outerArcSize = new Size(OuterRadius, OuterRadius);
Size innerArcSize = new Size(innerArcDim, innerArcDim);
context.BeginFigure(outerArcStartPoint, 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);
}
示例9: _drawCircularTail
// draws a circle at the tail
private void _drawCircularTail(StreamGeometryContext c, Point p, Vector v, double r) {
var p0 = p - v * 2 * r;
c.BeginFigure(p, true, true);
c.ArcTo(p0, new Size(r, r), 0, false, SweepDirection.Clockwise, true, false);
c.ArcTo(p, new Size(r, r), 0, false, SweepDirection.Clockwise, true, false);
}
示例10: _DrawArcToStream
void _DrawArcToStream(StreamGeometryContext context) {
var rotationAngle = 65F;
var innerRadius = 0F;
var centerX = _r;
var centreY = _r;
var wedgeAngle = 150F;
Point startPoint = new Point(centerX, centreY);
Point innerArcStartPoint = Tools.ComputeCartesianCoordinate(rotationAngle, innerRadius);
innerArcStartPoint.Offset(centerX, centreY);
Point outerArcStartPoint = Tools.ComputeCartesianCoordinate(rotationAngle, _r);
outerArcStartPoint.Offset(centerX, centreY);
Point outerArcEndPoint = Tools.ComputeCartesianCoordinate(rotationAngle + wedgeAngle, _r);
outerArcEndPoint.Offset(centerX, centreY);
bool largeArc = wedgeAngle > 180.0;
Size outerArcSize = new Size(_r, _r);
context.BeginFigure(innerArcStartPoint, true, true);
context.LineTo(outerArcStartPoint, true, true);
context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true);
}
示例11: AddRectangleFigure
/// <summary>See <c>WpfExtensions</c> for details.</summary>
public static void AddRectangleFigure(StreamGeometryContext ctx, Rect rect, bool fill, bool stroke, CornerRadius corners, CornerStyle cornerStyle) {
double x0 = rect.Left, x1 = rect.Right, y0 = rect.Top, y1 = rect.Bottom;
double TL = corners.TopLeft, TR = corners.TopRight, BL = corners.BottomLeft, BR = corners.BottomRight;
var sweep = (cornerStyle == CornerStyle.Round ? SweepDirection.Counterclockwise : SweepDirection.Clockwise);
var round = (cornerStyle != CornerStyle.Diagonal);
// left side
ctx.BeginFigure(new Point(x0, y0 + TL), fill, true);
ctx.LineTo(new Point(x0, y1 - BL), stroke, false);
// bottom-left corner
if (BL > 0) {
var bl = new Point(x0 + BL, y1);
if (round) {
ctx.ArcTo(bl, new Size(BL, BL), 0, false, sweep, stroke, false);
} else {
ctx.LineTo(bl, stroke, false);
}
}
// bottom side
ctx.LineTo(new Point(x1 - BR, y1), stroke, false);
// bottom-right corner
if (BR > 0) {
var br = new Point(x1, y1 - BR);
if (round) {
ctx.ArcTo(br, new Size(BR, BR), 0, false, sweep, stroke, false);
} else {
ctx.LineTo(br, stroke, false);
}
}
// right side
ctx.LineTo(new Point(x1, y0 + TR), stroke, false);
// top-right corner
if (TR > 0) {
var tr = new Point(x1 - TR, y0);
if (round) {
ctx.ArcTo(tr, new Size(TR, TR), 0, false, sweep, stroke, false);
} else {
ctx.LineTo(tr, stroke, false);
}
}
// top side and top-left corner
if (TL > 0) {
ctx.LineTo(new Point(x0 + TL, y0), stroke, false);
if (round) {
ctx.ArcTo(new Point(x0, y0 + TL), new Size(TL, TL), 0, false, sweep, stroke, false);
}
}
}
示例12: InternalDrawArrowGeometry
private void InternalDrawArrowGeometry(StreamGeometryContext context)
{
double theta;
if (this.CurveDirection == CurveDirection.Concave)
theta = Math.Atan2(Y1 - Y2, X1 - X2) + (Math.PI / 10);
else
theta = Math.Atan2(Y1 - Y2, X1 - X2) - (Math.PI / 10);
double sint = Math.Sin(theta);
double cost = Math.Cos(theta);
Point pt1 = new Point(X1, this.Y1);
Point pt2 = new Point(X2, this.Y2);
Point pt3 = new Point(
X2 + (HeadWidth * cost - HeadHeight * sint),
Y2 + (HeadWidth * sint + HeadHeight * cost));
Point pt4 = new Point(
X2 + (HeadWidth * cost + HeadHeight * sint),
Y2 - (HeadHeight * cost - HeadWidth * sint));
double ellipseSize = Math.Max(Math.Abs(X1 - X2), Math.Abs(Y1 - Y2)) * 1.7;
context.BeginFigure(pt1, true, false);
if (this.CurveDirection == CurveDirection.Concave)
context.ArcTo(pt2, new Size(ellipseSize, ellipseSize), 45, false, SweepDirection.Clockwise, true, true);
else
context.ArcTo(pt2, new Size(ellipseSize, ellipseSize), 45, false, SweepDirection.Counterclockwise, true, true);
//context.LineTo(pt2, true, true);
context.LineTo(pt3, true, true);
context.LineTo(pt2, true, true);
context.LineTo(pt4, true, true);
context.LineTo(pt2, true, true);
}
示例13: InternalDrawArrowGeometry
private void InternalDrawArrowGeometry(StreamGeometryContext context)
{
Point pt1, pt2, pt3, pt4;
if (ConnectionArrowType == ConnectionArrowType.Normal)
{
var theta = Math.Atan2(Y1 - Y2, X1 - X2);
var sint = Math.Sin(theta);
var cost = Math.Cos(theta);
switch (ViewType)
{
case 0: // прямая в центр
pt1 = new Point(X1, Y1);
pt2 = new Point(X2, Y2);
pt3 = new Point(
X2 + (HeadWidth * cost - HeadHeight * sint),
Y2 + (HeadWidth * sint + HeadHeight * cost));
pt4 = new Point(
X2 + (HeadWidth * cost + HeadHeight * sint),
Y2 - (HeadHeight * cost - HeadWidth * sint));
context.BeginFigure(pt1, true, false);
context.LineTo(pt2, true, true);
context.LineTo(pt3, true, true);
context.LineTo(pt2, true, true);
context.LineTo(pt4, true, true);
break;
case 1: // безье (слабое) в центр
pt1 = new Point(X1, Y1);
pt2 = new Point(X2, Y2);
var ptTemp1 = new Point(
X1 - (X1 - X2) / 2,
Y1 - (Y1 - Y2) / 3);
var ptTemp2 = new Point(
X1 - (X1 - X2) / 4 * 3,
Y1 - (Y1 - Y2) / 3 * 2);
pt3 = new Point(
X2 + (HeadWidth * cost - HeadHeight * sint),
Y2 + (HeadWidth * sint + HeadHeight * cost));
pt4 = new Point(
X2 + (HeadWidth * cost + HeadHeight * sint),
Y2 - (HeadHeight * cost - HeadWidth * sint));
context.BeginFigure(pt1, true, false);
context.BezierTo(ptTemp1, ptTemp2, pt2, true, true);
context.LineTo(pt3, true, true);
context.LineTo(pt2, true, true);
context.LineTo(pt4, true, true);
break;
case 2: // к ближайшему краю
var startPoint = GetBoundPoint(false);
X1 = startPoint.X;
Y1 = startPoint.Y;
var endPoint = GetBoundPoint(true);
X2 = endPoint.X;
Y2 = endPoint.Y;
pt3 = new Point(
X2 + (HeadWidth * cost - HeadHeight * sint),
Y2 + (HeadWidth * sint + HeadHeight * cost));
pt4 = new Point(
X2 + (HeadWidth * cost + HeadHeight * sint),
Y2 - (HeadHeight * cost - HeadWidth * sint));
context.BeginFigure(startPoint, true, false);
context.LineTo(endPoint, true, false);
context.LineTo(pt3, true, true);
context.LineTo(endPoint, true, true);
context.LineTo(pt4, true, true);
break;
}
}
else if (ConnectionArrowType == ConnectionArrowType.Loopback)
{
pt1 = new Point(FromItem.Position.X - 5, FromItem.Position.Y + 83);
pt2 = new Point(pt1.X + 10, pt1.Y - 10);
pt3 = new Point(pt2.X - 4, pt2.Y + 9);
pt4 = new Point(pt2.X - 6, pt2.Y + 16);
context.BeginFigure(pt1, true, false);
context.ArcTo(pt2, new Size(6, 6), 125, true, SweepDirection.Clockwise, true, true);
context.ArcTo(pt1, new Size(6, 6), 125, true, SweepDirection.Clockwise, true, true);
context.LineTo(pt3, true, true);
context.LineTo(pt1, true, true);
context.LineTo(pt4, true, true);
}
else
{
pt1 = new Point(X1 + 20, Y1 - 25);
//.........这里部分代码省略.........
示例14: AddArrow
void AddArrow(Edge drawingEdge, StreamGeometryContext context, Point start, Point end, double lineWidthOfAttachedNode)
{
Point dir = end - start;
double dl = dir.Length;
double scaling = (dl<12? 1 : 12 / dl) / _scale;
Point new_start = end - (end - start) * scaling;
//take into account the widths
double delta = Math.Min(dl / 2, drawingEdge.Attr.LineWidth + lineWidthOfAttachedNode / 2);
//dir *= (dl - delta) / dl;
end = start + dir;
dir = dir.Rotate(Math.PI / 2);
Point s = dir * HalfArrowAngleTan * scaling;
context.BeginFigure(CommonX.WpfPoint(start), true, true);
context.LineTo(CommonX.WpfPoint(new_start), true, true);
if (_category == "References")
{
double r = dl * scaling / 2;
context.ArcTo(CommonX.WpfPoint(end), new Size(r, r), 0, true, SweepDirection.Clockwise, true, true);
context.ArcTo(CommonX.WpfPoint(new_start), new Size(r, r), 0, true, SweepDirection.Clockwise, true, true);
}
else
{
context.LineTo(CommonX.WpfPoint(new_start + s), true, true);
context.LineTo(CommonX.WpfPoint(end), true, true);
context.LineTo(CommonX.WpfPoint(new_start - s), true, true);
context.LineTo(CommonX.WpfPoint(new_start), true, true);
}
}
示例15: method_18
private void method_18(StreamGeometryContext streamGeometryContext_0)
{
Point point = new Point(this.method_10(), this.method_12());
Point point2 = Utils.ComputeCartesianCoordinate(this.method_8(), this.method_4());
point2.Offset(this.method_10(), this.method_12());
Point point3 = Utils.ComputeCartesianCoordinate(this.method_8() + this.method_6(), this.method_4());
point3.Offset(this.method_10(), this.method_12());
Point point4 = Utils.ComputeCartesianCoordinate(this.method_8(), this.method_0());
point4.Offset(this.method_10(), this.method_12());
Point point5 = Utils.ComputeCartesianCoordinate(this.method_8() + this.method_6(), this.method_0());
point5.Offset(this.method_10(), this.method_12());
bool isLargeArc = this.method_6() > 180.0;
if (this.method_2() > 0.0)
{
Point point6 = Utils.ComputeCartesianCoordinate(this.method_8() + this.method_6() / 2.0, this.method_2());
point2.Offset(point6.X, point6.Y);
point3.Offset(point6.X, point6.Y);
point4.Offset(point6.X, point6.Y);
point5.Offset(point6.X, point6.Y);
}
Size size = new Size(this.method_0(), this.method_0());
Size size2 = new Size(this.method_4(), this.method_4());
streamGeometryContext_0.BeginFigure(point2, true, true);
streamGeometryContext_0.LineTo(point4, true, true);
streamGeometryContext_0.ArcTo(point5, size, 0.0, isLargeArc, SweepDirection.Clockwise, true, true);
streamGeometryContext_0.LineTo(point3, true, true);
streamGeometryContext_0.ArcTo(point2, size2, 0.0, isLargeArc, SweepDirection.Counterclockwise, true, true);
}