protected override void UpdateBackgroundColor() { // background color change must be handled separately // because the background would protrude through the border if the corners are rounded // as the background would be applied to the renderer's FrameworkElement var pancake = (PancakeView)Element; if (content != null) { if (pancake.BackgroundGradientStops != null && pancake.BackgroundGradientStops.Any()) { // A range of colors is given. Let's add them. var orderedStops = pancake.BackgroundGradientStops.OrderBy(x => x.Offset).ToList(); var gc = new Windows.UI.Xaml.Media.GradientStopCollection(); foreach (var item in orderedStops) { gc.Add(new Windows.UI.Xaml.Media.GradientStop { Offset = item.Offset, Color = item.Color.ToWindowsColor() }); } var gradient = new Windows.UI.Xaml.Media.LinearGradientBrush(gc, 0); gradient.StartPoint = new Windows.Foundation.Point(pancake.BackgroundGradientStartPoint.X, pancake.BackgroundGradientStartPoint.Y); gradient.EndPoint = new Windows.Foundation.Point(pancake.BackgroundGradientEndPoint.X, pancake.BackgroundGradientEndPoint.Y); this.content.Background = gradient; } else { content.Background = Element.BackgroundColor.IsDefault ? null : Element.BackgroundColor.ToBrush(); } } }
private void UpdateBorder(PancakeView pancake) { //// Create the border layer if (content != null && pancake.Border != null) { this.content.BorderThickness = new Windows.UI.Xaml.Thickness(pancake.Border.Thickness); if (pancake.Border.GradientStops != null && pancake.Border.GradientStops.Any()) { // A range of colors is given. Let's add them. var orderedStops = pancake.Border.GradientStops.OrderBy(x => x.Offset).ToList(); var gc = new Windows.UI.Xaml.Media.GradientStopCollection(); foreach (var item in orderedStops) { gc.Add(new Windows.UI.Xaml.Media.GradientStop { Offset = item.Offset, Color = item.Color.ToWindowsColor() }); } var gradient = new Windows.UI.Xaml.Media.LinearGradientBrush(gc, 0); gradient.StartPoint = new Windows.Foundation.Point(pancake.Border.GradientStartPoint.X, pancake.Border.GradientStartPoint.Y); gradient.EndPoint = new Windows.Foundation.Point(pancake.Border.GradientEndPoint.X, pancake.Border.GradientEndPoint.Y); this.content.BorderBrush = gradient; } else { this.content.BorderBrush = pancake.Border.Color.IsDefault ? null : pancake.Border.Color.ToBrush(); } } }
protected override void UpdateBackgroundColor() { // background color change must be handled separately // because the background would protrude through the border if the corners are rounded // as the background would be applied to the renderer's FrameworkElement var pancake = (PancakeView)Element; if (Control != null) { if ((pancake.BackgroundGradientStartColor != default(Color) && pancake.BackgroundGradientEndColor != default(Color)) || (pancake.BackgroundGradientStops != null && pancake.BackgroundGradientStops.Any())) { // Create a gradient layer that draws our background. if (pancake.BackgroundGradientStops != null && pancake.BackgroundGradientStops.Count > 0) { // A range of colors is given. Let's add them. var orderedStops = pancake.BackgroundGradientStops.OrderBy(x => x.Offset).ToList(); var gc = new Windows.UI.Xaml.Media.GradientStopCollection(); foreach (var item in orderedStops) { gc.Add(new Windows.UI.Xaml.Media.GradientStop { Offset = item.Offset, Color = item.Color.ToWindowsColor() }); } this.Control.Background = new LinearGradientBrush(gc, pancake.BackgroundGradientAngle); } else { var gs1 = new Windows.UI.Xaml.Media.GradientStop { Offset = 0, Color = pancake.BackgroundGradientStartColor.ToWindowsColor() }; var gs2 = new Windows.UI.Xaml.Media.GradientStop { Offset = 1, Color = pancake.BackgroundGradientEndColor.ToWindowsColor() }; var gc = new Windows.UI.Xaml.Media.GradientStopCollection { gs1, gs2 }; this.Control.Background = new LinearGradientBrush(gc, pancake.BackgroundGradientAngle); } } else { Control.Background = Element.BackgroundColor.IsDefault ? null : Element.BackgroundColor.ToBrush(); } } }
private void UpdateBorder(PancakeView pancake) { //// Create the border layer if (Control != null) { this.Control.BorderThickness = new Windows.UI.Xaml.Thickness(pancake.BorderThickness); if ((pancake.BorderGradientStartColor != default(Color) && pancake.BorderGradientEndColor != default(Color)) || (pancake.BorderGradientStops != null && pancake.BorderGradientStops.Any())) { // Create a gradient layer that draws our background. if (pancake.BorderGradientStops != null && pancake.BorderGradientStops.Count > 0) { // A range of colors is given. Let's add them. var orderedStops = pancake.BorderGradientStops.OrderBy(x => x.Offset).ToList(); var gc = new Windows.UI.Xaml.Media.GradientStopCollection(); foreach (var item in orderedStops) { gc.Add(new Windows.UI.Xaml.Media.GradientStop { Offset = item.Offset, Color = item.Color.ToWindowsColor() }); } this.Control.BorderBrush = new LinearGradientBrush(gc, pancake.BorderGradientAngle); } else { var gs1 = new Windows.UI.Xaml.Media.GradientStop { Offset = 0, Color = pancake.BorderGradientStartColor.ToWindowsColor() }; var gs2 = new Windows.UI.Xaml.Media.GradientStop { Offset = 1, Color = pancake.BorderGradientEndColor.ToWindowsColor() }; var gc = new Windows.UI.Xaml.Media.GradientStopCollection { gs1, gs2 }; this.Control.BorderBrush = new LinearGradientBrush(gc, pancake.BorderGradientAngle); } } else { this.Control.BorderBrush = pancake.BorderColor.IsDefault ? null : pancake.BorderColor.ToBrush(); } } }