private GeometryHelper(CornerRadius cornerRadius, Rect bounds)
 {
     // The CornerRadius must never be larger than the size. Otherwise, the geometry will
     // look totally off, since (for instance) an arc is drawn further than the next line segment's destination.
     // To avoid this, shrink a too-large CornerRadius to the exact size of the bounds rect.
     _cornerRadius = CornerRadiusHelper.ShrinkToSize(cornerRadius, bounds.Size);
     _boundsRect   = bounds;
 }
Example #2
0
        protected override void OnElementChanged(ElementChangedEventArgs <ContentView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                return;
            }
            Control.CornerRadius = CornerRadiusHelper.FromUniformRadius(((ContentViewRoundedCorners)Element).CornerRadius);
        }
        private void ToggleCornerRadius(object sender, RoutedEventArgs args)
        {
            var currentRadius = SubjectBorder.CornerRadius;
            var newRadius     = currentRadius.TopLeft == 0 ?
                                CornerRadiusHelper.FromUniformRadius(5) :
                                default(CornerRadius);

            SubjectBorder.CornerRadius       = newRadius;
            ToggleCornerRadiusButton.Content = $"Toggle CornerRadius (current={newRadius.TopLeft})";
            StatusTextBlock.Text             = newRadius.TopLeft.ToString();
        }
Example #4
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     n++;
     MyBorder.CornerRadius = CornerRadiusHelper.FromUniformRadius(n * 5);
 }