當前位置: 首頁>>代碼示例>>C#>>正文


C# DrawingContext.DrawQuarterCicle方法代碼示例

本文整理匯總了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);
        }
開發者ID:hgbink,項目名稱:OpenGoldenRuler,代碼行數:63,代碼來源:GoldenSpiral.cs


注:本文中的System.Windows.Media.DrawingContext.DrawQuarterCicle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。