예제 #1
0
 internal void writeProgess(ProgressBar progressBar)
 {
     progressBar.Refresh();
     using (Graphics gr = progressBar.CreateGraphics())
     {
         String s = progressBar.Value.ToString() + "/" + progressBar.Maximum.ToString();
         gr.DrawString(s,
             SystemFonts.DefaultFont,
             Brushes.Black,
             new PointF(progressBar.Width / 2 - (gr.MeasureString(s,
                 SystemFonts.DefaultFont).Width / 2.0F),
             progressBar.Height / 2 - (gr.MeasureString(s,
                 SystemFonts.DefaultFont).Height / 2.0F)));
     }
     //progressBar.Refresh();
     //progressBar.CreateGraphics().DrawString(progressBar.Value.ToString() + "/" +  progressBar.Maximum.ToString(), new Font("Arial", (float)8.25, FontStyle.Regular), Brushes.Black, new PointF(progressBar.Width / 2 - 10, progressBar.Height / 2 - 7));
 }
예제 #2
0
        private void UpdateLabel()
        {
            lblProgress.Text = (Math.Round((decimal)(Bar.Value * 100) /
                                           Bar.Maximum)).ToString();
            lblProgress.Text += "% Done";

            using (Graphics gr = Bar.CreateGraphics())
            {
                string       sString = "Progress Bar Visible";
                Brush        b       = new SolidBrush(Color.Red);
                StringFormat sf      = new StringFormat(StringFormatFlags.NoWrap);
                sf.Alignment = StringAlignment.Center;
                gr.DrawString(sString, new Font("Arial", 12.0f, FontStyle.Bold), b, Bar.ClientRectangle, sf);
                gr.Dispose();
                b.Dispose();
                sf.Dispose();
            }
        }
예제 #3
0
        private bool bUpdateOneSoCBar(ProgressBar prbrOneBar, int iPerc, char chState)
        {
            bool bRes=false;
            prbrOneBar.Value=iPerc;
            // compute forgeround color
            prbrOneBar.ForeColor=clrGetColorFromChargePercent(iPerc);
            // compute background color
            //			prbrOneBar.BackColor=Color.Gray;
            prbrOneBar.BackColor=clrGetBgColorFromChargePercent(iPerc);

            string strTempPerc=iPerc.ToString() + "%";
            strTempPerc+=" " + chState;
            Debug.WriteLine("Form1::bUpdateOneSoCBar() "+strTempPerc);
            prbrOneBar.CreateGraphics().DrawString(strTempPerc, new Font("Arial", (float)8.25, FontStyle.Regular), Brushes.Black, new PointF(prbrOneBar.Width / 2 - 10, prbrOneBar.Height / 2 - 7));

            return bRes;
        }
예제 #4
0
 public static void ResetProgressBarHavePercent(ProgressBar prgb, int Max, bool visi)
 {
     prgb.Step = 1;
     prgb.Visible = visi;
     prgb.Maximum = Max;
     prgb.Minimum = 0;
     int percent = (int)(((double)prgb.Value / (double)prgb.Maximum) * 100);
     prgb.CreateGraphics().DrawString(percent.ToString() + "%", new Font("Arial", (float)8.25, FontStyle.Regular), Brushes.Black, new PointF(prgb.Width / 2 - 10, prgb.Height / 2 - 7));
     prgb.Value = 0;
 }