Example #1
0
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            // Paint the default cell appearance.

            DataGridViewCellStyle style = cellStyle;

            base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, style, advancedBorderStyle, paintParts);

            // Paint the progress bar.

            double progressValue      = Convert.ToDouble(value);
            double progressPercentage = progressValue / 100.0;
            string progressStr        = $"{progressValue:0.#}%";

            Color outlineColor         = BackgroundColor.AddShade(0.15f);
            Color progressOutlineColor = ProgressColor.AddShade(0.15f);

            // Paint the progress bar background.

            Rectangle drawRect = new Rectangle(cellBounds.X + 2, cellBounds.Y + 2, cellBounds.Width - 4, cellBounds.Height - 4);

            using (Brush brush = new SolidBrush(BackgroundColor))
                graphics.FillRectangle(brush, drawRect);

            using (Pen pen = new Pen(outlineColor))
                graphics.DrawRectangle(pen, drawRect);

            // Paint the progress bar foreground.

            if (progressValue > 0)
            {
                Rectangle progressRect = new Rectangle(drawRect.X, drawRect.Y, Convert.ToInt32(progressPercentage * drawRect.Width), drawRect.Height);

                using (Brush brush = new SolidBrush(ProgressColor))
                    graphics.FillRectangle(brush, progressRect);

                using (Pen pen = new Pen(progressOutlineColor))
                    graphics.DrawRectangle(pen, progressRect);
            }

            // Paint the progress bar text.

            if (ShowProgressPercentage)
            {
                bool isSelected = DataGridView.CurrentCell?.RowIndex == rowIndex;

                Color textColor = TextColor == default ? (isSelected ? style.SelectionForeColor : style.ForeColor) : TextColor;
                Font  textFont  = style.Font;

                TextRenderer.DrawText(graphics, progressStr, textFont, drawRect, textColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
            }
        }
    private int ProgressSort(ProgressColor pc1, ProgressColor pc2)
    {
        float delta = pc1.progress - pc2.progress;

        if (delta < 0)
        {
            return(-1);
        }
        if (delta > 0)
        {
            return(1);
        }
        return(0);
    }
        void DrawCupertinoProgressBar(ICanvas canvas, RectangleF dirtyRect)
        {
            canvas.SaveState();

            canvas.FillColor = ProgressColor.ToGraphicsColor(Cupertino.Color.SystemColor.Light.Blue, Cupertino.Color.SystemColor.Dark.Blue);

            var x = dirtyRect.X;
            var y = (float)((HeightRequest - CupertinoTrackHeight) / 2);

            var width = dirtyRect.Width;

            canvas.FillRoundedRectangle(x, y, (float)(width * Progress), CupertinoTrackHeight, 2);

            canvas.RestoreState();
        }
        /// <inheritdoc />
        protected override void OnPaint(SpriteRocket2D renderer)
        {
            var height    = Skin.LayoutInfo.ProgressBarHeight;
            var bounds    = ContentRectangle;
            var bgColor   = BackgroundColor.GetColor(this);
            var fgColor   = ProgressColor.GetColor(this);
            var barBounds = new Rectangle(bounds.Left, bounds.Top + ((bounds.Height - height) / 2), bounds.Width,
                                          height);
            var progressBounds = new Rectangle(barBounds.Left, barBounds.Top,
                                               (int)(barBounds.Width * MathHelper.Clamp(Percentage, 0, 1)), barBounds.Height);

            renderer.Begin();
            renderer.FillRectangle(barBounds, bgColor);
            renderer.FillRectangle(progressBounds, fgColor);
            renderer.End();
        }
        void DrawFluentProgressBar(ICanvas canvas, RectangleF dirtyRect)
        {
            canvas.SaveState();

            if (IsEnabled)
            {
                canvas.FillColor = ProgressColor.ToGraphicsColor(Fluent.Color.Primary.ThemePrimary);
            }
            else
            {
                canvas.FillColor = ColorHelper.GetGraphicsColor(Fluent.Color.Background.NeutralTertiaryAlt, Fluent.Color.Background.NeutralDark);
            }

            var x = dirtyRect.X;
            var y = (float)((HeightRequest - FluentTrackHeight) / 2);

            var width = dirtyRect.Width;

            canvas.FillRoundedRectangle(x, y, (float)(width * Progress), FluentTrackHeight, 0);

            canvas.RestoreState();
        }
Example #6
0
    static void Main()
    {
        const string firstMsg  = "1stステップ 1stステップ 1stステップ 1stステップ 1stステップ 1stステップ 1stステップ 1stステップ 1stステップ 1stステップ 1stステップ 1stステップ 1stステップ 1stステップ 1stステップ";
        const string secondMsg = "2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ 2ndステップ";
        const string thirdMsg  = "3rdステップ 3rdステップ 3rdステップ 3rdステップ 3rdステップ";

        Console.Write("READY...");
        Console.ReadKey();
        Console.WriteLine("\rSTART!  ");

        const int width = 55;
        const int works = 270;
        //モノクロ版
        //var prg=new Progress(width,works);
        //カラー版
        var prg = new ProgressColor(width, works);

        for (var i = 0; i <= works; i++)
        {
            Thread.Sleep(20);
            if (i < 130)
            {
                prg.update(firstMsg);
            }
            else if (i < 210)
            {
                prg.update(secondMsg);
            }
            else
            {
                prg.update(thirdMsg);
            }
        }
        prg.done("Done!");
        Console.WriteLine("終了しました!");
        Console.ReadLine();
    }
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            if (BorderRadius > 0)
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;
            }

            Rectangle rect = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - BorderThickness, ClientRectangle.Height - BorderThickness);

            g.FillPath(new SolidBrush(BackColor), ExtendedForms.RoundedRect(rect, BorderRadius));


            if (Figure == ProgressBarFigure.Normal)
            {
                Rectangle progressRect = new Rectangle(_value, rect.Y + 2, IndicatorWidth, rect.Bottom - 3);

                Brush brush = new LinearGradientBrush(progressRect, BackColor, ProgressColor, 0F);   //new SolidBrush( ProgressColor );

                g.FillPath(brush, ExtendedForms.RoundedRect(progressRect, BorderRadius));
                _value++;
                if (_value > rect.Width)
                {
                    _value = -_indicatorWidth;
                }

                g.DrawPath(new Pen(BorderColor, BorderThickness), ExtendedForms.RoundedRect(rect, BorderRadius));
            }
            else
            {
                Rectangle arcRect = new Rectangle(ClientRectangle.X + IndicatorHeight / 2, ClientRectangle.Y + IndicatorHeight / 2, ClientRectangle.Width - BorderThickness - IndicatorHeight, ClientRectangle.Height - BorderThickness - IndicatorHeight);
                Color     color1;
                Color     color2;


                //g.FillPie( new SolidBrush( ProgressColor ), rect, 0, Value );
                _value++;
                if (_value >= 720)
                {
                    _value = 360;
                }
                //if ( _value > 360 ) {
                //    _value = 0;
                //    _delta *= -1;
                //}

                //if ( _delta > 0 ) {
                //    color1 = ProgressColor.SetAlpha( IndicatorBackAlpha );
                //    color2 = ProgressColor;
                //}
                //else {
                //    color1 = ProgressColor;
                //    color2 = ProgressColor.SetAlpha( IndicatorBackAlpha );
                //}

                //g.DrawArc( new Pen( color1, IndicatorHeight ), arcRect, 0, 360 );
                //g.DrawArc( new Pen( color2, IndicatorHeight ), arcRect, -90, _value );

                //Console.WriteLine( _value );



                g.DrawArc(new Pen(ProgressColor.SetAlpha(IndicatorBackAlpha), IndicatorHeight), arcRect, 0, 360);
                g.DrawArc(new Pen(ProgressColor, IndicatorHeight), arcRect, _value, IndicatorWidth);

                g.DrawArc(new Pen(Color.Black.SetAlpha(50), IndicatorHeight), arcRect, _value * -2, 1);


                //_alpha += _delta;
                //if ( _alpha > 255 ) {
                //    _alpha = 255;
                //    _delta *= -1;
                //}
                //if ( _alpha < 0 ) {
                //    _alpha = 0;
                //    _delta *= -1;
                //}
            }

            string text = (Style == ProgressBarStyle.Marquee) ? Text : Value.ToString();

            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;

            g.DrawString(
                text,
                this.Font,
                new SolidBrush(ForeColor),
                rect,
                stringFormat);
        }
Example #8
0
        protected override void OnPaintSurface(SKPaintSurfaceEventArgs args)
        {
            base.OnPaintSurface(args);

            var info   = args.Info;
            var canvas = args.Surface.Canvas;

            canvas.Clear();

            var lineSize     = info.Height * 0.25f; //25%
            var lineSizeHalf = lineSize * 0.5f;

            BackgroundPaint.StrokeWidth     = lineSize;
            ForegroundPaint.StrokeWidth     = lineSize;
            ProgressCirclePaint.StrokeWidth = lineSize;
            FinishCirclePaint.StrokeWidth   = lineSize * 2;

            var rect = new SKRect(lineSizeHalf, 0, info.Width - lineSize, info.Height);

            var progress      = Math.Min(Math.Max(0, Progress), TotalProgress) / TotalProgress;
            var progressWidth = rect.Left + (rect.Width * progress);

            // Draw Background
            canvas.DrawLine(rect.Left, rect.MidY, rect.Right, rect.MidY, BackgroundPaint);

            // Draw Foreground
            ForegroundPaint.StrokeWidth = lineSize;

            canvas.DrawLine(rect.Left, rect.MidY, progressWidth, rect.MidY, ForegroundPaint);

            // Draw current progress line
            if (progress > 0 && progress < 1)
            {
                // Draw Top Progress Text
                var progressText = Progress.ToString(CultureInfo.InvariantCulture);
                var textRect     = new SKRect();
                TextPaint.MeasureText(progressText, ref textRect);
                canvas.DrawText(progressText,
                                progressWidth - 1 - textRect.MidX,
                                rect.Top + textRect.Height,
                                ActiveTextPaint);

                // Draw Progress Line
                ForegroundPaint.StrokeWidth = 1;
                canvas.DrawLine(progressWidth - 1, rect.Top + textRect.Height + lineSize * 0.3f, progressWidth - 1, rect.MidY + lineSizeHalf, ForegroundPaint);
            }

            // Draw end and start circle
            if (progress > 0)
            {
                canvas.DrawLine(rect.Left, rect.MidY, rect.Left, rect.MidY, ProgressCirclePaint);
            }
            if (progress >= 1)
            {
                canvas.DrawLine(rect.Right, rect.MidY, rect.Right, rect.MidY, ProgressCirclePaint);
            }

            // Draw Finish Circle
            FinishCirclePaint.Color = progress >= 1 ? ProgressColor.ToSKColor() : ProgressBackgroundColor.ToSKColor();
            var end = rect.Right;

            canvas.DrawLine(end, rect.MidY, end, rect.MidY, FinishCirclePaint);

            // Draw Labels
            if (LabelCount > 1)
            {
                var width    = rect.Width;
                var interval = width / (LabelCount - 1);
                for (var i = 0; i < LabelCount; i++)
                {
                    var xPos = rect.Left + interval * i;

                    var text     = (i * (TotalProgress / (LabelCount - 1))).ToString(CultureInfo.InvariantCulture);
                    var textRect = new SKRect();
                    TextPaint.MeasureText(text, ref textRect);
                    canvas.DrawText(text,
                                    XPosInsideBounds(xPos, textRect, info),
                                    rect.Bottom - 2,
                                    TextPaint);
                }
            }

            // Draw Finish Flag
            canvas.Save();
            FlagPaint.Color = TextPaint.Color.WithAlpha(150);
            FLAG_PATH.GetTightBounds(out var bounds);
            canvas.Translate(end, rect.MidY);
            var size  = lineSize * 0.75f;
            var scale = new SKPoint(size / (bounds.Width + FlagPaint.StrokeWidth),
                                    size / (bounds.Height + FlagPaint.StrokeWidth));

            canvas.Scale(scale);
            canvas.Translate(-bounds.MidX, -bounds.MidY);
            canvas.DrawPath(FLAG_PATH, FlagPaint);
            canvas.Restore();
        }