当前位置: 首页>>代码示例>>C#>>正文


C# CornerRadius.IsUniform方法代码示例

本文整理汇总了C#中System.Windows.CornerRadius.IsUniform方法的典型用法代码示例。如果您正苦于以下问题:C# CornerRadius.IsUniform方法的具体用法?C# CornerRadius.IsUniform怎么用?C# CornerRadius.IsUniform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.CornerRadius的用法示例。


在下文中一共展示了CornerRadius.IsUniform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawRectangle

      /// <summary>See <c>WpfExtensions</c> for details.</summary>
      public static void DrawRectangle(DrawingContext dc, Rect rect, Paint paint, CornerRadius corners, CornerStyle cornerStyle, BorderSide borderSide, bool snapToPixel) {
         // get brush and stroke resources
         if (paint == null) return;
         var fill = paint.Fill;
         var strokes = paint.GetStrokePens().ToArray();
         var hasFill = (fill != null);
         var hasStroke = (strokes.Length > 0 && borderSide != BorderSide.None);
         if (!hasFill && !hasStroke) return;

         // compute the drawing rectangle with offset for pixel snapping 
         // (assumptions: the box itself is pixel snapped, all strokes have same thickness, and the thickness is a whole number)
         var halfThickness = Math.Round(hasStroke ? strokes[0].Thickness : 0.0) / 2;
         if (snapToPixel && hasStroke) {
            rect = new Rect(rect.X + halfThickness, rect.Y + halfThickness, (rect.Width - 2 * halfThickness).Max(0), (rect.Height - 2 * halfThickness).Max(0));
         }

         // select drawing function based on the corners complexity 
         DrawingFunction fillFunc = null;
         if (corners.IsZero()) {
            fillFunc = _drawSimpleRectangle;
         } else if (corners.IsUniform()) {
            fillFunc = _drawRoundedRectangle;
         } else {
            fillFunc = _drawComplexRectangle;
         }

         // draw the border 
         if (hasStroke) {
            if (paint.IsA<QuadPaint>()) {
               rect = _drawSide(dc, rect, null, strokes[0], corners, cornerStyle, BorderSide.Left);
               rect = _drawSide(dc, rect, null, strokes[1], corners, cornerStyle, BorderSide.Top);
               rect = _drawSide(dc, rect, null, strokes[2], corners, cornerStyle, BorderSide.Right);
               rect = _drawSide(dc, rect, null, strokes[3], corners, cornerStyle, BorderSide.Bottom);
               corners = _inflateCorners(corners, strokes[3]);
            } else {
               var strokeFunc = (borderSide == BorderSide.All ? fillFunc : _drawSide);
               foreach (var stroke in strokes) {
                  rect = strokeFunc(dc, rect, null, stroke, corners, cornerStyle, borderSide);
                  corners = _inflateCorners(corners, stroke);
               }
            }
         }

         // draw the background
         if (hasFill) {
            if (snapToPixel) {
               rect = _deflateRect(rect, -halfThickness);
            }
            if (paint.FillMode == BrushMappingMode.Absolute) {
               fill = _mapAbsoluteFill(fill, rect);
            }
            fillFunc(dc, rect, fill, null, corners, cornerStyle, borderSide);
         }

      }
开发者ID:borkaborka,项目名称:gmit,代码行数:56,代码来源:DrawingUtilities.cs


注:本文中的System.Windows.CornerRadius.IsUniform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。