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();
                }
            }
        }
Example #3
0
        public static D2D.GradientStopCollection ToSharpDX(
            this Jupiter.Media.GradientStopCollection gradientStopCollection,
            D2D.RenderTarget renderTarget)
        {
            var gradientStops = new D2D.GradientStop[gradientStopCollection.Count];

            for (int i = 0; i < gradientStopCollection.Count; i++)
            {
                gradientStops[i] = gradientStopCollection[i].ToSharpDX();
            }

            return(new D2D.GradientStopCollection(renderTarget, gradientStops));
        }
Example #4
0
        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();
                }
            }
        }
Example #5
0
        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();
                }
            }
        }
Example #6
0
 public LinearGradientBrush()
 {
     GradientStops = new GradientStopCollection();
 }
Example #7
0
 protected GradientBrush()
 {
     GradientStops = new GradientStopCollection();
 }