コード例 #1
0
        private void StepArchiveProgress(ExtractProgressEventArgs e)
        {
            if (this.progressBar1.InvokeRequired)
            {
                this.progressBar2.Invoke(new ExtractEntryProgress(this.StepArchiveProgress), new object[] { e });
            }
            else
            {
                this.progressBar1.PerformStep();

                // reset the progress bar for the entry:
                this.progressBar2.Value = this.progressBar2.Maximum = 1;
                this.lblStatus.Text = "";
                this.Update();
            }
        }
コード例 #2
0
        private void StepEntryProgress(ExtractProgressEventArgs e)
        {
            if (this.progressBar2.InvokeRequired)
            {
                this.progressBar2.Invoke(new ExtractEntryProgress(this.StepEntryProgress), new object[] { e });
            }
            else
            {
                if (this.progressBar2.Maximum == 1)
                {
                    // reset
                    Int64 max = e.TotalBytesToTransfer;
                    _progress2MaxFactor = 0;
                    while (max > System.Int32.MaxValue)
                    {
                        max /= 2;
                        _progress2MaxFactor++;
                    }
                    this.progressBar2.Maximum = (int)max;
                    this.lblStatus.Text = String.Format("Extracting {0}/{1}: {2} ...",
                                                        this.progressBar1.Value, zip.Entries.Count, e.CurrentEntry.FileName);
                }

                int xferred = (int)(e.BytesTransferred >> _progress2MaxFactor);

                this.progressBar2.Value = (xferred >= this.progressBar2.Maximum)
                    ? this.progressBar2.Maximum
                    : xferred;

                this.Update();
            }
        }
コード例 #3
0
 void Streams_ExtractProgress(object sender, ExtractProgressEventArgs e)
 {
     switch (e.EventType)
     {
         case ZipProgressEventType.Extracting_AfterExtractEntry:
             _numExtracted++;
             if ((_numExtracted % 512) == 0)
                 _txrx.Send("pb 1 value " + _numExtracted);
             else if ((_numExtracted % 256) == 0)
                 _txrx.Send(String.Format("status extract {0}/{1} {2:N0}%",
                                          _numExtracted, _numFilesToExtract,
                                          _numExtracted / (0.01 *_numFilesToExtract)));
             break;
     }
 }
コード例 #4
0
        private void ExtractProgress(object sender, ExtractProgressEventArgs e)
        {
            if (e.EventType == ZipProgressEventType.Extracting_EntryBytesWritten)
            {
                StepEntryProgress(e);
            }

            else if (e.EventType == ZipProgressEventType.Extracting_AfterExtractEntry)
            {
                StepArchiveProgress(e);
            }
            if (_setCancel)
                e.Cancel = true;
        }
コード例 #5
0
 internal static ExtractProgressEventArgs ExtractAllCompleted(string archiveName, string extractLocation)
 {
     var x = new ExtractProgressEventArgs(archiveName, ZipProgressEventType.Extracting_AfterExtractAll);
     x._target = extractLocation;
     return x;
 }
コード例 #6
0
 internal static ExtractProgressEventArgs ByteUpdate(string archiveName, ZipEntry entry, Int64 bytesWritten, Int64 totalBytes)
 {
     var x = new ExtractProgressEventArgs(archiveName, ZipProgressEventType.Extracting_EntryBytesWritten);
     x.ArchiveName = archiveName;
     x.CurrentEntry = entry;
     x.BytesTransferred = bytesWritten;
     x.TotalBytesToTransfer = totalBytes;
     return x;
 }
コード例 #7
0
 internal static ExtractProgressEventArgs AfterExtractEntry(string archiveName, ZipEntry entry, string extractLocation)
 {
     var x = new ExtractProgressEventArgs
         {
             ArchiveName = archiveName,
             EventType = ZipProgressEventType.Extracting_AfterExtractEntry,
             CurrentEntry = entry,
             _target = extractLocation,
         };
     return x;
 }
コード例 #8
0
 internal static ExtractProgressEventArgs ExtractExisting(string archiveName, ZipEntry entry, string extractLocation)
 {
     var x = new ExtractProgressEventArgs
         {
             ArchiveName = archiveName,
             EventType = ZipProgressEventType.Extracting_ExtractEntryWouldOverwrite,
             CurrentEntry = entry,
             _target = extractLocation,
         };
     return x;
 }
コード例 #9
0
        void LF_ExtractProgress(object sender, ExtractProgressEventArgs e)
        {
            switch (e.EventType)
            {
                case ZipProgressEventType.Extracting_BeforeExtractEntry:
                    if (!_pb1Set)
                    {
                        _txrx.Send(String.Format("pb 1 max {0}", _numFilesToExtract));
                        _pb1Set = true;
                    }
                    _pb2Set = false;
                    _epCycles=0;
                    break;

                case ZipProgressEventType.Extracting_EntryBytesWritten:
                    _epCycles++;
                    if ((_epCycles % 32) == 0)
                    {
                        if (!_pb2Set)
                        {
                            _txrx.Send(String.Format("pb 2 max {0}", e.TotalBytesToTransfer));
                            _pb2Set = true;
                        }
                        _txrx.Send(String.Format("status Extracting {0} :: [{1}/{2}mb] ({3:N0}%)",
                                                 e.CurrentEntry.FileName,
                                                 e.BytesTransferred/(1024*1024),
                                                 e.TotalBytesToTransfer/(1024*1024),
                                                 ((double)e.BytesTransferred / (0.01 * e.TotalBytesToTransfer))
                                                 ));
                        string msg = String.Format("pb 2 value {0}", e.BytesTransferred);
                        _txrx.Send(msg);
                    }
                        if (maxBytesXferred < e.BytesTransferred)
                            maxBytesXferred = e.BytesTransferred;
                    break;

                case ZipProgressEventType.Extracting_AfterExtractEntry:
                    _txrx.Send("pb 1 step");
                    break;
            }
        }
コード例 #10
0
        void ExtractProgress(object sender, ExtractProgressEventArgs e)
        {
            switch (e.EventType)
            {
                case ZipProgressEventType.Extracting_AfterExtractEntry:
                    _progressEventCalls++;
                    TestContext.WriteLine("Extracted: {0} ({1}/{2})", e.CurrentEntry.FileName, e.EntriesExtracted, e.EntriesTotal);
                    // synthetic cancellation
                    if (_cancelIndex == _progressEventCalls)
                    {
                        e.Cancel = true;
                        TestContext.WriteLine("Cancelling...");
                    }
                    break;

                case ZipProgressEventType.Extracting_EntryBytesWritten:
                    maxBytesXferred = e.BytesTransferred;
                    break;

                default:
                    break;
            }
        }
コード例 #11
0
 void OverwriteDecider(object sender, ExtractProgressEventArgs e)
 {
     switch (e.EventType)
     {
         case ZipProgressEventType.Extracting_ExtractEntryWouldOverwrite:
             // randomly choose whether to overwrite or not
             e.CurrentEntry.ExtractExistingFile = (_rnd.Next(2) == 0)
                 ? ExtractExistingFileAction.DoNotOverwrite
                 : ExtractExistingFileAction.OverwriteSilently;
             break;
     }
 }