本文整理汇总了C#中System.Windows.Media.EllipseGeometry.GetOutlinedPathGeometry方法的典型用法代码示例。如果您正苦于以下问题:C# EllipseGeometry.GetOutlinedPathGeometry方法的具体用法?C# EllipseGeometry.GetOutlinedPathGeometry怎么用?C# EllipseGeometry.GetOutlinedPathGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.EllipseGeometry
的用法示例。
在下文中一共展示了EllipseGeometry.GetOutlinedPathGeometry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArcUpdate
public void ArcUpdate()
{
// 線の太さ
double thick = this.ViewModel.StrokeThickness;
// 入力値切捨て
double inputValue = Math.Floor(this.ViewModel.Percentage * 100.0);
// 角度の計算
double angle = (inputValue * 3.6);
if(angle < 0)
{
angle += 360;
}
if(angle > 360)
{
angle %= 360.0;
}
// 0-360を許容
if (0 < angle && angle < 360)
{
// 角度によってフラグを変える
this.ViewModel.IsLargeArcFlg = false;
if (angle >= 180)
{
// 180°を超える(180を含む)場合はフラグをtrue
this.ViewModel.IsLargeArcFlg = true;
}
}
// 角度と半径から座標を計算
double radius = (this.pathArc.Width / 2) - thick;
pathArc.StrokeThickness = thick;
pathCircleBackground.StrokeThickness = thick;
if (angle != 0 && angle != 360)
{
angle -= 90;
double radian = Math.PI * angle / 180.0;
double x = radius * Math.Cos(radian);
double y = radius * Math.Sin(radian);
x = ToRoundDown(x, 3);
y = ToRoundDown(y, 3);
// 終点計算
double endPointX = radius + x + thick;
double endPointY = radius + y + thick;
// 図形生成
PathFigure pfArc = new PathFigure();
pfArc.StartPoint = new Point(100, thick); // 開始点
// セグメント生成
ArcSegment arc = new ArcSegment();
arc.Point = new Point(endPointX, endPointY); // 終点(計算値)
arc.Size = new Size(radius, radius); // 半径
arc.IsLargeArc = this.ViewModel.IsLargeArcFlg;
arc.SweepDirection = SweepDirection.Clockwise;
//arc.RotationAngle = Math.PI * -90.0 / 180.0;
// 図形入れ替え
pfArc.Segments.Clear();
pfArc.Segments.Add(arc);
this.pathGeometryArc.Figures.Clear();
this.pathGeometryArc.Figures.Add(pfArc);
// 図形生成(背景)
PathFigure pfCircle = new PathFigure();
pfCircle.StartPoint = new Point(100, thick); // 開始点
// セグメント生成
ArcSegment circle = new ArcSegment();
circle.Point = new Point(endPointX, endPointY); // 終点(計算値)
circle.Size = new Size(radius, radius); // 半径
circle.IsLargeArc = !this.ViewModel.IsLargeArcFlg;
circle.SweepDirection = SweepDirection.Counterclockwise;
// 図形入れ替え
pfCircle.Segments.Clear();
pfCircle.Segments.Add(circle);
this.pathGeometryCircle.Figures.Clear();
this.pathGeometryCircle.Figures.Add(pfCircle);
}
else
{
var center = new Point(this.pathArc.Width / 2, this.pathArc.Height / 2);
var circle = new EllipseGeometry(center, radius, radius);
var pathgeo = circle.GetOutlinedPathGeometry();
this.pathGeometryArc.Clear();
this.pathGeometryCircle.Clear();
if (angle == 0)
this.pathGeometryCircle.Figures = pathgeo.Figures;
else
//.........这里部分代码省略.........
示例2: GetPosition
private Point GetPosition(double value, EllipseGeometry geometry)
{
var pathGeometry = geometry.GetOutlinedPathGeometry();
if (pathGeometry.Figures.Count == 0)
return geometry.Center;
var outherGeometry = new PathGeometry(new[] { pathGeometry.Figures[0] });
Point outherPoint, outherTangent;
outherGeometry.GetPointAtFractionLength(value, out outherPoint, out outherTangent);
return outherPoint;
}