示例#1
0
 public GradientColorSet(Color[] colors, float[] blend_positions, GradientStyle gradient_style, float rotate_angle)
 {
     this.Colors         = colors;
     this.BlendPositions = blend_positions;
     this.GradientStyle  = gradient_style;
     this.RotateAngle    = rotate_angle;
 }
示例#2
0
 public GradientColorSetSimple(GradientStyle gradient_style, float rotate_angle, bool is_reverse, bool same_edge_color)
 {
     this.gradient_style  = gradient_style;
     this.rotate_angle    = rotate_angle;
     this.is_reverse      = is_reverse;
     this.same_edge_color = same_edge_color;
 }
示例#3
0
        protected void Gradient_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            HatchStyle.SelectedIndex = 0;

            // Set Gradient Type
            Chart1.BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), Gradient.SelectedItem.Text);
            Chart1.BackHatchStyle    = ChartHatchStyle.None;
        }
示例#4
0
 /// <summary>
 /// Apply opacity
 /// </summary>
 /// <param name="rawColors">raw color array including 512 element</param>
 /// <param name="opacity">opacity</param>
 /// <returns>apply opacity</returns>
 protected uint[] ApplyOpacity(uint[] rawColors, uint opacity, GradientStyle gradientStyle)
 {
     uint[] result = new uint[rawColors.Length];
     for (int i = 0; i < 256; i++)
     {
     }
     return(result);
 }
 /// <summary>
 /// Create a new object with the specified properties.
 /// </summary>
 /// <param name="parent">Parent control used to determine what defaults to use. Null is ok.</param>
 /// <param name="color1">The first color of the gradient or this is the solid brush color.</param>
 /// <param name="color2">The second color of the gradient.</param>
 /// <param name="style">The gradient style for the brush.</param>
 /// <param name="gammaCorrection">Controls the overall brightness and ratio of red to green to blue hues. Enables a more uniform intensity across the gradient. This is ignored if the style is Solid.</param>
 public GradientBrush(Control parent, Color color1, Color color2, GradientStyle style, bool gammaCorrection)
 {
     Host            = parent;
     Color1          = color1;
     Color2          = color2;
     Style           = style;
     GammaCorrection = gammaCorrection;
 }
示例#6
0
 public GradientColorSetSimple(GradientStyle gradient_style, float rotate_angle, int secondary_opacity, int secondary_alpha, bool is_reverse, bool same_edge_color)
 {
     this.gradient_style    = gradient_style;
     this.rotate_angle      = rotate_angle;
     this.secondary_opacity = secondary_opacity;
     this.secondary_alpha   = secondary_alpha;
     this.is_reverse        = is_reverse;
     this.same_edge_color   = same_edge_color;
 }
示例#7
0
 public static void SetGradientBackground(Control control, GradientStyle style)
 {
     if (control == null || control.IsDisposed)
     {
         return;
     }
     control.BackgroundImageLayout = ImageLayout.Stretch;
     control.BackgroundImage       = style.GetImage(control.Size);
 }
示例#8
0
        private void ControlChanged(object sender, System.EventArgs e)
        {
            if (this.StripEndColor.SelectedIndex >= 0)
            {
                this.Chart1.ChartAreas[0].AxisX.StripLines[0].BackSecondaryColor =
                    Color.FromName(this.StripEndColor.SelectedItem.ToString());
            }

            if (this.StripColor.SelectedIndex >= 0)
            {
                this.Chart1.ChartAreas[0].AxisX.StripLines[0].BackColor =
                    Color.FromName(this.StripColor.SelectedItem.ToString());
            }

            if (this.LineColor.SelectedIndex >= 0)
            {
                this.Chart1.ChartAreas[0].AxisX.StripLines[0].BorderColor =
                    Color.FromName(this.LineColor.SelectedItem.ToString());
            }

            if (this.LineWidth.SelectedIndex >= 0)
            {
                this.Chart1.ChartAreas[0].AxisX.StripLines[0].BorderWidth =
                    int.Parse(this.LineWidth.SelectedItem.ToString());
            }

            if (this.Interval.SelectedIndex >= 0)
            {
                this.Chart1.ChartAreas[0].AxisX.StripLines[0].Interval =
                    int.Parse(this.Interval.SelectedItem.ToString());
            }

            if (this.HatchStyle.SelectedIndex >= 0)
            {
                // Set Hatch Style
                this.Chart1.ChartAreas[0].AxisX.StripLines[0].BackHatchStyle =
                    (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), this.HatchStyle.SelectedItem.ToString());
            }

            if (this.Gradient.SelectedIndex >= 0)
            {
                // Set Gradient Type
                this.Chart1.ChartAreas[0].AxisX.StripLines[0].BackGradientStyle =
                    (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), this.Gradient.SelectedItem.ToString());
            }

            if (this.StripLinesStyle.SelectedIndex >= 0)
            {
                this.Chart1.ChartAreas[0].AxisX.StripLines[0].BorderDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), this.StripLinesStyle.SelectedItem.ToString());
            }

            // Enable/disable attribute	contros
            StripEndColor.Enabled = (Gradient.SelectedIndex != 0 || HatchStyle.SelectedIndex != 0);
            LineColor.Enabled     = (StripLinesStyle.SelectedIndex != 0);
            LineWidth.Enabled     = (StripLinesStyle.SelectedIndex != 0);
        }
示例#9
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     BorderColor       = ccboBorderColor.SelectedItem;
     BorderDashStyle   = (ChartDashStyle)cboBorderDashStyle.SelectedItem;
     BorderWidth       = (int)nudBorderWidth.Value;
     BackColor         = ccboBackColor.SelectedItem;
     BackSecondColor   = ccboBackSecondColor.SelectedItem;
     BackHatchStyle    = (ChartHatchStyle)cboBackHatchStyle.SelectedItem;
     BackGradientStyle = (GradientStyle)cboBackGradientStyle.SelectedItem;
     this.DialogResult = DialogResult.OK;
 }
        private void AppearanceChange(object sender)
        {
            // Set Back Color
            Chart1.ChartAreas["Default"].BackColor = Color.FromName(BackColorCom.GetItemText(BackColorCom.SelectedItem));

            // Set Back Gradient End Color
            Chart1.ChartAreas["Default"].BackSecondaryColor = Color.FromName(ForeColorCom.GetItemText(ForeColorCom.SelectedItem));

            // Set Border Color
            Chart1.ChartAreas["Default"].BorderColor = Color.FromName(BorderColor.GetItemText(BorderColor.SelectedItem));

            // Set Gradient Type
            if (Gradient.SelectedItem != null)
            {
                Chart1.ChartAreas["Default"].BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), Gradient.GetItemText(Gradient.SelectedItem));
            }

            // Set Gradient Type
            if (HatchStyle.SelectedItem != null)
            {
                Chart1.ChartAreas["Default"].BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchStyle.GetItemText(HatchStyle.SelectedItem));
            }

            if (sender == Gradient && Chart1.ChartAreas["Default"].BackGradientStyle != GradientStyle.None)
            {
                HatchStyle.SelectedIndex = 0;
            }

            if (sender == HatchStyle && Chart1.ChartAreas["Default"].BackHatchStyle != ChartHatchStyle.None)
            {
                Gradient.SelectedIndex = 0;
            }


            // Set Border Width
            if (BorderSizeCom.SelectedItem != null)
            {
                Chart1.ChartAreas["Default"].BorderWidth = int.Parse(BorderSizeCom.GetItemText(BorderSizeCom.SelectedItem));
            }

            // Set Border Style
            if (BorderDashStyle.SelectedItem != null)
            {
                Chart1.ChartAreas["Default"].BorderDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyle.GetItemText(BorderDashStyle.SelectedItem));
            }

            // Set Shadow Offset
            if (ShadowOffset.SelectedItem != null)
            {
                Chart1.ChartAreas["Default"].ShadowOffset = int.Parse(ShadowOffset.GetItemText(ShadowOffset.SelectedItem));
            }
        }
示例#11
0
        /// <summary>
        /// mg panel class - used to support double buffering on panel
        /// </summary>
        public MgPanel()
            : base()
        {
#if !PocketPC
            DoubleBuffered = true;
#else
            dummy         = new Control();
            dummy.Size    = new Size(0, 0);
            dummy.TabStop = false;
            Controls.Add(dummy);
#endif
            GradientStyle = GradientStyle.None;
        }
示例#12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="control"></param>
        /// <param name="properties"></param>
        static void BuildGradientStyleProperty(MgControlBase control, Dictionary <string, DesignerPropertyInfo> properties)
        {
            bool          isDefaultvalue = false;
            GradientStyle value          = (GradientStyle)GetRuntimeValueAsInt(control, PropInterface.PROP_TYPE_GRADIENT_STYLE, ref isDefaultvalue);

            properties.Add(Constants.WinPropGradientStyle, new DesignerPropertyInfo()
            {
                VisibleInPropertyGrid = false,
                Value            = value,
                IsDefaultValue   = isDefaultvalue,
                IsNativeProperty = true,
            });
        }
示例#13
0
        public static Series CreateSeriesByType(SeriesChartType type, GradientStyle style, int r, int g, int b, string name)
        {
            Series s1 = new Series();

            s1.ChartType          = type;
            s1.Font               = new Font("Lucida Sans Unicode", 9f);
            s1.Color              = Color.FromArgb(255, 250, 250);
            s1.BorderColor        = Color.Transparent;
            s1.BackSecondaryColor = Color.FromArgb(r, g, b);
            s1.BackGradientStyle  = style;
            s1.Name               = name;
            s1.Legend             = name;
            return(s1);
        }
示例#14
0
 public GradientColorSet(Color[] colors, GradientStyle gradient_style, float rotate_angle)
 {
     this.Colors        = colors;
     this.GradientStyle = gradient_style;
     this.RotateAngle   = rotate_angle;
     if (colors != null)
     {
         BlendPositions = new float[colors.Length];
     }
     else
     {
         BlendPositions = null;
     }
 }
 private static string ToKey(GradientStyle style)
 {
     switch (style)
     {
         case GradientStyle.VerticalBlackToTransparent: return "Gradient.Vertical.Black-Transparent";
         case GradientStyle.VerticalTransparentToBlack: return "Gradient.Vertical.Transparent-Black";
         case GradientStyle.VerticalWhiteToTransparent: return "Gradient.Vertical.White-Transparent";
         case GradientStyle.VerticalTransparentToWhite: return "Gradient.Vertical.Transparent-White";
         case GradientStyle.HorizontalBlackToTransparent: return "Gradient.Horizontal.Black-Transparent";
         case GradientStyle.HorizontalTransparentToBlack: return "Gradient.Horizontal.Transparent-Black";
         case GradientStyle.HorizontalWhiteToTransparent: return "Gradient.Horizontal.White-Transparent";
         case GradientStyle.HorizontalTransparentToWhite: return "Gradient.Horizontal.Transparent-White";
     }
     return null;
 }
示例#16
0
文件: Frame.cs 项目: ishani/Oddity
        static public void Gradient(float t, GradientColouring gColouring, GradientStyle gStyle, ref LED result)
        {
            Byte[] A = new Byte[11] {
                1, 2, 3, 3, 3, 3, 2, 1, 0, 0, 0
            };
            Byte[] B = new Byte[11] {
                0, 0, 0, 1, 2, 3, 3, 3, 3, 2, 1
            };

            if (t < 0.0f)
            {
                t = 0.0f;
            }
            if (t > 1.0f)
            {
                t = 1.0f;
            }

            int index = (int)(t * ((gStyle == GradientStyle.Half) ? 5.0f : 10.0f));

            if (gColouring == GradientColouring.RedFirst ||
                gColouring == GradientColouring.RedOnly)
            {
                result.R = A[index];

                if (gColouring == GradientColouring.RedOnly)
                {
                    result.G = 0;
                }
                else
                {
                    result.G = B[index];
                }
            }
            else
            {
                result.G = A[index];

                if (gColouring == GradientColouring.GreenOnly)
                {
                    result.R = 0;
                }
                else
                {
                    result.R = B[index];
                }
            }
        }
示例#17
0
        /// <summary></summary>
        /// <param name="control"></param>
        public static GradientStyle GetGradientStyle(Control control)
        {
            GradientStyle gradientStyle = GradientStyle.None;

            if (IsMdiClient(control))
            {
                control = control.Parent;
            }

            if (control is IGradientColorProperty)
            {
                gradientStyle = ((IGradientColorProperty)control).GradientStyle;
            }

            return(gradientStyle);
        }
        public void UpdateColor()
        {
            if (!ApplyToPoint.Checked)
            {
                // Set Series["Default"] visual attributes
                Chart1.Series["Default"].Color = Color.FromName(ColorList.SelectedItem.Text);
                Chart1.Series["Default"].BackSecondaryColor = Color.FromName(EndColorList.SelectedItem.Text);
                Chart1.Series["Default"].BorderColor        = Color.FromName(BorderColorList.SelectedItem.Text);
                Chart1.Series["Default"].BackGradientStyle  = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), GradientList.SelectedItem.Text);
                Chart1.Series["Default"].BackHatchStyle     = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchingList.SelectedItem.Text);
                Chart1.Series["Default"].BorderWidth        = int.Parse(BorderSizeList.SelectedItem.Text);
                Chart1.Series["Default"].BorderDashStyle    = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyleList.SelectedItem.Text);
                Chart1.Series["Default"].ShadowOffset       = int.Parse(ShadowOffsetList.SelectedItem.Text);

                // Disable fore color control if gradient or hatching are not used
                if (HatchingList.SelectedItem.Text == "None" && GradientList.SelectedItem.Text == "None")
                {
                    EndColorList.Enabled = false;
                }
                else
                {
                    EndColorList.Enabled = true;
                }
            }
            else
            {
                // Set Series["Default"] visual attributes
                Chart1.Series["Default"].Points[2].Color = Color.FromName(ColorList.SelectedItem.Text);
                Chart1.Series["Default"].Points[2].BackSecondaryColor = Color.FromName(EndColorList.SelectedItem.Text);
                Chart1.Series["Default"].Points[2].BorderColor        = Color.FromName(BorderColorList.SelectedItem.Text);
                Chart1.Series["Default"].Points[2].BackGradientStyle  = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), GradientList.SelectedItem.Text);
                Chart1.Series["Default"].Points[2].BackHatchStyle     = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchingList.SelectedItem.Text);
                Chart1.Series["Default"].Points[2].BorderWidth        = int.Parse(BorderSizeList.SelectedItem.Text);
                Chart1.Series["Default"].Points[2].BorderDashStyle    = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyleList.SelectedItem.Text);
                Chart1.Series["Default"].ShadowOffset = int.Parse(ShadowOffsetList.SelectedItem.Text);

                // Disable fore color control if gradient or hatching are not used
                if (HatchingList.SelectedItem.Text == "None" && GradientList.SelectedItem.Text == "None")
                {
                    EndColorList.Enabled = false;
                }
                else
                {
                    EndColorList.Enabled = true;
                }
            }
        }
示例#19
0
        private void GradientStyleClick(object sender, System.EventArgs e)
        {
            this.barItem27.Checked = false;
            this.barItem28.Checked = false;
            this.barItem29.Checked = false;
            this.barItem30.Checked = false;
            this.barItem31.Checked = false;
            this.barItem32.Checked = false;
            this.barItem33.Checked = false;
            BarItem mi = sender as BarItem;

            mi.Checked = true;
            switch (mi.Text)
            {
            case "BackwardDiagonal":
                gradientStyle = GradientStyle.BackwardDiagonal;
                break;

            case "ForwardDiagonal":
                gradientStyle = GradientStyle.ForwardDiagonal;
                break;

            case "Horizontal":
                gradientStyle = GradientStyle.Horizontal;
                break;

            case "None":
                gradientStyle = GradientStyle.None;
                break;

            case "PathEllipse":
                gradientStyle = GradientStyle.PathEllipse;
                break;

            case "PathRectangle":
                gradientStyle = GradientStyle.PathRectangle;
                break;

            case "Vertical":
                gradientStyle = GradientStyle.Vertical;
                break;
            }

            this.editControl1.WordWrapMarginBrush = new BrushInfo(gradientStyle, foreColor, backColor);
        }
示例#20
0
        //TODO: Kaushal. When the rendering code will be moved from MgUtils to MgControls,
        //the scope of many methods in this class should be changed to private.

        /// <summary>
        /// paint background of control
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rect"></param>
        /// <param name="bgColor"></param>
        /// <param name="fgColor"></param>
        /// <param name="style"></param>
        /// <param name="textBoxBorder"></param>
        /// <param name="gradientColor"></param>
        /// <param name="gradientStyle"></param>
        /// <param name="borderType"></param>
        /// <returns></returns>
        public static Rectangle FillRectAccordingToGradientStyle(Graphics g, Rectangle rect, Color bgColor, Color fgColor,
                                                                 ControlStyle style, bool textBoxBorder, GradientColor gradientColor,
                                                                 GradientStyle gradientStyle, BorderType borderType = BorderType.Thin)
        {
            if (gradientStyle == GradientStyle.None)
            {
                PaintBackGround(g, rect, bgColor, true);
            }
            else
            {
                PaintBackGroundGradient(g, rect, bgColor, fgColor, style, textBoxBorder,
                                        gradientColor, gradientStyle, false, 0);
            }

            BorderRenderer.PaintBorder(g, rect, fgColor, style, textBoxBorder, borderType);

            return(rect);
        }
示例#21
0
        /// <summary></summary>
        /// <param name="control"></param>
        /// <param name="gradientStyle"></param>
        public static void SetGradientStyle(Control control, GradientStyle gradientStyle)
        {
            if (IsMdiClient(control))
            {
                control = control.Parent;
            }

            if (control is IGradientColorProperty)
            {
                IGradientColorProperty gradientColorProperty = (IGradientColorProperty)control;
                if (gradientColorProperty.GradientStyle != gradientStyle)
                {
                    gradientColorProperty.GradientStyle = gradientStyle;

                    control.Refresh();
                }
            }
        }
示例#22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="g"></param>
        /// <param name="gradientRect"></param>
        /// <param name="bgColor"></param>
        /// <param name="fgColor"></param>
        /// <param name="style"></param>
        /// <param name="TextBoxBorder"></param>
        /// <param name="GradientFromColor"></param>
        /// <param name="GradientToColor"></param>
        /// <param name="GradientStyle"></param>
        /// <returns></returns>
        internal static void PaintBackGroundGradientMobile(Graphics g, Rectangle gradientRect, Color bgColor, Color fgColor,
                                                           ControlStyle style, bool textBoxBorder, GradientColor gradientColor,
                                                           GradientStyle gradientStyle)
        {
            //QCR #915016, enable has effect in foreground only
            // GradientFromColor = (enabled ? GradientFromColor : getGrayScaleColor(GradientFromColor));
            // GradientToColor = (enabled ? GradientToColor : getGrayScaleColor(GradientToColor));
            if (gradientStyle == GradientStyle.None)
            {
                Debug.Assert(false);
            }

            switch (gradientStyle)
            {
            case GradientStyle.Horizontal:
            case GradientStyle.HorizontalSymmetric:
            case GradientStyle.HorizontalWide:
                GradientFill.Fill(g, gradientRect, gradientColor.From, gradientColor.To,
                                  GradientFill.FillDirection.Vertical);
                break;

            case GradientStyle.Vertical:
            case GradientStyle.VerticalSymmetric:
            case GradientStyle.VerticalWide:
                GradientFill.Fill(g, gradientRect, gradientColor.From, gradientColor.To,
                                  GradientFill.FillDirection.Horizontal);
                break;

            case GradientStyle.CornerBottomRight:
            case GradientStyle.CornerBottomLeft:
            case GradientStyle.CornerTopLeft:
            case GradientStyle.CornerTopRight:
            case GradientStyle.Center:
                PaintBackgroundAndBorder(g, gradientRect, bgColor, fgColor, style, textBoxBorder, true);
                break;

            case GradientStyle.None://1
                //assert(false);
                break;

            default:
                break;
            }
        }
示例#23
0
        protected override void OnElementChanged(ElementChangedEventArgs <StackLayout> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }
            try
            {
                stack = e.NewElement as CustomLayout;

                this.StartColor    = stack.StartColor;
                this.EndColor      = stack.EndColor;
                this.gradientStyle = stack.GradientDirection;


                _cornerRadius = 0.0f;
                try
                {
                    if (stack.CornerWRT == CornerRadiusReference.WRTHeightRequest && stack.CornerRadius == 0)
                    {
                        _cornerRadius = (float)(stack.HeightRequest);
                    }
                    else if (stack.CornerWRT == CornerRadiusReference.WRTWidthRequest && stack.CornerRadius == 0)
                    {
                        _cornerRadius = (float)(stack.WidthRequest);
                    }
                    else
                    {
                        _cornerRadius = (float)(stack.CornerRadius);
                    }
                }
                catch (Exception ex)
                {
                    var msg = ex.Message;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(@"ERROR:", ex.Message);
            }
        }
示例#24
0
        private void lstGradientStyle_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (lstGradientStyle.SelectedIndex)
            {
            case 0:
                gradientStyle = GradientStyle.Reflect;
                break;

            case 1:
                gradientStyle = GradientStyle.Repeat;
                break;

            case 2:
                gradientStyle = GradientStyle.Pad;
                break;
            }
            if (drawer != null)
            {
                Draw();
            }
        }
示例#25
0
        /// <summary> paint control backgound and image</summary>
        /// <param name="control"></param>
        /// <param name="graphics"></param>
        /// <param name="useImageSize" - do the image will be display on all the control (for button image)></param>
        /// <param name="DisplayRect" - the display rect of the color></param>
        public static void PaintBackgoundColorAndImage(Control control, Graphics graphics, bool useImageSize, Rectangle DisplayRect)
        {
            Image         backgroundImage = null;
            GradientColor gradientColor   = ControlUtils.GetGradientColor(control);
            GradientStyle gradientStyle   = ControlUtils.GetGradientStyle(control);

            ControlRenderer.FillRectAccordingToGradientStyle(graphics, DisplayRect, control.BackColor,
                                                             control.ForeColor, ControlStyle.NoBorder,
                                                             false, gradientColor, gradientStyle);

#if !PocketPC
            backgroundImage = control.BackgroundImage;
#else
            if (control is ButtonBase)
            {
                ButtonBase button = (ButtonBase)control;
                backgroundImage = button.BackgroundImage;
            }
            else if (control is MgPanel)
            {
                MgPanel panel = (MgPanel)control;
                backgroundImage = panel.BackGroundImage;
            }
#endif

            if (backgroundImage != null)
            {
                Rectangle rectImage;
                if (useImageSize)
                {
                    rectImage = new Rectangle(DisplayRect.X, DisplayRect.Y, backgroundImage.Width, backgroundImage.Height);
                }
                else
                {
                    rectImage = control.ClientRectangle;
                }

                DrawImage(graphics, rectImage, backgroundImage, 0, 0);
            }
        }
示例#26
0
        //-----------------------------------------------------------------------------
        // set corner according to the to the sent gradientStyle and rect
        //-----------------------------------------------------------------------------
        private static void SetCorner(PathGradientBrush pthGrBrush, GradientStyle gradientStyle, Rectangle rect)
        {
            int x = rect.X;
            int y = rect.Y;

            switch (gradientStyle)
            {
            case GradientStyle.CornerBottomRight:
                x = rect.Right;
                y = rect.Bottom;
                break;

            case GradientStyle.CornerBottomLeft:
                x = rect.Left;
                y = rect.Bottom;
                break;

            case GradientStyle.CornerTopLeft:
                x = rect.Left;
                y = rect.Top;
                break;

            case GradientStyle.CornerTopRight:
                x = rect.Right;
                y = rect.Top;
                break;

            case GradientStyle.Center:
                x = rect.Left + ((rect.Width) / 2);
                y = rect.Top + ((rect.Height) / 2);
                break;

            default:
                // assert(FALSE);
                break;
            }

            pthGrBrush.CenterPoint = new Point(x, y);
        }
示例#27
0
        /// <summary>
        /// get the linear gradient mode according to the gradientStyle
        /// </summary>
        /// <param name="GradientStyle"></param>
        /// <returns></returns>
        private static LinearGradientMode GetLinearGradientMode(GradientStyle gradientStyle)
        {
            LinearGradientMode retLinearGradientMode = LinearGradientMode.Horizontal;

            switch (gradientStyle)
            {
            case GradientStyle.Horizontal:          //2
            case GradientStyle.HorizontalSymmetric: //3
                retLinearGradientMode = LinearGradientMode.Vertical;
                break;

            case GradientStyle.Vertical:          //5
            case GradientStyle.VerticalSymmetric: //6
                retLinearGradientMode = LinearGradientMode.Horizontal;
                break;

            case GradientStyle.DiagonalLeft:          //8
            case GradientStyle.DiagonalLeftSymmetric: //9
                retLinearGradientMode = LinearGradientMode.ForwardDiagonal;
                break;

            case GradientStyle.DiagonalRight:          //10
            case GradientStyle.DiagonalRightSymmetric: //11
                retLinearGradientMode = LinearGradientMode.BackwardDiagonal;
                break;

            case GradientStyle.CornerBottomRight: //15
            case GradientStyle.CornerBottomLeft:  //14
            case GradientStyle.Center:            //16
            case GradientStyle.None:              //1
            case GradientStyle.CornerTopLeft:     //12
            case GradientStyle.CornerTopRight:    //13
                //assert(false);
                break;
            }

            return(retLinearGradientMode);
        }
示例#28
0
        /// <summary>
        /// Draws 3D border.
        /// </summary>
        /// <param name="graph">Graphics to draw the border on.</param>
        /// <param name="borderSkin">Border skin object.</param>
        /// <param name="rect">Rectangle of the border.</param>
        /// <param name="backColor">Color of rectangle</param>
        /// <param name="backHatchStyle">Hatch style</param>
        /// <param name="backImage">Back Image</param>
        /// <param name="backImageWrapMode">Image mode</param>
        /// <param name="backImageTransparentColor">Image transparent color.</param>
        /// <param name="backImageAlign">Image alignment</param>
        /// <param name="backGradientStyle">Gradient type</param>
        /// <param name="backSecondaryColor">Gradient End Color</param>
        /// <param name="borderColor">Border Color</param>
        /// <param name="borderWidth">Border Width</param>
        /// <param name="borderDashStyle">Border Style</param>
        public virtual void DrawBorder(
            ChartGraphics graph,
            BorderSkin borderSkin,
            SKRect rect,
            SKColor backColor,
            ChartHatchStyle backHatchStyle,
            string backImage,
            ChartImageWrapMode backImageWrapMode,
            SKColor backImageTransparentColor,
            ChartImageAlignmentStyle backImageAlign,
            GradientStyle backGradientStyle,
            SKColor backSecondaryColor,
            SKColor borderColor,
            int borderWidth,
            ChartDashStyle borderDashStyle)
        {
            SKRect absolute = ChartGraphics.Round(rect);

            // Calculate shadow colors (0.2 - 0.6)
            float   colorDarkeningIndex = 0.2f + (0.4f * (borderSkin.PageColor.Red + borderSkin.PageColor.Green + borderSkin.PageColor.Blue) / 765f);
            SKColor shadowColor         = new(
                (byte)(borderSkin.PageColor.Red * colorDarkeningIndex),
                (byte)(borderSkin.PageColor.Green * colorDarkeningIndex),
                (byte)(borderSkin.PageColor.Blue * colorDarkeningIndex));

            if (borderSkin.PageColor == SKColors.Transparent)
            {
                shadowColor = new(0, 0, 0, 60);
            }

            colorDarkeningIndex += 0.2f;
            SKColor shadowLightColor = new(
                (byte)(borderSkin.PageColor.Red * colorDarkeningIndex),
                (byte)(borderSkin.PageColor.Green * colorDarkeningIndex),
                (byte)(borderSkin.PageColor.Blue * colorDarkeningIndex));

            // Calculate rounded rect radius
            float radius = defaultRadiusSize;

            radius = Math.Max(radius, 2f * resolution / 96.0f);
            radius = Math.Min(radius, rect.Width / 2f);
            radius = Math.Min(radius, rect.Height / 2f);
            radius = (float)Math.Ceiling(radius);

            // Fill page background color
            using (SKPaint brush = new() { Style = SKPaintStyle.Fill, Color = borderSkin.PageColor })
            {
                graph.FillRectangle(brush, rect);
            }

            // Top/Left shadow
            SKRect shadowRect = absolute;

            shadowRect.Right  -= radius * .3f;
            shadowRect.Bottom -= radius * .3f;
            graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius + 1 * resolution / 96.0f, shadowLightColor, borderSkin.PageColor, 1.4f);

            // Bottom/Right shadow
            shadowRect         = absolute;
            shadowRect.Left    = absolute.Left + radius / 3f;
            shadowRect.Top     = absolute.Top + radius / 3f;
            shadowRect.Right  -= radius / 3.5f;
            shadowRect.Bottom -= radius / 3.5f;
            graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius, shadowColor, borderSkin.PageColor, 1.3f);

            // Draw Background
            shadowRect         = absolute;
            shadowRect.Left    = absolute.Left + 3f * resolution / 96.0f;
            shadowRect.Top     = absolute.Top + 3f * resolution / 96.0f;
            shadowRect.Right  -= radius * .75f;
            shadowRect.Bottom -= radius * .75f;
            SKPath path = ChartGraphics.CreateRoundedRectPath(shadowRect, cornerRadius);

            graph.DrawPathAbs(
                path,
                backColor,
                backHatchStyle,
                backImage,
                backImageWrapMode,
                backImageTransparentColor,
                backImageAlign,
                backGradientStyle,
                backSecondaryColor,
                borderColor,
                borderWidth,
                borderDashStyle,
                PenAlignment.Inset);

            // Dispose Graphic path
            if (path != null)
            {
                path.Dispose();
            }

            // Bottom/Right inner shadow
            SKRegion innerShadowRegion = new(
                ChartGraphics.CreateRoundedRectPath(
                    new SKRect(
                        shadowRect.Left - radius,
                        shadowRect.Top - radius,
                        shadowRect.Width + radius - radius * 0.25f,
                        shadowRect.Height + radius - radius * 0.25f),
                    cornerRadius));

            innerShadowRegion.Op(ChartGraphics.CreateRoundedRectPath(shadowRect, cornerRadius), SKRegionOperation.Difference);
            graph.Clip = innerShadowRegion;
            graph.DrawRoundedRectShadowAbs(
                shadowRect,
                cornerRadius,
                radius,
                SKColors.Transparent,
                new(SKColors.Gray.Red, SKColors.Gray.Green, SKColors.Gray.Blue, 128),
                .5f);
            graph.Clip = new();
        }
示例#29
0
        /// <summary>
        /// paint the BackGround Gradient
        /// </summary>
        /// <param name="g"></param>
        /// <param name="gradientRect"></param>
        /// <param name="bgColor"></param>
        /// <param name="fgColor"></param>
        /// <param name="style"></param>
        /// <param name="TextBoxBorder"></param>
        /// <param name="GradientFromColor"></param>
        /// <param name="GradientToColor"></param>
        /// <param name="GradientStyle"></param>
        /// <returns></returns>
        public static void PaintBackGroundGradient(Graphics g, Rectangle gradientRect, Color bgColor, Color fgColor,
                                                   ControlStyle style, bool textBoxBorder, GradientColor gradientColor,
                                                   GradientStyle gradientStyle, bool paintRoundedRectangle, ulong cornerRadius)
        {
            if (gradientRect.Width <= 0 || gradientRect.Height <= 0)
            {
                return;
            }

#if PocketPC
            PaintBackGroundGradientMobile(g, gradientRect, bgColor, fgColor, style,
                                          textBoxBorder, gradientColor, gradientStyle);
#else
            //QCR #915016, enable has effect in foreground only
            //GradientFromColor = (enabled ? GradientFromColor : getGrayScaleColor(GradientFromColor));
            // GradientToColor = (enabled ? GradientToColor : getGrayScaleColor(GradientToColor));
            if (gradientStyle == GradientStyle.None)
            {
                Debug.Assert(false);
            }
            // Create a horizontal linear gradient with four stops.
            Blend blend = new Blend(3);
            blend.Factors   = new float[] { 0.0f, 0.75f, 1.0f };
            blend.Positions = new float[] { 0.0f, 0.5f, 1.0f };
            switch (gradientStyle)
            {
            case GradientStyle.HorizontalSymmetric:
            case GradientStyle.VerticalSymmetric:
            case GradientStyle.DiagonalLeftSymmetric:
            case GradientStyle.DiagonalRightSymmetric:
                blend.Factors[1] = 1.0f;
                blend.Factors[2] = 0.0f;
                break;
            }
            switch (gradientStyle)
            {
            case GradientStyle.HorizontalSymmetric:
            case GradientStyle.VerticalSymmetric:
            case GradientStyle.DiagonalLeftSymmetric:
            case GradientStyle.DiagonalRightSymmetric:
            case GradientStyle.Horizontal:
            case GradientStyle.Vertical:
            case GradientStyle.DiagonalLeft:
            case GradientStyle.DiagonalRight:
                LinearGradientBrush myHorizontalGradient1 = new LinearGradientBrush(gradientRect, gradientColor.From, gradientColor.To, GetLinearGradientMode(gradientStyle));
                myHorizontalGradient1.Blend           = blend;
                myHorizontalGradient1.GammaCorrection = true;
                // Use the brush to paint the rectangle.
                if (paintRoundedRectangle)
                {
                    GraphicsExtension.FillRoundedRectangle(g, myHorizontalGradient1, gradientRect.Left, gradientRect.Top, gradientRect.Width, gradientRect.Height, (int)cornerRadius);
                }
                else
                {
                    g.FillRectangle(myHorizontalGradient1, gradientRect);
                }
                break;

            case GradientStyle.VerticalWide:
            case GradientStyle.HorizontalWide:
            {
                // Create a path that consists of a single rectangle.
                GraphicsPath path = new GraphicsPath();
                /// Add the rectangle
                path.AddRectangle(gradientRect);
                // Use the path to construct a brush.
                PathGradientBrush pthGrBrush = new PathGradientBrush(path);
                // Set the center point to a location that is not the centroid of the path.
                if (gradientStyle == GradientStyle.HorizontalWide)
                {
                    pthGrBrush.FocusScales = new PointF(0.92f, 0.5f);
                }
                else if (gradientStyle == GradientStyle.VerticalWide)
                {
                    pthGrBrush.FocusScales = new PointF(0.5f, 0.92f);
                }
                // Set the color at the center point to blue.
                pthGrBrush.CenterColor = gradientColor.To;
                // Set the color along the entire boundary of the path to aqua.
                Color[] colors = new Color[] { gradientColor.From };
                pthGrBrush.SurroundColors = colors;
                //? pthGrBrush.GammaCorrection = true;
                // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=94101&wa=wsignin1.0
                if (paintRoundedRectangle)
                {
                    GraphicsExtension.FillRoundedRectangle(g, pthGrBrush, gradientRect.Left, gradientRect.Top, gradientRect.Width, gradientRect.Height, (int)cornerRadius);
                }
                else
                {
                    g.FillRectangle(pthGrBrush, gradientRect);
                }
            }
            break;

            case GradientStyle.CornerBottomRight:
            case GradientStyle.CornerBottomLeft:
            case GradientStyle.CornerTopLeft:
            case GradientStyle.CornerTopRight:
            case GradientStyle.Center:
            {
                // Create a path that consists of a single rectangle.
                GraphicsPath path = new GraphicsPath();
                /// Add the rectangle
                path.AddRectangle(gradientRect);
                // Use the path to construct a brush.
                PathGradientBrush pthGrBrush = new PathGradientBrush(path);
                // Set the center point to a location that is not the centroid of the path.
                SetCorner(pthGrBrush, gradientStyle, gradientRect);
                // Set the color at the center point to blue.
                pthGrBrush.CenterColor = gradientColor.From;
                // Set the color along the entire boundary of the path to aqua.
                Color[] colors = new Color[] { gradientColor.To };
                pthGrBrush.SurroundColors = colors;
                //? pthGrBrush.GammaCorrection = true;
                // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=94101&wa=wsignin1.0
                if (paintRoundedRectangle)
                {
                    GraphicsExtension.FillRoundedRectangle(g, pthGrBrush, gradientRect.Left, gradientRect.Top, gradientRect.Width, gradientRect.Height, (int)cornerRadius);
                }
                else
                {
                    g.FillRectangle(pthGrBrush, gradientRect);
                }
            }
            break;

            case GradientStyle.None:
                //assert(false);
                break;

            default:
                break;
            }
#endif
        }
 public void Set__Gradient_Style(Grid control, GradientStyle style = GradientStyle.HorizontalBlackToTransparent)
 {
     var brush = StyleResources.Colors[ToKey(style)] as Brush;
     border.Background = brush;
     currentGradientStyle = style;
 }
示例#31
0
        /// <summary>
        /// Build uint array (512 elements)
        /// </summary>
        /// <param name="mode">Reflect or Repeat mode.</param>
        internal uint[] Build(GradientStyle mode, uint opacity)
        {
            #region implementation to remove the aliased when repeat mode
            // when change
            if ((IsChangeStops) || (oldStyleMode != mode) || (opacity != oldOpacity))
            {
                if (mCount >= 2)
                {
                    #region build cache

                    uint[] destArray = CachedRepeatColor;
                    int i = 0;

                    int distance = 0;
                    int ik = 0;
                    uint beginColor = 0;
                    uint finishColor = 0;
                    uint beginColorAG = 0;
                    uint beginColorRB = 0;
                    uint finishColorAG = 0;
                    uint finishColorRB = 0;

                    if (mode != GradientStyle.Repeat)
                    {
                        #region when mode are reflect or pad
                        int start = (int)(mItems[0].mStop * NumberOfElementInDestArray + 0.5);
                        int end = 0;

                        // first color of gradient
                        uint color = mItems[0].Color.Data;
                        //apply opacity
                        color = ((((color >> 24) * opacity) >> 8) << 24) | (color & 0x00FFFFFF);

                        NoBlendingColor = true;
                        if ((color >> 24) < 255)
                        {
                            NoBlendingColor = false;
                        }
                        #region 0.0 -> this[0].offset
                        for (i = 0; i < start; i++)
                        {
                            destArray[i] = color;
                        }
                        #endregion
                        #region this[0].mStop -> this[Count-1].mStop
                        for (i = 1; i < Count; i++)
                        {
                            //temp = start;
                            end = (int)(mItems[i].mStop * NumberOfElementInDestArray + 0.5);
                            distance = end - start;

                            beginColor = mItems[i - 1].Color.Data;
                            finishColor = mItems[i].Color.Data;

                            //apply opacity
                            beginColor = ((((beginColor >> 24) * opacity) >> 8) << 24) | (beginColor & 0x00FFFFFF);
                            finishColor = ((((finishColor >> 24) * opacity) >> 8) << 24) | (finishColor & 0x00FFFFFF);

                            beginColorAG = ((beginColor >> 8) & 0x00FF00FF);
                            beginColorRB = (beginColor & 0x00FF00FF);

                            finishColorAG = ((finishColor >> 8) & 0x00FF00FF);
                            finishColorRB = (finishColor & 0x00FF00FF);

                            if ((finishColor >> 24) < 255)
                            {
                                NoBlendingColor = false;
                            }
                            while (start < end)
                            {
                                //result[start] = (this[i - 1].StopColor.Gradient(this[i].StopColor, (double)(start + distance - end) / distance)).Data;

                                ik = (int)(((double)(start + distance - end) / distance) * 256 + 0.5);
                                destArray[start] =
                                   ((((uint)(beginColorAG + (((finishColorAG - beginColorAG) * ik) >> 8)) << 8) & 0xFF00FF00) |
                                   ((uint)(beginColorRB + (((finishColorRB - beginColorRB) * ik) >> 8)) & 0x00FF00FF));

                                ++start;
                            }
                        }
                        #endregion
                        #region this[Count-1].offset -> 1.0
                        color = mItems[Count - 1].Color.Data;
                        //apply opacity
                        color = ((((color >> 24) * opacity) >> 8) << 24) | (color & 0x00FFFFFF);
                        if ((color >> 24) < 255)
                        {
                            NoBlendingColor = false;
                        }
                        for (; end < NumberOfElementInDestArray; end++)
                        {
                            destArray[end] = color;
                        }
                        #endregion
                        #endregion
                    }
                    else
                    {
                        #region when mode is repeat
                        int start = (int)(mItems[0].mStop * NumberOfElementInDestArrayInRepeatMode + 0.5);
                        int end = 0;

                        // first color of gradient
                        uint color = mItems[0].Color.Data;
                        //apply opacity
                        color = ((((color >> 24) * opacity) >> 8) << 24) | (color & 0x00FFFFFF);
                        NoBlendingColor = true;
                        if ((color >> 24) < 255)
                        {
                            NoBlendingColor = false;
                        }
                        #region 0.0 -> this[0].offset
                        for (i = 0; i < start; i++)
                        {
                            destArray[i] = color;
                        }
                        #endregion
                        #region this[0].mStop -> this[Count-1].mStop
                        for (i = 1; i < Count; i++)
                        {
                            //temp = start;
                            end = (int)(mItems[i].mStop * NumberOfElementInDestArrayInRepeatMode + 0.5);
                            distance = end - start;

                            beginColor = mItems[i - 1].Color.Data;
                            finishColor = mItems[i].Color.Data;
                            //apply opacity
                            beginColor = ((((beginColor >> 24) * opacity) >> 8) << 24) | (beginColor & 0x00FFFFFF);
                            finishColor = ((((finishColor >> 24) * opacity) >> 8) << 24) | (finishColor & 0x00FFFFFF);


                            beginColorAG = ((beginColor >> 8) & 0x00FF00FF);
                            beginColorRB = (beginColor & 0x00FF00FF);

                            finishColorAG = ((finishColor >> 8) & 0x00FF00FF);
                            finishColorRB = (finishColor & 0x00FF00FF);

                            if ((finishColor >> 24) < 255)
                            {
                                NoBlendingColor = false;
                            }
                            while (start < end)
                            {
                                //result[start] = (this[i - 1].StopColor.Gradient(this[i].StopColor, (double)(start + distance - end) / distance)).Data;

                                ik = (int)(((double)(start + distance - end) / distance) * 256 + 0.5);
                                destArray[start] =
                                   ((((uint)(beginColorAG + (((finishColorAG - beginColorAG) * ik) >> 8)) << 8) & 0xFF00FF00) |
                                   ((uint)(beginColorRB + (((finishColorRB - beginColorRB) * ik) >> 8)) & 0x00FF00FF));

                                ++start;
                            }
                        }
                        #endregion
                        #region this[Count-1].offset -> 1.0
                        color = mItems[Count - 1].Color.Data;
                        //apply opacity
                        color = ((((color >> 24) * opacity) >> 8) << 24) | (color & 0x00FFFFFF);
                        if ((color >> 24) < 255)
                        {
                            NoBlendingColor = false;
                        }
                        for (; start < NumberOfElementInDestArrayInRepeatMode; start++)
                        {
                            destArray[start] = color;
                        }
                        #endregion

                        #region the rest to make repeat mode more smooth
                        end = NumberOfElementInDestArray;
                        distance = end - start;

                        beginColor = mItems[mCount - 1].Color.Data;
                        finishColor = mItems[0].Color.Data;

                        beginColorAG = ((beginColor >> 8) & 0x00FF00FF);
                        beginColorRB = (beginColor & 0x00FF00FF);

                        finishColorAG = ((finishColor >> 8) & 0x00FF00FF);
                        finishColorRB = (finishColor & 0x00FF00FF);
                        while (start < end)
                        {
                            //result[start] = (this[i - 1].StopColor.Gradient(this[i].StopColor, (double)(start + distance - end) / distance)).Data;

                            ik = (int)(((double)(start + distance - end) / distance) * 256 + 0.5);
                            destArray[start] =
                               ((((uint)(beginColorAG + (((finishColorAG - beginColorAG) * ik) >> 8)) << 8) & 0xFF00FF00) |
                               ((uint)(beginColorRB + (((finishColorRB - beginColorRB) * ik) >> 8)) & 0x00FF00FF));

                            ++start;
                        }
                        #endregion
                        #endregion
                    }
                    #endregion

                    if (mode != GradientStyle.Pad)
                    {
                        // for repeat mode and reflect mode, need copy 256 element
                        Buffer.BlockCopy(CachedRepeatColor, 0, CachedRepeatColor, 256 * 4, 256 * 4);
                    }
                }

                if (opacity < 255)
                {
                    NoBlendingColor = false;
                }
                IsChangeStops = false;
                oldStyleMode = mode;
                oldOpacity = opacity;
                if (mode == GradientStyle.Reflect)
                {
                    //Buffer.BlockCopy(CachedRepeatColor, 0, CachedRepeatColor, 0, 256 * 4);
                    Buffer.BlockCopy(CachedRepeatColor, 0, CachedRepeatColor, 256 * 4, 256 * 4);
                    // reverve the back
                    Array.Reverse(CachedRepeatColor, 256, 256);
                }
            }
            return CachedRepeatColor;
            #endregion
        }
示例#32
0
 public GradientColorSetSimple(GradientStyle gradient_style, float rotate_angle)
 {
     this.gradient_style = gradient_style;
     this.rotate_angle   = rotate_angle;
 }
示例#33
0
        private void lstGradientStyle_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (lstGradientStyle.SelectedIndex)
            {
                case 0:
                    gradientStyle = GradientStyle.Reflect;
                    break;

                case 1:
                    gradientStyle = GradientStyle.Repeat;
                    break;

                case 2:
                    gradientStyle = GradientStyle.Pad;
                    break;
            }
            if (drawer != null) Draw();
        }
示例#34
0
 public static void SetGradientBackground(Control control, GradientStyle style)
 {
     if (control == null || control.IsDisposed) return;
     control.BackgroundImageLayout = ImageLayout.Stretch;
     control.BackgroundImage = style.GetImage(control.Size);
 }
示例#35
0
 void IFillFormat.OneColorGradient(GradientStyle style, int variant, float degree)
 {
     instance.GetType().InvokeMember("OneColorGradient", BindingFlags.InvokeMethod, null, instance, new object[] { style, variant, degree });
 }
示例#36
0
 void IFillFormat.TwoColorGradient(GradientStyle style, int variant)
 {
     instance.GetType().InvokeMember("TwoColorGradient", BindingFlags.InvokeMethod, null, instance, new object[] { style, variant });
 }
        /// <summary>
        /// Apply opacity
        /// </summary>
        /// <param name="rawColors">raw color array including 512 element</param>
        /// <param name="opacity">opacity</param>
        /// <returns>apply opacity</returns>
        protected uint[] ApplyOpacity(uint[] rawColors, uint opacity, GradientStyle gradientStyle)
        {
            uint[] result = new uint[rawColors.Length];
            for (int i = 0; i < 256; i++)
            {

            }
            return result;
        }
        protected void UpdateElement(CoreGraphics.CGRect rect)
        {
            RoundEdgeStackLayout stack = (RoundEdgeStackLayout)this.Element;
            CGColor startColor         = stack.StartColor.ToCGColor();
            CGColor endColor           = stack.EndColor.ToCGColor();

            try
            {
                //if(stack.HasBorderColor == true)
                //{

                //}
                //else if(stack.BorderColor != null)
                //{

                //}
                if (stack.HasBorderColor == true && stack.BorderColor.ToCGColor() != null)
                {
                    double min = Math.Min(Element.Width, Element.Height);
                    this.Layer.CornerRadius  = (float)(min / 2.0);
                    this.Layer.MasksToBounds = false;
                    this.Layer.BorderColor   = stack.BorderColor.ToCGColor();
                    this.Layer.BorderWidth   = Convert.ToSingle(stack.BorderThickness);
                    this.ClipsToBounds       = true;
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
                //Debug.WriteLine("Unable to create circle image: " + ex);
            }

            var           gradientLayer = new CAGradientLayer();
            GradientStyle gradientStyle = stack.GradientDirection;

            if (gradientStyle != GradientStyle.None)
            {
                if (gradientStyle == GradientStyle.Vertical)
                {
                }
                else if (gradientStyle == GradientStyle.Horizontal)
                {
                    gradientLayer.StartPoint = new CGPoint(0, 0.5);
                    gradientLayer.EndPoint   = new CGPoint(1, 0.5);
                }
                else if (gradientStyle == GradientStyle.Inclined)
                {
                    gradientLayer.StartPoint = new CGPoint(0, 0.5);
                    gradientLayer.EndPoint   = new CGPoint(1, 0.5);
                }
                else
                {
                }
            }

            nfloat cornerRadius = 0.0f;

            try
            {
                if (stack.CornerWRT == CornerRadiusReference.WRTHeightRequest && stack.CornerRadius == 0)
                {
                    cornerRadius = (float)(stack.HeightRequest / 2);
                }
                else if (stack.CornerWRT == CornerRadiusReference.WRTWidthRequest && stack.CornerRadius == 0)
                {
                    cornerRadius = (float)(stack.WidthRequest / 2);
                }
                else
                {
                    cornerRadius = (float)(stack.CornerRadius);
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }

            gradientLayer.Frame  = rect;
            gradientLayer.Colors = new CGColor[] { startColor, endColor };
            gradientLayer.ModelLayer.CornerRadius = cornerRadius;//(float)(stack.CornerRadius);
            NativeView.Layer.InsertSublayer(gradientLayer, 0);
        }