void UpdateBorderRadius() { var radius = BorderRadius == -1 ? 0 : BorderRadius; var cornerRadius = new Windows.UI.Xaml.CornerRadius(radius); if (_contentPresenter != null) { _contentPresenter.CornerRadius = cornerRadius; } if (_rootGrid != null) { _rootGrid.CornerRadius = cornerRadius; } }
protected override void OnElementChanged(ElementChangedEventArgs <Frame> e) { base.OnElementChanged(e); var myFrame = Element as RoundedFrame; if (Control != null) { if (myFrame.CornerRadius != -1 && myFrame.CornerRadius != 0) { _radiusCorner = myFrame.CornerRadius; } var frame = e.NewElement; _frameBg = Windows.UI.Color.FromArgb( (byte)(frame.BackgroundColor.A * 255), (byte)(frame.BackgroundColor.R * 255), (byte)(frame.BackgroundColor.G * 255), (byte)(frame.BackgroundColor.B * 255)); CornerRadius corner; switch (myFrame.RoundedStyle) { case RoundedFrame.RoundedStyleEnum.Full: corner = new Windows.UI.Xaml.CornerRadius(_radiusCorner); break; case RoundedFrame.RoundedStyleEnum.Down: corner = new Windows.UI.Xaml.CornerRadius(_radiusCorner, _radiusCorner, 0, 0); break; case RoundedFrame.RoundedStyleEnum.Top: corner = new Windows.UI.Xaml.CornerRadius(0, 0, _radiusCorner, _radiusCorner); break; default: corner = new CornerRadius(_radiusCorner); break; } Control.CornerRadius = corner; Control.Background = new SolidColorBrush(_frameBg); frame.BackgroundColor = Xamarin.Forms.Color.Transparent; } }
static Windows.UI.Xaml.CornerRadius ParseCornerRadius(string s) { Windows.UI.Xaml.CornerRadius radius = new Windows.UI.Xaml.CornerRadius(); if (string.IsNullOrEmpty(s)) { return(radius); } string[] strArray = s.Split(new char[] { ',', ' ' }); if (strArray.Length == 1) { return(new Windows.UI.Xaml.CornerRadius(double.Parse(strArray[0], (IFormatProvider)CultureInfo.InvariantCulture))); } if (strArray.Length != 4) { throw new FormatException(string.Format("String {0} does not represent CornerRadius", (object[])new object[] { s })); } return(new Windows.UI.Xaml.CornerRadius(double.Parse(strArray[0], (IFormatProvider)CultureInfo.InvariantCulture), double.Parse(strArray[1], (IFormatProvider)CultureInfo.InvariantCulture), double.Parse(strArray[2], (IFormatProvider)CultureInfo.InvariantCulture), double.Parse(strArray[3], (IFormatProvider)CultureInfo.InvariantCulture))); }
public MessageEntry(MalMessageModel msg) { Msg = msg; if (Msg.Sender.Equals(Credentials.UserName, StringComparison.CurrentCultureIgnoreCase)) { HorizontalAlignment = HorizontalAlignment.Right; Margin = new Thickness(20, 0, 0, 0); CornerRadius = new CornerRadius(10, 10, 0, 10); Background = Application.Current.Resources["SystemControlHighlightAltListAccentLowBrush"] as Brush; } else { HorizontalAlignment = HorizontalAlignment.Left; Margin = new Thickness(0, 0, 20, 0); CornerRadius = new CornerRadius(10, 10, 10, 0); Background = Application.Current.Resources["SystemControlHighlightListAccentLowBrush"] as Brush; Background.Opacity = .5; } }
/// <summary> /// Constructor /// </summary> /// <param name="corners">CornerRadius</param> /// <param name="borders">BorderThickness</param> /// <param name="padding">Padding</param> /// <param name="isOuterBorder">Flag to indicate whether outer or inner border needs /// to be calculated</param> internal CompositionPathInfo(CornerRadius corners, Thickness borders, Thickness padding, bool isOuterBorder) { var factor = 0.5; var left = factor * (borders.Left + padding.Left); var top = factor * (borders.Top + padding.Top); var right = factor * (borders.Right + padding.Right); var bottom = factor * (borders.Bottom + padding.Bottom); if (isOuterBorder) { if (corners.TopLeft.IsZero()) { LeftTop = TopLeft = 0.0; } else { LeftTop = corners.TopLeft + left; TopLeft = corners.TopLeft + top; } if (corners.TopRight.IsZero()) { TopRight = RightTop = 0.0; } else { TopRight = corners.TopRight + top; RightTop = corners.TopRight + right; } if (corners.BottomRight.IsZero()) { RightBottom = BottomRight = 0.0; } else { RightBottom = corners.BottomRight + right; BottomRight = corners.BottomRight + bottom; } if (corners.BottomLeft.IsZero()) { BottomLeft = LeftBottom = 0.0; } else { BottomLeft = corners.BottomLeft + bottom; LeftBottom = corners.BottomLeft + left; } } else { LeftTop = Math.Max(0.0, corners.TopLeft - left); TopLeft = Math.Max(0.0, corners.TopLeft - top); TopRight = Math.Max(0.0, corners.TopRight - top); RightTop = Math.Max(0.0, corners.TopRight - right); RightBottom = Math.Max(0.0, corners.BottomRight - right); BottomRight = Math.Max(0.0, corners.BottomRight - bottom); BottomLeft = Math.Max(0.0, corners.BottomLeft - bottom); LeftBottom = Math.Max(0.0, corners.BottomLeft - left); } }
public bool Equals(CornerRadius cornerRadius) { return (this == cornerRadius); }
public bool Equals(CornerRadius cornerRadius) { return(this == cornerRadius); }
protected void SetCornerRadius(CornerRadius cornerRadius) => BorderLayerRenderer.SetCornerRadius(this, cornerRadius);
internal static bool TryGetCornerRadius(this IFrameworkElement frameworkElement, out CornerRadius cornerRadius) { switch (frameworkElement) { case Grid g: cornerRadius = g.CornerRadius; return(true); case StackPanel sp: cornerRadius = sp.CornerRadius; return(true); case Control c: cornerRadius = c.CornerRadius; return(true); case ContentPresenter cp: cornerRadius = cp.CornerRadius; return(true); case Border b: cornerRadius = b.CornerRadius; return(true); case Panel p: cornerRadius = p.CornerRadius; return(true); } cornerRadius = default; return(false); }