Пример #1
0
 private static void ProgressUpdate(IProgress <TaskProgressUpdate> progress, string v)
 {
     // Show Update
     if (progress != null)
     {
         var update = new TaskProgressUpdate();
         update.MessageText = v;
         progress.Report(update);
     }
 }
Пример #2
0
        /// <summary>
        /// Updates the TaskForm controls after a Progress.Report() has been recieved
        /// </summary>
        /// <param name="e">The TaskProgressUpdate object with the update information</param>
        private void ProgressChanged(TaskProgressUpdate e)
        {
            // Prevent null exception
            if (!IsOpen)
            {
                return;
            }

            // Wrap this in an invoke t
            if (e.HeaderText.Length > 0)
            {
                labelInstructionText.Text = e.HeaderText;
            }

            // Update message
            if (e.MessageText.Length > 0 && !Cancelling)
            {
                labelContent.Text = e.MessageText;
            }

            // Update window title
            if (e.WindowTitle.Length > 0)
            {
                Text = e.WindowTitle;
            }

            // Only increment progress bar if the style is not marguee, and we have progress
            if (progressBar.Style != ProgressBarStyle.Marquee && e.ProgressPercent > 0)
            {
                if (e.IncrementProgress)
                {
                    progressBar.Increment(e.ProgressPercent);
                }
                else
                {
                    progressBar.ValueFast(e.ProgressPercent);
                }

                progressBar.Update();
            }
        }