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();
        }
Beispiel #2
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();
        }
Beispiel #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,
            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();
        }
        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();
        }
        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();
        }
Beispiel #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 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();
        }