本文整理汇总了C#中System.Windows.Media.ArcSegment类的典型用法代码示例。如果您正苦于以下问题:C# ArcSegment类的具体用法?C# ArcSegment怎么用?C# ArcSegment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArcSegment类属于System.Windows.Media命名空间,在下文中一共展示了ArcSegment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
m_StartSegment = Substitute.For <ITurnCircleArcSegment>();
m_MiddleSegment = Substitute.For <ITurnCircleArcSegment>();
m_EndSegment = Substitute.For <ITurnCircleArcSegment>();
m_Path = Substitute.For <IPath>();
var segments = new List <IPolylineSegment>
{
m_StartSegment,
m_MiddleSegment,
m_EndSegment
};
m_Path.Segments.Returns(segments);
m_ArcSegmentOne = new ArcSegment(new Point(10.0,
10.0),
new Size(10.0,
10.0),
45.0,
false,
SweepDirection.Clockwise,
false);
m_LineSegment = new LineSegment(new Point(20.0,
20.0),
false);
m_ArcSegmentTwo = new ArcSegment(new Point(30.0,
30.0),
new Size(30.0,
30.0),
90.0,
false,
SweepDirection.Counterclockwise,
false);
m_ArcSegmentThree = new ArcSegment(new Point(40.0,
40.0),
new Size(40.0,
40.0),
135.0,
false,
SweepDirection.Counterclockwise,
false);
m_Point = new Point(10.0,
10.0);
m_Helper = Substitute.For <IPathSegmentHelper>();
m_Helper.SegmentToLineSegment(Line.Unknown).ReturnsForAnyArgs(m_LineSegment);
m_Helper.SegmentToArcSegment(TurnCircleArcSegment.Unknown).ReturnsForAnyArgs(m_ArcSegmentOne,
m_ArcSegmentTwo,
m_ArcSegmentThree);
m_Helper.PointRelativeToOrigin(null).ReturnsForAnyArgs(m_Point);
m_Converter = new RacetrackPathUTurnToFiguresConverter(m_Helper);
}
示例2: WpfArc
public WpfArc(IArc arc)
{
_xarc = arc;
_fillBrush = new SolidColorBrush(_xarc.Fill.ToNativeColor());
_fillBrush.Freeze();
_strokeBrush = new SolidColorBrush(_xarc.Stroke.ToNativeColor());
_strokeBrush.Freeze();
_path = new Path();
_path.Tag = this;
_path.Fill = _fillBrush;
_path.Stroke = _strokeBrush;
_path.StrokeThickness = arc.StrokeThickness;
_pg = new PathGeometry();
_pf = new PathFigure();
_pf.IsFilled = arc.IsFilled;
_pf.IsClosed = arc.IsClosed;
_start = new Point();
_as = new ArcSegment();
SetArcSegment(_as, arc, out _start);
_pf.StartPoint = _start;
_pf.Segments.Add(_as);
_pg.Figures.Add(_pf);
_path.Data = _pg;
Native = _path;
}
示例3: CreateArcShape
public static Tuple<Path, PathFigure, ArcSegment> CreateArcShape()
{
var arcSegment = new ArcSegment()
{
SweepDirection = SweepDirection.Counterclockwise,
RotationAngle = 0
};
var figure = new PathFigure()
{
IsClosed = false,
IsFilled = false,
Segments = new PathSegmentCollection()
{
arcSegment
}
};
var path = new Path()
{
Data = new PathGeometry()
{
Figures = new PathFigureCollection()
{
figure
}
},
Stroke = new SolidColorBrush(Colors.Black),
StrokeThickness = 1
};
return Tuple.Create(path, figure, arcSegment);
}
示例4: AddCircularArcGraph
private void AddCircularArcGraph(Point startPoint, Point endPoint, Size size)
{
PathFigure pf = new PathFigure();
pf.StartPoint = new Point(startPoint.X, startPoint.Y);
ArcSegment arcSegment = new ArcSegment();
arcSegment.Point = new Point(endPoint.X, endPoint.Y);
arcSegment.Size = size;
arcSegment.SweepDirection = SweepDirection.Counterclockwise;
PathSegmentCollection psc = new PathSegmentCollection();
psc.Add(arcSegment);
pf.Segments = psc;
PathFigureCollection pfc = new PathFigureCollection();
pfc.Add(pf);
PathGeometry pg = new PathGeometry();
pg.Figures = pfc;
var path = new Path();
path.Stroke = Brushes.Black;
path.StrokeThickness = 1;
path.Data = pg;
path.Fill = Brushes.Orange;
path.Stretch = Stretch.Fill;
var viewportPanel = new ViewportHostPanel();
ViewportPanel.SetViewportBounds(path, new DataRect(0, 0, 50, 50));
viewportPanel.Children.Add(path);
plotter.Children.Add(viewportPanel);
}
示例5: AddArc
public PathFigure AddArc(int start, int end)
{
int horizontalPostion = 100;
var startPoint = new Point(horizontalPostion, start);
var endPoint = new Point(horizontalPostion, end);
PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = startPoint;
ArcSegment arcSeg = new ArcSegment();
arcSeg.Point = endPoint;
arcSeg.Size = new Size(25, 25);
arcSeg.IsLargeArc = true;
arcSeg.SweepDirection = SweepDirection.Clockwise;
arcSeg.RotationAngle = 90;
var arrowhead = new Polygon();
arrowhead.Stroke = Brushes.Black;
arrowhead.StrokeThickness = 2;
arrowhead.Points.Add(new Point(endPoint.X - 4, endPoint.Y));
arrowhead.Points.Add(new Point(endPoint.X + 4, endPoint.Y + 3));
arrowhead.Points.Add(new Point(endPoint.X + 4, endPoint.Y - 3));
arrowhead.Fill = Brushes.Black;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(arcSeg);
pathFigure.Segments = myPathSegmentCollection;
_pathFigureCollection.Add(pathFigure);
_root.Children.Add(arrowhead);
return pathFigure;
}
示例6: RenderArc
private void RenderArc(double Angle, Path pathRoot, PathFigure pathFigure, ArcSegment arcSegment)
{
Point startPoint = new Point(Radius, 0);
Point endPoint = ComputeCartesianCoordinate(Angle, Radius);
endPoint.X += Radius;
endPoint.Y += Radius;
pathRoot.Width = Radius * 2 + StrokeThickness;
pathRoot.Height = Radius * 2 + StrokeThickness;
pathRoot.Margin = new Thickness(StrokeThickness, StrokeThickness, 0, 0);
bool largeArc = Angle > 180.0;
Size outerArcSize = new Size(Radius, Radius);
pathFigure.StartPoint = startPoint;
if (startPoint.X == Math.Round(endPoint.X) && startPoint.Y == Math.Round(endPoint.Y))
{
endPoint.X -= 0.01;
}
arcSegment.Point = endPoint;
arcSegment.Size = outerArcSize;
arcSegment.IsLargeArc = largeArc;
}
示例7: Arc
public Arc(Path path, LineSegment lineSegment, ArcSegment arcSegment, Point zeroPos, Color color)
{
Path = path;
LineSegment = lineSegment;
ArcSegment = arcSegment;
ZeroPos = zeroPos;
Path.Stroke = ToBrush(color);
Path.Fill = ToBrush(color);
}
示例8: DefineGeometry
private void DefineGeometry()
{
PointCollection points = Points;
if (points == null)
{
_geometry = Geometry.Empty;
return;
}
PathFigure figure = new PathFigure();
if (points.Count > 0)
{
// start point
figure.StartPoint = points[0];
if (points.Count > 1)
{
// points between
double desiredRadius = Radius;
for (int i = 1; i < (points.Count - 1); i++)
{
// adjust radius if points are too close
Vector v1 = points[i] - points[i - 1];
Vector v2 = points[i + 1] - points[i];
double radius = Math.Min(Math.Min(v1.Length, v2.Length) / 2, desiredRadius);
// draw the line, and stop before the next point
double len = v1.Length;
v1.Normalize();
v1 *= (len - radius);
LineSegment line = new LineSegment(points[i - 1] + v1, true);
figure.Segments.Add(line);
// draw the arc to the next point
v2.Normalize();
v2 *= radius;
SweepDirection direction = (Vector.AngleBetween(v1, v2) > 0) ? SweepDirection.Clockwise : SweepDirection.Counterclockwise;
ArcSegment arc = new ArcSegment(points[i] + v2, new Size(radius, radius), 0, false, direction, true);
figure.Segments.Add(arc);
}
// last point
figure.Segments.Add(new LineSegment(points[points.Count - 1], true));
}
}
PathGeometry geometry = new PathGeometry();
geometry.Figures.Add(figure);
geometry.FillRule = FillRule;
if (geometry.Bounds == Rect.Empty)
{
_geometry = Geometry.Empty;
}
else
{
_geometry = geometry;
}
}
示例9: switch
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.arc = ((System.Windows.Media.ArcSegment)(target));
return;
}
this._contentLoaded = true;
}
示例10: CreateArcSegment
public ArcSegment CreateArcSegment(Point point,
Size size,
SweepDirection sweepDirection,
bool isLargeArc = false)
{
const double rotationAngle = 0.0;
const bool isStroked = true;
var arcSegment = new ArcSegment(point,
size,
rotationAngle,
isLargeArc,
sweepDirection,
isStroked);
return arcSegment;
}
示例11: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
this.Root = base.GetTemplateChild("Root") as Border;
this.ArrowRow = base.GetTemplateChild("ArrowRow") as RowDefinition;
this.ToolTipPathFigure = base.GetTemplateChild("ToolTipPathFigure") as PathFigure;
this.BottomCenterLeft = base.GetTemplateChild("BottomCenterLeft") as LineSegment;
this.BottomLeftCorner1 = base.GetTemplateChild("BottomLeftCorner1") as LineSegment;
this.BottomLeftCorner2 = base.GetTemplateChild("BottomLeftCorner2") as ArcSegment;
this.TopLeftCorner1 = base.GetTemplateChild("TopLeftCorner1") as LineSegment;
this.TopLeftCorner2 = base.GetTemplateChild("TopLeftCorner2") as ArcSegment;
this.TopRightCorner1 = base.GetTemplateChild("TopRightCorner1") as LineSegment;
this.TopRightCorner2 = base.GetTemplateChild("TopRightCorner2") as ArcSegment;
this.BottomRightCorner1 = base.GetTemplateChild("BottomRightCorner1") as LineSegment;
this.BottomRightCorner2 = base.GetTemplateChild("BottomRightCorner2") as ArcSegment;
this.BottomCenterRight = base.GetTemplateChild("BottomCenterRight") as LineSegment;
}
示例12: ClippedGrid_SizeChanged
void ClippedGrid_SizeChanged(object sender, SizeChangedEventArgs e)
{
double w = this.ActualWidth;
double h = this.ActualHeight;
PathFigure figure = new PathFigure();
figure.StartPoint = new Point(0, h);
LineSegment left = new LineSegment();
left.Point = new Point(0, _arcSizeY + _offsetY);
figure.Segments.Add(left);
ArcSegment topLeftRounding = new ArcSegment();
topLeftRounding.Size = new Size(_arcSizeX, _arcSizeY);
topLeftRounding.RotationAngle = 0;
topLeftRounding.IsLargeArc = false;
topLeftRounding.SweepDirection = SweepDirection.Clockwise;
topLeftRounding.Point = new Point(_arcSizeX, _offsetY);
figure.Segments.Add(topLeftRounding);
LineSegment top = new LineSegment();
top.Point = new Point(w - _arcSizeX, _offsetY);
figure.Segments.Add(top);
ArcSegment topRightRounding = new ArcSegment();
topRightRounding.Size = new Size(_arcSizeX, _arcSizeY);
topRightRounding.RotationAngle = 0;
topRightRounding.IsLargeArc = false;
topRightRounding.SweepDirection = SweepDirection.Clockwise;
topRightRounding.Point = new Point(w, _arcSizeY + _offsetY);
figure.Segments.Add(topRightRounding);
LineSegment right = new LineSegment();
right.Point = new Point(w, h);
figure.Segments.Add(right);
LineSegment bottom = new LineSegment();
bottom.Point = new Point(0, h);
figure.Segments.Add(bottom);
PathGeometry clip = new PathGeometry();
clip.Figures.Add(figure);
this.Clip = clip;
}
示例13: Draw
public Path Draw(double X, double Y)
{
Path path = new Path();
Canvas.SetTop(path, Y);
Canvas.SetLeft(path, X);
//Make Geometry
_arcSeg = new ArcSegment(new Point(X+800, Y+800), new Size(1000, 2000), 0.0, true, SweepDirection.Clockwise, true);
PathSegmentCollection psc = new PathSegmentCollection(){_arcSeg};
_pathFig = new PathFigure(new Point(X, Y), psc, false);
PathFigureCollection pfc = new PathFigureCollection(){_pathFig};
PathGeometry pgeo = new PathGeometry(pfc);
path.Data = pgeo;
path.StrokeThickness = 200;
path.Fill = Brushes.White;
path.Stroke = Brushes.Black;
return path;
}
示例14: CalculateArcInfo
/// <summary>
/// Calculates the midpoint of the arc passed as a parameter, as well as whether the arc is small.
/// </summary>
/// <param name="center">The center of the pie chart.</param>
/// <param name="startPoint">The start point of the arc segment.</param>
/// <param name="arcSegment">The arc of the pie wedge itself.</param>
/// <param name="arcMidpoint">he midpoint of the arc in the pie wedge.</param>
/// <param name="isArcSmall">True if the arc is small, false otherwise.</param>
private static void CalculateArcInfo(Point center, Point startPoint, ArcSegment arcSegment, out Point arcMidpoint, out bool isArcSmall)
{
// Note: we assume a valid arcSegment with equal radii.
Debug.Assert(arcSegment != null);
Debug.Assert(arcSegment.Size.Width == arcSegment.Size.Height);
Point endPoint = arcSegment.Point;
Point chordMidpoint = new Point(0.5 * (startPoint.X + endPoint.X), 0.5 * (startPoint.Y + endPoint.Y));
Vector chordDirection = endPoint - startPoint;
double chordLength = chordDirection.Length;
double radius = arcSegment.Size.Width;
isArcSmall = chordLength < DistanceSmallArc;
// If the chord length is less than the distance tolerance, just use the chord midpoint
// or the point on the opposite side of the circle as appropriate.
if (chordLength < DistanceTolerance)
{
arcMidpoint = arcSegment.IsLargeArc ? center - (chordMidpoint - center) : chordMidpoint;
}
else
{
chordDirection /= chordLength;
Vector radialDirection = new Vector(-chordDirection.Y, chordDirection.X);
double halfChordLength = 0.5 * chordLength;
double radialOffset;
if (radius >= halfChordLength)
{
double sectorRadius = Math.Sqrt(radius * radius - halfChordLength * halfChordLength);
radialOffset = -radius + (arcSegment.IsLargeArc ? -sectorRadius : sectorRadius);
}
else
{
radialOffset = -halfChordLength;
}
if (arcSegment.SweepDirection == SweepDirection.Counterclockwise)
{
radialOffset = -radialOffset;
}
arcMidpoint = chordMidpoint + radialOffset * radialDirection;
}
}
示例15: SurfaceWindow1
/// <summary>
/// Default constructor.
/// </summary>
public SurfaceWindow1()
{
InitializeComponent();
Path myShape = new Path();
myShape.StrokeThickness = 3.0;
myShape.Fill = System.Windows.Media.Brushes.Wheat;
myShape.Stroke = System.Windows.Media.Brushes.BlueViolet;
PathGeometry myGeometry = new PathGeometry();
PathFigure figure = new PathFigure();
//Figure draws the segments upside down (this the coordinate system in negatives to draw objects)
Double width = 200;
Double height = 100;
figure.SetValue(PathFigure.StartPointProperty, new Point(height, 0));
ArcSegment arc = new ArcSegment(new Point(height, height), new Size(height / 2, height / 2), 0.0, true, SweepDirection.Counterclockwise, true);
//Note: LineSegments take end point as the constructor, Their Start point will be the end point of previous segment(the order you added into path figure(Source API))
LineSegment arcVertical1 = new LineSegment(new Point(height, height - 25), true);
LineSegment horizontal1 = new LineSegment(new Point(height + 275, height - 25), true);
LineSegment vertical = new LineSegment(new Point(height + 275, 25), true);
LineSegment horizontal2 = new LineSegment(new Point(height, 25), true);
LineSegment arcVertical2 = new LineSegment(new Point(height, 0), true);
figure.Segments.Add(arc);
figure.Segments.Add(arcVertical1);
figure.Segments.Add(horizontal1);
figure.Segments.Add(vertical);
figure.Segments.Add(horizontal2);
figure.Segments.Add(arcVertical2);
myGeometry.Figures.Add(figure);
myShape.Data = myGeometry;
myCanvas.Children.Add(myShape);
//****************************** Register for Stroke change events*************************
// This is how we can get the currently being drawn stroke information
inkCanvas.Strokes.StrokesChanged += new StrokeCollectionChangedEventHandler(canvasStrokesChanged);
// Add handlers for window availability events
AddWindowAvailabilityHandlers();
}