Esempio n. 1
0
 public static void Blend(Graphics g, Color c1, Color c2, Color c3, float c, int d, int x, int y, int width, int height)
 {
     ColorBlend V = new ColorBlend(3);
     V.Colors = new Color[] { c1, c2, c3 };
     V.Positions = new float[] { 0F, c, 1F };
     Rectangle R = new Rectangle(x, y, width, height);
     using (LinearGradientBrush T = new LinearGradientBrush(R, c1, c1, (LinearGradientMode)d))
     {
         T.InterpolationColors = V;
         g.FillRectangle(T, R);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Creates a <see cref="GradientTheme"/>
        /// </summary>
        /// <param name="attribute">Name of the feature attribute</param>
        /// <param name="defaultStyle">Default <see cref="VectorStyle"/> to base this theme on</param>
        /// <param name="blend"><see cref="ColorBlend"/> 
        ///   defining the min and max colors
        ///   Note: Silently assumes 2 Colors defined
        /// </param>
        /// <param name="minValue">Minimum value of the feature attribute values</param>
        /// <param name="maxValue">Maximum value of the feature attribute values</param>
        /// <param name="sizeMin">Minimum line/point size in pixels</param>
        /// <param name="sizeMax">Maximum line/point size in pixels</param>
        /// <param name="skipColors">Use the min and max colors (false) or the defaultStyle fill color (true)</param>
        /// <param name="skipSizes">Let the size of a point depend on the value (false) or use the defaultStyle size (true)</param>
        /// <param name="numberOfClasses">The number of classes (ThemeItems) to generate (default = 8)</param>
        /// <returns>A new <see cref="GradientTheme"/></returns>
        public static GradientTheme CreateGradientTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend,
            double minValue, double maxValue, int sizeMin, int sizeMax, bool skipColors, bool skipSizes, int numberOfClasses = 8)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle { GeometryType = typeof(IPolygon) };
            }

            Color minColor = (skipColors) ? ((SolidBrush)defaultStyle.Fill).Color : blend.GetColor(0);
            Color maxColor = (skipColors) ? ((SolidBrush)defaultStyle.Fill).Color : blend.GetColor(1);

            var deltaWidth = (defaultStyle.Outline.Width - defaultStyle.Line.Width);

            float minOutlineSize = deltaWidth + sizeMin;
            float maxOutlineSize = deltaWidth + sizeMax;

            // Use default styles if not working with VectorLayers (i.e. RegularGridCoverageLayers)
            var minStyle = (VectorStyle)defaultStyle.Clone();
            var maxStyle = (VectorStyle)defaultStyle.Clone();

            minStyle.GeometryType = defaultStyle.GeometryType;
            maxStyle.GeometryType = defaultStyle.GeometryType;

            if (defaultStyle.GeometryType == typeof(IPoint))
            {
                UpdateMinMaxForPoints(defaultStyle, sizeMin, sizeMax, minStyle, maxStyle, minColor, maxColor, skipSizes);
            }
            else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
            {
                UpdateMinMaxForPolygons(defaultStyle, minStyle, maxStyle, minColor, maxColor, minOutlineSize, maxOutlineSize);
            }
            else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
            {
                UpdateMinMaxForLineStrings(defaultStyle, sizeMin, sizeMax, minStyle, maxStyle, minColor, maxColor, minOutlineSize, maxOutlineSize, skipSizes);
            }
            else
            {
                //use for unknown geometry..
                minStyle.Fill = new SolidBrush(minColor);
                maxStyle.Fill = new SolidBrush(maxColor);
                minStyle.Outline = CreatePen(minColor, minOutlineSize, defaultStyle.Outline);
                maxStyle.Outline = CreatePen(maxColor, maxOutlineSize, defaultStyle.Outline);
            }

            return new GradientTheme(attribute, minValue, maxValue, minStyle, maxStyle, blend, blend, null, numberOfClasses);
        }
Esempio n. 3
0
 protected void DrawGradient(ColorBlend blend, Rectangle r, float angle)
 {
     DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, angle);
     DrawGradientBrush.InterpolationColors = blend;
     G.FillRectangle(DrawGradientBrush, r);
 }
Esempio n. 4
0
        internal void RenderTabBackgroundInternal(
            Graphics g,
            Rectangle rect,
            Color baseColor,
            Color borderColor,
            float basePosition,
            LinearGradientMode mode)
        {
            using (GraphicsPath path = CreateTabPath(rect))
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(
                           rect, Color.Transparent, Color.Transparent, mode))
                {
                    Color[] colors = new Color[4];
                    colors[0] = GetColor(baseColor, 0, 35, 24, 9);
                    colors[1] = GetColor(baseColor, 0, 13, 8, 3);
                    colors[2] = baseColor;
                    colors[3] = GetColor(baseColor, 0, 68, 69, 54);

                    ColorBlend blend = new ColorBlend();
                    blend.Positions =
                        new float[] { 0.0f, basePosition, basePosition + 0.05f, 1.0f };
                    blend.Colors = colors;
                    brush.InterpolationColors = blend;
                    g.FillPath(brush, path);
                }

                if (baseColor.A > 80)
                {
                    Rectangle rectTop = rect;
                    if (mode == LinearGradientMode.Vertical)
                    {
                        rectTop.Height = (int)(rectTop.Height * basePosition);
                    }
                    else
                    {
                        rectTop.Width = (int)(rect.Width * basePosition);
                    }
                    using (SolidBrush brushAlpha =
                               new SolidBrush(Color.FromArgb(80, 255, 255, 255)))
                    {
                        g.FillRectangle(brushAlpha, rectTop);
                    }
                }

                rect.Inflate(-1, -1);
                using (GraphicsPath path1 = CreateTabPath(rect))
                {
                    using (Pen pen = new Pen(Color.FromArgb(255, 255, 255)))
                    {
                        if (Multiline)
                        {
                            g.DrawPath(pen, path1);
                        }
                        else
                        {
                            g.DrawLines(pen, path1.PathPoints);
                        }
                    }
                }

                using (Pen pen = new Pen(borderColor))
                {
                    if (Multiline)
                    {
                        g.DrawPath(pen, path);
                    }
                    {
                        g.DrawLines(pen, path.PathPoints);
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Draws the arrow down button for the scrollbar.
        /// </summary>
        /// <param name="state">The button state.</param>
        /// <returns>The arrow down button as <see cref="Image"/>.</returns>
        private static Image GetArrowDownButtonImage(
            ScrollBarArrowButtonState state)
        {
            Rectangle rect   = new Rectangle(0, 0, 15, 17);
            Bitmap    bitmap = new Bitmap(15, 17, PixelFormat.Format32bppArgb);

            bitmap.SetResolution(72f, 72f);

            using (Graphics g = Graphics.FromImage(bitmap))
            {
                g.SmoothingMode     = SmoothingMode.None;
                g.InterpolationMode = InterpolationMode.Low;

                int index = -1;

                switch (state)
                {
                case ScrollBarArrowButtonState.UPHOT:
                case ScrollBarArrowButtonState.DOWNHOT:
                {
                    index = 1;

                    break;
                }

                case ScrollBarArrowButtonState.UPACTIVE:
                case ScrollBarArrowButtonState.DOWNACTIVE:
                {
                    index = 0;

                    break;
                }

                case ScrollBarArrowButtonState.UPPRESSED:
                case ScrollBarArrowButtonState.DOWNPRESSED:
                {
                    index = 2;

                    break;
                }
                }

                if (index != -1)
                {
                    using (Pen p1 = new Pen(arrowBorderColours[0]),
                           p2 = new Pen(arrowBorderColours[1]))
                    {
                        g.DrawLine(p1, rect.X, rect.Y, rect.Right - 1, rect.Y);
                        g.DrawLine(p2, rect.X, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
                    }

                    rect.Inflate(0, -1);

                    using (LinearGradientBrush brush = new LinearGradientBrush(
                               rect,
                               arrowBorderColours[2],
                               arrowBorderColours[1],
                               LinearGradientMode.Vertical))
                    {
                        ColorBlend blend = new ColorBlend(3)
                        {
                            Positions = new[] { 0f, .5f, 1f },
                            Colors    = new[] {
                                arrowBorderColours[2],
                                arrowBorderColours[3],
                                arrowBorderColours[0]
                            }
                        };

                        brush.InterpolationColors = blend;

                        using (Pen p = new Pen(brush))
                        {
                            g.DrawLine(p, rect.X, rect.Y, rect.X, rect.Bottom - 1);
                            g.DrawLine(p, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1);
                        }
                    }

                    rect.Inflate(0, 1);

                    Rectangle upper = rect;
                    upper.Inflate(-1, 0);
                    upper.Y++;
                    upper.Height = 7;

                    using (LinearGradientBrush brush = new LinearGradientBrush(
                               upper,
                               arrowColours[index, 2],
                               arrowColours[index, 3],
                               LinearGradientMode.Vertical))
                    {
                        g.FillRectangle(brush, upper);
                    }

                    upper.Inflate(-1, 0);
                    upper.Height = 6;

                    using (LinearGradientBrush brush = new LinearGradientBrush(
                               upper,
                               arrowColours[index, 0],
                               arrowColours[index, 1],
                               LinearGradientMode.Vertical))
                    {
                        g.FillRectangle(brush, upper);
                    }

                    Rectangle lower = rect;
                    lower.Inflate(-1, 0);
                    lower.Y      = 8;
                    lower.Height = 8;

                    using (LinearGradientBrush brush = new LinearGradientBrush(
                               lower,
                               arrowColours[index, 6],
                               arrowColours[index, 7],
                               LinearGradientMode.Vertical))
                    {
                        g.FillRectangle(brush, lower);
                    }

                    lower.Inflate(-1, 0);

                    using (LinearGradientBrush brush = new LinearGradientBrush(
                               lower,
                               arrowColours[index, 4],
                               arrowColours[index, 5],
                               LinearGradientMode.Vertical))
                    {
                        g.FillRectangle(brush, lower);
                    }
                }

                using (Image arrowIcon = (Image)GetScrollBarArrowDownBitmap().Clone())
                {
                    if (state == ScrollBarArrowButtonState.DOWNDISABLED ||
                        state == ScrollBarArrowButtonState.UPDISABLED)
                    {
                        System.Windows.Forms.ControlPaint.DrawImageDisabled(
                            g,
                            arrowIcon,
                            3,
                            6,
                            Color.Transparent);
                    }
                    else
                    {
                        g.DrawImage(arrowIcon, 3, 6);
                    }
                }
            }

            return(bitmap);
        }
Esempio n. 6
0
        public static CategorialTheme CreateCategorialTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend, 
            int numberOfClasses, IList<IComparable> values, List<string> categories, int sizeMin, int sizeMax)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle
                                   {
                                       GeometryType = typeof (IPolygon)
                                   };
            }

            var categorialTheme = new CategorialTheme(attribute, defaultStyle);

            for (int i = 0; i < numberOfClasses; i++)
            {
                string label = (categories != null)
                                   ? categories[i]
                                   : values[i].ToString();

                Color color = (numberOfClasses > 1)
                                  ? blend.GetColor((float) i/(numberOfClasses - 1))
                                  : ((SolidBrush) defaultStyle.Fill).Color;
                
                var vectorStyle = (VectorStyle) defaultStyle.Clone();

                var size = sizeMin + (sizeMax - sizeMin)*i/(float) numberOfClasses;

                if (defaultStyle.GeometryType == typeof(IPoint))
                {
                    vectorStyle.Fill = new SolidBrush(color);
                    vectorStyle.Line.Width = 16;
                    vectorStyle.Shape = defaultStyle.Shape;
                }
                else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }
                else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
                {
                    vectorStyle.Line = CreatePen(color, size, defaultStyle.Line);
                }
                else
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }

                CategorialThemeItem categorialThemeItem = (values[i] != null)
                                                              ? new CategorialThemeItem(label, vectorStyle, vectorStyle.LegendSymbol, values[i])
                                                              : new CategorialThemeItem(label, vectorStyle, vectorStyle.LegendSymbol);

                
                categorialTheme.AddThemeItem(categorialThemeItem);
            }

            return categorialTheme;
        }
Esempio n. 7
0
 public void DrawRadial(ColorBlend blend, int x, int y, int width, int height, int cx, int cy)
 {
     DrawRadialRectangle = new Rectangle(x, y, width, height);
     DrawRadial(blend, DrawRadialRectangle, cx, cy);
 }
Esempio n. 8
0
 protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height, float angle)
 {
     DrawGradientRectangle = new Rectangle(x, y, width, height);
     DrawGradient(blend, DrawGradientRectangle, angle);
 }
Esempio n. 9
0
 public void DrawRadial(ColorBlend blend, Rectangle r)
 {
     DrawRadial(blend, r, r.Width / 2, r.Height / 2);
 }
Esempio n. 10
0
 public void DrawRadial(ColorBlend blend, int x, int y, int width, int height, int cx, int cy)
 {
     DrawRadialRectangle = new Rectangle(x, y, width, height);
     DrawRadial(blend, DrawRadialRectangle, cx, cy);
 }
Esempio n. 11
0
 public void DrawRadial(ColorBlend blend, int x, int y, int width, int height, Point center)
 {
     DrawRadialRectangle = new Rectangle(x, y, width, height);
     DrawRadial(blend, DrawRadialRectangle, center.X, center.Y);
 }
Esempio n. 12
0
 public void DrawRadial(ColorBlend blend, int x, int y, int width, int height)
 {
     DrawRadialRectangle = new Rectangle(x, y, width, height);
     DrawRadial(blend, DrawRadialRectangle, width / 2, height / 2);
 }
Esempio n. 13
0
        internal static void RenderBackgroundInternal(
            Graphics g,
            Rectangle rect,
            Color baseColor,
            Color borderColor,
            Color innerBorderColor,
            RoundStyle style,
            int roundWidth,
            float basePosition,
            bool drawBorder,
            bool drawGlass,
            LinearGradientMode mode)
        {
            if (drawBorder)
            {
                rect.Width--;
                rect.Height--;
            }

            using (LinearGradientBrush brush = new LinearGradientBrush(
                       rect, Color.Transparent, Color.Transparent, mode))
            {
                Color[] colors = new Color[4];
                colors[0] = GetColor(baseColor, 0, 35, 24, 9);
                colors[1] = GetColor(baseColor, 0, 13, 8, 3);
                colors[2] = baseColor;
                colors[3] = GetColor(baseColor, 0, 35, 24, 9);

                ColorBlend blend = new ColorBlend();
                blend.Positions           = new float[] { 0.0f, basePosition, basePosition + 0.05f, 1.0f };
                blend.Colors              = colors;
                brush.InterpolationColors = blend;
                if (style != RoundStyle.None)
                {
                    using (GraphicsPath path =
                               GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
                    {
                        g.FillPath(brush, path);
                    }

                    if (baseColor.A > 80)
                    {
                        Rectangle rectTop = rect;

                        if (mode == LinearGradientMode.Vertical)
                        {
                            rectTop.Height = (int)(rectTop.Height * basePosition);
                        }
                        else
                        {
                            rectTop.Width = (int)(rect.Width * basePosition);
                        }
                        using (GraphicsPath pathTop = GraphicsPathHelper.CreatePath(
                                   rectTop, roundWidth, RoundStyle.Top, false))
                        {
                            using (SolidBrush brushAlpha =
                                       new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
                            {
                                g.FillPath(brushAlpha, pathTop);
                            }
                        }
                    }

                    if (drawGlass)
                    {
                        RectangleF glassRect = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            glassRect.Y      = rect.Y + rect.Height * basePosition;
                            glassRect.Height = (rect.Height - rect.Height * basePosition) * 2;
                        }
                        else
                        {
                            glassRect.X     = rect.X + rect.Width * basePosition;
                            glassRect.Width = (rect.Width - rect.Width * basePosition) * 2;
                        }
                        ControlPaintEx.DrawGlass(g, glassRect, 170, 0);
                    }

                    if (drawBorder)
                    {
                        using (GraphicsPath path =
                                   GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
                        {
                            using (Pen pen = new Pen(borderColor))
                            {
                                g.DrawPath(pen, path);
                            }
                        }

                        rect.Inflate(-1, -1);
                        using (GraphicsPath path =
                                   GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
                        {
                            using (Pen pen = new Pen(innerBorderColor))
                            {
                                g.DrawPath(pen, path);
                            }
                        }
                    }
                }
                else
                {
                    g.FillRectangle(brush, rect);
                    if (baseColor.A > 80)
                    {
                        Rectangle rectTop = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            rectTop.Height = (int)(rectTop.Height * basePosition);
                        }
                        else
                        {
                            rectTop.Width = (int)(rect.Width * basePosition);
                        }
                        using (SolidBrush brushAlpha =
                                   new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
                        {
                            g.FillRectangle(brushAlpha, rectTop);
                        }
                    }

                    if (drawGlass)
                    {
                        RectangleF glassRect = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            glassRect.Y      = rect.Y + rect.Height * basePosition;
                            glassRect.Height = (rect.Height - rect.Height * basePosition) * 2;
                        }
                        else
                        {
                            glassRect.X     = rect.X + rect.Width * basePosition;
                            glassRect.Width = (rect.Width - rect.Width * basePosition) * 2;
                        }
                        ControlPaintEx.DrawGlass(g, glassRect, 200, 0);
                    }

                    if (drawBorder)
                    {
                        using (Pen pen = new Pen(borderColor))
                        {
                            g.DrawRectangle(pen, rect);
                        }

                        rect.Inflate(-1, -1);
                        using (Pen pen = new Pen(innerBorderColor))
                        {
                            g.DrawRectangle(pen, rect);
                        }
                    }
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// 绘制四角的阴影
        /// </summary>
        /// <param name="g"></param>
        /// <param name="corSize">圆角区域正方形的大小</param>
        /// <returns></returns>
        private void DrawCorners(Graphics g, Size corSize)
        {
            /*
             * 四个角,每个角都是一个扇面
             * 画图时扇面由外弧、内弧以及两段的连接线构成图形
             * 然后在内弧中间附近向外做渐变
             *
             * 阴影分为9宫格,5为内部背景图部分
             *  1   2   3
             *  4   5   6
             *  7   8   9
             */
            Action <int> DrawCorenerN = (n) =>
            {
                using (GraphicsPath gp = new GraphicsPath())
                {
                    // 扇面外沿、内沿曲线的尺寸
                    Size sizeOutSide = new Size(corSize.Width * 2, corSize.Height * 2);
                    Size sizeInSide  = new Size(radius * 2, radius * 2);

                    // 扇面外沿、内沿曲线的位置
                    Point locationOutSide, locationInSide;
                    // 当圆角半径小于MinCornerRadius时,内沿不绘制曲线,而以线段绘制近似值。该线段绘制方向是从p1指向p2。
                    Point p1, p2;

                    // 渐变起点位置
                    PointF brushCenter;

                    // 扇面起始角度
                    float startAngle;

                    // 根据四个方位不同,确定扇面的位置、角度及渐变起点位置
                    switch (n)
                    {
                    case 1:
                        locationOutSide = new Point(0, 0);
                        startAngle      = 180;
                        brushCenter     = new PointF((float)sizeOutSide.Width - sizeInSide.Width * 0.5f, (float)sizeOutSide.Height - sizeInSide.Height * 0.5f);
                        p1 = new Point(corSize.Width, shadowWidth);
                        p2 = new Point(shadowWidth, corSize.Height);
                        break;

                    case 3:
                        locationOutSide = new Point(this.Width - sizeOutSide.Width, 0);
                        startAngle      = 270;
                        brushCenter     = new PointF((float)locationOutSide.X + sizeInSide.Width * 0.5f, (float)sizeOutSide.Height - sizeInSide.Height * 0.5f);
                        p1 = new Point(this.Width - shadowWidth, corSize.Height);
                        p2 = new Point(this.Width - corSize.Width, shadowWidth);
                        break;

                    case 7:
                        locationOutSide = new Point(0, this.Height - sizeOutSide.Height);
                        startAngle      = 90;
                        brushCenter     = new PointF((float)sizeOutSide.Width - sizeInSide.Width * 0.5f, (float)locationOutSide.Y + sizeInSide.Height * 0.5f);
                        p1 = new Point(shadowWidth, this.Height - corSize.Height);
                        p2 = new Point(corSize.Width, this.Height - shadowWidth);
                        break;

                    default:
                        locationOutSide = new Point(this.Width - sizeOutSide.Width, this.Height - sizeOutSide.Height);
                        startAngle      = 0;
                        brushCenter     = new PointF((float)locationOutSide.X + sizeInSide.Width * 0.5f, (float)locationOutSide.Y + sizeInSide.Height * 0.5f);
                        p1 = new Point(this.Width - corSize.Width, this.Height - shadowWidth);
                        p2 = new Point(this.Width - shadowWidth, this.Height - corSize.Height);
                        break;
                    }

                    // 扇面外沿曲线
                    Rectangle recOutSide = new Rectangle(locationOutSide, sizeOutSide);

                    // 扇面内沿曲线的位置
                    locationInSide = new Point(locationOutSide.X + (sizeOutSide.Width - sizeInSide.Width) / 2, locationOutSide.Y + (sizeOutSide.Height - sizeInSide.Height) / 2);

                    // 扇面内沿曲线
                    Rectangle recInSide = new Rectangle(locationInSide, sizeInSide);

                    // 将扇面添加到形状,以备绘制
                    gp.AddArc(recOutSide, startAngle, 90);

                    if (radius > 3)
                    {
                        gp.AddArc(recInSide, startAngle + 90, -90);
                    }
                    else
                    {
                        gp.AddLine(p1, p2);
                    }

                    // 使用渐变笔刷
                    using (PathGradientBrush shadowBrush = new PathGradientBrush(gp))
                    {
                        Color[]    colors    = new Color[2];
                        float[]    positions = new float[2];
                        ColorBlend sBlend    = new ColorBlend();
                        // 扇面外沿色
                        colors[0] = CornerColors[1];
                        // 扇面内沿色
                        colors[1]        = CornerColors[0];
                        positions[0]     = 0.0f;
                        positions[1]     = 1.0f;
                        sBlend.Colors    = colors;
                        sBlend.Positions = positions;

                        shadowBrush.InterpolationColors = sBlend;
                        shadowBrush.CenterPoint         = brushCenter;
                        // 上色中心点
                        g.FillPath(shadowBrush, gp);
                    }
                }
            };

            DrawCorenerN(1);
            DrawCorenerN(3);
            DrawCorenerN(7);
            DrawCorenerN(9);
        }
Esempio n. 15
0
    public void FillGradientBeam(Graphics g, Color Col1, Color Col2, Rectangle rect, GradientAlignment align)
    {
        SmoothingMode stored = g.SmoothingMode;
        ColorBlend Blend = new ColorBlend();
        g.SmoothingMode = SmoothingMode.HighQuality;
        LinearGradientBrush PathGradient;
        switch (align)
        {
            case GradientAlignment.Vertical:
                PathGradient = new LinearGradientBrush(new Point(rect.X, rect.Y), new Point(rect.X + rect.Width - 1, rect.Y), Color.Black, Color.Black);
                Blend.Positions = new[] { 0, 1 / 2f, 1 };

                Blend.Colors = new[]{Col1,Col2,Col1};
                PathGradient.InterpolationColors = Blend;
                g.FillRectangle(PathGradient, rect);
                break;
            case GradientAlignment.Horizontal:
                PathGradient = new LinearGradientBrush(new Point(rect.X, rect.Y), new Point(rect.X, rect.Y + rect.Height), Color.Black, Color.Black);
                Blend.Positions = new[]{0,1 / 2f,1 };
                Blend.Colors = new[]{
                    Col1,
                    Col2,
                    Col1
                };
                PathGradient.InterpolationColors = Blend;
                PathGradient.RotateTransform(0);
                g.FillRectangle(PathGradient, rect);
                break;
        }
        g.SmoothingMode = stored;
    }
Esempio n. 16
0
 protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height, float angle)
 {
     DrawGradientRectangle = new Rectangle(x, y, width, height);
     DrawGradient(blend, DrawGradientRectangle, angle);
 }
Esempio n. 17
0
 public void DrawRadial(ColorBlend blend, Rectangle r, Point center)
 {
     DrawRadial(blend, r, center.X, center.Y);
 }
Esempio n. 18
0
        private LinearGradientBrush GetBrush(SvgLinearGradientElement res, RectangleF bounds)
        {
            //LinearGradientBrush brush = new LinearGradientBrush(new RectangleF(fEffectiveLeft - 1,
            //    fEffectiveTop - 1, fEffectiveWidth + 2, fEffectiveHeight + 2),
            //    Color.White, Color.White, mode);

            XmlNodeList stops = res.Stops;

            ColorBlend cb = new ColorBlend();

            //List<Color> adjcolors = new List<Color>();
            //List<float> adjpositions = new List<float>();
            //GetColorsAndPositions(stops, adjpositions, adjcolors);
            var gradientStops = this.GetGradientStops(stops);

            if (gradientStops == null || gradientStops.Count == 0)
            {
                return(null);
            }

            float fLeft   = (float)res.X1.AnimVal.Value;
            float fRight  = (float)res.X2.AnimVal.Value;
            float fTop    = (float)res.Y1.AnimVal.Value;
            float fBottom = (float)res.Y2.AnimVal.Value;

            bool bForceUserSpaceOnUse = (fLeft > 1 || fRight > 1 || fTop > 1 || fBottom > 1);

            float fEffectiveLeft   = fLeft;
            float fEffectiveRight  = fRight;
            float fEffectiveTop    = fTop;
            float fEffectiveBottom = fBottom;

            if (res.GradientUnits.AnimVal.Equals((ushort)SvgUnitType.ObjectBoundingBox) && !bForceUserSpaceOnUse)
            {
                if (res.SpreadMethod.AnimVal.Equals((ushort)SvgSpreadMethod.Pad))
                {
                    fEffectiveRight = bounds.Right;
                    fEffectiveLeft  = bounds.Left;
                }
                else
                {
                    fEffectiveLeft  = bounds.Left + fLeft * (bounds.Width);
                    fEffectiveRight = bounds.Left + fRight * (bounds.Width);
                }

                fEffectiveTop    = bounds.Top + fTop * (bounds.Height);
                fEffectiveBottom = bounds.Top + fBottom * (bounds.Height);
            }

            LinearGradientMode mode = LinearGradientMode.Horizontal;

            if (fTop == fBottom)
            {
                mode = LinearGradientMode.Horizontal;
            }
            else
            {
                if (fLeft == fRight)
                {
                    mode = LinearGradientMode.Vertical;
                }
                else
                {
                    if (fLeft < fRight)
                    {
                        mode = LinearGradientMode.ForwardDiagonal;
                    }
                    else
                    {
                        mode = LinearGradientMode.BackwardDiagonal;
                    }
                }
            }

            float fEffectiveWidth = fEffectiveRight - fEffectiveLeft;

            if (fEffectiveWidth <= 0)
            {
                fEffectiveWidth = bounds.Width;
            }

            float fEffectiveHeight = fEffectiveBottom - fEffectiveTop;

            if (fEffectiveHeight <= 0)
            {
                fEffectiveHeight = bounds.Height;
            }

            int stopCount = gradientStops.Count;
            var colors    = new Color[stopCount];
            var positions = new float[stopCount];

            for (int i = 0; i < stopCount; i++)
            {
                var gradientStop = gradientStops[i];
                colors[i]    = gradientStop.Color;
                positions[i] = gradientStop.Offset;
            }
            //LinearGradientBrush brush = new LinearGradientBrush(new PointF(fLeft, fTop),
            //    new PointF(fRight, fBottom), gradientStops[0].Color, gradientStops[stopCount - 1].Color);
            LinearGradientBrush brush = new LinearGradientBrush(new RectangleF(fEffectiveLeft - 1,
                                                                               fEffectiveTop - 1, fEffectiveWidth + 2, fEffectiveHeight + 2),
                                                                Color.Transparent, Color.Transparent, mode);

            if (res.GradientUnits.AnimVal.Equals((ushort)SvgUnitType.ObjectBoundingBox) && !bForceUserSpaceOnUse)
            {
                if (res.SpreadMethod.AnimVal.Equals((ushort)SvgSpreadMethod.Pad))
                {
                    for (int i = 0; i < stopCount; i++)
                    {
                        if (fLeft == fRight)
                        {
                            positions[i] = fTop + positions[i] * (fBottom - fTop);
                        }
                        else
                        {
                            positions[i] = fLeft + positions[i] * (fRight - fLeft);
                        }
                    }

                    // this code corrects the values again... fix
                    int nSize = colors.Length;

                    if (positions[0] > 0.0)
                    {
                        ++nSize;
                    }

                    if (positions[colors.Length - 1] < 1)
                    {
                        ++nSize;
                    }

                    Color[] readjcolors    = new Color[nSize];
                    float[] readjpositions = new float[nSize];

                    if (positions[0] > 0.0)
                    {
                        positions.CopyTo(readjpositions, 1);
                        colors.CopyTo(readjcolors, 1);

                        readjcolors[0]    = readjcolors[1];
                        readjpositions[0] = 0;
                    }
                    else
                    {
                        positions.CopyTo(readjpositions, 0);
                        colors.CopyTo(readjcolors, 0);
                    }

                    if (positions[colors.Length - 1] < 1)
                    {
                        readjcolors[nSize - 1]    = readjcolors[nSize - 2];
                        readjpositions[nSize - 1] = 1;
                    }

                    cb.Colors    = readjcolors;
                    cb.Positions = readjpositions;
                }
                else
                {
                    cb.Colors    = colors;
                    cb.Positions = positions;
                }
            }
            else
            {
                cb.Colors    = colors;
                cb.Positions = positions;
            }

            brush.InterpolationColors = cb;

            if (res.SpreadMethod.AnimVal.Equals((ushort)SvgSpreadMethod.Reflect))
            {
                brush.WrapMode = WrapMode.TileFlipXY;
            }
            else if (res.SpreadMethod.AnimVal.Equals((ushort)SvgSpreadMethod.Repeat))
            {
                brush.WrapMode = WrapMode.Tile;
            }
            else if (res.SpreadMethod.AnimVal.Equals((ushort)SvgSpreadMethod.Pad))
            {
                brush.WrapMode = WrapMode.Tile;
            }

            brush.Transform = GetTransformMatrix(res);

            if (res.GetPropertyValue("color-interpolation") == "linearRGB")
            {
                brush.GammaCorrection = true;
            }
            else
            {
                brush.GammaCorrection = false;
            }

            return(brush);
        }
Esempio n. 19
0
 public void DrawRadial(ColorBlend blend, int x, int y, int width, int height)
 {
     DrawRadialRectangle = new Rectangle(x, y, width, height);
     DrawRadial(blend, DrawRadialRectangle, width / 2, height / 2);
 }
Esempio n. 20
0
 // Internal constructor
 private BrushPainter(BrushPainterType type, Color color1, Color color2, HatchStyle hatchStyle, float linearGradientAngle, BrushPathGradientType pathGradientType, ColorBlend gradientColors)
 {
     FillType              = type;
     this.color1           = color1;
     this.color2           = color2;
     HatchStyle            = hatchStyle;
     LinearGradientAngle   = linearGradientAngle;
     BrushPathGradientType = pathGradientType;
     GradientColors        = (gradientColors == null) ? Utils.GetDefaultColorBlend() : gradientColors;
 }
Esempio n. 21
0
 public void DrawRadial(ColorBlend blend, Rectangle r, Point center)
 {
     DrawRadial(blend, r, center.X, center.Y);
 }
Esempio n. 22
0
        private void pictureBox2_Paint(object sender, PaintEventArgs e)
        {
            Graphics gnp = e.Graphics;

            if (radioButton2.Checked)
            {
                GraphicsPath gp = new GraphicsPath();
                gp.AddEllipse(pictureBox2.ClientRectangle);
                PathGradientBrush pgb = new PathGradientBrush(gp);

                ColorBlend cb  = new ColorBlend();
                float      max = gradientColorHolder1.Colors.Count;
                cb.Positions = new float[(int)max];
                cb.Colors    = new Color[(int)max];
                for (int x = 0; x < max; x++)
                {
                    cb.Positions[x] = (float)x / max;
                    cb.Colors[x]    = gradientColorHolder1.Colors[x];
                }
                cb.Positions[(int)max - 1] = 1.0f;

                positions = cb.Positions;

                pgb.CenterPoint = new PointF(CP1_init.X, CP1_init.Y);

                pgb.InterpolationColors = cb;

                gnp.FillRectangle(pgb, pictureBox2.ClientRectangle);

                finished = (PathGradientBrush)pgb;
            }
            if (radioButton3.Checked)
            {
                GraphicsPath gp = new GraphicsPath();
                gp.AddRectangle(pictureBox2.ClientRectangle);
                PathGradientBrush pgb = new PathGradientBrush(gp);
                pgb.CenterColor = gradientColorHolder1.Colors[0];

                ColorBlend cb  = new ColorBlend();
                float      max = gradientColorHolder1.Colors.Count;
                cb.Positions = new float[(int)max];
                cb.Colors    = new Color[(int)max];
                for (int x = 0; x < max; x++)
                {
                    cb.Positions[x] = (float)x / max;
                    cb.Colors[x]    = gradientColorHolder1.Colors[x];
                }
                cb.Positions[(int)max - 1] = 1.0f;

                positions = cb.Positions;

                pgb.CenterPoint = new PointF(CP1_init.X, CP1_init.Y);

                pgb.InterpolationColors = cb;

                gnp.FillRectangle(pgb, pictureBox2.ClientRectangle);

                finished = (PathGradientBrush)pgb;
            }

            gnp.DrawEllipse(new Pen(new SolidBrush(Color.Black)), new Rectangle(CP1_init.X, CP1_init.Y, 4, 4));
        }
Esempio n. 23
0
 public static QuantityTheme CreateQuantityTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend,
     int numberOfClasses, IList<IComparable> values, float minSize, float maxSize, bool skipColors, bool skipSizes, QuantityThemeIntervalType intervalType)
 {
     var intervals = ThemeFactoryHelper.GetIntervalsForNumberOfClasses(values.Select(i=>Convert.ToSingle(i)).ToList(),
                                                                       intervalType, numberOfClasses);
     return CreateQuantityTheme(attribute, defaultStyle, blend, numberOfClasses, intervals,minSize,maxSize,skipColors,skipSizes);
 }
Esempio n. 24
0
        private void GenerateGradient()
        {
            if (radioButton1.Checked)
            {
                LinearGradientBrush lgb = new LinearGradientBrush(pictureBox1.ClientRectangle, Color.Black, Color.Black, 0f);
                ColorBlend          cb  = new ColorBlend();
                float max = gradientColorHolder1.Colors.Count;
                cb.Positions = new float[(int)max];
                cb.Colors    = new Color[(int)max];
                for (int x = 0; x < max; x++)
                {
                    cb.Positions[x] = (float)x / max;
                    cb.Colors[x]    = gradientColorHolder1.Colors[x];
                }
                cb.Positions[(int)max - 1] = 1.0f;
                lgb.InterpolationColors    = cb;

                positions = cb.Positions;

                Graphics gp = pictureBox1.CreateGraphics();
                gp.FillRectangle(lgb, pictureBox1.ClientRectangle);
                gp.Dispose();

                finished = (LinearGradientBrush)lgb.Clone();

                lgb.Dispose();

                gtype = GradientType.Linear;
            }
            if (radioButton2.Checked)
            {
                GraphicsPath gp = new GraphicsPath();
                gp.AddEllipse(pictureBox2.ClientRectangle);
                PathGradientBrush pgb = new PathGradientBrush(gp);
                pgb.CenterColor = gradientColorHolder1.Colors[0];

                ColorBlend cb  = new ColorBlend();
                float      max = gradientColorHolder1.Colors.Count;
                cb.Positions = new float[(int)max];
                cb.Colors    = new Color[(int)max];
                for (int x = 0; x < max; x++)
                {
                    cb.Positions[x] = (float)x / max;
                    cb.Colors[x]    = gradientColorHolder1.Colors[x];
                }
                cb.Positions[(int)max - 1] = 1.0f;

                pgb.CenterPoint = CP1_init;

                positions = cb.Positions;

                pgb.InterpolationColors = cb;

                Graphics gn = pictureBox2.CreateGraphics();
                gn.Clear(SystemColors.Control);
                gn.FillRectangle(pgb, pictureBox2.ClientRectangle);

                finished = (PathGradientBrush)pgb.Clone();

                gn.Dispose();
                gp.Dispose();
                pgb.Dispose();
                gtype = GradientType.Circular;
            }
            if (radioButton3.Checked)
            {
                GraphicsPath gp = new GraphicsPath();
                gp.AddRectangle(pictureBox2.ClientRectangle);
                PathGradientBrush pgb = new PathGradientBrush(gp);
                pgb.CenterColor = gradientColorHolder1.Colors[0];

                ColorBlend cb  = new ColorBlend();
                float      max = gradientColorHolder1.Colors.Count;
                cb.Positions = new float[(int)max];
                cb.Colors    = new Color[(int)max];
                for (int x = 0; x < max; x++)
                {
                    cb.Positions[x] = (float)x / max;
                    cb.Colors[x]    = gradientColorHolder1.Colors[x];
                }
                cb.Positions[(int)max - 1] = 1.0f;

                pgb.CenterPoint = CP1_init;

                positions = cb.Positions;

                pgb.InterpolationColors = cb;

                Graphics gn = pictureBox2.CreateGraphics();
                gn.Clear(SystemColors.Control);
                gn.FillRectangle(pgb, pictureBox2.ClientRectangle);

                finished = (PathGradientBrush)pgb.Clone();

                gn.Dispose();
                gp.Dispose();
                pgb.Dispose();
                gtype = GradientType.Rectangular;
            }
        }
Esempio n. 25
0
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        Graphics G = e.Graphics;
        base.OnPaint(e);
        TopGrip = TopSize + TopSpace;

        this.Padding = new Padding(BorderSize + InsideBorderSize, TopSize + TopSpace + InsideBorderSize, BorderSize + InsideBorderSize, BorderSize + InsideBorderSize);
        this.ParentForm.TransparencyKey = Color.Fuchsia;
        this.ParentForm.MinimumSize = MinimumSize;
        if (!(this.ParentForm.FormBorderStyle == FormBorderStyle.None))
        {
            this.ParentForm.FormBorderStyle = FormBorderStyle.None;
        }
        G.Clear(this.ParentForm.TransparencyKey);

        //| Drawing the main rectangle base.
        Rectangle MainRect = new Rectangle(0, TopSpace, Width - 1, Height - (1 + TopSpace));
        Rectangle MainHighlightRect = new Rectangle(1, 1 + TopSpace, Width - 3, Height - (3+ TopSpace));
        TextureBrush BGTextureBrush = new TextureBrush(D.CodeToImage(D.BGTexture), WrapMode.TileFlipXY);
        G.FillRectangle(BGTextureBrush, MainRect);
        G.DrawRectangle(new Pen(Color.FromArgb(40, Pal.ColHighest)), MainHighlightRect);
        G.DrawRectangle(Pens.Black, MainRect);

        //| Detail to the main rect's top grip
        Rectangle ShineRect = new Rectangle(0, TopSpace, Width, Height);
        //G.FillRectangle(new SolidBrush(Color.FromArgb(40, Pal.ColMed)), ShineRect);
        LinearGradientBrush SubShineLGB1 = new LinearGradientBrush(ShineRect, Color.Black, Color.Black, 0, false);
        LinearGradientBrush SubShineLGB2 = new LinearGradientBrush(ShineRect, Color.Black, Color.Black, 0, false);
        ColorBlend Blend = new ColorBlend();
        Blend.Positions = new[]{0,1 / 3f,2 / 3f,1};
        Blend.Colors = new[]{
            Color.FromArgb(50, Color.Black),
            Color.FromArgb(150, Color.Black),
            Color.FromArgb(50, Color.Black),
            Color.Transparent
        };
        SubShineLGB1.InterpolationColors = Blend;
        SubShineLGB1.RotateTransform(45);
        Blend.Colors = new[]{
            Color.FromArgb(50, Pal.ColHighest),
            Color.FromArgb(150, Pal.ColHighest),
            Color.FromArgb(50, Pal.ColHighest),
            Color.Transparent
        };
        SubShineLGB2.InterpolationColors = Blend;
        SubShineLGB2.RotateTransform(45);
        //|
        //D.FillGradientBeam(G, Color.Transparent, Color.FromArgb(80, Pal.ColHighest), ShineRect, GradientAlignment.Vertical);
        //G.DrawLine(new Pen(SubShineLGB1), new Point(1, ShineRect.Height), new Point(Width - 2, ShineRect.Height));
        //G.DrawLine(new Pen(SubShineLGB2), new Point(1, ShineRect.Height + 1), new Point(Width - 2, ShineRect.Height + 1));

        //| Goind back through and making the rect below the detail darker
        Rectangle DarkRect = new Rectangle(2, TopSpace + 2, Width - 4, Height - 4 - TopSpace);
        LinearGradientBrush DarkLGB = new LinearGradientBrush(DarkRect, Color.FromArgb(100, Color.Black), Color.FromArgb(100, Color.Black), 90);
        if (Darker) {
            G.FillRectangle(DarkLGB, DarkRect);
        }
        //Lighter
        //G.FillRectangle(new SolidBrush(Color.FromArgb(80, Pal.ColHigh)), DarkRect);

        //| The inner and slightly brigher rectangle of the form
        Rectangle InnerRect = new Rectangle(BorderSize-1, TopSpace + TopSize-1, Width - (BorderSize*2)+1, Height - BorderSize - TopSize - TopSpace+1);
        Rectangle InnerHighlightRect = new Rectangle(BorderSize + 1, TopSpace + TopSize + 1, Width - (BorderSize * 2) - 1, Height - BorderSize - TopSize - TopSpace - 1);
        Rectangle InnerHighlightRect2 = new Rectangle(BorderSize + InsideBorderSize, TopSpace + TopSize + InsideBorderSize, Width - (BorderSize * 2) - (InsideBorderSize*2), Height - BorderSize - TopSize - TopSpace - (InsideBorderSize*2));
        // G.FillRectangle(BGTextureBrush, InnerRect);
        // G.FillRectangle(new SolidBrush(Color.FromArgb(45, Pal.ColHigh)), InnerRect);
        G.FillRectangle(new SolidBrush(D.ColorFromHex("#33373B")), InnerRect);
        G.FillRectangle(new SolidBrush(BackColor), InnerHighlightRect2);
        G.DrawRectangle(new Pen(Color.FromArgb(65, Pal.ColHighest)), InnerRect);
        //G.DrawRectangle(new Pen(Color.FromArgb(40, Pal.ColHighest)), MainHighlightRect);
        //G.DrawRectangle(Pens.Black, MainRect);

        //G.FillRectangle(new SolidBrush(D.ColorFromHex("#33373B")), InnerHighlightRect);
        //G.FillRectangle(new SolidBrush(BackColor), InnerHighlightRect2);
        //G.DrawRectangle(new Pen(Color.FromArgb(80, Pal.ColHighest)), InnerHighlightRect);
        //G.DrawRectangle(Pens.Black, InnerRect);

        int textPad = 0;

        if (this.ParentForm.ShowIcon)
        {
            G.DrawIcon(this.ParentForm.Icon, new Rectangle(BorderSize-4, TopSpace + 3, TopSize - 4, TopSize - 4));
            textPad = BorderSize + TopSize - 5 + 4;
        }

        if(TitleAlignment == HorizontalAlignment.Center) {
            textPad = 0;
        }else if(TitleAlignment == HorizontalAlignment.Left && this.ParentForm.ShowIcon == false){
            textPad = BorderSize + 1;
        }
        D.DrawTextWithShadow(G, new Rectangle(textPad, TopSpace, Width, TopSize + TitleYOffset), Text, TitleFont, TitleAlignment, TitleColor, Color.Black);

        if (Sizable == true)
        {
            Rectangle SizeRect = new Rectangle(Width - BorderSize+1, Height - BorderSize+1, BorderSize-3, BorderSize-3);
            LinearGradientBrush SizeLGB = new LinearGradientBrush(DarkRect, Color.FromArgb(10, Color.LightGray), Color.FromArgb(10, Color.LightGray), 90);
            G.FillRectangle(SizeLGB, SizeRect);
            G.FillRectangle(SizeLGB, SizeRect);
        }
    }
Esempio n. 26
0
        private void CreateSweepGradient3(ColorBlend blend)
        {
            GraphicsPath path          = new GraphicsPath();
            int          width         = AnimationConfig.Width;
            int          height        = AnimationConfig.Height;
            int          halfWidth     = width / 2;
            int          halfHeight    = height / 2;
            int          quarterWidth  = width / 4;
            int          quarterHeight = height / 3;


            //path.AddLine(0, height, 0, halfHeight);
            //path.AddLine(0, halfHeight, 0, 0);
            //path.AddLine(0, 0, halfWidth, 0);
            //path.AddLine(halfWidth, 0, width, 0);
            //path.AddLine(width, 0, width, halfHeight);
            //path.AddLine(width, halfHeight, width, height);

            //path.AddLine(0, height, 0, height - quarterHeight);
            //path.AddLine(0, height - quarterHeight, 0, halfHeight);
            //path.AddLine(0, halfHeight, 0, quarterHeight);
            //path.AddLine(0, quarterHeight, 0, 0);

            //path.AddLine(0, 0, quarterWidth, 0);
            //path.AddLine(quarterWidth, 0, halfWidth, 0);
            //path.AddLine(halfWidth, 0, width - quarterWidth, 0);
            //path.AddLine(width - quarterWidth, 0, width, 0);

            //path.AddLine(width, 0, width, quarterHeight);
            //path.AddLine(width, quarterHeight, width, halfHeight);
            //path.AddLine(width, halfHeight, width, height - quarterHeight);
            //path.AddLine(width, height - quarterHeight, width, height);

            List <PointF> points = new List <PointF>();
            List <Color>  colors = new List <Color>();

            PointF center    = new PointF(AnimationConfig.Width / 2.0F, AnimationConfig.Height);
            double radius    = Math.Sqrt(center.X * center.X + center.Y * center.Y);
            double colorStep = 10;

            for (double angle = 0; angle < 360; angle += colorStep)
            {
                double angleR   = angle * (Math.PI / 180);
                PointF location = GetColorLocation(center, angleR, radius);
                points.Add(location);
            }
            path.AddLines(points.ToArray());


            int size = path.PointCount;

            Color[] baseColor = new Color[] { Color.Green, Color.Yellow, Color.Red, Color.Blue };
            sweepColors = new Color[size];
            int colorIndex     = 0;
            int colorIndexStep = 0;

            for (int i = 0; i < size; i++)
            {
                sweepColors[i] = baseColor[colorIndex];
                colorIndexStep++;
                if (colorIndexStep == 2)
                {
                    colorIndexStep = 0;
                    colorIndex++;
                    if (colorIndex == baseColor.Length)
                    {
                        colorIndex = 0;
                    }
                }
            }

            PathGradientBrush tempBrush = new PathGradientBrush(path);

            tempBrush.WrapMode       = WrapMode.Tile;
            tempBrush.SurroundColors = sweepColors;
            tempBrush.CenterColor    = Color.FromArgb(50, 250, 250, 250);
            tempBrush.CenterPoint    = center;

            brush = tempBrush;
            pen   = new Pen(tempBrush);
        }
Esempio n. 27
0
        /*
         * public override void Draw(Graphics g)
         * {
         *
         *  try
         *  {
         *      g.SmoothingMode = SmoothingMode.AntiAlias;
         *      Color bcolor = Color.White;
         *      Color fColor1 = Color.White;
         *      Color fColor2 = Color.White;
         *
         *      SelecactiveColor(ref  bcolor, ref fColor1, ref fColor2,shapefill,shapeoutline);
         *
         *      Pen pen = MakePen(bcolor,shapeoutline);
         *
         *
         *      GraphicsPath gp = new GraphicsPath();
         *
         *      ///////////////////////////
         *      switch (shapefill.FillType)
         *      {
         *          case FillTypePatern.Transparent:
         *
         *              for (int i = 0; i < pointArray.Count - 1; i++)
         *              {
         *                  gp.AddLine(((Point)pointArray[i]), ((Point)pointArray[i + 1]));
         *              }
         *              if (ShapeType == STATIC_OBJ_TYPE.ID_POLYGON)
         *              {
         *                  gp.CloseFigure();
         *              }
         *              g.DrawPath(pen, gp);
         *              pen.Dispose();
         *              gp.Dispose();
         *              break;
         *          case FillTypePatern.Solid:
         *
         *              Brush b;
         *              b = new SolidBrush(fColor1);
         *
         *              for (int i = 0; i < pointArray.Count - 1; i++)
         *              {
         *                  gp.AddLine(((Point)pointArray[i]), ((Point)pointArray[i + 1]));
         *              }
         *              if (ShapeType == STATIC_OBJ_TYPE.ID_POLYGON)
         *              {
         *                  gp.CloseFigure();
         *              }
         *
         *              g.DrawPath(pen, gp);
         *              g.FillPath(b, gp);
         *              gp.Dispose();
         *              pen.Dispose();
         *              b.Dispose();
         *              break;
         *          case FillTypePatern.Hatched:
         *
         *              HatchBrush hatchbrush = new HatchBrush(shapefill.hatchStyle, fColor1, Color.Transparent);
         *
         *              for (int i = 0; i < pointArray.Count - 1; i++)
         *              {
         *                  gp.AddLine(((Point)pointArray[i]), ((Point)pointArray[i + 1]));
         *              }
         *              if (ShapeType == STATIC_OBJ_TYPE.ID_POLYGON)
         *              {
         *                  gp.CloseFigure();
         *              }
         *
         *              g.DrawPath(pen, gp);
         *              g.FillPath(hatchbrush, gp);
         *              g.FillPath(hatchbrush, gp);
         *              gp.Dispose();
         *              pen.Dispose();
         *              hatchbrush.Dispose();
         *
         *
         *              break;
         *          case FillTypePatern.Gradient:
         *              LinearGradientBrush linearBrush;
         *
         *              //linearBrush = new LinearGradientBrush(rectangle, fColor1, fColor2, linearGradientBrush);
         *              linearBrush = new LinearGradientBrush(rectangle, fColor1, fColor2,LinearGradientMode.ForwardDiagonal);
         *
         *              for (int i = 0; i < pointArray.Count - 1; i++)
         *              {
         *                  gp.AddLine(((Point)pointArray[i]), ((Point)pointArray[i + 1]));
         *              }
         *              if (ShapeType == STATIC_OBJ_TYPE.ID_POLYGON)
         *              {
         *                  gp.CloseFigure();
         *              }
         *
         *              g.DrawPath(pen, gp);
         *              g.FillPath(linearBrush, gp);
         *              gp.Dispose();
         *              pen.Dispose();
         *              linearBrush.Dispose();
         *
         *              break;
         *          default:
         *              break;
         *      }
         *      ///////////////////////////
         *
         *      //for (int i = 0; i < pointArray.Count - 1; i++)
         *      //{
         *      //    gp.AddLine(((Point)pointArray[i]), ((Point)pointArray[i + 1]));
         *      //}
         *      //g.DrawPath(pen, gp);
         *      //gp.Dispose();
         *      //pen.Dispose();
         *
         *  }
         *  catch (Exception e)
         *  {
         *      MessageBox.Show(e.Message);
         *  }
         * }
         */

        public override void Draw(Graphics g)
        {
            Color bcolor  = Color.White;
            Color fColor1 = Color.White;
            Color fColor2 = Color.White;

            try
            {
                if (this.Visible)
                {
                    if (Common.Blinking && shapeoutline.BoarderBlinking)
                    {
                        bcolor = shapeoutline.BoarderColor2;
                    }
                    else
                    {
                        bcolor = shapeoutline.BoarderColor1;
                    }
                    Pen pen = new Pen(bcolor, shapeoutline.BoarderWidth);
                    pen.DashStyle = shapeoutline.BoarderDashStyle;
                    GraphicsPath gp = new GraphicsPath();

                    switch (shapefill.FillType)
                    {
                    case FillTypePatern.Transparent:
                        break;

                    case FillTypePatern.Solid:


                        if (Common.Blinking && shapefill.Blinking)
                        {
                            fColor1 = shapefill.FillColor12;
                        }
                        else
                        {
                            fColor1 = shapefill.FillColor11;
                        }
                        break;

                    case FillTypePatern.Hatched:
                        if (Common.Blinking && shapefill.Blinking)
                        {
                            fColor1 = Color.Transparent;
                        }
                        else
                        {
                            fColor1 = shapefill.FillColor11;
                        }

                        break;

                    case FillTypePatern.Gradient:
                        if (Common.Blinking && shapefill.Blinking)
                        {
                            fColor1 = Color.Transparent;
                            fColor2 = Color.Transparent;
                        }
                        else
                        {
                            fColor1 = shapefill.FillColor11;
                            fColor2 = shapefill.FillColor21;
                        }

                        break;
                    }
                    gp.AddPolygon(pointArray.ToArray());
                    //if ((RoundnessX == 0) && (RoundnessY == 0))
                    //{
                    //    gp.AddRectangle(rectangle);
                    //}
                    //else
                    //{
                    //    if (RoundnessX == 0)
                    //    {
                    //        RoundnessX = 1;
                    //    }
                    //    if (RoundnessY == 0)
                    //    {
                    //        RoundnessY = 1;
                    //    }

                    //    if (2 * RoundnessY > rectangle.Height)
                    //        RoundnessY = rectangle.Height / 2;
                    //    if (2 * RoundnessX > rectangle.Width)
                    //        RoundnessX = rectangle.Width / 2;
                    //    gp.AddLine(rectangle.Left + RoundnessX, rectangle.Top, rectangle.Left + rectangle.Width - (RoundnessX), rectangle.Top); // Line
                    //    gp.AddArc(rectangle.Left + rectangle.Width - (RoundnessX * 2), rectangle.Top, RoundnessX * 2, RoundnessY * 2, 270, 90); // Corner
                    //    gp.AddLine(rectangle.Left + rectangle.Width, rectangle.Top + RoundnessY, rectangle.Left + rectangle.Width, rectangle.Top + rectangle.Height - (RoundnessY)); // Line
                    //    gp.AddArc(rectangle.Left + rectangle.Width - (RoundnessX * 2), rectangle.Top + rectangle.Height - (RoundnessY * 2), RoundnessX * 2, RoundnessY * 2, 0, 90); // Corner
                    //    gp.AddLine(rectangle.Left + rectangle.Width - (RoundnessX), rectangle.Top + rectangle.Height, rectangle.Left + RoundnessX, rectangle.Top + rectangle.Height); // Line
                    //    gp.AddArc(rectangle.Left, rectangle.Top + rectangle.Height - (RoundnessY * 2), RoundnessX * 2, RoundnessY * 2, 90, 90); // Corner
                    //    gp.AddLine(rectangle.Left, rectangle.Top + rectangle.Height - (RoundnessY), rectangle.Left, rectangle.Top + RoundnessY); // Line
                    //    gp.AddArc(rectangle.Left, rectangle.Top, RoundnessX * 2, RoundnessY * 2, 180, 90); // Corner
                    //}

                    switch (shapefill.FillType)
                    {
                    case FillTypePatern.Transparent:

                        if (shapeoutline.BoarderWidth != 0)
                        {
                            g.DrawPath(pen, gp);
                        }
                        pen.Dispose();
                        gp.Dispose();
                        break;

                    case FillTypePatern.Solid:

                        Brush b = new SolidBrush(fColor1);

                        g.FillPath(b, gp);
                        if (shapeoutline.BoarderWidth != 0)
                        {
                            g.DrawPath(pen, gp);
                        }

                        gp.Dispose();
                        pen.Dispose();
                        b.Dispose();
                        break;

                    case FillTypePatern.Hatched:

                        using (HatchBrush hatchbrush = new HatchBrush(shapefill.hatchStyle, fColor1, Color.Transparent))
                        {
                            if (shapeoutline.BoarderWidth != 0)
                            {
                                g.DrawPath(pen, gp);
                            }

                            g.FillPath(hatchbrush, gp);
                        }
                        gp.Dispose();
                        pen.Dispose();
                        //hatchbrush.Dispose();


                        break;

                    case FillTypePatern.Gradient:
                        int x1, x2, y1, y2;
                        x1 = 1000000;
                        y1 = 1000000;
                        x2 = 0;
                        y2 = 0;
                        getSurroundingRect(ref x1, ref y1, ref x2, ref y2);
                        //x1 = rectangle.X;
                        //y1 = rectangle.Y;
                        //x2 = rectangle.Right;
                        //y2 = rectangle.Bottom;
                        Point pt1 = new Point();
                        Point pt2 = new Point();
                        switch (shapefill.Fillgradienttype)
                        {
                        case FillGradientType.Buttom2Top:
                            pt1 = new Point(x1, y2);
                            pt2 = new Point(x1, y1);
                            break;

                        case FillGradientType.Left2Right:
                            pt1 = new Point(x1, y1);
                            pt2 = new Point(x2, y1);
                            break;

                        case FillGradientType.Top2Buttom:
                            pt1 = new Point(x1, y1);
                            pt2 = new Point(x1, y2);
                            break;

                        case FillGradientType.Right2Left:
                            pt1 = new Point(x2, y1);
                            pt2 = new Point(x1, y1);
                            break;

                        case FillGradientType.NE2SW:
                            pt1 = new Point(x2, y1);
                            pt2 = new Point(x1, y2);
                            break;

                        case FillGradientType.NW2SE:
                            pt1 = new Point(x1, y1);
                            pt2 = new Point(x2, y2);
                            break;

                        case FillGradientType.SE2NW:
                            pt1 = new Point(x2, y2);
                            pt2 = new Point(x1, y1);
                            break;

                        case FillGradientType.SW2NE:
                            pt1 = new Point(x1, y2);
                            pt2 = new Point(x2, y1);
                            break;

                        case FillGradientType.FromHCenter:
                            pt1 = new Point(x1, y1);
                            pt2 = new Point(x1, y2);
                            break;

                        case FillGradientType.FromVCenter:
                            pt1 = new Point(x1, y1);
                            pt2 = new Point(x2, y1);
                            break;

                        case FillGradientType.ToHCenter:
                            pt1 = new Point(x1, y1);
                            pt2 = new Point(x1, y2);
                            break;

                        case FillGradientType.ToVCenter:
                            pt1 = new Point(x1, y1);
                            pt2 = new Point(x2, y1);
                            break;
                        }

                        switch (shapefill.Fillgradienttype)
                        {
                        case FillGradientType.Buttom2Top:
                        case FillGradientType.Left2Right:
                        case FillGradientType.Top2Buttom:
                        case FillGradientType.Right2Left:
                        case FillGradientType.NE2SW:
                        case FillGradientType.NW2SE:
                        case FillGradientType.SE2NW:
                        case FillGradientType.SW2NE:
                            using (LinearGradientBrush br = new LinearGradientBrush(pt1, pt2, fColor1, fColor2))
                            {
                                g.FillPath(br, gp);
                                if (shapeoutline.BoarderWidth != 0)
                                {
                                    g.DrawPath(pen, gp);
                                }
                            }
                            break;

                        case FillGradientType.FromHCenter:
                        case FillGradientType.FromVCenter:
                            using (LinearGradientBrush br = new LinearGradientBrush(pt1, pt2, fColor1, fColor2))
                            {
                                ColorBlend cb = new ColorBlend();
                                cb.Colors              = new Color[] { fColor2, fColor1, fColor2 };
                                cb.Positions           = new float[] { 0, 0.5F, 1 };
                                br.InterpolationColors = cb;
                                g.FillPath(br, gp);
                                if (shapeoutline.BoarderWidth != 0)
                                {
                                    g.DrawPath(pen, gp);
                                }
                            }
                            break;

                        case FillGradientType.ToHCenter:
                        case FillGradientType.ToVCenter:
                            using (LinearGradientBrush br = new LinearGradientBrush(pt1, pt2, fColor1, fColor2))
                            {
                                ColorBlend cb = new ColorBlend();
                                cb.Colors              = new Color[] { fColor1, fColor2, fColor1 };
                                cb.Positions           = new float[] { 0, 0.5F, 1 };
                                br.InterpolationColors = cb;
                                g.FillPath(br, gp);
                                if (shapeoutline.BoarderWidth != 0)
                                {
                                    g.DrawPath(pen, gp);
                                }
                            }
                            break;
                        }

                        gp.Dispose();
                        pen.Dispose();
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            //Trace.WriteLine("Draw rectangle.Left=" + rectangle.Left.ToString() + " rectangle.Top=" + rectangle.Top.ToString() + " rectangle.Width=" + rectangle.Width.ToString() + " rectangle.Height=" + rectangle.Height.ToString());
        }
Esempio n. 28
0
 /// <summary>
 /// Constructor that creates a linear gradient multi-color-fill, setting <see cref="Type"/> to
 /// <see cref="FillType.Brush"/> using the specified colors.  This gradient fill
 /// consists of many colors based on a <see cref="ColorBlend"/> object.  The gradient
 /// angle is defaulted to zero.
 /// </summary>
 /// <param name="blend">The <see cref="ColorBlend"/> object that defines the colors
 /// and positions along the gradient.</param>
 public Fill(ColorBlend blend) :
     this(blend, 0.0F)
 {
 }
Esempio n. 29
0
 public NSPathGradientBrushInfo(ColorBlend cb)
 {
     LinearGradient = new NSLinearGradientBrushInfo(cb, 0);
 }
Esempio n. 30
0
 /// <summary>
 /// Constructor that creates a linear gradient multi-color-fill, setting <see cref="Type"/> to
 /// <see cref="FillType.Brush"/> using the specified colors.  This gradient fill
 /// consists of many colors based on a <see cref="ColorBlend"/> object, drawn at the
 /// specified angle (degrees).
 /// </summary>
 /// <param name="blend">The <see cref="ColorBlend"/> object that defines the colors
 /// and positions along the gradient.</param>
 /// <param name="angle">The angle (degrees) of the gradient fill</param>
 public Fill(ColorBlend blend, float angle)
 {
     Init();
     _type = FillType.Brush;
     CreateBrushFromBlend(blend, angle);
 }
Esempio n. 31
0
 protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height)
 {
     DrawGradient(blend, x, y, width, height, 90);
 }
Esempio n. 32
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Bitmap B = new Bitmap(Width, Height);

            Graphics G = Graphics.FromImage(B);

            try
            {
                SelectedTab.BackColor = Color.White;
            }
            catch
            {
            }
            G.Clear(Parent.FindForm().BackColor);
            G.FillRectangle(new SolidBrush(Color.FromArgb(96, 110, 121)), new Rectangle(0, 0, ItemSize.Height + 4, Height));
            for (int i = 0; i <= TabCount - 1; i++)
            {
                if (i == SelectedIndex)
                {
                    Rectangle  x2      = new Rectangle(new Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), new Size(GetTabRect(i).Width + 3, GetTabRect(i).Height - 1));
                    ColorBlend myBlend = new ColorBlend();
                    myBlend.Colors = new Color[] {
                        Color.FromArgb(96, 110, 121),
                        Color.FromArgb(96, 110, 121),
                        Color.FromArgb(96, 110, 121)
                    };
                    myBlend.Positions = new float[] {
                        0f,
                        0.5f,
                        1f
                    };
                    LinearGradientBrush lgBrush = new LinearGradientBrush(x2, Color.Black, Color.Black, 90f);
                    lgBrush.InterpolationColors = myBlend;
                    G.FillRectangle(lgBrush, x2);
                    G.DrawRectangle(new Pen(Color.FromArgb(96, 110, 121)), x2);
                    Rectangle tabRect = new Rectangle(GetTabRect(i).Location.X + 4, GetTabRect(i).Location.Y + 2, GetTabRect(i).Size.Width + 10, GetTabRect(i).Size.Height - 11);
                    G.FillPath(new SolidBrush(Color.FromArgb(80, 90, 100)), RoundRect(tabRect, 5));
                    G.DrawPath(new Pen(Color.FromArgb(67, 77, 87)), RoundRect(new Rectangle(tabRect.X + 1, tabRect.Y + 1, tabRect.Width - 1, tabRect.Height - 2), 5));
                    G.DrawPath(new Pen(Color.FromArgb(115, 125, 135)), RoundRect(tabRect, 5));

                    G.SmoothingMode = SmoothingMode.HighQuality;
                    //Dim p() As Point = {New Point(ItemSize.Height - 3, GetTabRect(i).Location.Y + 20), New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 14), New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 27)}
                    //G.FillPolygon(Brushes.White, p)

                    if (ImageList != null)
                    {
                        try
                        {
                            if (ImageList.Images[TabPages[i].ImageIndex] != null)
                            {
                                G.DrawImage(ImageList.Images[TabPages[i].ImageIndex], new Point(x2.Location.X + 8, x2.Location.Y + 6));
                                G.DrawString("      " + TabPages[i].Text.ToUpper(), new Font(Font.FontFamily, Font.Size, FontStyle.Bold), Brushes.White, x2, new StringFormat
                                {
                                    LineAlignment = StringAlignment.Center,
                                    Alignment     = StringAlignment.Center
                                });
                            }
                            else
                            {
                                G.DrawString(TabPages[i].Text.ToUpper(), new Font(Font.FontFamily, Font.Size, FontStyle.Bold), Brushes.White, x2, new StringFormat
                                {
                                    LineAlignment = StringAlignment.Center,
                                    Alignment     = StringAlignment.Center
                                });
                            }
                        }
                        catch (Exception ex)
                        {
                            G.DrawString(TabPages[i].Text.ToUpper(), new Font(Font.FontFamily, Font.Size, FontStyle.Bold), Brushes.White, x2, new StringFormat
                            {
                                LineAlignment = StringAlignment.Center,
                                Alignment     = StringAlignment.Center
                            });
                        }
                    }
                    else
                    {
                        G.DrawString(TabPages[i].Text.ToUpper(), new Font(Font.FontFamily, Font.Size, FontStyle.Bold), Brushes.White, x2, new StringFormat
                        {
                            LineAlignment = StringAlignment.Center,
                            Alignment     = StringAlignment.Center
                        });
                    }

                    G.DrawLine(new Pen(Color.FromArgb(96, 110, 121)), new Point(x2.Location.X - 1, x2.Location.Y - 1), new Point(x2.Location.X, x2.Location.Y));
                    G.DrawLine(new Pen(Color.FromArgb(96, 110, 121)), new Point(x2.Location.X - 1, x2.Bottom - 1), new Point(x2.Location.X, x2.Bottom));
                }
                else
                {
                    Rectangle x2 = new Rectangle(new Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), new Size(GetTabRect(i).Width + 3, GetTabRect(i).Height + 1));
                    G.FillRectangle(new SolidBrush(Color.FromArgb(96, 110, 121)), x2);
                    G.DrawLine(new Pen(Color.FromArgb(96, 110, 121)), new Point(x2.Right, x2.Top), new Point(x2.Right, x2.Bottom));
                    if (ImageList != null)
                    {
                        try
                        {
                            if (ImageList.Images[TabPages[i].ImageIndex] != null)
                            {
                                G.DrawImage(ImageList.Images[TabPages[i].ImageIndex], new Point(x2.Location.X + 8, x2.Location.Y + 6));
                                G.DrawString("      " + TabPages[i].Text, Font, Brushes.White, x2, new StringFormat
                                {
                                    LineAlignment = StringAlignment.Near,
                                    Alignment     = StringAlignment.Near
                                });
                            }
                            else
                            {
                                G.DrawString(TabPages[i].Text.ToUpper(), new Font(Font.FontFamily, Font.Size, FontStyle.Bold), new SolidBrush(Color.FromArgb(210, 220, 230)), x2, new StringFormat
                                {
                                    LineAlignment = StringAlignment.Center,
                                    Alignment     = StringAlignment.Center
                                });
                            }
                        }
                        catch (Exception ex)
                        {
                            G.DrawString(TabPages[i].Text.ToUpper(), new Font(Font.FontFamily, Font.Size, FontStyle.Bold), new SolidBrush(Color.FromArgb(210, 220, 230)), x2, new StringFormat
                            {
                                LineAlignment = StringAlignment.Center,
                                Alignment     = StringAlignment.Center
                            });
                        }
                    }
                    else
                    {
                        G.DrawString(TabPages[i].Text.ToUpper(), new Font(Font.FontFamily, Font.Size, FontStyle.Bold), new SolidBrush(Color.FromArgb(210, 220, 230)), x2, new StringFormat
                        {
                            LineAlignment = StringAlignment.Center,
                            Alignment     = StringAlignment.Center
                        });
                    }
                }
                G.FillPath(Brushes.White, RoundRect(new Rectangle(86, 0, Width - 89, Height - 3), 5));
                G.DrawPath(new Pen(Color.FromArgb(65, 75, 85)), RoundRect(new Rectangle(86, 0, Width - 89, Height - 3), 5));
            }

            e.Graphics.DrawImage((Bitmap)B.Clone(), 0, 0);
            G.Dispose();
            B.Dispose();
        }
Esempio n. 33
0
	    public object Clone()
	    {
            ColorBlend colorBlend = new ColorBlend();
	        colorBlend.Colors = (Color[]) Colors.Clone();
	        for (int i = 0; i < _Colors.Length; i++)
	        {
	            colorBlend.Colors[i] = _Colors[i];
	        }
	        colorBlend.Positions = (float[]) Positions.Clone();
	        
            return colorBlend;
	    }
Esempio n. 34
0
        public void FillGradients(Graphics gr, GraphicsPath pa)
        {
            int origin = this.Height / 3; int end = this.Height; int oe = (end - origin) / 2;
            LinearGradientBrush lgbrush; Rectangle rect;

            if (_showbase == e_showbase.Yes)
            {
                rect = new Rectangle(new Point(0, 0), new Size(this.Width - 1, this.Height - 1));
                pa   = new GraphicsPath();
                DrawArc(rect, pa);
                lgbrush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, LinearGradientMode.Vertical);

                #region Main Gradient
                float[] pos = new float[4];
                pos[0] = 0.0F; pos[1] = 0.3F; pos[2] = 0.35F; pos[3] = 1.0F;
                Color[] colors = new Color[4];
                if (i_mode == 0)
                {
                    colors[0] = GetColor(0, 35, 24, 9);
                    colors[1] = GetColor(0, 13, 8, 3);
                    colors[2] = Color.FromArgb(A0, R0, G0, B0);
                    colors[3] = GetColor(0, 28, 29, 14);
                }
                else
                {
                    colors[0] = GetColor(0, 0, 50, 100);
                    colors[1] = GetColor(0, 0, 0, 30);
                    colors[2] = Color.FromArgb(A0, R0, G0, B0);
                    colors[3] = GetColor(0, 0, 50, 100);
                }
                ColorBlend mix = new ColorBlend();
                mix.Colors    = colors;
                mix.Positions = pos;
                lgbrush.InterpolationColors = mix;
                gr.FillPath(lgbrush, pa);
                #endregion

                #region Fill Band
                rect = new Rectangle(new Point(0, 0), new Size(this.Width, this.Height / 3));
                pa   = new GraphicsPath(); int _rtemp = _radius; _radius = _rtemp - 1;
                DrawArc(rect, pa);
                if (A0 > 80)
                {
                    gr.FillPath(new SolidBrush(Color.FromArgb(60, 255, 255, 255)), pa);
                }
                _radius = _rtemp;
                #endregion

                #region SplitFill
                if (_splitbutton == e_splitbutton.Yes & mouse)
                {
                    FillSplit(gr);
                }
                #endregion

                #region Shadow
                if (i_mode == 2)
                {
                    rect = new Rectangle(1, 1, this.Width - 2, this.Height);
                    pa   = new GraphicsPath();
                    DrawShadow(rect, pa);
                    gr.DrawPath(new Pen(Color.FromArgb(50, 20, 20, 20), 2.0F), pa);
                }
                else
                {
                    rect = new Rectangle(1, 1, this.Width - 2, this.Height - 1);
                    pa   = new GraphicsPath();
                    DrawShadow(rect, pa);
                    if (A0 > 80)
                    {
                        gr.DrawPath(new Pen(Color.FromArgb(100, 250, 250, 250), 3.0F), pa);
                    }
                }
                #endregion

                #region SplitLine

                if (_splitbutton == e_splitbutton.Yes)
                {
                    if (_imagelocation == e_imagelocation.Top)
                    {
                        switch (i_mode)
                        {
                        case 1:
                            gr.DrawLine(new Pen(_onStroke), new Point(1, this.Height - _splitdistance), new Point(this.Width - 1, this.Height - _splitdistance));
                            break;

                        case 2:
                            gr.DrawLine(new Pen(_pressStroke), new Point(1, this.Height - _splitdistance), new Point(this.Width - 1, this.Height - _splitdistance));
                            break;

                        default:
                            break;
                        }
                    }
                    else if (_imagelocation == e_imagelocation.Left)
                    {
                        switch (i_mode)
                        {
                        case 1:
                            gr.DrawLine(new Pen(_onStroke), new Point(this.Width - _splitdistance, 0), new Point(this.Width - _splitdistance, this.Height));
                            break;

                        case 2:
                            gr.DrawLine(new Pen(_pressStroke), new Point(this.Width - _splitdistance, 0), new Point(this.Width - _splitdistance, this.Height));
                            break;

                        default:
                            break;
                        }
                    }
                }
                #endregion

                rect = new Rectangle(new Point(0, 0), new Size(this.Width - 1, this.Height - 1));
                pa   = new GraphicsPath();
                DrawArc(rect, pa);
                gr.DrawPath(new Pen(_colorStroke, 0.9F), pa);

                pa.Dispose(); lgbrush.Dispose();
            }
        }
Esempio n. 35
0
 protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height)
 {
     DrawGradient(blend, x, y, width, height, 90);
 }
Esempio n. 36
0
        private void c1Chart1_DrawDataSeries(object sender, C1.Win.C1Chart.DrawDataSeriesEventArgs e)
        {
            SeriesInfo serInfo = m_serData.SeriesArray[e.SeriesIndex];

            switch (serInfo.BrushType)
            {
            case BrushType.Hatch:
                HatchBrush hb = new HatchBrush(serInfo.HatchStyle, serInfo.Color2, serInfo.Color1);
                e.Brush = hb;
                break;

            case BrushType.Gradient:
                RectangleF r = e.Bounds;
                PointF     pt1 = PointF.Empty, pt2 = PointF.Empty;
                bool       blend = false;

                switch (serInfo.GradientStyle)
                {
                case GradientStyle.Horizontal1:
                case GradientStyle.Horizontal2:
                    pt1    = r.Location;
                    pt2    = pt1;
                    pt2.X += r.Width;
                    if (serInfo.GradientStyle == GradientStyle.Horizontal2)
                    {
                        blend = true;
                    }
                    break;

                case GradientStyle.Vertical1:
                case GradientStyle.Vertical2:
                    pt1    = r.Location;
                    pt2    = pt1;
                    pt2.Y += r.Height;
                    if (serInfo.GradientStyle == GradientStyle.Vertical2)
                    {
                        blend = true;
                    }
                    break;

                case GradientStyle.Diagonal1:
                case GradientStyle.Diagonal2:
                    pt1    = r.Location;
                    pt2    = pt1;
                    pt2.X += r.Width;
                    pt2.Y += r.Height;
                    if (serInfo.GradientStyle == GradientStyle.Diagonal2)
                    {
                        blend = true;
                    }
                    break;

                case GradientStyle.BackDiagonal1:
                case GradientStyle.BackDiagonal2:
                    pt1    = r.Location;
                    pt2    = pt1;
                    pt2.X += r.Width;
                    pt1.Y += r.Height;
                    if (serInfo.GradientStyle == GradientStyle.BackDiagonal2)
                    {
                        blend = true;
                    }
                    break;

                case GradientStyle.Radial1:
                case GradientStyle.Radial2:
                    GraphicsPath path = new GraphicsPath();
                    if (c1Chart1.ChartGroups[0].ChartType == Chart2DTypeEnum.Pie)
                    {
                        path.AddEllipse(e.Bounds);
                    }
                    else
                    {
                        path.AddRectangle(e.Bounds);
                    }

                    PathGradientBrush pb = new PathGradientBrush(path);
                    pb.CenterColor    = serInfo.Color2;
                    pb.CenterPoint    = new PointF(e.Bounds.X + e.Bounds.Width / 2, e.Bounds.Y + e.Bounds.Height / 2);
                    pb.SurroundColors = new Color[] { serInfo.Color1 };
                    if (serInfo.GradientStyle == GradientStyle.Radial2)
                    {
                        ColorBlend cb = new ColorBlend();
                        cb.Colors              = new Color[] { serInfo.Color1, serInfo.Color2, serInfo.Color1 };
                        cb.Positions           = new float[] { 0, 0.5f, 1.0f };
                        pb.InterpolationColors = cb;
                    }
                    e.Brush = pb;
                    path.Dispose();
                    break;
                }

                if (!pt1.IsEmpty && !pt2.IsEmpty)
                {
                    LinearGradientBrush gb = new LinearGradientBrush(pt1, pt2, serInfo.Color1, serInfo.Color2);
                    if (blend)
                    {
                        ColorBlend cb = new ColorBlend();
                        cb.Colors              = new Color[] { serInfo.Color1, serInfo.Color2, serInfo.Color1 };
                        cb.Positions           = new float[] { 0, 0.5f, 1.0f };
                        gb.InterpolationColors = cb;
                    }
                    e.Brush = gb;
                }
                break;

            case BrushType.Texture:
                if (serInfo.Image != null)
                {
                    TextureBrush tb = new TextureBrush(serInfo.Image, WrapMode.Tile);
                    e.Brush = tb;
                }
                break;
            }
        }
Esempio n. 37
0
 protected void DrawGradient(ColorBlend blend, Rectangle r, float angle)
 {
     DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, angle);
     DrawGradientBrush.InterpolationColors = blend;
     G.FillRectangle(DrawGradientBrush, r);
 }
Esempio n. 38
0
 /// <summary>
 /// Builds two gradient graphic objects that are use to get a pixel color for transitioning between one color to another
 /// </summary>
 private void BuildGradientTransition()
 {
     lock (meditativeStateBitmapColor)
     {
         using (var graphics = Graphics.FromImage(fromTransitionBitmap))
         {
             ColorBlend blend = new ColorBlend(3);
             blend.Colors = new Color[3] {
                 CurrentColor, CurrentSecondaryColor, CurrentTertiaryColor
             };
             blend.Positions = new float[3] {
                 0f, 0.5f, 1f
             };
             using (var gradientBrush = new LinearGradientBrush(new Point(0, 0), new Point(meditativeStateBitmapColor.Width, meditativeStateBitmapColor.Height), CurrentColor, CurrentSecondaryColor)
             {
                 InterpolationColors = blend
             })
             {
                 graphics.FillRectangle(gradientBrush, gradientBrush.Rectangle);
             }
         }
     }
     lock (fromTransitionBitmap)
     {
         using (var graphics = Graphics.FromImage(fromTransitionBitmap))
         {
             using (var gradientBrush = new LinearGradientBrush(new Point(0, 0),
                                                                new Point(fromTransitionBitmap.Width, fromTransitionBitmap.Height), PreviousColor, Color.White))
             {
                 graphics.FillRectangle(gradientBrush, gradientBrush.Rectangle);
             }
         }
     }
     lock (toTransitionBitmap)
     {
         using (var graphics = Graphics.FromImage(toTransitionBitmap))
         {
             using (var gradientBrush = new LinearGradientBrush(new Point(0, 0), new Point(toTransitionBitmap.Width, toTransitionBitmap.Height), Color.White, CurrentColor))
             {
                 graphics.FillRectangle(gradientBrush, gradientBrush.Rectangle);
             }
         }
     }
     lock (fromTransitionBitmapSecondaryColor)
     {
         using (var graphics = Graphics.FromImage(fromTransitionBitmapSecondaryColor))
         {
             using (var gradientBrush = new LinearGradientBrush(new Point(0, 0), new Point(fromTransitionBitmapSecondaryColor.Width, fromTransitionBitmapSecondaryColor.Height), PreviousColor, Color.White))
             {
                 graphics.FillRectangle(gradientBrush, gradientBrush.Rectangle);
             }
         }
     }
     lock (toTransitionBitmapSecondaryColor)
     {
         using (var graphics = Graphics.FromImage(toTransitionBitmapSecondaryColor))
         {
             using (var gradientBrush = new LinearGradientBrush(new Point(0, 0), new Point(toTransitionBitmapSecondaryColor.Width, toTransitionBitmapSecondaryColor.Height), Color.White, CurrentColor)){
                 graphics.FillRectangle(gradientBrush, gradientBrush.Rectangle);
             }
         }
     }
     lock (fromTransitionBitmapTertiaryColor)
     {
         using (var graphics = Graphics.FromImage(fromTransitionBitmapTertiaryColor))
         {
             using (var gradientBrush = new LinearGradientBrush(new Point(0, 0), new Point(fromTransitionBitmapTertiaryColor.Width, fromTransitionBitmapTertiaryColor.Height), PreviousColor, Color.White))
             {
                 graphics.FillRectangle(gradientBrush, gradientBrush.Rectangle);
             }
         }
     }
     lock (toTransitionBitmapTertiaryColor)
     {
         using (var graphics = Graphics.FromImage(toTransitionBitmapTertiaryColor))
         {
             using (var gradientBrush = new LinearGradientBrush(new Point(0, 0), new Point(toTransitionBitmapTertiaryColor.Width, toTransitionBitmapTertiaryColor.Height), Color.White, CurrentColor))
             {
                 graphics.FillRectangle(gradientBrush, gradientBrush.Rectangle);
             }
         }
     }
 }
Esempio n. 39
0
 public void DrawRadial(ColorBlend blend, int x, int y, int width, int height, Point center)
 {
     DrawRadialRectangle = new Rectangle(x, y, width, height);
     DrawRadial(blend, DrawRadialRectangle, center.X, center.Y);
 }
Esempio n. 40
0
        /*
         * RenderUsingGdiPlus
         */

        /// <summary>
        /// Renders this <see cref="T:Genetibase.UI.NuGenMeters.NuGenPushGraphBar"/> using GDI+ algorythms.
        /// </summary>
        /// <param name="g">Specifies a GDI+ drawing surface.</param>
        protected virtual void RenderUsingGdiPlus(Graphics g)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            // High quality drawing.
            g.SmoothingMode = SmoothingMode.AntiAlias;

            Rectangle tweakedRectangle = new Rectangle(
                this.ClientRectangle.X,
                this.ClientRectangle.Y,
                this.ClientRectangle.Width - PEN_WIDTH,
                this.ClientRectangle.Height - PEN_WIDTH * 3
                );

            /*
             * Background.
             */

            if (this.BackgroundImage == null)
            {
                switch (this.BackgroundStyle)
                {
                case NuGenBackgroundStyle.Gradient:
                    using (LinearGradientBrush lgb = new LinearGradientBrush(
                               tweakedRectangle,
                               NuGenControlPaint.ColorFromArgb(this.BackgroundTransparency, this.BackGradientStartColor),
                               NuGenControlPaint.ColorFromArgb(this.BackgroundTransparency, this.BackGradientEndColor),
                               90
                               ))
                    {
                        g.FillRectangle(lgb, this.ClientRectangle);
                    }
                    break;

                case NuGenBackgroundStyle.Tube:
                    using (LinearGradientBrush lgb = new LinearGradientBrush(
                               tweakedRectangle,
                               NuGenControlPaint.ColorFromArgb(this.BackgroundTransparency, this.BackTubeGradientStartColor),
                               NuGenControlPaint.ColorFromArgb(this.BackgroundTransparency, this.BackTubeGradientEndColor),
                               90
                               ))
                    {
                        ColorBlend colorBlend = new ColorBlend(3);

                        colorBlend.Colors = new Color[] {
                            NuGenControlPaint.ColorFromArgb(this.BackgroundTransparency, this.BackTubeGradientEndColor),
                            NuGenControlPaint.ColorFromArgb(this.BackgroundTransparency, this.BackTubeGradientStartColor),
                            NuGenControlPaint.ColorFromArgb(this.BackgroundTransparency, this.BackTubeGradientEndColor)
                        };

                        colorBlend.Positions = new float[] { 0.0f, 0.5f, 1.0f };

                        lgb.InterpolationColors = colorBlend;

                        g.FillRectangle(lgb, this.ClientRectangle);
                    }
                    break;

                case NuGenBackgroundStyle.VerticalGradient:
                    using (LinearGradientBrush lgb = new LinearGradientBrush(
                               tweakedRectangle,
                               NuGenControlPaint.ColorFromArgb(this.BackgroundTransparency, this.BackGradientStartColor),
                               NuGenControlPaint.ColorFromArgb(this.BackgroundTransparency, this.BackGradientEndColor),
                               360
                               ))
                    {
                        g.FillRectangle(lgb, this.ClientRectangle);
                    }
                    break;
                }
            }
            else
            {
                if (this.StretchImage)
                {
                    g.DrawImage(
                        this.BackgroundImage,
                        tweakedRectangle,
                        0,
                        0,
                        this.BackgroundImage.Width,
                        this.BackgroundImage.Height,
                        GraphicsUnit.Pixel,
                        NuGenControlPaint.GetTransparentImageAttributes(this.BackgroundTransparency, false)
                        );
                }
                else
                {
                    g.DrawImage(
                        this.BackgroundImage,
                        tweakedRectangle,
                        tweakedRectangle.X,
                        tweakedRectangle.Y,
                        tweakedRectangle.Width,
                        tweakedRectangle.Height,
                        GraphicsUnit.Pixel,
                        NuGenControlPaint.GetTransparentImageAttributes(this.BackgroundTransparency, true)
                        );
                }
            }

            /*
             * Grid.
             */

            if (this.ShowGrid)
            {
                this.DrawGridGdiPlus(g, tweakedRectangle, NuGenControlPaint.ColorFromArgb(this.GridTransparency, this.GridColor), this.GridStep);
            }

            /*
             * Graph.
             */

            this.DrawGraphGdiPlus(g, tweakedRectangle);

            /*
             * Border.
             */

            NuGenControlPaint.DrawBorder(g, this.ClientRectangle, NuGenControlPaint.ColorFromArgb(this.ForegroundTransparency, this.BorderColor), this.BorderStyle);

            /*
             * Grayscale.
             */

            if (this.Enabled == false)
            {
                Image img = NuGenControlPaint.CreateBitmapFromGraphics(g, this.ClientRectangle);
                ControlPaint.DrawImageDisabled(g, img, 0, 0, this.BackColor);
            }
        }
Esempio n. 41
0
 public void DrawRadial(ColorBlend blend, Rectangle r)
 {
     DrawRadial(blend, r, r.Width / 2, r.Height / 2);
 }
Esempio n. 42
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.HighQuality;
            g.Clear(Parent.BackColor);

            DrawingHelper dh    = new DrawingHelper();
            int           slope = Adjustments.Roundness;

            Rectangle           mainRect = new Rectangle(2, 0, Width - 5, Height - 1);
            GraphicsPath        mainPath = dh.RoundRect(mainRect, slope);
            LinearGradientBrush backLGB  = null;

            if (_scheme == ColorScheme.Orange)
            {
                backLGB = new LinearGradientBrush(mainRect, Color.FromArgb(255, 120, 0), Color.FromArgb(200, 50, 0), 90.0F);
            }
            else
            {
                ColorBlend backCB = new ColorBlend(3);
                backCB.Colors               = new[] { Color.WhiteSmoke, Color.WhiteSmoke, Color.FromArgb(225, 230, 230) };
                backCB.Positions            = new[] { 0.0f, 0.75f, 1.0f };
                backLGB                     = new LinearGradientBrush(mainRect, Color.Black, Color.Black, 90.0F);
                backLGB.InterpolationColors = backCB;
            }
            g.FillPath(backLGB, mainPath);

            if (_scheme == ColorScheme.Orange)
            {
                if (state == MouseState.Over)
                {
                    g.FillPath(new SolidBrush(Color.FromArgb(18, Color.White)), mainPath);
                }
                else if (state == MouseState.Down)
                {
                    g.FillPath(new SolidBrush(Color.FromArgb(30, Color.White)), mainPath);
                }
            }
            else
            {
                if (state == MouseState.Over)
                {
                    g.FillPath(new SolidBrush(Color.FromArgb(10, Color.Black)), mainPath);
                }
                else if (state == MouseState.Down)
                {
                    g.FillPath(new SolidBrush(Color.FromArgb(18, Color.Black)), mainPath);
                }
            }

            int textX = 0;
            int textY = 0;

            if (_image != null)
            {
                int       bufferWidth   = 4;
                Size      imageSize     = new Size(Height - 20, Height - 20);
                Point     imageLocation = new Point();
                Rectangle imageRect     = new Rectangle();
                if (_alignment == HorizontalAlignment.Left)
                {
                    imageRect = new Rectangle(new Point(14, 10), imageSize);
                    textX     = imageRect.X + imageSize.Width + bufferWidth;
                }
                else if (_alignment == HorizontalAlignment.Center)
                {
                    imageLocation = new Point((int)((Width / 2) - (imageSize.Width / 2.0) - (bufferWidth / 2.0) - (g.MeasureString(Text, Font).Width / 2.0)), (int)((Height / 2) - (imageSize.Height / 2.0)));
                    imageRect     = new Rectangle(imageLocation, imageSize);
                    textX         = imageLocation.X + imageSize.Width + bufferWidth;
                }
                else if (_alignment == HorizontalAlignment.Right)
                {
                    textX     = (int)(Width - 14 - g.MeasureString(Text, Font).Width);
                    imageRect = new Rectangle(new Point(textX - bufferWidth - imageSize.Width, 10), imageSize);
                }
                g.DrawImage(_image, imageRect);
            }
            else
            {
                if (_alignment == HorizontalAlignment.Left)
                {
                    textX = 14;
                }
                else if (_alignment == HorizontalAlignment.Center)
                {
                    textX = (int)((this.Width / 2.0) - (g.MeasureString(Text, Font).Width / 2.0));
                }
                else if (_alignment == HorizontalAlignment.Right)
                {
                    textX = (int)(Width - g.MeasureString(Text, Font).Width - 14);
                }
            }
            textY = (int)((this.Height / 2.0) - (g.MeasureString(Text, Font).Height / 2.0) + 1);

            LinearGradientBrush borderLGB = null;

            if (_scheme == ColorScheme.Orange)
            {
                g.DrawString(Text, Font, Brushes.WhiteSmoke, new Point(textX, textY));
                borderLGB = new LinearGradientBrush(new Rectangle(0, 0, Width, Height), Color.FromArgb(180, 60, 0), Color.FromArgb(220, 120, 60), 90.0F);
            }
            else
            {
                g.DrawString(Text, Font, new SolidBrush(Color.FromArgb(50, 50, 50)), new Point(textX, textY));
                borderLGB = new LinearGradientBrush(new Rectangle(0, 0, Width, Height), Color.Silver, Color.Gainsboro, 90.0F);
            }

            g.DrawPath(new Pen(borderLGB), mainPath);
        }
Esempio n. 43
0
    public void DrawRadial(ColorBlend blend, Rectangle r, int cx, int cy)
    {
        DrawRadialPath.Reset();
        DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1);

        DrawRadialBrush1 = new PathGradientBrush(DrawRadialPath);
        DrawRadialBrush1.CenterPoint = new Point(r.X + cx, r.Y + cy);
        DrawRadialBrush1.InterpolationColors = blend;

        if (G.SmoothingMode == SmoothingMode.AntiAlias)
        {
            G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3);
        }
        else
        {
            G.FillEllipse(DrawRadialBrush1, r);
        }
    }
Esempio n. 44
0
        /// <summary>
        /// Paints the bar.
        /// </summary>
        /// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
        protected virtual void PaintBar(PaintEventArgs e)
        {
            float angle;

            angle = this.Orientation == Orientation.Horizontal ? 0 : 90;

            if (this.BarBounds.Height > 0 && this.BarBounds.Width > 0)
            {
                ColorBlend blend;

                // HACK: Inflating the brush rectangle by 1 seems to get rid of a odd issue where the last color is drawn on the first pixel

                blend = new ColorBlend();
                using (LinearGradientBrush brush = new LinearGradientBrush(Rectangle.Inflate(this.BarBounds, 1, 1), Color.Empty, Color.Empty, angle, false))
                {
                    switch (this.BarStyle)
                    {
                    case ColorBarStyle.TwoColor:
                        blend.Colors = new[]
                        {
                            this.Color1,
                            this.Color2
                        };
                        blend.Positions = new[]
                        {
                            0F,
                            1F
                        };
                        break;

                    case ColorBarStyle.ThreeColor:
                        blend.Colors = new[]
                        {
                            this.Color1,
                            this.Color2,
                            this.Color3
                        };
                        blend.Positions = new[]
                        {
                            0,
                            0.5F,
                            1
                        };
                        break;

                    case ColorBarStyle.Custom:
                        ColorCollection custom;
                        int             count;

                        custom = this.CustomColors;
                        count  = custom?.Count ?? 0;

                        if (custom != null && count > 0)
                        {
                            blend.Colors    = custom.ToArray();
                            blend.Positions = Enumerable.Range(0, count).Select(i => i == 0 ? 0 : i == count - 1 ? 1 : (float)(1.0D / count) * i).ToArray();
                        }
                        else
                        {
                            blend.Colors = new[]
                            {
                                this.Color1,
                                this.Color2
                            };
                            blend.Positions = new[]
                            {
                                0F,
                                1F
                            };
                        }
                        break;
                    }

                    brush.InterpolationColors = blend;
                    e.Graphics.FillRectangle(brush, this.BarBounds);
                }
            }
        }
Esempio n. 45
0
        public static QuantityTheme CreateQuantityTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend, 
            int numberOfClasses, IList<Interval> intervals)
        {
            float minSize = defaultStyle.Line.Width;
            float maxSize = defaultStyle.Line.Width;

            return CreateQuantityTheme(attribute, defaultStyle, blend, numberOfClasses, intervals, minSize, maxSize, false, false);
        }
Esempio n. 46
0
        public override void DrawAt(Graphics g, float ratio, bool preview)
        {
            base.DrawAt(g, ratio, preview);

            if (ControlState.Move == this.State)
            {
                Pen pen = new Pen(Color.Navy, 2.0f);
                DrawRoundRectangle(g, pen, this.RectInPage, this.Radius, 1.0f, ratio);
            }
            else
            {
                Rectangle rect = new Rectangle(Point.Empty, this.RectInPage.Size);
                Bitmap    bm   = new Bitmap(this.RectInPage.Width, this.RectInPage.Height);
                Graphics  gp   = Graphics.FromImage(bm);

                if (null != this.ImgBackgroundImage)
                {
                    gp.DrawImage(ImageHelper.Resize(this.ImgBackgroundImage, rect.Size, false), 0, 0);
                }
                else
                {
                    Color backColor = Color.FromArgb((int)(this.Alpha * 255), this.BackgroundColor);
                    if (EFlatStyle.Stereo == this.FlatStyle)
                    {
                        /* 绘制立体效果,三色渐变 */
                        LinearGradientBrush brush  = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, LinearGradientMode.Vertical);
                        Color[]             colors = new Color[3];
                        colors[0] = ColorHelper.changeBrightnessOfColor(backColor, 100);
                        colors[1] = backColor;
                        colors[2] = ColorHelper.changeBrightnessOfColor(backColor, -50);
                        ColorBlend blend = new ColorBlend();
                        blend.Positions           = new float[] { 0.0f, 0.3f, 1.0f };
                        blend.Colors              = colors;
                        brush.InterpolationColors = blend;
                        FillRoundRectangle(gp, brush, rect, this.Radius, 1.0f, ratio);
                        brush.Dispose();
                    }
                    else if (EFlatStyle.Flat == this.FlatStyle)
                    {
                        SolidBrush brush = new SolidBrush(backColor);
                        FillRoundRectangle(gp, brush, rect, this.Radius, 1.0f, ratio);
                        brush.Dispose();
                    }
                }

                int pl = (int)Math.Round(this.Padding.Left * ratio, 0);
                int pt = (int)Math.Round(this.Padding.Top * ratio, 0);
                int pr = (int)Math.Round(this.Padding.Right * ratio, 0);
                int pb = (int)Math.Round(this.Padding.Bottom * ratio, 0);

                /* 图标 */
                int   x      = pl;
                int   y      = pt;                    // 到父视图顶部的距离
                int   height = rect.Height - pt - pb; // 计算出高度
                int   width  = rect.Width - pl - pr;
                Image img    = this.ImgSymbol;
                if (null != img)
                {
                    gp.DrawImage(ImageHelper.Resize(img, new Size(width, height), false), x, y);
                }

                if (EBool.Yes == this.DisplayBorder)
                {
                    Color borderColor = this.BorderColor;
                    DrawRoundRectangle(gp, new Pen(borderColor, 1), rect, this.Radius, 1.0f, ratio);
                }

                g.DrawImage(bm,
                            this.VisibleRectInPage,
                            new Rectangle(new Point(this.VisibleRectInPage.X - this.RectInPage.X, this.VisibleRectInPage.Y - this.RectInPage.Y), this.VisibleRectInPage.Size),
                            GraphicsUnit.Pixel);

                if (!preview)
                {
                    this.FrameIsVisible = false;

                    if (this.IsThisSelected)
                    {
                        this.SetFrame();
                        Pen pen = new Pen(Color.LightGray, 1.0f);
                        pen.DashStyle = DashStyle.Dot;//设置为虚线,用虚线画四边,模拟微软效果
                        g.DrawLine(pen, this.LinePoints[0], this.LinePoints[1]);
                        g.DrawLine(pen, this.LinePoints[2], this.LinePoints[3]);
                        g.DrawLine(pen, this.LinePoints[4], this.LinePoints[5]);
                        g.DrawLine(pen, this.LinePoints[6], this.LinePoints[7]);
                        g.DrawLine(pen, this.LinePoints[8], this.LinePoints[9]);
                        g.DrawLine(pen, this.LinePoints[10], this.LinePoints[11]);
                        g.DrawLine(pen, this.LinePoints[12], this.LinePoints[13]);
                        g.DrawLine(pen, this.LinePoints[14], this.LinePoints[15]);

                        g.FillRectangles(Brushes.White, this.SmallRects); //填充8个小矩形的内部
                        g.DrawRectangles(Pens.Black, this.SmallRects);    //绘制8个小矩形的黑色边线

                        this.FrameIsVisible = true;
                    }
                }
            }
        }
Esempio n. 47
0
        public static QuantityTheme CreateQuantityTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend, 
            int numberOfClasses, IList<Interval> intervals, float minSize, float maxSize, bool skipColors, bool skipSizes)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle();
                defaultStyle.GeometryType = typeof(IPolygon);
            }

            var quantityTheme = new QuantityTheme(attribute, defaultStyle);
            
            var totalMinValue = (float) intervals[0].Min;
            var totalMaxValue = (float) intervals[intervals.Count - 1].Max;
            
            if (totalMinValue == totalMaxValue)
            {
                return null;
            }

            for (int i = 0; i < numberOfClasses; i++)
            {
                Color color = numberOfClasses > 1
                                  ? blend.GetColor(1 - (float) i/(numberOfClasses - 1))
                                  : ((SolidBrush) defaultStyle.Fill).Color;

                float size = defaultStyle.Line.Width;

                if (!skipSizes)
                {
                    var minValue = (float) intervals[i].Min;
                    var maxValue = (float) intervals[i].Max;
                    
                    float width = maxValue - minValue;
                    float mean = minValue + 0.5f * width;

                    float fraction = (mean - totalMinValue) / (totalMaxValue - totalMinValue);

                    size = minSize + fraction * (maxSize - minSize);
                }

                var vectorStyle = new VectorStyle
                                      {
                                          GeometryType = defaultStyle.GeometryType
                                      };

                if (defaultStyle.GeometryType == typeof(IPoint))
                {
                    if (skipColors)
                    {
                        color = ((SolidBrush)defaultStyle.Fill).Color;
                    }

                    vectorStyle.Fill = new SolidBrush(color);
                    vectorStyle.Shape = defaultStyle.Shape;

                    if (!skipSizes)
                    {
                        vectorStyle.ShapeSize = Convert.ToInt32(size);
                        vectorStyle.Line.Width = size;
                    }

                }
                else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
                {
                    if (skipColors)
                    {
                        color = ((SolidBrush)defaultStyle.Fill).Color;
                    }
                    vectorStyle.Fill = new SolidBrush(color);
                    vectorStyle.Line = CreatePen(color, size, defaultStyle.Line);
                    vectorStyle.Outline.Width = (defaultStyle.Outline.Width - defaultStyle.Line.Width) + size;
                }
                else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
                {
                    if (skipColors)
                    {
                        color = defaultStyle.Line.Color;
                    }
                    vectorStyle.Line = CreatePen(color, size, defaultStyle.Line);
                    vectorStyle.Outline.Width = (defaultStyle.Outline.Width - defaultStyle.Line.Width) + size;
                }
                else
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }
              
                quantityTheme.AddStyle(vectorStyle, intervals[i]);
            }

            return quantityTheme;
        }
Esempio n. 48
0
        public override Image Apply(Image img)
        {
            if (string.IsNullOrEmpty(Text))
            {
                return(img);
            }

            using (Font textFont = TextFont)
            {
                if (textFont == null || textFont.Size < 1)
                {
                    return(img);
                }

                NameParser parser = new NameParser(NameParserType.Text)
                {
                    Picture = img
                };
                string parsedText = parser.Parse(Text);

                Size      textSize           = Helpers.MeasureText(parsedText, textFont);
                Size      watermarkSize      = new Size(textSize.Width + BackgroundPadding * 2, textSize.Height + BackgroundPadding * 2);
                Point     watermarkPosition  = Helpers.GetPosition(Placement, Offset, img.Size, watermarkSize);
                Rectangle watermarkRectangle = new Rectangle(watermarkPosition, watermarkSize);

                if (AutoHide && !new Rectangle(0, 0, img.Width, img.Height).Contains(watermarkRectangle))
                {
                    return(img);
                }

                using (Bitmap bmpWatermark = new Bitmap(watermarkSize.Width, watermarkSize.Height))
                    using (Graphics gWatermark = Graphics.FromImage(bmpWatermark))
                    {
                        gWatermark.SetHighQuality();

                        if (DrawBackground)
                        {
                            using (GraphicsPath backgroundPath = new GraphicsPath())
                            {
                                Rectangle backgroundRect = new Rectangle(0, 0, watermarkSize.Width, watermarkSize.Height);
                                backgroundPath.AddRoundedRectangle(backgroundRect, CornerRadius);

                                Brush backgroundBrush = null;

                                try
                                {
                                    if (UseGradient)
                                    {
                                        backgroundBrush = new LinearGradientBrush(backgroundRect, BackgroundColor, BackgroundColor2, GradientType);

                                        if (UseCustomGradient && CustomGradientList != null && CustomGradientList.Count > 1)
                                        {
                                            ColorBlend colorBlend = new ColorBlend();
                                            IEnumerable <GradientStop> gradient = CustomGradientList.OrderBy(x => x.Offset);
                                            colorBlend.Colors    = gradient.Select(x => x.Color).ToArray();
                                            colorBlend.Positions = gradient.Select(x => x.Offset).ToArray();
                                            ((LinearGradientBrush)backgroundBrush).InterpolationColors = colorBlend;
                                        }
                                    }
                                    else
                                    {
                                        backgroundBrush = new SolidBrush(BackgroundColor);
                                    }

                                    gWatermark.FillPath(backgroundBrush, backgroundPath);
                                }
                                finally
                                {
                                    if (backgroundBrush != null)
                                    {
                                        backgroundBrush.Dispose();
                                    }
                                }

                                using (Pen borderPen = new Pen(BorderColor))
                                {
                                    gWatermark.DrawPath(borderPen, backgroundPath);
                                }
                            }
                        }

                        gWatermark.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

                        using (StringFormat sf = new StringFormat {
                            Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                        })
                        {
                            float centerX = bmpWatermark.Width / 2f;
                            float centerY = bmpWatermark.Height / 2f;

                            if (DrawTextShadow)
                            {
                                using (Brush textShadowBrush = new SolidBrush(TextShadowColor))
                                {
                                    gWatermark.DrawString(parsedText, textFont, textShadowBrush,
                                                          centerX + TextShadowOffset.X, centerY + TextShadowOffset.Y, sf);
                                }
                            }

                            using (Brush textBrush = new SolidBrush(TextColor))
                            {
                                gWatermark.DrawString(parsedText, textFont, textBrush, centerX, centerY, sf);
                            }
                        }

                        using (Graphics gResult = Graphics.FromImage(img))
                        {
                            gResult.SetHighQuality();
                            gResult.DrawImage(bmpWatermark, watermarkRectangle);
                        }
                    }
            }

            return(img);
        }
Esempio n. 49
0
 public BullProgressBar()
 {
     C1 = Color.FromArgb(246, 246, 246); //Background
     P1 = new Pen(Color.FromArgb(70, Color.White), 2F);
     P2 = new Pen(C2);
     P3 = new Pen(Color.FromArgb(255, 255, 255)); //Highlight
     B3 = new SolidBrush(Color.FromArgb(100, Color.White));
     X = new ColorBlend(4);
     X.Colors = new Color[] { C2, C3, C3, C2 };
     X.Positions = new float[] { 0.0F, 0.1F, 0.9F, 1.0F };
     R2 = new Rectangle(2, 2, 2, 2);
     B2 = new LinearGradientBrush(R2, Color.Transparent, Color.Transparent, 180.0F);
     B2.InterpolationColors = X;
 }
Esempio n. 50
0
	    public bool Equals(ColorBlend other)
	    {
	        if (ReferenceEquals(null, other)) return false;
	        if (ReferenceEquals(this, other)) return true;
            if ((Colors.Length != other.Colors.Length) || (Positions.Length != other.Positions.Length))
	            return false;
            //this equals a for loop comparing items in Colors to items in other.Colors
            if (Colors.Where((t, i) => (t.R != other.Colors[i].R) || (t.G != other.Colors[i].G) || (t.B != other.Colors[i].B) || (t.A != other.Colors[i].A)).Any())
            {
                return false;
            }
            //any difference in position is also not equals anymore
            if (Positions.Where((t,i)=>t!= other.Positions[i]).Any())
                return false;

	        return true;
	    }