本文整理汇总了C#中System.Windows.Media.DrawingContext.DrawQuarterCicle方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext.DrawQuarterCicle方法的具体用法?C# DrawingContext.DrawQuarterCicle怎么用?C# DrawingContext.DrawQuarterCicle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.DrawingContext
的用法示例。
在下文中一共展示了DrawingContext.DrawQuarterCicle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateGoldenSquares
private void GenerateGoldenSquares(Rect ParentRect, DrawingContext drawingContext, int maxLevel, int currentAngle = 0)
{
Pen BlackPen;
if(maxLevel<=0) return;
int absCurrentAngle = currentAngle%360;
Point startPoint, drawPoint;
double a = ParentRect.GetLongerLine(), a1 = a/GOLDEN_RATIO;
Size newRectSize, newSquareSize;
if (absCurrentAngle == 0)
{
startPoint = new Point(ParentRect.X + a1, ParentRect.Y);
drawPoint = new Point(ParentRect.X, ParentRect.Y);
newRectSize = new Size(a-a1, a1);
newSquareSize = new Size(a1, a1);
}
else if (absCurrentAngle == 90)
{
startPoint = new Point(ParentRect.X, ParentRect.Y + a1);
drawPoint = new Point(ParentRect.X, ParentRect.Y);
newRectSize = new Size(a1, a - a1);
newSquareSize = new Size(a1, a1);
}
else if (absCurrentAngle == 180)
{
startPoint = new Point(ParentRect.X, ParentRect.Y);
drawPoint = new Point(ParentRect.X + a - a1, ParentRect.Y);
newRectSize = new Size(a - a1, a1);
newSquareSize = new Size(a1, a1);
}
else if (absCurrentAngle == 270)
{
startPoint = new Point(ParentRect.X, ParentRect.Y);
drawPoint = new Point(ParentRect.X, ParentRect.Y + a - a1);
newRectSize = new Size(a1, a - a1);
newSquareSize = new Size(a1, a1);
}
else
{
throw new NotImplementedException();
}
BlackPen = new Pen(new SolidColorBrush(GoldenUtils.ColorStack[maxLevel % GoldenUtils.ColorStack.Count]), 1.5);
drawingContext.DrawRectangle(Brushes.Transparent, BlackPen, new Rect(startPoint, newRectSize));
drawingContext.DrawQuarterCicle(RedPen, Brushes.Transparent, new Rect(drawPoint, newSquareSize), absCurrentAngle + 180, 90);
Rect square = new Rect(drawPoint, newSquareSize);
drawingContext.DrawRectangle(Brushes.Transparent, BlackPen, square);
FormattedText ft = new FormattedText(Math.Round(square.Size.Height, 3).ToString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Arial"), DipHelper.PtToDip(8), BlackPen.Brush);
if(ft.Height < square.Height) drawingContext.DrawText(ft, new Point(square.X + square.Height/2.8, square.Y + square.Height/2.2));
currentAngle += 90;
GenerateGoldenSquares(new Rect(startPoint, newRectSize), drawingContext, --maxLevel, currentAngle);
}