public static CornerRadiusExt AdjustRadius(CornerRadius r, Thickness th, double w, double h) { CornerRadiusExt radius = new CornerRadiusExt(); double lside = h - th.Top - th.Bottom; if (lside < r.TopLeft + r.BottomLeft) { radius.TopLeftLeft = lside * r.TopLeft / (r.TopLeft + r.BottomLeft + double.Epsilon); radius.BottomLeftLeft = lside * r.BottomLeft / (r.TopLeft + r.BottomLeft + double.Epsilon); } else { radius.TopLeftLeft = r.TopLeft; radius.BottomLeftLeft = r.BottomLeft; } double rside = h - th.Top - th.Bottom; if (rside < r.TopRight + r.BottomRight) { radius.TopRightRight = rside * r.TopRight / (r.TopRight + r.BottomRight + double.Epsilon); radius.BottomRightRight = rside * r.BottomRight / (r.TopRight + r.BottomRight + double.Epsilon); } else { radius.TopRightRight = r.TopRight; radius.BottomRightRight = r.BottomRight; } double tside = w - th.Left - th.Right; if (tside < r.TopLeft + r.TopRight) { radius.TopLeftTop = tside * r.TopLeft / (r.TopLeft + r.TopRight + double.Epsilon); radius.TopRightTop = tside * r.TopRight / (r.TopLeft + r.TopRight + double.Epsilon); } else { radius.TopLeftTop = r.TopLeft; radius.TopRightTop = r.TopRight; } double bside = w - th.Left - th.Right; if (bside < r.BottomRight + r.BottomLeft) { radius.BottomLeftBottom = bside * r.BottomLeft / (r.BottomLeft + r.BottomRight + double.Epsilon); radius.BottomRightBottom = bside * r.BottomRight / (r.BottomLeft + r.BottomRight + double.Epsilon); } else { radius.BottomLeftBottom = r.BottomLeft; radius.BottomRightBottom = r.BottomRight; } return(radius); }
public override bool Equals(object obj) { CornerRadiusExt other = obj as CornerRadiusExt; if (other == null) { return(false); } bool equals = TopLeftLeft == other.TopLeftLeft && TopLeftTop == other.TopLeftTop && TopRightTop == other.TopRightTop && TopRightRight == other.TopRightRight && BottomRightRight == other.BottomRightRight && BottomRightBottom == other.BottomRightBottom && BottomLeftBottom == other.BottomLeftBottom && BottomLeftLeft == other.BottomLeftLeft; return(equals); }
private static void DefineRectangle(StreamGeometryContext context, Thickness th, CornerRadiusExt r, double w, double h) { context.BeginFigure(new Point(th.Left, th.Top + r.TopLeftLeft), true, true); context.QuadraticBezierTo(new Point(th.Left, th.Top), new Point(th.Left + r.TopLeftTop, th.Top), false, false); context.LineTo(new Point(w - th.Right - r.TopRightTop, th.Top), false, false); context.QuadraticBezierTo(new Point(w - th.Right, th.Top), new Point(w - th.Right, th.Top + r.TopRightRight), false, false); context.LineTo(new Point(w - th.Right, h - th.Bottom - r.BottomRightRight), false, false); context.QuadraticBezierTo(new Point(w - th.Right, h - th.Bottom), new Point(w - th.Right - r.BottomRightBottom, h - th.Bottom), false, false); context.LineTo(new Point(th.Left + r.BottomLeftBottom, h - th.Bottom), false, false); context.QuadraticBezierTo(new Point(th.Left, h - th.Bottom), new Point(th.Left, h - th.Bottom - r.BottomLeftLeft), false, false); }