Example #1
0
 private static void RaiseEvent(int pbNum, int total, int current, string message = "")
 {
     if (ProgressUpdated != null)
     {
         ProgressUpdatedEventArgs args = new ProgressUpdatedEventArgs(pbNum, total, current, message);
         ProgressUpdated(args);
     }
 }
Example #2
0
 private void ProgressUpdated(ProgressUpdatedEventArgs progressUpdated)
 {
     if (InvokeRequired)
     {
         Invoke(new ProgressUpdatedCallaback(this.UpdateProgress), new object[] { progressUpdated });
     }
     else
     {
         UpdateProgress(progressUpdated);
     }
 }
Example #3
0
        private void UpdateProgress(ProgressUpdatedEventArgs args)
        {
            ProgressBar pb = new ProgressBar();
            Label       lb = new Label();

            if (args.Message == "")
            {
                if (args.PBNum == 1)
                {
                    pb = progressBar1;
                    lb = label1;
                }
                else if (args.PBNum == 2)
                {
                    pb = progressBar2;
                    lb = label2;
                }

                if (pb.Maximum != args.Total)
                {
                    // initial setup
                    pb.Minimum = 0;
                    pb.Maximum = args.Total;
                    pb.Style   = ProgressBarStyle.Continuous;
                }

                pb.Value = args.Processed;

                if (args.Total > 0)
                {
                    double progress = args.Processed / (args.Total * 1.0);
                    lb.Text = progress.ToString("P2");
                }
            }
            else
            {
                this.richTextBox1.Text += args.Message;
                //Goto last line
                this.richTextBox1.SelectionStart = this.richTextBox1.Text.Length;
                this.richTextBox1.ScrollToCaret();
            }
            //Application.DoEvents();
        }