public Comment(Node hostNode) { HostNode = hostNode; var scrollViewer = new ScrollViewer { HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled, VerticalScrollBarVisibility = ScrollBarVisibility.Visible, Height = 70, CanContentScroll = true }; var textBlock = new TextBlock { Background = Brushes.Transparent, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(5), FontSize = 12 }; Child = scrollViewer; CornerRadius = new CornerRadius(5); scrollViewer.Content = textBlock; var bindingTextToTextBlock = new Binding("Text") { Source = this, Mode = BindingMode.OneWay }; textBlock.SetBinding(TextBlock.TextProperty, bindingTextToTextBlock); hostNode.SpaceCanvas.Children.Add(this); }
/// <summary>Checks whether two nullable corner radii are close enough to be considered equal.</summary> /// <summary>Use this method instead of strict equality check to reduce the chance for floating-point errors.</summary> public static bool AlmostEquals(this CornerRadius? c1, CornerRadius? c2) { if (c1.HasValue && c2.HasValue) { return c1.Value.AlmostEquals(c2.Value); } else { return !c1.HasValue && !c2.HasValue; } }
static void CheckProperties (CornerRadius cr, double value) { Assert.AreEqual (value, cr.TopLeft, "TopLeft"); Assert.AreEqual (value, cr.TopRight, "TopRight"); Assert.AreEqual (value, cr.BottomRight, "BottomRight"); Assert.AreEqual (value, cr.BottomLeft, "BottomLeft"); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values.Length < 2) throw new ArgumentException(string.Format("not enough arguments, expected 2, but {0} present", values.Length)); Align align; Enum.TryParse(values[0].ToString(), out align); double val = 0.0; double.TryParse(values[1].ToString(), out val); CornerRadius radius = new CornerRadius(); if ((align & Align.TopRight) == Align.TopRight) { radius.TopRight = val; } if ((align & Align.TopLeft) == Align.TopLeft) { radius.TopLeft = val; } if ((align & Align.BottomRight) == Align.BottomRight) { radius.BottomRight = val; } if ((align & Align.BottomLeft) == Align.BottomLeft) { radius.BottomLeft = val; } return radius; }
public WidgetActionBarStyle() { BackgroundOpacity = 0.5; CornerRadius = new CornerRadius(4); BackgroundColor = Color.FromRgb(32, 32, 32); TextColor = Colors.WhiteSmoke; HorizontalAlignment = HorizontalAlignment.Center; VerticalAlignment = VerticalAlignment.Top; }
public void Border(CornerRadius CornerRadius, Color culoare, Thickness thickness, double Width, double Height) { myBorder.Width = Width; myBorder.Height = Height; myBorder.BorderThickness = thickness; myBorder.BorderBrush = new SolidColorBrush(culoare); myBorder.CornerRadius = CornerRadius; }
protected virtual void OnCornerRadiusChanged(CornerRadius oldValue, CornerRadius newValue) { //we always want the InnerBorderRadius to be one less than the CornerRadius CornerRadius newInnerCornerRadius = new CornerRadius(Math.Max(0, newValue.TopLeft - 1), Math.Max(0, newValue.TopRight - 1), Math.Max(0, newValue.BottomRight - 1), Math.Max(0, newValue.BottomLeft - 1)); InnerCornerRadius = newInnerCornerRadius; }
public override void ConfigureFromNode(System.Xml.Linq.XElement node) { base.ConfigureFromNode(node); Banner = XmlUtilities.GetTextFromAttribute(node, "banner"); BorderSize = XmlUtilities.ConvertFromAttributeUsingConverter( node, "borderSize", new ThicknessConverter(), new Thickness(0)); BorderColor = XmlUtilities.GetTextFromAttribute(node, "borderColor"); CornerRadius = XmlUtilities.ConvertFromAttributeUsingConverter( node, "cornerRadius", new CornerRadiusConverter(), new CornerRadius(0)); }
/// <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); } }
static WindowChrome() { Class6.yDnXvgqzyB5jw(); WindowChrome.WindowChromeProperty = DependencyProperty.RegisterAttached("WindowChrome", typeof(WindowChrome), typeof(WindowChrome), new PropertyMetadata(null, new PropertyChangedCallback(WindowChrome._OnChromeChanged))); WindowChrome.IsHitTestVisibleInChromeProperty = DependencyProperty.RegisterAttached("IsHitTestVisibleInChrome", typeof(bool), typeof(WindowChrome), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits)); WindowChrome.ResizeGripDirectionProperty = DependencyProperty.RegisterAttached("ResizeGripDirection", typeof(ResizeGripDirection), typeof(WindowChrome), new FrameworkPropertyMetadata((object)ResizeGripDirection.None, FrameworkPropertyMetadataOptions.Inherits)); WindowChrome.CaptionHeightProperty = DependencyProperty.Register("CaptionHeight", typeof(double), typeof(WindowChrome), new PropertyMetadata((object)0, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint()), (object value) => (double)value >= 0); Type type = typeof(Thickness); Type type1 = typeof(WindowChrome); Thickness thickness = new Thickness(); WindowChrome.ResizeBorderThicknessProperty = DependencyProperty.Register("ResizeBorderThickness", type, type1, new PropertyMetadata((object)thickness), (object value) => ((Thickness)value).IsNonNegative()); Type type2 = typeof(Thickness); Type type3 = typeof(WindowChrome); thickness = new Thickness(); WindowChrome.GlassFrameThicknessProperty = DependencyProperty.Register("GlassFrameThickness", type2, type3, new PropertyMetadata((object)thickness, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint(), (DependencyObject d, object o) => WindowChrome._CoerceGlassFrameThickness((Thickness)o))); WindowChrome.UseAeroCaptionButtonsProperty = DependencyProperty.Register("UseAeroCaptionButtons", typeof(bool), typeof(WindowChrome), new FrameworkPropertyMetadata(true)); WindowChrome.IgnoreTaskbarOnMaximizeProperty = DependencyProperty.Register("IgnoreTaskbarOnMaximize", typeof(bool), typeof(WindowChrome), new FrameworkPropertyMetadata(false, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint())); WindowChrome.UseNoneWindowStyleProperty = DependencyProperty.Register("UseNoneWindowStyle", typeof(bool), typeof(WindowChrome), new FrameworkPropertyMetadata(false, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint())); Type type4 = typeof(System.Windows.CornerRadius); Type type5 = typeof(WindowChrome); System.Windows.CornerRadius cornerRadiu = new System.Windows.CornerRadius(); WindowChrome.CornerRadiusProperty = DependencyProperty.Register("CornerRadius", type4, type5, new PropertyMetadata((object)cornerRadiu, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint()), (object value) => ((System.Windows.CornerRadius)value).IsValid()); WindowChrome.SacrificialEdgeProperty = DependencyProperty.Register("SacrificialEdge", typeof(Microsoft.Windows.Shell.SacrificialEdge), typeof(WindowChrome), new PropertyMetadata((object)Microsoft.Windows.Shell.SacrificialEdge.None, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint()), new ValidateValueCallback(WindowChrome._IsValidSacrificialEdge)); WindowChrome.SacrificialEdge_All = Microsoft.Windows.Shell.SacrificialEdge.Left | Microsoft.Windows.Shell.SacrificialEdge.Top | Microsoft.Windows.Shell.SacrificialEdge.Right | Microsoft.Windows.Shell.SacrificialEdge.Bottom | Microsoft.Windows.Shell.SacrificialEdge.Office; List <WindowChrome._SystemParameterBoundProperty> _SystemParameterBoundProperties = new List <WindowChrome._SystemParameterBoundProperty>(); WindowChrome._SystemParameterBoundProperty __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.CornerRadiusProperty, SystemParameterPropertyName = "WindowCornerRadius" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.CaptionHeightProperty, SystemParameterPropertyName = "WindowCaptionHeight" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.ResizeBorderThicknessProperty, SystemParameterPropertyName = "WindowResizeBorderThickness" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.GlassFrameThicknessProperty, SystemParameterPropertyName = "WindowNonClientFrameThickness" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); WindowChrome._BoundProperties = _SystemParameterBoundProperties; }
public void ShouldShareCornerRadiusValueWithBorder() { var radius1 = new CornerRadius(1, 2, 3, 4); model.CornerRadius = radius1; model.Border.CornerRadius.ShouldBe(radius1); var radius2 = new CornerRadius(9,8,7,6); model.Border.CornerRadius = radius2; model.CornerRadius.ShouldBe(radius2); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { double d = parameter != null ? double.Parse(parameter.ToString()) : -1; CornerRadius r = (CornerRadius)value; CornerRadius result = new CornerRadius( Math.Max(0, r.TopLeft + d), Math.Max(0, r.TopRight + d), Math.Max(0, r.BottomRight + d), Math.Max(0, r.BottomLeft + d)); return result; }
static WindowChrome() { WindowChrome.WindowChromeProperty = DependencyProperty.RegisterAttached("WindowChrome", typeof(WindowChrome), typeof(WindowChrome), new PropertyMetadata(null, new PropertyChangedCallback(WindowChrome._OnChromeChanged))); WindowChrome.IsHitTestVisibleInChromeProperty = DependencyProperty.RegisterAttached("IsHitTestVisibleInChrome", typeof(bool), typeof(WindowChrome), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits)); WindowChrome.CaptionHeightProperty = DependencyProperty.Register("CaptionHeight", typeof(double), typeof(WindowChrome), new PropertyMetadata((object)0, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint()), (object value) => (double)value >= 0); Type type = typeof(Thickness); Type type1 = typeof(WindowChrome); Thickness thickness = new Thickness(); WindowChrome.ResizeBorderThicknessProperty = DependencyProperty.Register("ResizeBorderThickness", type, type1, new PropertyMetadata((object)thickness), (object value) => Utility.IsThicknessNonNegative((Thickness)value)); Type type2 = typeof(Thickness); Type type3 = typeof(WindowChrome); thickness = new Thickness(); WindowChrome.GlassFrameThicknessProperty = DependencyProperty.Register("GlassFrameThickness", type2, type3, new PropertyMetadata((object)thickness, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint(), (DependencyObject d, object o) => WindowChrome._CoerceGlassFrameThickness((Thickness)o))); Type type4 = typeof(System.Windows.CornerRadius); Type type5 = typeof(WindowChrome); System.Windows.CornerRadius cornerRadiu = new System.Windows.CornerRadius(); WindowChrome.CornerRadiusProperty = DependencyProperty.Register("CornerRadius", type4, type5, new PropertyMetadata((object)cornerRadiu, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint()), (object value) => Utility.IsCornerRadiusValid((System.Windows.CornerRadius)value)); List <WindowChrome._SystemParameterBoundProperty> _SystemParameterBoundProperties = new List <WindowChrome._SystemParameterBoundProperty>(); WindowChrome._SystemParameterBoundProperty __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.CornerRadiusProperty, SystemParameterPropertyName = "WindowCornerRadius" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.CaptionHeightProperty, SystemParameterPropertyName = "WindowCaptionHeight" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.ResizeBorderThicknessProperty, SystemParameterPropertyName = "WindowResizeBorderThickness" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.GlassFrameThicknessProperty, SystemParameterPropertyName = "WindowNonClientFrameThickness" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); WindowChrome._BoundProperties = _SystemParameterBoundProperties; }
public HtmlBorderRenderElement(IRenderQueue renderQueue, IHtmlValueConverter converter) : base(renderQueue) { this.converter = converter; bounds = Rect.Zero; borderThickness = Thickness.Zero; cornerRadius = CornerRadius.Zero; Style.SetValue("background-clip", "content-box"); Style.SetBackground(Background, converter); Style.SetBorderThickness(BorderThickness, converter); Style.SetBounds(new Rect(Bounds.Location, (Bounds.Size - BorderThickness.Size).Max(Size.Zero)), converter); Style.SetBorderBrush(BorderBrush, converter); Style.SetCornerRadius(cornerRadius, converter); Style.SetIsHitTestVisible(IsHitTestVisible && Background != null); }
public void CtorFourDoubles () { CornerRadius cr = new CornerRadius (4, 3, 2, 1); Assert.AreEqual ("4,3,2,1", cr.ToString (), "ToString"); CornerRadius cr2 = new CornerRadius (4, 3, 2, 1); Assert.IsTrue (cr == cr2, "== true"); Assert.IsFalse (cr != cr2, "== false"); cr.TopLeft = 0; cr.TopRight = 0; cr.BottomRight = 0; cr.BottomLeft = 0; CheckProperties (cr, 0); Assert.IsFalse (cr == cr2, "== false"); Assert.IsTrue (cr != cr2, "== true"); }
public FlexButton() { HighlightMargin = new Thickness(0); HighlightBrightness = 100; GlowColor = Brushes.WhiteSmoke; OuterBorderBrush = Brushes.Gray; InnerBorderBrush = new LinearGradientBrush(Colors.White, Colors.LightGray, 90); InnerBorderThickness = new Thickness(1); CornerRadius = new CornerRadius(3); UpdateButtonColor(this, Brushes.Gainsboro); Foreground = Brushes.Black; IsEnabledChanged += FlexButtonIsEnabledChanged; }
public static bool Parse(string text, out CornerRadius cornerRadius) { cornerRadius = new CornerRadius(); Match match = Regex.Match(text, @"(\d),(\d),(\d),(\d)"); if (!match.Success) { return(false); } cornerRadius = new System.Windows.CornerRadius( System.Convert.ToDouble(match.Groups[1].Value), System.Convert.ToDouble(match.Groups[2].Value), System.Convert.ToDouble(match.Groups[3].Value), System.Convert.ToDouble(match.Groups[4].Value) ); return(true); }
public void AddCornerRadius(CornerRadius th, string prefix, string suffix = null) { // if (th.IsZero()) return; if (th.TopLeft == th.TopRight && th.TopRight== th.BottomLeft && th.BottomLeft == th.BottomRight) { if (0 != th.TopLeft) { AddComposed(th.TopLeft + "px", prefix, suffix); } } else { // TODO: /*AddComposed(th.Left + "px", prefix, "left", suffix); AddComposed(th.Top + "px", prefix, "top", suffix); AddComposed(th.Right + "px", prefix, "right", suffix); AddComposed(th.Bottom + "px", prefix, "bottom", suffix);*/ } }
public void CtorDouble () { CornerRadius cr = new CornerRadius (0); CheckProperties (cr, 0); cr.TopLeft = 1; cr.TopRight = 2; cr.BottomRight = 3; cr.BottomLeft = 4; Assert.AreEqual ("1,2,3,4", cr.ToString (), "ToString"); CornerRadius cr2 = new CornerRadius (0); Assert.IsFalse (cr.Equals (cr2), "!Equals"); Assert.IsFalse (cr2.Equals (cr), "!Equals2"); Assert.IsFalse (cr.Equals (null), "Equals(null)"); Assert.IsTrue (cr.Equals (cr), "Equals(self)"); Assert.Throws<ArgumentException> (delegate { new CornerRadius (-0.1); }, "Negative"); }
public Comment(Node hostNode) { HostNode = hostNode; var scrollViewer = new ScrollViewer { HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled, VerticalScrollBarVisibility = ScrollBarVisibility.Visible, Height = 70, CanContentScroll = true, Background = Brushes.Transparent }; var textBlock = new TextBlock { Background = Brushes.Transparent, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(5), FontSize = 12 }; scrollViewer.Content = textBlock; CornerRadius= new CornerRadius(5); Child = scrollViewer; BorderThickness = new Thickness(2); Background = Application.Current.Resources["BrushBlue"] as Brush; var bindingTextToTextBlock = new Binding("Text") { Source = this, Mode = BindingMode.OneWay }; textBlock.SetBinding(TextBlock.TextProperty, bindingTextToTextBlock); HostNode.HostCanvas.Children.Add(this); HostNode_PropertyChanged(null, null); HostNode.PropertyChanged+= HostNode_PropertyChanged; }
// Creates a border containing a textbox public static Border CreateCombinedRectangle(TextBlock text, double x, double y, double width, double height, SolidColorBrush color, double opacity, double haloOpacity, SolidColorBrush borderColor, CornerRadius radius, Border cachedBorder, string tooltip = "") { // Attempt to use a cached Border before creating a new one Border border; if (cachedBorder == null) border = new Border(); else border = cachedBorder; border.Background = color; border.BorderThickness = Cached.StandardBorderThickness; border.BorderBrush = borderColor; border.Width = width; border.Height = height; //border.Opacity = opacity; border.CornerRadius = radius; border.VerticalAlignment = VerticalAlignment.Center; border.HorizontalAlignment = HorizontalAlignment.Center; if (tooltip != "") border.ToolTip = tooltip; float left = (float)(x - (border.Width / 2)); float top = (float)(y - (border.Height / 2)); border.Margin = new Thickness(left, top, 0, 0); Canvas.SetZIndex(border, 5); return border; }
private Brush[] GetBrushes(System.Windows.Media.Color c, System.Windows.CornerRadius cornerRadius) { if (_commonBrushes == null) { lock (_resourceAccess) { if (_commonBrushes == null) { _commonBrushes = CreateBrushes(c, cornerRadius); _commonCornerRadius = cornerRadius; } } } if ((c == ((SolidColorBrush)_commonBrushes[4]).Color) && (cornerRadius == _commonCornerRadius)) { this._brushes = null; return(_commonBrushes); } if (this._brushes == null) { this._brushes = CreateBrushes(c, cornerRadius); } return(this._brushes); }
protected override double GetRadius(CornerRadius cornerRadius) => cornerRadius.TopLeft;
/// <summary> /// Renders the control. /// </summary> /// <param name="drawingContext"></param> protected override void OnRender(DrawingContext drawingContext) { System.Windows.CornerRadius cornerRadius = this.CornerRadius; Rect rect = new Rect(new Point(5.0, 5.0), new Size(base.RenderSize.Width, base.RenderSize.Height)); System.Windows.Media.Color c = this.Color; if (((rect.Width > 0.0) && (rect.Height > 0.0)) && (c.A > 0)) { double width = (rect.Right - rect.Left) - 10.0; double height = (rect.Bottom - rect.Top) - 10.0; double num3 = Math.Min((double)(width * 0.5), (double)(height * 0.5)); cornerRadius.TopLeft = Math.Min(cornerRadius.TopLeft, num3); cornerRadius.TopRight = Math.Min(cornerRadius.TopRight, num3); cornerRadius.BottomLeft = Math.Min(cornerRadius.BottomLeft, num3); cornerRadius.BottomRight = Math.Min(cornerRadius.BottomRight, num3); Brush[] brushes = this.GetBrushes(c, cornerRadius); double num4 = rect.Top + 5.0; double num5 = rect.Left + 5.0; double num6 = rect.Right - 5.0; double num7 = rect.Bottom - 5.0; double[] guidelinesX = new double[] { num5, num5 + cornerRadius.TopLeft, num6 - cornerRadius.TopRight, num5 + cornerRadius.BottomLeft, num6 - cornerRadius.BottomRight, num6 }; double[] guidelinesY = new double[] { num4, num4 + cornerRadius.TopLeft, num4 + cornerRadius.TopRight, num7 - cornerRadius.BottomLeft, num7 - cornerRadius.BottomRight, num7 }; drawingContext.PushGuidelineSet(new GuidelineSet(guidelinesX, guidelinesY)); cornerRadius.TopLeft += 5.0; cornerRadius.TopRight += 5.0; cornerRadius.BottomLeft += 5.0; cornerRadius.BottomRight += 5.0; Rect rectangle = new Rect(rect.Left, rect.Top, cornerRadius.TopLeft, cornerRadius.TopLeft); drawingContext.DrawRectangle(brushes[0], null, rectangle); double num8 = guidelinesX[2] - guidelinesX[1]; if (num8 > 0.0) { Rect rect3 = new Rect(guidelinesX[1], rect.Top, num8, 5.0); drawingContext.DrawRectangle(brushes[1], null, rect3); } Rect rect4 = new Rect(guidelinesX[2], rect.Top, cornerRadius.TopRight, cornerRadius.TopRight); drawingContext.DrawRectangle(brushes[2], null, rect4); double num9 = guidelinesY[3] - guidelinesY[1]; if (num9 > 0.0) { Rect rect5 = new Rect(rect.Left, guidelinesY[1], 5.0, num9); drawingContext.DrawRectangle(brushes[3], null, rect5); } double num10 = guidelinesY[4] - guidelinesY[2]; if (num10 > 0.0) { Rect rect6 = new Rect(guidelinesX[5], guidelinesY[2], 5.0, num10); drawingContext.DrawRectangle(brushes[5], null, rect6); } Rect rect7 = new Rect(rect.Left, guidelinesY[3], cornerRadius.BottomLeft, cornerRadius.BottomLeft); drawingContext.DrawRectangle(brushes[6], null, rect7); double num11 = guidelinesX[4] - guidelinesX[3]; if (num11 > 0.0) { Rect rect8 = new Rect(guidelinesX[3], guidelinesY[5], num11, 5.0); drawingContext.DrawRectangle(brushes[7], null, rect8); } Rect rect9 = new Rect(guidelinesX[4], guidelinesY[4], cornerRadius.BottomRight, cornerRadius.BottomRight); drawingContext.DrawRectangle(brushes[8], null, rect9); if (((cornerRadius.TopLeft == 5.0) && (cornerRadius.TopLeft == cornerRadius.TopRight)) && ((cornerRadius.TopLeft == cornerRadius.BottomLeft) && (cornerRadius.TopLeft == cornerRadius.BottomRight))) { Rect rect10 = new Rect(guidelinesX[0], guidelinesY[0], width, height); drawingContext.DrawRectangle(brushes[4], null, rect10); } else { PathFigure figure = new PathFigure(); if (cornerRadius.TopLeft > 5.0) { figure.StartPoint = new Point(guidelinesX[1], guidelinesY[0]); figure.Segments.Add(new LineSegment(new Point(guidelinesX[1], guidelinesY[1]), true)); figure.Segments.Add(new LineSegment(new Point(guidelinesX[0], guidelinesY[1]), true)); } else { figure.StartPoint = new Point(guidelinesX[0], guidelinesY[0]); } if (cornerRadius.BottomLeft > 5.0) { figure.Segments.Add(new LineSegment(new Point(guidelinesX[0], guidelinesY[3]), true)); figure.Segments.Add(new LineSegment(new Point(guidelinesX[3], guidelinesY[3]), true)); figure.Segments.Add(new LineSegment(new Point(guidelinesX[3], guidelinesY[5]), true)); } else { figure.Segments.Add(new LineSegment(new Point(guidelinesX[0], guidelinesY[5]), true)); } if (cornerRadius.BottomRight > 5.0) { figure.Segments.Add(new LineSegment(new Point(guidelinesX[4], guidelinesY[5]), true)); figure.Segments.Add(new LineSegment(new Point(guidelinesX[4], guidelinesY[4]), true)); figure.Segments.Add(new LineSegment(new Point(guidelinesX[5], guidelinesY[4]), true)); } else { figure.Segments.Add(new LineSegment(new Point(guidelinesX[5], guidelinesY[5]), true)); } if (cornerRadius.TopRight > 5.0) { figure.Segments.Add(new LineSegment(new Point(guidelinesX[5], guidelinesY[2]), true)); figure.Segments.Add(new LineSegment(new Point(guidelinesX[2], guidelinesY[2]), true)); figure.Segments.Add(new LineSegment(new Point(guidelinesX[2], guidelinesY[0]), true)); } else { figure.Segments.Add(new LineSegment(new Point(guidelinesX[5], guidelinesY[0]), true)); } figure.IsClosed = true; figure.Freeze(); PathGeometry geometry = new PathGeometry { Figures = { figure } }; geometry.Freeze(); drawingContext.DrawGeometry(brushes[4], null, geometry); } drawingContext.Pop(); } }
private void _InitializeWindowCornerRadius() { // The radius of window corners isn't exposed as a true system parameter. // It instead is a logical size that we're approximating based on the current theme. // There aren't any known variations based on theme color. Assert.IsNeitherNullNorEmpty(UxThemeName); // These radii are approximate. The way WPF does rounding is different than how // rounded-rectangle HRGNs are created, which is also different than the actual // round corners on themed Windows. For now we're not exposing anything to // mitigate the differences. var cornerRadius = default(CornerRadius); // This list is known to be incomplete and very much not future-proof. // On XP there are at least a couple of shipped themes that this won't catch, // "Zune" and "Royale", but WPF doesn't know about these either. // If a new theme was to replace Aero, then this will fall back on "classic" behaviors. // This isn't ideal, but it's not the end of the world. WPF will generally have problems anyways. switch (UxThemeName.ToUpperInvariant()) { case "LUNA": cornerRadius = new CornerRadius(6, 6, 0, 0); break; case "AERO": // Aero has two cases. One with glass and one without... if (NativeMethods.DwmIsCompositionEnabled()) { cornerRadius = new CornerRadius(8); } else { cornerRadius = new CornerRadius(6, 6, 0, 0); } break; case "CLASSIC": case "ZUNE": case "ROYALE": default: cornerRadius = new CornerRadius(0); break; } WindowCornerRadius = cornerRadius; }
private void SetCornerRadius() { // CornerRadius is relative to the center of the border line, interpolate the outline radius CornerRadius borderOutlineCornerRadius = new CornerRadius( CornerRadius.TopLeft + (BorderThickness.Top + BorderThickness.Left) / 4, CornerRadius.TopRight + (BorderThickness.Top + BorderThickness.Right) / 4, CornerRadius.BottomRight + (BorderThickness.Bottom + BorderThickness.Right) / 4, CornerRadius.BottomLeft + (BorderThickness.Bottom + BorderThickness.Left) / 4); Style.SetCornerRadius(borderOutlineCornerRadius, converter); }
private static Brush[] CreateBrushes(System.Windows.Media.Color c, System.Windows.CornerRadius cornerRadius) { GradientStopCollection stops2; GradientStopCollection stops3; GradientStopCollection stops4; GradientStopCollection stops5; Brush[] brushArray = new Brush[9]; brushArray[4] = new SolidColorBrush(c); brushArray[4].Freeze(); GradientStopCollection gradientStopCollection = CreateStops(c, 0.0); LinearGradientBrush brush = new LinearGradientBrush(gradientStopCollection, new Point(0.0, 1.0), new Point(0.0, 0.0)); brush.Freeze(); brushArray[1] = brush; LinearGradientBrush brush2 = new LinearGradientBrush(gradientStopCollection, new Point(1.0, 0.0), new Point(0.0, 0.0)); brush2.Freeze(); brushArray[3] = brush2; LinearGradientBrush brush3 = new LinearGradientBrush(gradientStopCollection, new Point(0.0, 0.0), new Point(1.0, 0.0)); brush3.Freeze(); brushArray[5] = brush3; LinearGradientBrush brush4 = new LinearGradientBrush(gradientStopCollection, new Point(0.0, 0.0), new Point(0.0, 1.0)); brush4.Freeze(); brushArray[7] = brush4; if (cornerRadius.TopLeft == 0.0) { stops2 = gradientStopCollection; } else { stops2 = CreateStops(c, cornerRadius.TopLeft); } RadialGradientBrush brush5 = new RadialGradientBrush(stops2) { RadiusX = 1.0, RadiusY = 1.0, Center = new Point(1.0, 1.0), GradientOrigin = new Point(1.0, 1.0) }; brush5.Freeze(); brushArray[0] = brush5; if (cornerRadius.TopRight == 0.0) { stops3 = gradientStopCollection; } else if (cornerRadius.TopRight == cornerRadius.TopLeft) { stops3 = stops2; } else { stops3 = CreateStops(c, cornerRadius.TopRight); } RadialGradientBrush brush6 = new RadialGradientBrush(stops3) { RadiusX = 1.0, RadiusY = 1.0, Center = new Point(0.0, 1.0), GradientOrigin = new Point(0.0, 1.0) }; brush6.Freeze(); brushArray[2] = brush6; if (cornerRadius.BottomLeft == 0.0) { stops4 = gradientStopCollection; } else if (cornerRadius.BottomLeft == cornerRadius.TopLeft) { stops4 = stops2; } else if (cornerRadius.BottomLeft == cornerRadius.TopRight) { stops4 = stops3; } else { stops4 = CreateStops(c, cornerRadius.BottomLeft); } RadialGradientBrush brush7 = new RadialGradientBrush(stops4) { RadiusX = 1.0, RadiusY = 1.0, Center = new Point(1.0, 0.0), GradientOrigin = new Point(1.0, 0.0) }; brush7.Freeze(); brushArray[6] = brush7; if (cornerRadius.BottomRight == 0.0) { stops5 = gradientStopCollection; } else if (cornerRadius.BottomRight == cornerRadius.TopLeft) { stops5 = stops2; } else if (cornerRadius.BottomRight == cornerRadius.TopRight) { stops5 = stops3; } else if (cornerRadius.BottomRight == cornerRadius.BottomLeft) { stops5 = stops4; } else { stops5 = CreateStops(c, cornerRadius.BottomRight); } RadialGradientBrush brush8 = new RadialGradientBrush(stops5) { RadiusX = 1.0, RadiusY = 1.0, Center = new Point(0.0, 0.0), GradientOrigin = new Point(0.0, 0.0) }; brush8.Freeze(); brushArray[8] = brush8; return(brushArray); }
public object ConvertFrom(XamlNamespaces namespaces, Uri sourceUri, object value) { return(CornerRadius.Parse(value.ToString().Trim())); }
protected virtual void OnInnerCornerRadiusChanged(CornerRadius oldValue, CornerRadius newValue) { // TODO: Add your property changed side-effects. Descendants can override as well. }
public bool Equals(CornerRadius cornerRadius) { return(this == cornerRadius); }
protected override double GetRadius(CornerRadius cornerRadius) => cornerRadius.BottomLeft;
private CornerRadius _ScaleCornerRadius(CornerRadius first, double currentRepeat) { return new CornerRadius( first.TopLeft * currentRepeat, first.TopRight * currentRepeat, first.BottomRight * currentRepeat, first.BottomLeft * currentRepeat); }
private CornerRadius _SubtractCornerRadius(CornerRadius first, CornerRadius second) { return new CornerRadius( first.TopLeft - second.TopLeft, first.TopRight - second.TopRight, first.BottomRight - second.BottomRight, first.BottomLeft - second.BottomLeft); }
private CornerRadius _InterpolateCornerRadius(CornerRadius from, CornerRadius to, double progress) { return this._ScaleCornerRadius(this._SubtractCornerRadius(to, from), progress); }
private CornerRadius _AddCornerRadius(CornerRadius first, CornerRadius second) { return new CornerRadius( first.TopLeft + second.TopLeft, first.TopRight + second.TopRight, first.BottomRight + second.BottomRight, first.BottomLeft + second.BottomLeft); }
private static bool _IsValidAnimationValueCornerRadius(CornerRadius defaultOriginValue) { return true; }
public static void SetCornerRadius(UIElement element, CornerRadius value) { ControlsHelper.SetCornerRadius(element, value); }
private static bool IsNeedToClip(CornerRadius cornerRadius) { return cornerRadius.BottomLeft > 0 || cornerRadius.BottomRight > 0 || cornerRadius.TopLeft > 0 || cornerRadius.TopRight > 0; }
public static CornerRadius DefaultIfNull(this CornerRadius cornerRadius, CornerRadius defaultValue = null) { return(cornerRadius ?? defaultValue ?? CornerRadius.Zero); }
private static bool IsCornerRadiusValid(object value) { System.Windows.CornerRadius radius = (System.Windows.CornerRadius)value; return((((((radius.TopLeft >= 0.0) && (radius.TopRight >= 0.0)) && ((radius.BottomLeft >= 0.0) && (radius.BottomRight >= 0.0))) && ((!double.IsNaN(radius.TopLeft) && !double.IsNaN(radius.TopRight)) && (!double.IsNaN(radius.BottomLeft) && !double.IsNaN(radius.BottomRight)))) && ((!double.IsInfinity(radius.TopLeft) && !double.IsInfinity(radius.TopRight)) && !double.IsInfinity(radius.BottomLeft))) && !double.IsInfinity(radius.BottomRight)); }