コード例 #1
0
        protected override void OnDrawItem(StatusBarDrawItemEventArgs e)
        {
            if (e.Panel.GetType().ToString().EndsWith("StatusBarPanelEx"))
            {
                StatusBarPanelEx ProgressPanel = (StatusBarPanelEx)e.Panel;

                //if this panel style!=ProgressBar? dont draw
                if (!(ProgressPanel.Style.ToString().EndsWith("ProgressBar")))
                {
                    return;
                }

                //draw if progress bar
                if (ProgressPanel.Value > ProgressPanel.Minimum)
                {
                    int NewWidth =
                        (int)(((double)ProgressPanel.Value / (double)ProgressPanel.Maximum) *
                              (double)ProgressPanel.Width);
                    Rectangle NewBounds = e.Bounds;

                    //select brush type
                    Brush PaintBrush;
                    if (ProgressPanel.Style == StatusBarPanelStyleEx.SmoothProgressBar)
                    {
                        PaintBrush = new SolidBrush(ProgressPanel.ForeColor);
                    }
                    else
                    {
                        PaintBrush = new HatchBrush(ProgressPanel.HatchedProgressBarStyle, ProgressPanel.ForeColor, this.Parent.BackColor);
                    }

                    NewBounds.Width = NewWidth;

                    e.Graphics.FillRegion(PaintBrush, new Region(NewBounds));
                    PaintBrush.Dispose();
                }
                else
                {
                    base.OnDrawItem(e);
                }
            }
            else
            {
                base.OnDrawItem(e);
            }
        }