Example #1
0
        public override void Paint(IGraphics graphics, IMapViewport viewport)
        {
            object state = graphics.SaveState();

            graphics.ChangeSmoothingMode(SmoothingMode.AntiAlias);
            MapVisualElementInfo info    = this.GetVisualElementInfo(viewport);
            GraphicsPath         path    = info.Path.Clone() as GraphicsPath;
            GraphicsPath         dotPath = new GraphicsPath();
            long   mapSize      = MapTileSystemHelper.MapSize(viewport.ZoomLevel);
            Matrix matrixOffset = new Matrix();

            matrixOffset.Translate(viewport.PanOffset.Width + info.Offset.X, viewport.PanOffset.Height + info.Offset.Y);
            path.Transform(matrixOffset);
            Matrix matrixWraparound = new Matrix();

            matrixWraparound.Translate(mapSize, 0);
            for (int i = 0; i < viewport.NumberOfWraparounds; i++)
            {
                RectangleF bounds   = path.GetBounds();
                float      diameter = bounds.Width / 3F;
                dotPath.AddEllipse(bounds.X + diameter, bounds.Y + diameter, diameter, diameter);
                graphics.FillPath(this.BorderColor, dotPath);
                //draw the image
                Point imageLocation = new Point((int)bounds.Location.X + (int)bounds.Width / 2 - this.image.Width / 2, (int)bounds.Location.Y);
                graphics.DrawImage(imageLocation, this.Image, true);
                path.Transform(matrixWraparound);
            }
            graphics.RestoreState(state);
        }
        private void DrawPath(
            IGraphics graphics,
            GraphicsPath path,
            RectangleF rectangle,
            Color[] gradientColors,
            float width)
        {
            graphics.ChangeSmoothingMode(this.borderElement.SmoothingMode);
            PenAlignment penAlignment = (double)width <= 1.0 ? PenAlignment.Inset : PenAlignment.Center;

            if (this.borderElement.GradientStyle == GradientStyles.Solid)
            {
                graphics.DrawPath(path, gradientColors[0], penAlignment, width, this.borderElement.BorderDashStyle, this.borderElement.BorderDashPattern);
            }
            else if (this.borderElement.GradientStyle == GradientStyles.Linear)
            {
                graphics.DrawLinearGradientPath(path, rectangle, gradientColors, penAlignment, width, this.borderElement.GradientAngle, this.borderElement.BorderDashStyle, this.borderElement.BorderDashPattern);
            }
            else if (this.borderElement.GradientStyle == GradientStyles.Radial)
            {
                graphics.DrawRadialGradientPath(path, Rectangle.Round(rectangle), gradientColors[0], new Color[3]
                {
                    gradientColors[1],
                    gradientColors[2],
                    gradientColors[3]
                }, penAlignment, width, this.borderElement.BorderDashStyle, this.borderElement.BorderDashPattern);
            }
            graphics.RestoreSmoothingMode();
        }
Example #3
0
        protected override void PrePaintElement(IGraphics graphics)
        {
            base.PrePaintElement(graphics);

            Graphics rawGraphics = (Graphics)graphics.UnderlayGraphics;

            graphicsCurrentSmoothingMode = rawGraphics.SmoothingMode;
            graphics.ChangeSmoothingMode(this.SmoothingMode);

            graphicsCurrentTextRenderingHint = rawGraphics.TextRenderingHint;
            if (this.Enabled)
            {
                rawGraphics.TextRenderingHint = this.TextRenderingHint;
            }
            else
            {
                rawGraphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
            }

            if (this.Opacity < 1)
            {
                this.saveGraphicsOpacity = graphics.Opacity;
                graphics.ChangeOpacity(this.Opacity * graphics.Opacity);
            }
        }
 private void DrawRectangle(
     IGraphics graphics,
     RectangleF rectangle,
     Color[] gradientColors,
     float width)
 {
     if (this.borderElement.BoxStyle == BorderBoxStyle.FourBorders)
     {
         graphics.DrawBorder(rectangle, this.borderElement);
     }
     else
     {
         graphics.ChangeSmoothingMode(this.borderElement.SmoothingMode);
         if (this.borderElement.GradientStyle == GradientStyles.Solid)
         {
             graphics.DrawRectangle(rectangle, gradientColors[0], PenAlignment.Center, width, this.borderElement.BorderDashStyle, this.borderElement.BorderDashPattern);
         }
         else if (this.borderElement.GradientStyle == GradientStyles.Linear)
         {
             graphics.DrawLinearGradientRectangle(rectangle, gradientColors, PenAlignment.Center, width, this.borderElement.GradientAngle, this.borderElement.BorderDashStyle, this.borderElement.BorderDashPattern);
         }
         else if (this.borderElement.GradientStyle == GradientStyles.Radial)
         {
             graphics.DrawRadialGradientRectangle(rectangle, gradientColors[0], gradientColors, PenAlignment.Inset, width, this.borderElement.BorderDashStyle, this.borderElement.BorderDashPattern);
         }
         graphics.RestoreSmoothingMode();
     }
 }
Example #5
0
        protected override void  PaintElement(IGraphics graphics, float angle, SizeF scale)
        {
            graphics.ChangeSmoothingMode(SmoothingMode.AntiAlias);
            if (this.Size.Width <= 2 || this.Size.Height <= 2)
            {
                return;
            }

            int   step       = this.StepWidth + this.SeparatorWidth;
            float beginPoint = this.StepWidth;

            LinearGradientBrush brush = this.CreateBrush();

            if (this.ProgressOrientation == ProgressOrientation.Left || this.ProgressOrientation == ProgressOrientation.Right)
            {
                if (this.ProgressOrientation == ProgressOrientation.Left)
                {
                    beginPoint  = this.Size.Width % step;
                    beginPoint += this.StepWidth;
                }

                float dx = (float)Math.Tan(DegreeToRadian(90 - this.SweepAngle)) * this.Size.Height;


                if (this.Dash && !this.Hatch)
                {
                    DrawHorizontalDashLines(graphics, beginPoint, step, dx, brush);
                }

                if (this.Hatch)
                {
                    DrawHorizontalDashLines(graphics, beginPoint, step, dx, brush);
                    DrawHorizontalDashLines(graphics, beginPoint, step, -dx, brush);
                }
            }
            else
            {
                if (this.ProgressOrientation == ProgressOrientation.Top)
                {
                    beginPoint  = this.Size.Height % step;
                    beginPoint += this.StepWidth;
                }

                float dy = (float)Math.Tan(DegreeToRadian(90 - this.SweepAngle)) * this.Size.Width;

                if (this.Dash && !this.Hatch)
                {
                    DrawVerticalDashLines(graphics, beginPoint, step, dy, brush);
                }

                if (this.Hatch)
                {
                    DrawVerticalDashLines(graphics, beginPoint, step, dy, brush);
                    DrawVerticalDashLines(graphics, beginPoint, step, -dy, brush);
                }
            }

            graphics.RestoreSmoothingMode();
            base.PaintElement(graphics, angle, scale);
        }
Example #6
0
 protected override void PrePaintElement(IGraphics graphics)
 {
     base.PrePaintElement(graphics);
     this.graphicsCurrentSmoothingMode = ((Graphics)graphics.UnderlayGraphics).SmoothingMode;
     graphics.ChangeSmoothingMode(this.SmoothingMode);
     if (this.Opacity >= 1.0)
     {
         return;
     }
     this.saveGraphicsOpacity = new double?(graphics.Opacity);
     graphics.ChangeOpacity(this.Opacity * graphics.Opacity);
 }
Example #7
0
        protected override void PostPaintElement(IGraphics graphics)
        {
            base.PostPaintElement(graphics);
            Graphics underlayGraphics = (Graphics)graphics.UnderlayGraphics;

            graphics.ChangeSmoothingMode(this.graphicsCurrentSmoothingMode);
            if (!this.saveGraphicsOpacity.HasValue || !this.saveGraphicsOpacity.HasValue)
            {
                return;
            }
            graphics.ChangeOpacity(this.saveGraphicsOpacity.Value);
        }
Example #8
0
        public override void PaintPrimitive(IGraphics graphics, float angle, SizeF scale)
        {
            graphics.ChangeSmoothingMode(SmoothingMode.AntiAlias);
            if (this.Size.Width <= 2 || this.Size.Height <= 2)
            {
                return;
            }
            int   step       = this.StepWidth + this.SeparatorWidth;
            float beginPoint = (float)this.StepWidth;

            (graphics.UnderlayGraphics as Graphics).SetClip(new RectangleF((float)this.Location.X, (float)this.Location.Y, (float)this.Size.Width, (float)this.Size.Height));
            Region clip = (graphics.UnderlayGraphics as Graphics).Clip;
            LinearGradientBrush brush = this.CreateBrush();

            if (this.ProgressOrientation == ProgressOrientation.Left || this.ProgressOrientation == ProgressOrientation.Right)
            {
                if (this.ProgressOrientation == ProgressOrientation.Right)
                {
                    beginPoint = (float)(this.Size.Width % step) + (float)this.StepWidth;
                }
                float dx = (float)Math.Tan(this.DegreeToRadian((double)(90 - this.SweepAngle))) * (float)this.Size.Height;
                if (this.dash && !this.hatch)
                {
                    this.DrawHorizontalDashLines(graphics, beginPoint, step, dx, brush);
                }
                if (this.hatch)
                {
                    this.DrawHorizontalDashLines(graphics, beginPoint, step, dx, brush);
                    this.DrawHorizontalDashLines(graphics, beginPoint, step, -dx, brush);
                }
            }
            else
            {
                if (this.ProgressOrientation == ProgressOrientation.Bottom)
                {
                    beginPoint = (float)(this.Size.Height % step) + (float)this.StepWidth;
                }
                float dy = (float)Math.Tan(this.DegreeToRadian((double)(90 - this.SweepAngle))) * (float)this.Size.Width;
                if (this.dash && !this.hatch)
                {
                    this.DrawVerticalDashLines(graphics, beginPoint, step, dy, brush);
                }
                if (this.hatch)
                {
                    this.DrawVerticalDashLines(graphics, beginPoint, step, dy, brush);
                    this.DrawVerticalDashLines(graphics, beginPoint, step, -dy, brush);
                }
            }
            (graphics.UnderlayGraphics as Graphics).Clip = clip;
            graphics.RestoreSmoothingMode();
        }
Example #9
0
        protected override void PostPaintElement(IGraphics graphics)
        {
            base.PostPaintElement(graphics);

            Graphics rawGraphics = (Graphics)graphics.UnderlayGraphics;

            graphics.ChangeSmoothingMode(this.graphicsCurrentSmoothingMode);
            rawGraphics.TextRenderingHint = this.graphicsCurrentTextRenderingHint;

            if (saveGraphicsOpacity != null && saveGraphicsOpacity.HasValue)
            {
                graphics.ChangeOpacity(this.saveGraphicsOpacity.Value);
            }
        }
Example #10
0
        ///////////////////////////////////////////////////////////////////////
        /// <summary>Draws the primitive on the screen.</summary>
        public override void PaintPrimitive(IGraphics graphics, float angle, SizeF scale)
        {
            Rectangle rect = new Rectangle(Point.Empty, this.Size);

            // Draw only in the four "clean" cases
            // Combinations of direction are not allowed
            graphics.ChangeSmoothingMode(System.Drawing.Drawing2D.SmoothingMode.None);

            //in Up and Down direction we need to add one-pixel correction to the GDI+ FillPolygon method
            switch (this.Direction)
            {
            case ArrowDirection.Left:
                graphics.FillPolygon(this.ForeColor,
                                     new Point[] {
                    new Point(rect.Width, rect.Top),
                    new Point(rect.Left, rect.Height / 2),
                    new Point(rect.Width, rect.Height)
                });
                break;

            case ArrowDirection.Right:
                graphics.FillPolygon(this.ForeColor,
                                     new Point[] {
                    new Point(rect.Left, rect.Top),
                    new Point(rect.Width, rect.Height / 2),
                    new Point(rect.Left, rect.Height)
                });
                break;

            case ArrowDirection.Up:
                graphics.FillPolygon(this.ForeColor,
                                     new Point[] {
                    new Point(rect.Left, rect.Height),
                    new Point(rect.Width / 2, rect.Top - 1),
                    new Point(rect.Width, rect.Height)
                });
                break;

            case ArrowDirection.Down:
                graphics.FillPolygon(this.ForeColor,
                                     new Point[] {
                    new Point(rect.Left + 1, rect.Top),
                    new Point(rect.Width / 2, rect.Height),
                    new Point(rect.Width, rect.Top)
                });
                break;
            }
            graphics.RestoreSmoothingMode();
        }
Example #11
0
        public override void PaintPrimitive(IGraphics graphics, float angle, SizeF scale)
        {
            Rectangle rectangle = new Rectangle(Point.Empty, this.Size);

            graphics.ChangeSmoothingMode(SmoothingMode.None);
            switch (this.Direction)
            {
            case ArrowDirection.Left:
                graphics.FillPolygon(this.ForeColor, new Point[3]
                {
                    new Point(rectangle.Width, rectangle.Top),
                    new Point(rectangle.Left, rectangle.Height / 2),
                    new Point(rectangle.Width, rectangle.Height)
                });
                break;

            case ArrowDirection.Up:
                graphics.FillPolygon(this.ForeColor, new Point[3]
                {
                    new Point(rectangle.Left, rectangle.Height),
                    new Point(rectangle.Width / 2, rectangle.Top - 1),
                    new Point(rectangle.Width, rectangle.Height)
                });
                break;

            case ArrowDirection.Right:
                graphics.FillPolygon(this.ForeColor, new Point[3]
                {
                    new Point(rectangle.Left, rectangle.Top),
                    new Point(rectangle.Width, rectangle.Height / 2),
                    new Point(rectangle.Left, rectangle.Height)
                });
                break;

            case ArrowDirection.Down:
                graphics.FillPolygon(this.ForeColor, new Point[3]
                {
                    new Point(rectangle.Left + 1, rectangle.Top),
                    new Point(rectangle.Width / 2, rectangle.Height),
                    new Point(rectangle.Width, rectangle.Top)
                });
                break;
            }
            graphics.RestoreSmoothingMode();
        }
Example #12
0
 public void PaintFill(IGraphics graphics, GraphicsPath clippingPath, RectangleF paintRect)
 {
     graphics.ChangeSmoothingMode(this.fillElement.SmoothingMode);
     if (clippingPath != null)
     {
         graphics.PushCurrentClippingPath(clippingPath);
     }
     if (this.fillElement.GradientStyle == GradientStyles.Radial)
     {
         RadGdiGraphics radGdiGraphics = graphics as RadGdiGraphics;
         if (radGdiGraphics != null)
         {
             int     val2           = 4;
             int     numberOfColors = this.fillElement.NumberOfColors;
             Color[] colorStops     = new Color[Math.Min(Math.Max(numberOfColors, 1), val2)];
             float[] colorOffsets   = new float[Math.Min(Math.Max(numberOfColors, 1), val2)];
             FillPrimitiveImpl.FillColorStopsAndOffsets(colorStops, colorOffsets, numberOfColors, this.fillElement);
             radGdiGraphics.FillGradientPath(clippingPath, paintRect, colorStops, colorOffsets, this.fillElement.GradientStyle, this.fillElement.GradientAngle, this.fillElement.GradientPercentage, this.fillElement.GradientPercentage2);
         }
     }
     else if (this.fillElement.GradientStyle == GradientStyles.Linear)
     {
         using (PathGradientBrush pathGradientBrush = new PathGradientBrush(clippingPath))
         {
             pathGradientBrush.CenterPoint    = new PointF(paintRect.X + paintRect.Width / 2f, paintRect.Y + paintRect.Height / 2f);
             pathGradientBrush.CenterColor    = this.fillElement.BackColor2;
             pathGradientBrush.SurroundColors = new Color[1]
             {
                 this.fillElement.BackColor
             };
             pathGradientBrush.SetBlendTriangularShape(this.fillElement.GradientPercentage, this.fillElement.GradientPercentage2);
             ((Graphics)graphics.UnderlayGraphics).FillPath((Brush)pathGradientBrush, clippingPath);
         }
     }
     else
     {
         this.FillRectangle(graphics, paintRect);
     }
     if (clippingPath != null)
     {
         graphics.PopCurrentClippingPath();
     }
     graphics.RestoreSmoothingMode();
 }
Example #13
0
        private void DrawLines(IGraphics g, int fillWidth, int fillHeight, int fillWidthValue2, int fillHeightValue2)
        {
            int       max = Math.Max(this.width, this.height);
            double    x1, x2, y1, y2;
            Rectangle rec = new Rectangle(fillWidth, 0, this.width, this.height);

            if (width == 0 || height == 0)//found empty Rectangle
            {
                return;
            }
            LinearGradientBrush lgb = new LinearGradientBrush(new Rectangle(0, 0, width, height), SeparatorColor1, SeparatorColor2, LinearGradientMode.Vertical);

            g.ChangeSmoothingMode(SmoothingMode.AntiAlias);
            x1         = x2 = y1 = y2 = 0;
            sweepAngle = SweepAngle;
            int sepCount = max / StepWidth;

            max = sepCount * 2;
            switch (Orientation)
            {
            case ProgressOrientation.Right:
            {
                rec = new Rectangle(0, 0, this.width - fillWidth, this.height);
                break;
            }

            case ProgressOrientation.Bottom:
            {
                rec = new Rectangle(0, 0, this.width, this.height - fillHeight);
                break;
            }

            case ProgressOrientation.Top:
            {
                rec = new Rectangle(0, fillHeight, this.width, this.height - fillHeight);
                break;
            }
            }
            Region backup = (g.UnderlayGraphics as Graphics).Clip;

            g.ExcludeClip(rec);
            int k = sweepAngle / 180;

            if (sweepAngle < 90 + k * 180)
            {
                x1 = (double)(StepWidth / Math.Cos(sweepAngle * Math.PI / 180));
                x2 = x1 + (double)(this.height * Math.Tan(sweepAngle * Math.PI / 180));
                y1 = 0;
                y2 = this.height;
                for (int i = -max; i <= max; i++)
                {
                    x2 = x1 * i + (double)(this.height * Math.Tan(sweepAngle * Math.PI / 180));
                    double p1 = x1 * i + (double)(SeparatorWidth / Math.Cos(sweepAngle * Math.PI / 180));
                    double p2 = p1 + (double)(this.height * Math.Tan(sweepAngle * Math.PI / 180));

                    g.FillPolygon(lgb, new PointF[] { new PointF((float)(x1 * i), (float)y1), new PointF((float)(x2),
                                                                                                         (float)y2), new PointF((float)(p2), (float)y2), new PointF((float)(p1), (float)y1) });

                    if (Hatch)
                    {
                        g.FillPolygon(lgb, new PointF[] { new PointF((float)(x1 * i),
                                                                     (float)y2), new PointF((float)(x2), (float)y1), new PointF((float)(p2), (float)y1), new PointF((float)(p1), (float)y2) });
                    }
                }
            }
            else
            {
                x1 = 0;
                x2 = (int)this.width;
                if ((Orientation == ProgressOrientation.Bottom) || (Orientation == ProgressOrientation.Top))
                {
                    x2 = (int)this.width;
                }

                y2 = y1 + (int)(this.width / Math.Tan(sweepAngle * Math.PI / 180));

                double p1 = 0;
                double p2 = 0;

                for (int i = -max; i <= max; i++)
                {
                    y1 = (int)(i * StepWidth / Math.Sin(sweepAngle * Math.PI / 180));
                    p1 = y1 + (int)(SeparatorWidth / Math.Sin(sweepAngle * Math.PI / 180));
                    p2 = p1 + (int)(this.width / Math.Tan(sweepAngle * Math.PI / 180));
                    y2 = y1 + (int)(this.width / Math.Tan(sweepAngle * Math.PI / 180));

                    g.FillPolygon(lgb, new PointF[] { new PointF((float)(x1),
                                                                 (float)y1), new PointF((float)(x2), (float)y2), new PointF((float)(x2), (float)p2), new PointF((float)(x1), (float)p1) });

                    if (Hatch)
                    {
                        g.FillPolygon(lgb, new PointF[] { new PointF((float)(x1),
                                                                     (float)y2), new PointF((float)(x2), (float)y1), new PointF((float)(x2), (float)p1), new PointF((float)(x1), (float)p2) });
                    }
                }
            }
            lgb.Dispose();
            g.RestoreSmoothingMode();
            (g.UnderlayGraphics as Graphics).Clip = backup;
        }
Example #14
0
        public override void PaintPrimitive(IGraphics graphics, float angle, SizeF scale)
        {
            Rectangle rect = new Rectangle(Point.Empty, this.Size);

            graphics.ChangeSmoothingMode(System.Drawing.Drawing2D.SmoothingMode.AntiAlias);
            switch (this.PanelBarStyle)
            {
            case PanelBarStyles.VisualStudio2005ToolBox:
                if (this.State == GroupState.Expanded)
                {
                    graphics.DrawLine(Color.Black, 0, rect.Height / 2, rect.Width, rect.Height / 2);
                }
                else
                {
                    graphics.DrawLine(Color.Black, 0, rect.Height / 2, rect.Width, rect.Height / 2);
                    graphics.DrawLine(Color.Black, rect.Width / 2, 0, rect.Width / 2, rect.Height);
                }
                break;

            case PanelBarStyles.ExplorerBarStyle:
                int arrowOffset = 4;
                if (this.State == GroupState.Expanded)
                {
                    graphics.FillPolygon(this.ForeColor,
                                         new Point[]
                    {
                        new Point(0, rect.Height / 2),
                        new Point(rect.Width / 2, 0),
                        new Point(rect.Width, rect.Height / 2),
                        new Point(rect.Width - 2, rect.Height / 2),
                        new Point(rect.Width / 2, 2),
                        new Point(2, rect.Height / 2)
                    });

                    graphics.FillPolygon(this.ForeColor,
                                         new Point[]
                    {
                        new Point(0, rect.Height / 2 + arrowOffset),
                        new Point(rect.Width / 2, arrowOffset),
                        new Point(rect.Width, rect.Height / 2 + arrowOffset),
                        new Point(rect.Width - 2, rect.Height / 2 + arrowOffset),
                        new Point(rect.Width / 2, 2 + arrowOffset),
                        new Point(2, rect.Height / 2 + arrowOffset)
                    });
                }
                else
                {
                    graphics.FillPolygon(this.ForeColor,
                                         new Point[]
                    {
                        new Point(0, rect.Height / 2),
                        new Point(rect.Width / 2, rect.Height),
                        new Point(rect.Width, rect.Height / 2),
                        new Point(rect.Width - 2, rect.Height / 2),
                        new Point(rect.Width / 2, rect.Height - 2),
                        new Point(2, rect.Height / 2)
                    });

                    graphics.FillPolygon(this.ForeColor,
                                         new Point[]
                    {
                        new Point(0, rect.Height / 2 - arrowOffset),
                        new Point(rect.Width / 2, rect.Height - arrowOffset),
                        new Point(rect.Width, rect.Height / 2 - arrowOffset),
                        new Point(rect.Width - 2, rect.Height / 2 - arrowOffset),
                        new Point(rect.Width / 2, rect.Height - 2 - arrowOffset),
                        new Point(2, rect.Height / 2 - arrowOffset)
                    });
                }
                break;
            }
            graphics.RestoreSmoothingMode();
        }
Example #15
0
 private void DrawRectangle(IGraphics graphics, Rectangle rectangle, Color color, float width)
 {
     graphics.ChangeSmoothingMode(SmoothingMode.None);
     graphics.DrawRectangle((RectangleF)rectangle, color, PenAlignment.Center, width, DashStyle.Dot);
     graphics.RestoreSmoothingMode();
 }
        private void DrawLines(
            IGraphics g,
            int fillWidth,
            int fillHeight,
            int fillWidthValue2,
            int fillHeightValue2)
        {
            int       num1      = Math.Max(this.width, this.height);
            Rectangle rectangle = new Rectangle(fillWidth, 0, this.width, this.height);

            if (this.width == 0 || this.height == 0)
            {
                return;
            }
            LinearGradientBrush linearGradientBrush = new LinearGradientBrush(new Rectangle(0, 0, this.width, this.height), this.SeparatorColor1, this.SeparatorColor2, LinearGradientMode.Vertical);

            g.ChangeSmoothingMode(SmoothingMode.AntiAlias);
            double num2;
            double num3 = num2 = 0.0;
            double num4 = num2;
            double num5 = num2;

            this.sweepAngle = this.SweepAngle;
            int num6 = num1 / this.StepWidth * 2;

            switch (this.Orientation)
            {
            case ProgressOrientation.Top:
                rectangle = new Rectangle(0, fillHeight, this.width, this.height - fillHeight);
                break;

            case ProgressOrientation.Bottom:
                rectangle = new Rectangle(0, 0, this.width, this.height - fillHeight);
                break;

            case ProgressOrientation.Right:
                rectangle = new Rectangle(0, 0, this.width - fillWidth, this.height);
                break;
            }
            Region clip = (g.UnderlayGraphics as Graphics).Clip;

            g.ExcludeClip(rectangle);
            if (this.sweepAngle < 90 + this.sweepAngle / 180 * 180)
            {
                double num7 = (double)this.StepWidth / Math.Cos((double)this.sweepAngle * Math.PI / 180.0);
                num5 = num7 + (double)this.height * Math.Tan((double)this.sweepAngle * Math.PI / 180.0);
                double num8   = 0.0;
                double height = (double)this.height;
                for (int index = -num6; index <= num6; ++index)
                {
                    double num9  = num7 * (double)index + (double)this.height * Math.Tan((double)this.sweepAngle * Math.PI / 180.0);
                    double num10 = num7 * (double)index + (double)this.SeparatorWidth / Math.Cos((double)this.sweepAngle * Math.PI / 180.0);
                    double num11 = num10 + (double)this.height * Math.Tan((double)this.sweepAngle * Math.PI / 180.0);
                    g.FillPolygon((Brush)linearGradientBrush, new PointF[4]
                    {
                        new PointF((float)num7 * (float)index, (float)num8),
                        new PointF((float)num9, (float)height),
                        new PointF((float)num11, (float)height),
                        new PointF((float)num10, (float)num8)
                    });
                    if (this.Hatch)
                    {
                        g.FillPolygon((Brush)linearGradientBrush, new PointF[4]
                        {
                            new PointF((float)num7 * (float)index, (float)height),
                            new PointF((float)num9, (float)num8),
                            new PointF((float)num11, (float)num8),
                            new PointF((float)num10, (float)height)
                        });
                    }
                }
            }
            else
            {
                double num7  = 0.0;
                double width = (double)this.width;
                if (this.Orientation == ProgressOrientation.Bottom || this.Orientation == ProgressOrientation.Top)
                {
                    width = (double)this.width;
                }
                num3 = num4 + (double)(int)((double)this.width / Math.Tan((double)this.sweepAngle * Math.PI / 180.0));
                for (int index = -num6; index <= num6; ++index)
                {
                    double num8  = (double)(int)((double)(index * this.StepWidth) / Math.Sin((double)this.sweepAngle * Math.PI / 180.0));
                    double num9  = num8 + (double)(int)((double)this.SeparatorWidth / Math.Sin((double)this.sweepAngle * Math.PI / 180.0));
                    double num10 = num9 + (double)(int)((double)this.width / Math.Tan((double)this.sweepAngle * Math.PI / 180.0));
                    double num11 = num8 + (double)(int)((double)this.width / Math.Tan((double)this.sweepAngle * Math.PI / 180.0));
                    g.FillPolygon((Brush)linearGradientBrush, new PointF[4]
                    {
                        new PointF((float)num7, (float)num8),
                        new PointF((float)width, (float)num11),
                        new PointF((float)width, (float)num10),
                        new PointF((float)num7, (float)num9)
                    });
                    if (this.Hatch)
                    {
                        g.FillPolygon((Brush)linearGradientBrush, new PointF[4]
                        {
                            new PointF((float)num7, (float)num11),
                            new PointF((float)width, (float)num8),
                            new PointF((float)width, (float)num9),
                            new PointF((float)num7, (float)num10)
                        });
                    }
                }
            }
            linearGradientBrush.Dispose();
            g.RestoreSmoothingMode();
            (g.UnderlayGraphics as Graphics).Clip = clip;
        }
Example #17
0
        public override void PaintPrimitive(IGraphics graphics, float angle, SizeF scale)
        {
            if (!this.DrawArrow)
            {
                return;
            }
            Rectangle rectangle = new Rectangle(Point.Empty, this.Size);

            graphics.ChangeSmoothingMode(SmoothingMode.AntiAlias);
            switch (this.Direction)
            {
            case ArrowDirection.Left:
                graphics.FillPolygon(this.ForeColor, new Point[3]
                {
                    new Point(rectangle.Width - 3, 0),
                    new Point(0, rectangle.Height / 2),
                    new Point(rectangle.Width - 3, rectangle.Height)
                });
                graphics.DrawLine(this.BackColor, rectangle.Width - 1, 0, rectangle.Width - 1, rectangle.Height - 1);
                graphics.DrawLine(this.ForeColor, rectangle.Width - 2, 0, rectangle.Width - 2, rectangle.Height);
                break;

            case ArrowDirection.Up:
                graphics.FillPolygon(this.ForeColor, new Point[3]
                {
                    new Point(0, rectangle.Height - 3),
                    new Point(rectangle.Width / 2, 0),
                    new Point(rectangle.Width, rectangle.Height - 3)
                });
                graphics.DrawLine(this.ForeColor, rectangle.Width / 2, rectangle.Height - 3, 0, rectangle.Width);
                graphics.DrawLine(this.ForeColor, 0, rectangle.Height - 1, rectangle.Width, rectangle.Height - 1);
                graphics.DrawLine(this.BackColor, 1, rectangle.Height - 2, rectangle.Width - 1, rectangle.Height - 2);
                break;

            case ArrowDirection.Right:
                graphics.FillPolygon(this.ForeColor, new Point[3]
                {
                    new Point(3, 0),
                    new Point(rectangle.Width, rectangle.Height / 2),
                    new Point(3, rectangle.Height)
                });
                graphics.DrawLine(this.ForeColor, 1, 0, 1, rectangle.Height);
                break;

            case ArrowDirection.Down:
                graphics.FillPolygon(this.ShadowColor, new Point[3]
                {
                    new Point(0, 5),
                    new Point((rectangle.Width - 1) / 2 + 1, rectangle.Height),
                    new Point(rectangle.Width, 5)
                });
                graphics.FillPolygon(this.ForeColor, new Point[3]
                {
                    new Point(0, 4),
                    new Point((rectangle.Width - 1) / 2, rectangle.Height - 1),
                    new Point(rectangle.Width - 1, 4)
                });
                graphics.DrawLine(this.ForeColor, 0, 1, rectangle.Width - 1, 1);
                graphics.DrawLine(this.ShadowColor, 1, 2, rectangle.Width, 2);
                break;
            }
            graphics.RestoreSmoothingMode();
        }
Example #18
0
        public void PaintFill(IGraphics graphics, float angle, SizeF scale, RectangleF paintRect)
        {
            if (this.IsTransparent())
            {
                return;
            }
            Size desired = Size.Round(paintRect.Size);

            if (desired.Width <= 0 || desired.Height <= 0)
            {
                return;
            }
            graphics.ChangeSmoothingMode(this.fillElement.SmoothingMode);
            this.lastScale = scale;
            ElementShape elementShape = (ElementShape)null;

            if (this.primitiveElement != null)
            {
                elementShape = this.primitiveElement.GetCurrentShape();
            }
            else if (this.shapedElement != null)
            {
                elementShape = this.shapedElement.GetCurrentShape();
            }
            FillElementPaintBuffer elementPaintBuffer = this.FillElementPaintBuffer;

            if (elementShape != null && elementPaintBuffer != null)
            {
                string str       = elementShape.SerializeProperties();
                int    shapeHash = string.IsNullOrEmpty(str) ? elementShape.GetHashCode() : str.GetHashCode();
                elementPaintBuffer.SetShapeHash(shapeHash);
            }
            bool flag = elementPaintBuffer != null && !elementPaintBuffer.IsDisabled && elementPaintBuffer.ShouldUsePaintBuffer() && this.primitiveElement.ShouldUsePaintBuffer();

            try
            {
                if (flag)
                {
                    if (!this.primitiveElement.IsDesignMode && elementPaintBuffer.PaintFromBuffer(graphics, scale, desired))
                    {
                        graphics.RestoreSmoothingMode();
                        return;
                    }
                    graphics.ChangeOpacity(1.0);
                    if (!this.primitiveElement.IsDesignMode)
                    {
                        elementPaintBuffer.SetGraphics(graphics, scale);
                    }
                }
            }
            catch
            {
                flag = false;
            }
            GraphicsPath path = (GraphicsPath)null;

            if (elementShape != null)
            {
                path = elementShape.CreatePath(paintRect);
                graphics.PushCurrentClippingPath(path);
            }
            this.FillRectangle(graphics, paintRect);
            if (path != null)
            {
                graphics.PopCurrentClippingPath();
                path.Dispose();
            }
            if (flag)
            {
                graphics.RestoreOpacity();
                if (!this.primitiveElement.IsDesignMode)
                {
                    elementPaintBuffer.ResetGraphics(graphics, scale);
                }
            }
            graphics.RestoreSmoothingMode();
        }