Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="g"></param>
 /// <param name="drawRect"></param>
 private void DrawTrackLine(Graphics g, RectangleF drawRect)
 {
     JYDrawStyleHelper.DrawAquaPillSingleLayer(g, drawRect, _trackLineColor, Orientation.Vertical);
 }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="g"></param>
 /// <param name="trackerRect"></param>
 private void DrawTracker(Graphics g, RectangleF trackerRect)
 {
     JYDrawStyleHelper.DrawAquaPill(g, trackerRect, ForeColor, Orientation.Vertical);
 }
Пример #3
0
        /// <summary>
        /// This member overrides <see cref="Control.OnPaint">Control.OnPaint</see>.
        /// </summary>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Brush      brush;
            RectangleF rectTemp, drawRect, drawFillRect;
            float      textAreaSize;
            //如果有问题 则更改这里,显示不够长的话
            Rectangle workingRect    = Rectangle.Inflate(this.ClientRectangle, -_indentWidth - 10, -_indentHeight);
            float     currentUsedPos = 0;

            //==========================================================================
            // Draw the background of the ProgressBar control.
            //==========================================================================
            brush    = new SolidBrush(this.BackColor);
            rectTemp = this.ClientRectangle;
            e.Graphics.FillRectangle(brush, rectTemp);
            brush.Dispose();
            //==========================================================================

            //==========================================================================

            //_orientation == Orientation.Vertical

            currentUsedPos = _indentWidth;
            //==========================================================================

            // Get Width of Text Area
            textAreaSize = e.Graphics.MeasureString(_maximum.ToString(), this.Font).Width;

            if (_textTickStyle == TickStyle.TopLeft || _textTickStyle == TickStyle.Both)
            {
                //==========================================================================
                // Draw the 1st Text Line.
                //==========================================================================
                // Get Height of Text Area
                drawRect = new RectangleF(currentUsedPos, workingRect.Top, textAreaSize, workingRect.Height);
                drawRect.Inflate(0, -_trackerSize.Width / 2);
                currentUsedPos += textAreaSize;

                DrawTickTextLine(e.Graphics, drawRect, _tickFrequency, _minimum, _maximum, this.ForeColor, this.Font, Orientation.Vertical);
                //==========================================================================
            }

            if (_tickStyle == TickStyle.TopLeft || _tickStyle == TickStyle.Both)
            {
                //==========================================================================
                // Draw the 1st Tick Line.
                //==========================================================================
                drawRect = new RectangleF(currentUsedPos, workingRect.Top, _tickHeight, workingRect.Height);
                drawRect.Inflate(0, -_trackerSize.Width / 2);
                currentUsedPos += _tickHeight + 1;

                DrawTickLine(e.Graphics, drawRect, _tickFrequency, _minimum, _maximum, _tickColor, Orientation.Vertical);
                //==========================================================================
            }

            //==========================================================================
            // Caculate the Tracker's rectangle
            //==========================================================================
            double currentTrackerPos;

            currentTrackerPos = 0;

            _trackerRect = new RectangleF(currentUsedPos, (float)(workingRect.Bottom - currentTrackerPos - _trackerSize.Width), _trackerSize.Height, _trackerSize.Width); // Remember this for drawing the Tracker later
                                                                                                                                                                          //_trackerRect.Inflate(-1,0);

            rectTemp = _trackerRect;                                                                                                                                      //Testing

            //==========================================================================
            // Draw the Track Line
            //==========================================================================


            drawRect = new RectangleF(currentUsedPos + _trackerSize.Height / 2 - _trackLineHeight / 2, workingRect.Top, _trackLineHeight, workingRect.Height);

            DrawTrackLine(e.Graphics, drawRect);
            drawRect = new RectangleF(currentUsedPos, workingRect.Top, _tickHeight, workingRect.Height);
            drawRect.Inflate(0, -_trackerSize.Width / 2);

            double currentValuePos = drawRect.Height * (Value - _minimum) / (_maximum - _minimum);

            //    drawFillRect = new RectangleF(currentUsedPos + _trackerSize.Height / 2 - _trackLineHeight / 2, drawRect.Bottom -(float) currentValuePos, _trackLineHeight, (float)( currentValuePos - _trackerSize.Width / 2));
            drawFillRect = new RectangleF(currentUsedPos + _trackerSize.Height / 2 - _trackLineHeight / 2, drawRect.Bottom - (float)currentValuePos, _trackLineHeight, (float)(currentValuePos - _trackerSize.Width / 4));

            JYDrawStyleHelper.DrawAquaPillSingleLayer(e.Graphics, drawFillRect, ForeColor, Orientation.Vertical);
            currentUsedPos += _trackerSize.Height;
            //==========================================================================

            if (_tickStyle == TickStyle.BottomRight || _tickStyle == TickStyle.Both)
            {
                //==========================================================================
                // Draw the 2st Tick Line.
                //==========================================================================
                currentUsedPos += 1;
                drawRect        = new RectangleF(currentUsedPos, workingRect.Top, _tickHeight, workingRect.Height);
                drawRect.Inflate(0, -_trackerSize.Width / 2);
                currentUsedPos += _tickHeight;

                DrawTickLine(e.Graphics, drawRect, _tickFrequency, _minimum, _maximum, _tickColor, Orientation.Vertical);
                //==========================================================================
            }

            if (_textTickStyle == TickStyle.BottomRight || _textTickStyle == TickStyle.Both)
            {
                //==========================================================================
                // Draw the 2st Text Line.
                //==========================================================================
                // Get Height of Text Area
                drawRect = new RectangleF(currentUsedPos, workingRect.Top, textAreaSize, workingRect.Height);
                drawRect.Inflate(0, -_trackerSize.Width / 2);
                currentUsedPos += textAreaSize;

                DrawTickTextLine(e.Graphics, drawRect, _tickFrequency, _minimum, _maximum, this.ForeColor, this.Font, Orientation.Vertical);
                //==========================================================================
            }


            //==========================================================================
            // Draw the Tracker
            //==========================================================================
            DrawTracker(e.Graphics, _trackerRect);
            //==========================================================================

            // Draws a focus rectangle
            //if(this.Focused && this.BackColor != Color.Transparent)
            if (this.Focused)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, Rectangle.Inflate(this.ClientRectangle, -2, -2));
            }
            //==========================================================================
        }