コード例 #1
0
        private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            TaskDialog.ProgressUpdate progress = e.UserState as TaskDialog.ProgressUpdate;
            if (progress != null)
            {
                int width = this.progressBar.ClientSize.Width;
                this.progressBar.Maximum = width;
                this.progressBar.Value   = Convert.ToInt32(progress.CurrentFileSize * (long)width / progress.TotalFileSize);
                return;
            }
            string path = e.UserState as string;

            if (!string.IsNullOrEmpty(path))
            {
                path = path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                int slashIndex = 0;
                while (path[slashIndex] == Path.DirectorySeparatorChar)
                {
                    slashIndex++;
                }
                path = path.Substring(slashIndex);
                this.sourcePathLabel.Text = path;
                if (this.destinationPath != null)
                {
                    this.destinationPathLabel.Text = Path.Combine(this.destinationPath, path);
                }
            }
        }
コード例 #2
0
 private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     lock (this.entries)
     {
         TaskDialog.ProgressUpdate progress = new TaskDialog.ProgressUpdate();
         foreach (NexonArchiveFileEntry entry in this.entries)
         {
             progress.TotalFileSize += entry.Size;
         }
         if (this.backgroundWorker.CancellationPending)
         {
             e.Cancel = true;
         }
         else
         {
             Delegate method = new Action <object>(this.InitializeProgressWork);
             object[] args   = new object[1];
             base.Invoke(method, args);
             if (this.backgroundWorker.CancellationPending)
             {
                 e.Cancel = true;
             }
             else
             {
                 foreach (NexonArchiveFileEntry entry2 in this.entries)
                 {
                     this.backgroundWorker.ReportProgress(0, entry2.Path);
                     if (!this.task(entry2))
                     {
                         throw new ApplicationException("Task sent an abort code.");
                     }
                     if (this.backgroundWorker.CancellationPending)
                     {
                         e.Cancel = true;
                         break;
                     }
                     progress.CurrentFileSize += entry2.Size;
                     this.backgroundWorker.ReportProgress(0, progress);
                 }
             }
         }
     }
 }