public void SetAttributes(DataPointAttributes attrib, bool area3D)
        {
            this.borderColor            = attrib.BorderColor;
            this.borderWidth            = attrib.BorderWidth;
            this.borderStyle            = attrib.BorderStyle;
            this.markerStyle            = attrib.MarkerStyle;
            this.markerSize             = attrib.MarkerSize;
            this.markerImage            = attrib.MarkerImage;
            this.markerImageTranspColor = attrib.MarkerImageTransparentColor;
            this.markerColor            = attrib.MarkerColor;
            this.markerBorderColor      = attrib.MarkerBorderColor;
            this.markerBorderWidth      = attrib.MarkerBorderWidth;
            float num = 96f;

            if (this.common != null)
            {
                num = this.common.graph.Graphics.DpiX;
            }
            int num2 = (int)Math.Round(2.0 * num / 96.0);

            if (this.markerBorderWidth > num2)
            {
                this.markerBorderWidth = num2;
            }
            if (attrib.MarkerBorderWidth <= 0)
            {
                this.markerBorderColor = Color.Transparent;
            }
            if (this.style == LegendImageStyle.Line && this.borderWidth <= (int)Math.Round(num / 96.0))
            {
                this.borderWidth = num2;
            }
            if (!area3D)
            {
                this.backGradientType     = attrib.BackGradientType;
                this.backGradientEndColor = attrib.BackGradientEndColor;
                this.backImageTranspColor = attrib.BackImageTransparentColor;
                this.backImage            = attrib.BackImage;
                this.backImageMode        = attrib.BackImageMode;
                this.backImageAlign       = attrib.BackImageAlign;
                this.backHatchStyle       = attrib.BackHatchStyle;
            }
        }
        internal void SetAttributes(DataPointAttributes attrib, bool area3D)
        {
            borderColor            = attrib.BorderColor;
            borderWidth            = attrib.BorderWidth;
            borderStyle            = attrib.BorderStyle;
            markerStyle            = attrib.MarkerStyle;
            markerSize             = attrib.MarkerSize;
            markerImage            = attrib.MarkerImage;
            markerImageTranspColor = attrib.MarkerImageTransparentColor;
            markerColor            = attrib.MarkerColor;
            markerBorderColor      = attrib.MarkerBorderColor;
            markerBorderWidth      = attrib.MarkerBorderWidth;
            float num = 96f;

            if (common != null)
            {
                num = common.graph.Graphics.DpiX;
            }
            int num2 = (int)Math.Round(2f * num / 96f);

            if (markerBorderWidth > num2)
            {
                markerBorderWidth = num2;
            }
            if (attrib.MarkerBorderWidth <= 0)
            {
                markerBorderColor = Color.Transparent;
            }
            if (style == LegendImageStyle.Line && borderWidth <= (int)Math.Round(num / 96f))
            {
                borderWidth = num2;
            }
            if (!area3D)
            {
                backGradientType     = attrib.BackGradientType;
                backGradientEndColor = attrib.BackGradientEndColor;
                backImageTranspColor = attrib.BackImageTransparentColor;
                backImage            = attrib.BackImage;
                backImageMode        = attrib.BackImageMode;
                backImageAlign       = attrib.BackImageAlign;
                backHatchStyle       = attrib.BackHatchStyle;
            }
        }
Exemple #3
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();
        }
        private void ChartAppearanceChange()
        {
            // Enable/disable appearance controls
            ForeColorCom.Enabled  = (HatchStyle.SelectedIndex != 0 || Gradient.SelectedIndex != 0);
            BorderColor.Enabled   = (BorderDashStyle.SelectedIndex != 0);
            BorderSizeCom.Enabled = (BorderDashStyle.SelectedIndex != 0);

            // Set Back Color
            Chart1.BackColor = Color.FromName(BackColorCom.GetItemText(BackColorCom.SelectedItem));

            // Set Back Gradient End Color
            Chart1.BackSecondaryColor = Color.FromName(ForeColorCom.GetItemText(ForeColorCom.SelectedItem));

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

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

            // Set background image
            if (!ShowImageCheck.Checked)
            {
                Chart1.BackImage   = "";
                ImageAlign.Enabled = false;
                ImageMode.Enabled  = false;
            }
            else
            {
                ImageMode.Enabled  = true;
                ImageAlign.Enabled = (ImageMode.SelectedIndex == 5);

                // Set chart image
                MainForm mainForm      = (MainForm)this.ParentForm;
                string   imageFileName = mainForm.CurrentSamplePath;
                imageFileName   += "\\Flag.gif";
                Chart1.BackImage = imageFileName;
                Chart1.BackImageTransparentColor = Color.Red;

                // Set Image Mode
                if (ImageMode.SelectedItem != null)
                {
                    Chart1.BackImageWrapMode = (ChartImageWrapMode)ChartImageWrapMode.Parse(typeof(ChartImageWrapMode), ImageMode.SelectedItem.ToString());
                }

                // Set Image Alignment
                if (ImageAlign.SelectedItem != null)
                {
                    Chart1.BackImageAlignment = (ChartImageAlignmentStyle)ChartImageAlignmentStyle.Parse(typeof(ChartImageAlignmentStyle), ImageAlign.SelectedItem.ToString());
                }
            }

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

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

            // Set Border Color
            Chart1.BorderColor = Color.FromName(BorderColor.GetItemText(BorderColor.SelectedItem));
        }
Exemple #5
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,
            RectangleF rect,
            Color backColor,
            ChartHatchStyle backHatchStyle,
            string backImage,
            ChartImageWrapMode backImageWrapMode,
            Color backImageTransparentColor,
            ChartImageAlignmentStyle backImageAlign,
            GradientStyle backGradientStyle,
            Color backSecondaryColor,
            Color borderColor,
            int borderWidth,
            ChartDashStyle borderDashStyle)
        {
            RectangleF absolute   = graph.Round(rect);
            RectangleF shadowRect = absolute;

            // Calculate shadow colors (0.2 - 0.6)
            float colorDarkeningIndex = 0.3f + (0.4f * (borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765f);
            Color shadowColor         = Color.FromArgb(
                (int)(backColor.R * colorDarkeningIndex),
                (int)(backColor.G * colorDarkeningIndex),
                (int)(backColor.B * colorDarkeningIndex));

            colorDarkeningIndex += 0.2f;
            Color shadowLightColor = Color.FromArgb(
                (int)(borderSkin.PageColor.R * colorDarkeningIndex),
                (int)(borderSkin.PageColor.G * colorDarkeningIndex),
                (int)(borderSkin.PageColor.B * colorDarkeningIndex));

            if (borderSkin.PageColor == Color.Transparent)
            {
                shadowLightColor = Color.FromArgb(60, 0, 0, 0);
            }

            // Calculate rounded rect radius
            float radius = defaultRadiusSize;

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

            // Fill page background color
            using (Brush brush = new SolidBrush(borderSkin.PageColor))
            {
                graph.FillRectangle(brush, rect);
            }

            if (drawOutsideTopLeftShadow)
            {
                // Top/Left outside shadow
                shadowRect         = absolute;
                shadowRect.X      -= radius * 0.3f;
                shadowRect.Y      -= radius * 0.3f;
                shadowRect.Width  -= radius * .3f;
                shadowRect.Height -= radius * .3f;
                graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius, Color.FromArgb(128, Color.Black), borderSkin.PageColor, outsideShadowRate);
            }

            // Bottom/Right outside shadow
            shadowRect         = absolute;
            shadowRect.X      += radius * 0.3f;
            shadowRect.Y      += radius * 0.3f;
            shadowRect.Width  -= radius * .3f;
            shadowRect.Height -= radius * .3f;
            graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius, shadowLightColor, borderSkin.PageColor, outsideShadowRate);

            // Background
            shadowRect         = absolute;
            shadowRect.Width  -= radius * .3f;
            shadowRect.Height -= radius * .3f;
            GraphicsPath path = graph.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();
            }

            // Draw ----s imitation in the corners of the farame
            if (drawScrews)
            {
                // Left/Top ----
                RectangleF screwRect = RectangleF.Empty;
                float      offset    = radius * 0.4f;
                screwRect.X      = shadowRect.X + offset;
                screwRect.Y      = shadowRect.Y + offset;
                screwRect.Width  = radius * 0.55f;
                screwRect.Height = screwRect.Width;
                DrawScrew(graph, screwRect);

                // Right/Top ----
                screwRect.X = shadowRect.Right - offset - screwRect.Width;
                DrawScrew(graph, screwRect);

                // Right/Bottom ----
                screwRect.X = shadowRect.Right - offset - screwRect.Width;
                screwRect.Y = shadowRect.Bottom - offset - screwRect.Height;
                DrawScrew(graph, screwRect);

                // Left/Bottom ----
                screwRect.X = shadowRect.X + offset;
                screwRect.Y = shadowRect.Bottom - offset - screwRect.Height;
                DrawScrew(graph, screwRect);
            }

            // Bottom/Right inner shadow
            Region innerShadowRegion = null;

            if (drawBottomShadow)
            {
                shadowRect         = absolute;
                shadowRect.Width  -= radius * .3f;
                shadowRect.Height -= radius * .3f;
                innerShadowRegion  = new Region(
                    graph.CreateRoundedRectPath(
                        new RectangleF(
                            shadowRect.X - radius,
                            shadowRect.Y - radius,
                            shadowRect.Width + 0.5f * radius,
                            shadowRect.Height + 0.5f * radius),
                        cornerRadius));
                innerShadowRegion.Complement(graph.CreateRoundedRectPath(shadowRect, cornerRadius));
                graph.Clip = innerShadowRegion;

                shadowRect.X      -= 0.5f * radius;
                shadowRect.Width  += 0.5f * radius;
                shadowRect.Y      -= 0.5f * radius;
                shadowRect.Height += 0.5f * radius;

                graph.DrawRoundedRectShadowAbs(
                    shadowRect,
                    cornerRadius,
                    radius,
                    Color.Transparent,
                    Color.FromArgb(175, (sunken) ? Color.White : shadowColor),
                    1.0f);
                graph.Clip = new Region();
            }

            // Top/Left inner shadow
            shadowRect         = absolute;
            shadowRect.Width  -= radius * .3f;
            shadowRect.Height -= radius * .3f;
            innerShadowRegion  = new Region(
                graph.CreateRoundedRectPath(
                    new RectangleF(
                        shadowRect.X + radius * .5f,
                        shadowRect.Y + radius * .5f,
                        shadowRect.Width - .2f * radius,
                        shadowRect.Height - .2f * radius),
                    cornerRadius));

            RectangleF shadowWithOffset = shadowRect;

            shadowWithOffset.Width  += radius;
            shadowWithOffset.Height += radius;
            innerShadowRegion.Complement(graph.CreateRoundedRectPath(shadowWithOffset, cornerRadius));

            innerShadowRegion.Intersect(graph.CreateRoundedRectPath(shadowRect, cornerRadius));
            graph.Clip = innerShadowRegion;
            graph.DrawRoundedRectShadowAbs(
                shadowWithOffset,
                cornerRadius,
                radius,
                Color.Transparent,
                Color.FromArgb(175, (sunken) ? shadowColor : Color.White),
                1.0f);
            graph.Clip = new Region();
        }
Exemple #6
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 override void DrawBorder(
            ChartGraphics graph,
            BorderSkin borderSkin,
            RectangleF rect,
            Color backColor,
            ChartHatchStyle backHatchStyle,
            string backImage,
            ChartImageWrapMode backImageWrapMode,
            Color backImageTransparentColor,
            ChartImageAlignmentStyle backImageAlign,
            GradientStyle backGradientStyle,
            Color backSecondaryColor,
            Color borderColor,
            int borderWidth,
            ChartDashStyle borderDashStyle)
        {
            drawBottomShadow         = true;
            sunken                   = false;
            outsideShadowRate        = .9f;
            drawOutsideTopLeftShadow = false;
            bool oldScrewsFlag = this.drawScrews;

            this.drawScrews = false;
            base.DrawBorder(
                graph,
                borderSkin,
                rect,
                borderSkin.BackColor,
                borderSkin.BackHatchStyle,
                borderSkin.BackImage,
                borderSkin.BackImageWrapMode,
                borderSkin.BackImageTransparentColor,
                borderSkin.BackImageAlignment,
                borderSkin.BackGradientStyle,
                borderSkin.BackSecondaryColor,
                borderSkin.BorderColor,
                borderSkin.BorderWidth,
                borderSkin.BorderDashStyle);

            this.drawScrews = oldScrewsFlag;
            rect.X         += sizeLeftTop.Width;
            rect.Y         += sizeLeftTop.Height;
            rect.Width     -= sizeRightBottom.Width + sizeLeftTop.Width;
            rect.Height    -= sizeRightBottom.Height + sizeLeftTop.Height;
            if (rect.Width > 0 && rect.Height > 0)
            {
                float[] oldCorners = new float[8];
                oldCorners               = (float[])cornerRadius.Clone();
                cornerRadius             = innerCorners;
                drawBottomShadow         = false;
                sunken                   = true;
                drawOutsideTopLeftShadow = true;
                outsideShadowRate        = 1.4f;
                Color oldPageColor = borderSkin.PageColor;
                borderSkin.PageColor = Color.Transparent;
                base.DrawBorder(
                    graph,
                    borderSkin,
                    rect,
                    backColor,
                    backHatchStyle,
                    backImage,
                    backImageWrapMode,
                    backImageTransparentColor,
                    backImageAlign,
                    backGradientStyle,
                    backSecondaryColor,
                    borderColor,
                    borderWidth,
                    borderDashStyle);
                borderSkin.PageColor = oldPageColor;
                cornerRadius         = oldCorners;
            }
        }
Exemple #7
0
        public static void SetChartArea(ChartArea chartArea
                                        , Color backColor
                                        , Color backGradientEndColor
                                        , Color borderColor
                                        , ChartDashStyle borderStyle
                                        , int borderWidth
                                        , ChartHatchStyle chartHatchStyle
                                        , GradientType gradientType
                                        , int shadowOffset
                                        , Color shadowColor
                                        , bool enable3D
                                        , string backImage
                                        , ChartImageAlign chartImageAlign
                                        , ChartImageWrapMode chartImageWrapMode
                                        , Color backImageTranspColor)
        {
            if (!backColor.Equals(Color.Empty))
            {
                chartArea.BackColor = backColor;
            }
            if (!backGradientEndColor.Equals(Color.Empty))
            {
                chartArea.BackGradientEndColor = backGradientEndColor;
            }
            if (!borderColor.Equals(Color.Empty))
            {
                chartArea.BorderColor = borderColor;
            }

            chartArea.BorderStyle = borderStyle;

            if (borderWidth != -1)
            {
                chartArea.BorderWidth = borderWidth;
            }
            if (chartHatchStyle != ChartHatchStyle.None)
            {
                chartArea.BackHatchStyle = chartHatchStyle;
            }
            if (gradientType != GradientType.None)
            {
                chartArea.BackGradientType = gradientType;
            }

            if (shadowOffset != -1)
            {
                chartArea.ShadowOffset = shadowOffset;
            }
            if (!shadowColor.Equals(Color.Empty))
            {
                chartArea.ShadowColor = shadowColor;
            }

            chartArea.Area3DStyle.Enable3D = enable3D;

            if (backImage != null)
            {
                chartArea.BackImage      = backImage;
                chartArea.BackImageAlign = chartImageAlign;
                chartArea.BackImageMode  = chartImageWrapMode;
                if (!backImageTranspColor.Equals(Color.Empty))
                {
                    chartArea.BackImageTranspColor = backImageTranspColor;
                }
            }
        }
Exemple #8
0
        public static void DundasChartBase(Chart chart
                                           , ChartImageType chartImageType
                                           , int width
                                           , int height
                                           , BorderSkinStyle borderSkinStyle
                                           , Color borderLineColor
                                           , int borderLineWidth
                                           , Color backColor
                                           , Color backGradientEndColor
                                           , Color borderColor
                                           , ChartDashStyle borderStyle
                                           , int borderWidth
                                           , ChartHatchStyle chartHatchStyle
                                           , GradientType gradientType
                                           , AntiAliasing antiAliasing
                                           , string backImage
                                           , ChartImageWrapMode backImageMode
                                           , ChartImageAlign backImageAlign
                                           , Color backImageTranspColor)
        {
            chart.ImageType = chartImageType;

            if (width != -1)
            {
                chart.Width = width;
            }

            if (height != -1)
            {
                chart.Height = height;
            }

            if (borderSkinStyle != BorderSkinStyle.None)
            {
                chart.BorderSkin.SkinStyle = borderSkinStyle;
            }

            if (!borderLineColor.Equals(Color.Empty))
            {
                chart.BorderLineColor = borderLineColor;
            }

            if (borderLineWidth != -1)
            {
                chart.BorderLineWidth = borderLineWidth;
            }

            if (!backColor.Equals(Color.Empty))
            {
                chart.BackColor = backColor;
            }
            // Set Back Gradient End Color
            if (!backGradientEndColor.Equals(Color.Empty))
            {
                chart.BackGradientEndColor = backGradientEndColor;
            }

            // Set Hatch Style
            // Set Border Color
            if (!borderColor.Equals(Color.Empty))
            {
                chart.BorderColor = borderColor;
            }
            // Set Border Style
            if (borderStyle != ChartDashStyle.NotSet)
            {
                chart.BorderStyle = borderStyle;
            }
            // Set Border Width
            if (borderWidth != -1)
            {
                chart.BorderWidth = borderWidth;
            }

            if (chartHatchStyle != ChartHatchStyle.None)
            {
                chart.BackHatchStyle = chartHatchStyle;
            }
            if (gradientType != GradientType.None)
            {
                chart.BackGradientType = gradientType;
            }

            if (antiAliasing != AntiAliasing.None)
            {
                chart.AntiAliasing = antiAliasing;
            }

            if (backImage != null)
            {
                chart.BackImage      = backImage;
                chart.BackImageMode  = backImageMode;
                chart.BackImageAlign = backImageAlign;

                if (!backImageTranspColor.Equals(Color.Empty))
                {
                    chart.BackImageTranspColor = backImageTranspColor;
                }
            }
        }
        public virtual void DrawBorder(ChartGraphics graph, BorderSkinAttributes borderSkin, RectangleF rect, Color backColor, ChartHatchStyle backHatchStyle, string backImage, ChartImageWrapMode backImageMode, Color backImageTranspColor, ChartImageAlign backImageAlign, GradientType backGradientType, Color backGradientEndColor, Color borderColor, int borderWidth, ChartDashStyle borderStyle)
        {
            RectangleF rectangleF  = graph.Round(rect);
            RectangleF rectangleF2 = rectangleF;
            float      num         = (float)(0.30000001192092896 + 0.40000000596046448 * (float)(borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765.0);
            Color      color       = Color.FromArgb((int)((float)(int)backColor.R * num), (int)((float)(int)backColor.G * num), (int)((float)(int)backColor.B * num));

            num = (float)(num + 0.20000000298023224);
            Color centerColor = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num));

            if (borderSkin.PageColor == Color.Transparent)
            {
                centerColor = Color.FromArgb(60, 0, 0, 0);
            }
            Color.FromArgb((int)((float)(int)backColor.R * num), (int)((float)(int)backColor.G * num), (int)((float)(int)backColor.B * num));
            float val = this.defaultRadiusSize;

            val = Math.Max(val, (float)(2.0 * this.resolution / 96.0));
            val = Math.Min(val, (float)(rect.Width / 2.0));
            val = Math.Min(val, (float)(rect.Height / 2.0));
            val = (float)Math.Ceiling((double)val);
            graph.FillRectangle(new SolidBrush(borderSkin.PageColor), rect);
            if (this.drawOutsideTopLeftShadow)
            {
                rectangleF2         = rectangleF;
                rectangleF2.X      -= (float)(val * 0.30000001192092896);
                rectangleF2.Y      -= (float)(val * 0.30000001192092896);
                rectangleF2.Width  -= (float)(val * 0.30000001192092896);
                rectangleF2.Height -= (float)(val * 0.30000001192092896);
                graph.DrawRoundedRectShadowAbs(rectangleF2, this.cornerRadius, val, Color.FromArgb(128, Color.Black), borderSkin.PageColor, this.outsideShadowRate);
            }
            rectangleF2         = rectangleF;
            rectangleF2.X      += (float)(val * 0.30000001192092896);
            rectangleF2.Y      += (float)(val * 0.30000001192092896);
            rectangleF2.Width  -= (float)(val * 0.30000001192092896);
            rectangleF2.Height -= (float)(val * 0.30000001192092896);
            graph.DrawRoundedRectShadowAbs(rectangleF2, this.cornerRadius, val, centerColor, borderSkin.PageColor, this.outsideShadowRate);
            rectangleF2         = rectangleF;
            rectangleF2.Width  -= (float)(val * 0.30000001192092896);
            rectangleF2.Height -= (float)(val * 0.30000001192092896);
            GraphicsPath graphicsPath = graph.CreateRoundedRectPath(rectangleF2, this.cornerRadius);

            graph.DrawPathAbs(graphicsPath, backColor, backHatchStyle, backImage, backImageMode, backImageTranspColor, backImageAlign, backGradientType, backGradientEndColor, borderColor, borderWidth, borderStyle, PenAlignment.Inset);
            if (graphicsPath != null)
            {
                graphicsPath.Dispose();
            }
            if (this.drawScrews)
            {
                RectangleF empty = RectangleF.Empty;
                float      num2  = (float)(val * 0.40000000596046448);
                empty.X      = rectangleF2.X + num2;
                empty.Y      = rectangleF2.Y + num2;
                empty.Width  = (float)(val * 0.550000011920929);
                empty.Height = empty.Width;
                this.DrawScrew(graph, empty);
                empty.X = rectangleF2.Right - num2 - empty.Width;
                this.DrawScrew(graph, empty);
                empty.X = rectangleF2.Right - num2 - empty.Width;
                empty.Y = rectangleF2.Bottom - num2 - empty.Height;
                this.DrawScrew(graph, empty);
                empty.X = rectangleF2.X + num2;
                empty.Y = rectangleF2.Bottom - num2 - empty.Height;
                this.DrawScrew(graph, empty);
            }
            Region region = null;

            if (this.drawBottomShadow)
            {
                rectangleF2         = rectangleF;
                rectangleF2.Width  -= (float)(val * 0.30000001192092896);
                rectangleF2.Height -= (float)(val * 0.30000001192092896);
                region              = new Region(graph.CreateRoundedRectPath(new RectangleF(rectangleF2.X - val, rectangleF2.Y - val, (float)(rectangleF2.Width + 0.5 * val), (float)(rectangleF2.Height + 0.5 * val)), this.cornerRadius));
                region.Complement(graph.CreateRoundedRectPath(rectangleF2, this.cornerRadius));
                graph.Clip          = region;
                rectangleF2.X      -= (float)(0.5 * val);
                rectangleF2.Width  += (float)(0.5 * val);
                rectangleF2.Y      -= (float)(0.5 * val);
                rectangleF2.Height += (float)(0.5 * val);
                graph.DrawRoundedRectShadowAbs(rectangleF2, this.cornerRadius, val, Color.Transparent, Color.FromArgb(175, this.sunken ? Color.White : color), 1f);
                graph.Clip = new Region();
            }
            rectangleF2         = rectangleF;
            rectangleF2.Width  -= (float)(val * 0.30000001192092896);
            rectangleF2.Height -= (float)(val * 0.30000001192092896);
            region              = new Region(graph.CreateRoundedRectPath(new RectangleF((float)(rectangleF2.X + val * 0.5), (float)(rectangleF2.Y + val * 0.5), (float)(rectangleF2.Width - 0.20000000298023224 * val), (float)(rectangleF2.Height - 0.20000000298023224 * val)), this.cornerRadius));
            RectangleF rect2 = rectangleF2;

            rect2.Width  += val;
            rect2.Height += val;
            region.Complement(graph.CreateRoundedRectPath(rect2, this.cornerRadius));
            region.Intersect(graph.CreateRoundedRectPath(rectangleF2, this.cornerRadius));
            graph.Clip = region;
            graph.DrawRoundedRectShadowAbs(rect2, this.cornerRadius, val, Color.Transparent, Color.FromArgb(175, this.sunken ? color : Color.White), 1f);
            graph.Clip = new Region();
        }
Exemple #10
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!this.IsPostBack)
            {
                // Add Hatch styles to control.
                foreach (string colorName in Enum.GetNames(typeof(ChartHatchStyle)))
                {
                    HatchStyle.Items.Add(colorName);
                }
                HatchStyle.Items[0].Selected = true;

                // Add Chart Gradient types to control.
                foreach (string colorName in Enum.GetNames(typeof(GradientStyle)))
                {
                    Gradient.Items.Add(colorName);
                }

                // Add Chart Line styles to control.
                foreach (string colorName in Enum.GetNames(typeof(ChartDashStyle)))
                {
                    BorderDashStyle.Items.Add(colorName);
                }

                BorderDashStyle.Items.FindByValue("Solid").Selected = true;

                // Add Image Mode
                foreach (string item in Enum.GetNames(typeof(ChartImageWrapMode)))
                {
                    ImageMode.Items.Add(item);
                }
                ImageMode.SelectedIndex = 5;

                // Add Image Aligne
                foreach (string item in Enum.GetNames(typeof(ChartImageAlignmentStyle)))
                {
                    ImageAlign1.Items.Add(item);
                }
                ImageAlign1.SelectedIndex = 2;
            }

            // Set Back Color
            Chart1.BackColor = Color.FromName(BackColor.SelectedItem.Value);

            // Set Back Gradient End Color
            Chart1.BackSecondaryColor = Color.FromName(ForeColor.SelectedItem.Value);

            // Set Hatch Style
            Chart1.BackHatchStyle = (ChartHatchStyle)ChartHatchStyle.Parse(typeof(ChartHatchStyle), HatchStyle.SelectedItem.Text);

            // Set Gradient Type
            Chart1.BackGradientStyle = (GradientStyle)GradientStyle.Parse(typeof(GradientStyle), Gradient.SelectedItem.Text);

            // Set Border Color
            Chart1.BorderColor = Color.FromName(BorderColor.SelectedItem.Value);

            // Set Border Style
            Chart1.BorderlineDashStyle = (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), BorderDashStyle.SelectedItem.Text);

            // Set Border Width
            Chart1.BorderWidth = int.Parse(BorderSize.SelectedItem.Value);

            // Chart Image Mode
            Chart1.BackImageWrapMode = (ChartImageWrapMode)ChartImageWrapMode.Parse(typeof(ChartImageWrapMode), ImageMode.SelectedItem.Text);

            // Chart Image Align
            Chart1.BackImageAlignment = (ChartImageAlignmentStyle)ChartImageAlignmentStyle.Parse(typeof(ChartImageAlignmentStyle), ImageAlign1.SelectedItem.Text);

            // Disable secondary back color if gradient and hatching are not used
            ForeColor.Enabled = (HatchStyle.SelectedIndex != 0 || Gradient.SelectedIndex != 0);

            // Set Image
            ImageAlign1.Enabled = false;
            ImageMode.Enabled   = Image1.Checked;
            if (Image1.Checked)
            {
                Chart1.BackImage = "Flag.gif";
                Chart1.BackImageTransparentColor = Color.White;
                if (ImageMode.SelectedItem.Value == "Unscaled")
                {
                    ImageAlign1.Enabled = true;
                }
            }
            else
            {
                Chart1.BackImage = "";
            }

            // Enable/disable border attributes
            BorderColor.Enabled = (BorderDashStyle.SelectedIndex != 0);
            BorderSize.Enabled  = (BorderDashStyle.SelectedIndex != 0);
        }
        public virtual void DrawBorder(ChartGraphics graph, BorderSkinAttributes borderSkin, RectangleF rect, Color backColor, ChartHatchStyle backHatchStyle, string backImage, ChartImageWrapMode backImageMode, Color backImageTranspColor, ChartImageAlign backImageAlign, GradientType backGradientType, Color backGradientEndColor, Color borderColor, int borderWidth, ChartDashStyle borderStyle)
        {
            RectangleF rectangleF  = graph.Round(rect);
            RectangleF rectangleF2 = rectangleF;
            float      num         = 0.3f + 0.4f * (float)(borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765f;
            Color      color       = Color.FromArgb((int)((float)(int)backColor.R * num), (int)((float)(int)backColor.G * num), (int)((float)(int)backColor.B * num));

            num += 0.2f;
            Color centerColor = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num));

            if (borderSkin.PageColor == Color.Transparent)
            {
                centerColor = Color.FromArgb(60, 0, 0, 0);
            }
            Color.FromArgb((int)((float)(int)backColor.R * num), (int)((float)(int)backColor.G * num), (int)((float)(int)backColor.B * num));
            float val = defaultRadiusSize;

            val = Math.Max(val, 2f * resolution / 96f);
            val = Math.Min(val, rect.Width / 2f);
            val = Math.Min(val, rect.Height / 2f);
            val = (float)Math.Ceiling(val);
            graph.FillRectangle(new SolidBrush(borderSkin.PageColor), rect);
            if (drawOutsideTopLeftShadow)
            {
                rectangleF2         = rectangleF;
                rectangleF2.X      -= val * 0.3f;
                rectangleF2.Y      -= val * 0.3f;
                rectangleF2.Width  -= val * 0.3f;
                rectangleF2.Height -= val * 0.3f;
                graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val, Color.FromArgb(128, Color.Black), borderSkin.PageColor, outsideShadowRate);
            }
            rectangleF2         = rectangleF;
            rectangleF2.X      += val * 0.3f;
            rectangleF2.Y      += val * 0.3f;
            rectangleF2.Width  -= val * 0.3f;
            rectangleF2.Height -= val * 0.3f;
            graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val, centerColor, borderSkin.PageColor, outsideShadowRate);
            rectangleF2         = rectangleF;
            rectangleF2.Width  -= val * 0.3f;
            rectangleF2.Height -= val * 0.3f;
            GraphicsPath graphicsPath = graph.CreateRoundedRectPath(rectangleF2, cornerRadius);

            graph.DrawPathAbs(graphicsPath, backColor, backHatchStyle, backImage, backImageMode, backImageTranspColor, backImageAlign, backGradientType, backGradientEndColor, borderColor, borderWidth, borderStyle, PenAlignment.Inset);
            graphicsPath?.Dispose();
            if (drawScrews)
            {
                RectangleF empty = RectangleF.Empty;
                float      num2  = val * 0.4f;
                empty.X      = rectangleF2.X + num2;
                empty.Y      = rectangleF2.Y + num2;
                empty.Width  = val * 0.55f;
                empty.Height = empty.Width;
                DrawScrew(graph, empty);
                empty.X = rectangleF2.Right - num2 - empty.Width;
                DrawScrew(graph, empty);
                empty.X = rectangleF2.Right - num2 - empty.Width;
                empty.Y = rectangleF2.Bottom - num2 - empty.Height;
                DrawScrew(graph, empty);
                empty.X = rectangleF2.X + num2;
                empty.Y = rectangleF2.Bottom - num2 - empty.Height;
                DrawScrew(graph, empty);
            }
            Region region = null;

            if (drawBottomShadow)
            {
                rectangleF2         = rectangleF;
                rectangleF2.Width  -= val * 0.3f;
                rectangleF2.Height -= val * 0.3f;
                region              = new Region(graph.CreateRoundedRectPath(new RectangleF(rectangleF2.X - val, rectangleF2.Y - val, rectangleF2.Width + 0.5f * val, rectangleF2.Height + 0.5f * val), cornerRadius));
                region.Complement(graph.CreateRoundedRectPath(rectangleF2, cornerRadius));
                graph.Clip          = region;
                rectangleF2.X      -= 0.5f * val;
                rectangleF2.Width  += 0.5f * val;
                rectangleF2.Y      -= 0.5f * val;
                rectangleF2.Height += 0.5f * val;
                graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val, Color.Transparent, Color.FromArgb(175, sunken ? Color.White : color), 1f);
                graph.Clip = new Region();
            }
            rectangleF2         = rectangleF;
            rectangleF2.Width  -= val * 0.3f;
            rectangleF2.Height -= val * 0.3f;
            region              = new Region(graph.CreateRoundedRectPath(new RectangleF(rectangleF2.X + val * 0.5f, rectangleF2.Y + val * 0.5f, rectangleF2.Width - 0.2f * val, rectangleF2.Height - 0.2f * val), cornerRadius));
            RectangleF rect2 = rectangleF2;

            rect2.Width  += val;
            rect2.Height += val;
            region.Complement(graph.CreateRoundedRectPath(rect2, cornerRadius));
            region.Intersect(graph.CreateRoundedRectPath(rectangleF2, cornerRadius));
            graph.Clip = region;
            graph.DrawRoundedRectShadowAbs(rect2, cornerRadius, val, Color.Transparent, Color.FromArgb(175, sunken ? color : Color.White), 1f);
            graph.Clip = new Region();
        }
Exemple #12
0
        public override void DrawBorder(ChartGraphics graph, BorderSkinAttributes borderSkin, RectangleF rect, Color backColor, ChartHatchStyle backHatchStyle, string backImage, ChartImageWrapMode backImageMode, Color backImageTranspColor, ChartImageAlign backImageAlign, GradientType backGradientType, Color backGradientEndColor, Color borderColor, int borderWidth, ChartDashStyle borderStyle)
        {
            base.drawBottomShadow         = true;
            base.sunken                   = false;
            base.outsideShadowRate        = 0.9f;
            base.drawOutsideTopLeftShadow = false;
            bool drawScrews = base.drawScrews;

            base.drawScrews = false;
            base.DrawBorder(graph, borderSkin, rect, borderSkin.FrameBackColor, borderSkin.FrameBackHatchStyle, borderSkin.FrameBackImage, borderSkin.FrameBackImageMode, borderSkin.FrameBackImageTransparentColor, borderSkin.FrameBackImageAlign, borderSkin.FrameBackGradientType, borderSkin.FrameBackGradientEndColor, borderSkin.FrameBorderColor, borderSkin.FrameBorderWidth, borderSkin.FrameBorderStyle);
            base.drawScrews = drawScrews;
            rect.X         += base.sizeLeftTop.Width;
            rect.Y         += base.sizeLeftTop.Height;
            rect.Width     -= base.sizeRightBottom.Width + base.sizeLeftTop.Width;
            rect.Height    -= base.sizeRightBottom.Height + base.sizeLeftTop.Height;
            if (rect.Width > 0.0 && rect.Height > 0.0)
            {
                float[] array = new float[8];
                array                         = (float[])base.cornerRadius.Clone();
                base.cornerRadius             = this.innerCorners;
                base.drawBottomShadow         = false;
                base.sunken                   = true;
                base.drawOutsideTopLeftShadow = true;
                base.outsideShadowRate        = 1.4f;
                Color pageColor = borderSkin.PageColor;
                borderSkin.PageColor = Color.Transparent;
                base.DrawBorder(graph, borderSkin, rect, backColor, backHatchStyle, backImage, backImageMode, backImageTranspColor, backImageAlign, backGradientType, backGradientEndColor, borderColor, borderWidth, borderStyle);
                borderSkin.PageColor = pageColor;
                base.cornerRadius    = array;
            }
        }
        public virtual void DrawBorder(ChartGraphics graph, BorderSkinAttributes borderSkin, RectangleF rect, Color backColor, ChartHatchStyle backHatchStyle, string backImage, ChartImageWrapMode backImageMode, Color backImageTranspColor, ChartImageAlign backImageAlign, GradientType backGradientType, Color backGradientEndColor, Color borderColor, int borderWidth, ChartDashStyle borderStyle)
        {
            RectangleF rectangleF  = graph.Round(rect);
            RectangleF rect2       = rectangleF;
            float      num         = (float)(0.20000000298023224 + 0.40000000596046448 * (float)(borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765.0);
            Color      centerColor = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num));

            if (borderSkin.PageColor == Color.Transparent)
            {
                centerColor = Color.FromArgb(60, 0, 0, 0);
            }
            num = (float)(num + 0.20000000298023224);
            Color centerColor2 = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num));
            float val          = this.defaultRadiusSize;

            val = Math.Max(val, (float)(2.0 * this.resolution / 96.0));
            val = Math.Min(val, (float)(rect.Width / 2.0));
            val = Math.Min(val, (float)(rect.Height / 2.0));
            val = (float)Math.Ceiling((double)val);
            graph.FillRectangle(new SolidBrush(borderSkin.PageColor), rect);
            rect2         = rectangleF;
            rect2.Width  -= (float)(val * 0.30000001192092896);
            rect2.Height -= (float)(val * 0.30000001192092896);
            graph.DrawRoundedRectShadowAbs(rect2, this.cornerRadius, (float)(val + 1.0 * this.resolution / 96.0), centerColor2, borderSkin.PageColor, 1.4f);
            rect2         = rectangleF;
            rect2.X       = (float)(rectangleF.X + val / 3.0);
            rect2.Y       = (float)(rectangleF.Y + val / 3.0);
            rect2.Width  -= (float)(val / 3.5);
            rect2.Height -= (float)(val / 3.5);
            graph.DrawRoundedRectShadowAbs(rect2, this.cornerRadius, val, centerColor, borderSkin.PageColor, 1.3f);
            rect2         = rectangleF;
            rect2.X       = (float)(rectangleF.X + 3.0 * this.resolution / 96.0);
            rect2.Y       = (float)(rectangleF.Y + 3.0 * this.resolution / 96.0);
            rect2.Width  -= (float)(val * 0.75);
            rect2.Height -= (float)(val * 0.75);
            GraphicsPath graphicsPath = graph.CreateRoundedRectPath(rect2, this.cornerRadius);

            graph.DrawPathAbs(graphicsPath, backColor, backHatchStyle, backImage, backImageMode, backImageTranspColor, backImageAlign, backGradientType, backGradientEndColor, borderColor, borderWidth, borderStyle, PenAlignment.Inset);
            if (graphicsPath != null)
            {
                graphicsPath.Dispose();
            }
            Region region = new Region(graph.CreateRoundedRectPath(new RectangleF(rect2.X - val, rect2.Y - val, (float)(rect2.Width + val - val * 0.25), (float)(rect2.Height + val - val * 0.25)), this.cornerRadius));

            region.Complement(graph.CreateRoundedRectPath(rect2, this.cornerRadius));
            graph.Clip = region;
            graph.DrawRoundedRectShadowAbs(rect2, this.cornerRadius, val, Color.Transparent, Color.FromArgb(128, Color.Gray), 0.5f);
            graph.Clip = new Region();
        }
Exemple #14
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,
            RectangleF rect,
            Color backColor,
            ChartHatchStyle backHatchStyle,
            string backImage,
            ChartImageWrapMode backImageWrapMode,
            Color backImageTransparentColor,
            ChartImageAlignmentStyle backImageAlign,
            GradientStyle backGradientStyle,
            Color backSecondaryColor,
            Color borderColor,
            int borderWidth,
            ChartDashStyle borderDashStyle)
        {
            RectangleF absolute   = graph.Round(rect);
            RectangleF shadowRect = absolute;

            // Calculate shadow colors (0.2 - 0.6)
            float colorDarkeningIndex = 0.2f + (0.4f * (borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765f);
            Color shadowColor         = Color.FromArgb(
                (int)(borderSkin.PageColor.R * colorDarkeningIndex),
                (int)(borderSkin.PageColor.G * colorDarkeningIndex),
                (int)(borderSkin.PageColor.B * colorDarkeningIndex));

            if (borderSkin.PageColor == Color.Transparent)
            {
                shadowColor = Color.FromArgb(60, 0, 0, 0);
            }

            colorDarkeningIndex += 0.2f;
            Color shadowLightColor = Color.FromArgb(
                (int)(borderSkin.PageColor.R * colorDarkeningIndex),
                (int)(borderSkin.PageColor.G * colorDarkeningIndex),
                (int)(borderSkin.PageColor.B * colorDarkeningIndex));

            // Calculate rounded rect radius
            float radius = defaultRadiusSize;

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

            // Fill page background color
            using (Brush brush = new SolidBrush(borderSkin.PageColor))
            {
                graph.FillRectangle(brush, rect);
            }

            // Top/Left shadow
            shadowRect         = absolute;
            shadowRect.Width  -= radius * .3f;
            shadowRect.Height -= radius * .3f;
            graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius + 1 * resolution / 96.0f, shadowLightColor, borderSkin.PageColor, 1.4f);

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

            // Draw Background
            shadowRect         = absolute;
            shadowRect.X       = absolute.X + 3f * resolution / 96.0f;
            shadowRect.Y       = absolute.Y + 3f * resolution / 96.0f;
            shadowRect.Width  -= radius * .75f;
            shadowRect.Height -= radius * .75f;
            GraphicsPath path = graph.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
            Region innerShadowRegion = new Region(
                graph.CreateRoundedRectPath(
                    new RectangleF(
                        shadowRect.X - radius,
                        shadowRect.Y - radius,
                        shadowRect.Width + radius - radius * 0.25f,
                        shadowRect.Height + radius - radius * 0.25f),
                    cornerRadius));

            innerShadowRegion.Complement(graph.CreateRoundedRectPath(shadowRect, cornerRadius));
            graph.Clip = innerShadowRegion;
            graph.DrawRoundedRectShadowAbs(
                shadowRect,
                cornerRadius,
                radius,
                Color.Transparent,
                Color.FromArgb(128, Color.Gray),
                .5f);
            graph.Clip = new Region();
        }
Exemple #15
0
        public virtual void DrawBorder(ChartGraphics graph, BorderSkinAttributes borderSkin, RectangleF rect, Color backColor, ChartHatchStyle backHatchStyle, string backImage, ChartImageWrapMode backImageMode, Color backImageTranspColor, ChartImageAlign backImageAlign, GradientType backGradientType, Color backGradientEndColor, Color borderColor, int borderWidth, ChartDashStyle borderStyle)
        {
            RectangleF rectangleF  = graph.Round(rect);
            RectangleF rectangleF2 = rectangleF;
            float      num         = 0.2f + 0.4f * (float)(borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765f;
            Color      centerColor = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num));

            if (borderSkin.PageColor == Color.Transparent)
            {
                centerColor = Color.FromArgb(60, 0, 0, 0);
            }
            num += 0.2f;
            Color centerColor2 = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num));
            float val          = defaultRadiusSize;

            val = Math.Max(val, 2f * resolution / 96f);
            val = Math.Min(val, rect.Width / 2f);
            val = Math.Min(val, rect.Height / 2f);
            val = (float)Math.Ceiling(val);
            graph.FillRectangle(new SolidBrush(borderSkin.PageColor), rect);
            rectangleF2         = rectangleF;
            rectangleF2.Width  -= val * 0.3f;
            rectangleF2.Height -= val * 0.3f;
            graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val + 1f * resolution / 96f, centerColor2, borderSkin.PageColor, 1.4f);
            rectangleF2         = rectangleF;
            rectangleF2.X       = rectangleF.X + val / 3f;
            rectangleF2.Y       = rectangleF.Y + val / 3f;
            rectangleF2.Width  -= val / 3.5f;
            rectangleF2.Height -= val / 3.5f;
            graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val, centerColor, borderSkin.PageColor, 1.3f);
            rectangleF2         = rectangleF;
            rectangleF2.X       = rectangleF.X + 3f * resolution / 96f;
            rectangleF2.Y       = rectangleF.Y + 3f * resolution / 96f;
            rectangleF2.Width  -= val * 0.75f;
            rectangleF2.Height -= val * 0.75f;
            GraphicsPath graphicsPath = graph.CreateRoundedRectPath(rectangleF2, cornerRadius);

            graph.DrawPathAbs(graphicsPath, backColor, backHatchStyle, backImage, backImageMode, backImageTranspColor, backImageAlign, backGradientType, backGradientEndColor, borderColor, borderWidth, borderStyle, PenAlignment.Inset);
            graphicsPath?.Dispose();
            Region region = new Region(graph.CreateRoundedRectPath(new RectangleF(rectangleF2.X - val, rectangleF2.Y - val, rectangleF2.Width + val - val * 0.25f, rectangleF2.Height + val - val * 0.25f), cornerRadius));

            region.Complement(graph.CreateRoundedRectPath(rectangleF2, cornerRadius));
            graph.Clip = region;
            graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val, Color.Transparent, Color.FromArgb(128, Color.Gray), 0.5f);
            graph.Clip = new Region();
        }
Exemple #16
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.3f + (0.4f * (borderSkin.PageColor.Red + borderSkin.PageColor.Green + borderSkin.PageColor.Blue) / 765f);
            SKColor shadowColor         = new(
                (byte)(backColor.Red * colorDarkeningIndex),
                (byte)(backColor.Green * colorDarkeningIndex),
                (byte)(backColor.Blue * colorDarkeningIndex));

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

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

            // 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() { Color = borderSkin.PageColor, Style = SKPaintStyle.Fill })
            {
                graph.FillRectangle(brush, rect);
            }

            SKRect shadowRect;

            if (drawOutsideTopLeftShadow)
            {
                // Top/Left outside shadow
                shadowRect         = absolute;
                shadowRect.Left   -= radius * 0.3f;
                shadowRect.Top    -= radius * 0.3f;
                shadowRect.Right  -= radius * .3f;
                shadowRect.Bottom -= radius * .3f;
                graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius, Color.FromArgb(128, SKColors.Black), borderSkin.PageColor, outsideShadowRate);
            }

            // Bottom/Right outside shadow
            shadowRect         = absolute;
            shadowRect.Left   += radius * 0.3f;
            shadowRect.Top    += radius * 0.3f;
            shadowRect.Right  -= radius * .3f;
            shadowRect.Bottom -= radius * .3f;
            graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius, shadowLightColor, borderSkin.PageColor, outsideShadowRate);

            // Background
            shadowRect         = absolute;
            shadowRect.Right  -= radius * .3f;
            shadowRect.Bottom -= radius * .3f;
            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();
            }

            // Draw screws imitation in the corners of the farame
            if (drawScrews)
            {
                // Left/Top screw
                SKRect screwRect = SKRect.Empty;
                float  offset    = radius * 0.4f;
                screwRect.Left = shadowRect.Left + offset;
                screwRect.Top  = shadowRect.Top + offset;
                screwRect.Size = new(radius * 0.55f, screwRect.Width);
                DrawScrew(graph, screwRect);

                // Right/Top screw
                screwRect.Left = shadowRect.Right - offset - screwRect.Width;
                DrawScrew(graph, screwRect);

                // Right/Bottom screw
                screwRect.Left = shadowRect.Right - offset - screwRect.Width;
                screwRect.Top  = shadowRect.Bottom - offset - screwRect.Height;
                DrawScrew(graph, screwRect);

                // Left/Bottom screw
                screwRect.Left = shadowRect.Left + offset;
                screwRect.Top  = shadowRect.Bottom - offset - screwRect.Height;
                DrawScrew(graph, screwRect);
            }

            // Bottom/Right inner shadow
            SKRegion innerShadowRegion;

            if (drawBottomShadow)
            {
                shadowRect         = absolute;
                shadowRect.Right  -= radius * .3f;
                shadowRect.Bottom -= radius * .3f;
                innerShadowRegion  = new SKRegion(
                    ChartGraphics.CreateRoundedRectPath(
                        new SKRect(
                            shadowRect.Left - radius,
                            shadowRect.Top - radius,
                            shadowRect.Width + 0.5f * radius,
                            shadowRect.Height + 0.5f * radius),
                        cornerRadius));

                // TODO: innerShadowRegion.Complement(graph.CreateRoundedRectPath(shadowRect, cornerRadius));

                graph.Clip = innerShadowRegion;

                shadowRect.Left   -= 0.5f * radius;
                shadowRect.Top    -= 0.5f * radius;
                shadowRect.Right  += 0.5f * radius;
                shadowRect.Bottom += 0.5f * radius;

                graph.DrawRoundedRectShadowAbs(
                    shadowRect,
                    cornerRadius,
                    radius,
                    SKColors.Transparent,
                    Color.FromArgb(175, (sunken) ? SKColors.White : shadowColor),
                    1.0f);
                graph.Clip = new SKRegion();
            }

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

            SKRect shadowWithOffset = shadowRect;

            shadowWithOffset.Right  += radius;
            shadowWithOffset.Bottom += radius;
            // TODO: innerShadowRegion.Complement(graph.CreateRoundedRectPath(shadowWithOffset, cornerRadius));

            innerShadowRegion.SetPath(ChartGraphics.CreateRoundedRectPath(shadowRect, cornerRadius), innerShadowRegion);
            graph.Clip = innerShadowRegion;
            graph.DrawRoundedRectShadowAbs(
                shadowWithOffset,
                cornerRadius,
                radius,
                SKColors.Transparent,
                Color.FromArgb(175, (sunken) ? shadowColor : SKColors.White),
                1.0f);
            graph.Clip = new();
        }