Exemple #1
0
        public double DrawSegment(NGraphics.ICanvas canvas, NGraphics.Point center, double radius, double startRadian, double pullLength, NGraphics.Font font, NGraphics.Color textColor, bool isNameVisible, NGraphics.Color percentColor, bool isPercentVisible, NGraphics.Color valueColor, bool isValueVisible)
        {
            double middleRadian = startRadian + Radian / 2.0;

            if (IsPull)
            {
                center = new NGraphics.Point(
                    center.X + pullLength * Math.Cos(middleRadian),
                    center.Y + pullLength * Math.Sin(middleRadian));
            }


            var brush = new SolidBrush((Color ?? NGraphics.Colors.Black));
            var pen   = new Pen(PenColor, PenWidth);

            canvas.DrawPath((path) =>
            {
                const double shardRadian = 0.02;

                path.MoveTo(center);
                path.LineTo(center.X + Math.Cos(startRadian) * radius, center.Y + Math.Sin(startRadian) * radius);

                for (var addRadian = 0.0; addRadian < Radian; addRadian += shardRadian)
                {
                    path.LineTo(center.X + Math.Cos(startRadian + addRadian) * radius, center.Y + Math.Sin(startRadian + addRadian) * radius);
                }
                path.LineTo(center.X + Math.Cos(startRadian + Radian) * radius, center.Y + Math.Sin(startRadian + Radian) * radius);

                path.Close();
            }, pen, brush);


            if (isNameVisible)
            {
                DrawName(canvas, center, radius, font, TitleColor ?? textColor, middleRadian);
            }
            if (isValueVisible)
            {
                DrawValue(canvas, center, radius, font, ValueColor ?? valueColor, middleRadian);
            }
            if (isPercentVisible)
            {
                DrawPercent(canvas, center, radius, font, PercentColor ?? percentColor, middleRadian);
            }

            return(startRadian + Radian);
        }
Exemple #2
0
        /// <summary>
        /// Draw the specified canvas.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        /// <param name="rect">Rect.</param>
        public override void Draw(NGraphics.ICanvas canvas, NGraphics.Rect rect)
        {
            base.Draw(canvas, rect);

            var backgroundBrush = new SolidBrush(new NGraphics.Color(BackgroundColor.R,
                                                                     BackgroundColor.G, BackgroundColor.B, BackgroundColor.A));

            var curveSize = CornerRadius;
            var width     = rect.Width;
            var height    = rect.Height;

            canvas.DrawPath(new PathOp [] {
                new MoveTo(curveSize, 0),
                // Top Right corner
                new LineTo(width - curveSize, 0),
                new CurveTo(
                    new NGraphics.Point(width - curveSize, 0),
                    new NGraphics.Point(width, 0),
                    new NGraphics.Point(width, curveSize)
                    ),
                new LineTo(width, height - curveSize),
                // Bottom right corner
                new CurveTo(
                    new NGraphics.Point(width, height - curveSize),
                    new NGraphics.Point(width, height),
                    new NGraphics.Point(width - curveSize, height)
                    ),
                new LineTo(curveSize, height),
                // Bottom left corner
                new CurveTo(
                    new NGraphics.Point(curveSize, height),
                    new NGraphics.Point(0, height),
                    new NGraphics.Point(0, height - curveSize)
                    ),
                new LineTo(0, curveSize),
                new CurveTo(
                    new NGraphics.Point(0, curveSize),
                    new NGraphics.Point(0, 0),
                    new NGraphics.Point(curveSize, 0)
                    ),
                new ClosePath()
            }, null, backgroundBrush);
        }
Exemple #3
0
        public override void Draw(NGraphics.ICanvas canvas, NGraphics.Rect rect)
        {
            base.Draw(canvas, rect);
            const double delta   = -10.0;
            const double yOffset = 20;
            var          width   = rect.Width;
            var          height  = rect.Height;

            var points = new PathOp[]
            {
                new MoveTo(0, yOffset - delta),
                new CurveTo(new NGraphics.Point(width / 2, yOffset + delta),
                            new NGraphics.Point(width / 2, yOffset + delta),
                            new NGraphics.Point(width, yOffset - delta)),
                new LineTo(width, height),
                new LineTo(0, height)
            };

            canvas.DrawPath(points, null, new SolidBrush(new NGraphics.Color(0, 0.722, 1, 1)));
        }