示例#1
0
        private void DrawProgressMarquee(Graphics graphics)
        {
            Rectangle _progressRectangle;

            switch (_orientation)
            {
            case Orientation.Horizontal:
            {
                _progressRectangle = new Rectangle(_marqueeX, 0, _marqueeWidth, ClientRectangle.Height);
                break;
            }

            case Orientation.Vertical:
            {
                _progressRectangle = new Rectangle(0, _marqueeY, ClientRectangle.Width, ClientRectangle.Height);
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException();
            }
            }

            GraphicsPath _progressPath = new GraphicsPath();

            _progressPath.AddRectangle(_progressRectangle);
            graphics.SetClip(ControlGraphicsPath);
            graphics.FillPath(new SolidBrush(_progressColor), _progressPath);
            VisualProgressRenderer.RenderHatch(graphics, _hatch, _progressPath);
            graphics.ResetClip();
        }
示例#2
0
        private void DrawProgress(Orientation orientation, Graphics graphics)
        {
            if (_progressBarStyle == ProgressBarStyle.Marquee)
            {
                if (!DesignMode && Enabled)
                {
                    StartTimer();
                }

                if (!Enabled)
                {
                    StopTimer();
                }

                if (Value == Maximum)
                {
                    StopTimer();
                    DrawProgressContinuous(graphics);
                }
                else
                {
                    DrawProgressMarquee(graphics);
                }
            }
            else
            {
                int _indexValue;

                GraphicsPath _progressPath;
                Rectangle    _progressRectangle;

                switch (orientation)
                {
                case Orientation.Horizontal:
                {
                    _indexValue        = (int)Math.Round(((Value - Minimum) / (double)(Maximum - Minimum)) * (Width - 2));
                    _progressRectangle = new Rectangle(0, 0, _indexValue + _border.Thickness, Height);
                    _progressPath      = VisualBorderRenderer.CreateBorderTypePath(_progressRectangle, _border);
                }

                break;

                case Orientation.Vertical:
                {
                    _indexValue        = (int)Math.Round(((Value - Minimum) / (double)(Maximum - Minimum)) * (Height - 2));
                    _progressRectangle = new Rectangle(0, Height - _indexValue - _border.Thickness - 1, Width, _indexValue);
                    _progressPath      = VisualBorderRenderer.CreateBorderTypePath(_progressRectangle, _border);
                }

                break;

                default:
                {
                    throw new ArgumentOutOfRangeException(nameof(orientation), orientation, null);
                }
                }

                if (_indexValue > 1)
                {
                    graphics.SetClip(ControlGraphicsPath);
                    graphics.FillRectangle(new SolidBrush(_progressColor), _progressRectangle);
                    VisualProgressRenderer.RenderHatch(graphics, _hatch, _progressPath);
                    graphics.ResetClip();
                }
            }

            DrawText(graphics);
        }