예제 #1
0
 public void SaveProgress(object sender, SaveProgressEventArgs e)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action<Object, SaveProgressEventArgs>(SaveProgress), new Object[] { sender, e });
     }
     else
     {
         switch (e.EventType)
         {
             case ZipProgressEventType.Saving_Started:
                 break;
             case ZipProgressEventType.Saving_BeforeWriteEntry:
                 lblDtdade.Text = (e.EntriesTotal.ToString());
                 this.windows7ProgressBar1.Maximum = Convert.ToInt32(e.EntriesTotal);
                 tot = int.Parse(e.EntriesTotal.ToString());
                 //// this.progresso1.Value += 1;
                 lblArquivo.Text = e.CurrentEntry.FileName;
                 break;
             case ZipProgressEventType.Saving_AfterWriteEntry:
                 // this.progresso1.PerformStep();
                 this.windows7ProgressBar1.Value += 1;
                 count++;
                 lblDtdade.Text = count.ToString()+" de "+tot;
                 break;
         }
         this.Update();
         Application.DoEvents();
     }
 }
예제 #2
0
        private void zip_SaveProgress(object sender, SaveProgressEventArgs e)
        {
            if(e.EventType == ZipProgressEventType.Saving_AfterWriteEntry) {
                _lblStatus.Invoke((MethodInvoker)delegate {
                    _lblStatus.Text = "Zipping... (" + e.EntriesSaved.ToString() + "/" + e.EntriesTotal.ToString() + ") " + e.CurrentEntry.FileName;
                });
            } else if(e.EventType == ZipProgressEventType.Error_Saving) {
                _lblStatus.Invoke((MethodInvoker)delegate {
                    _lblStatus.Text = "Error occurred while zipping.  Please try again.";
                });

            } else if(e.EventType == ZipProgressEventType.Saving_Completed) {
                Client.form_QuickUpload.Invoke((MethodInvoker)delegate {
                    _lblStatus.Text = "Completed.";
                    Client.form_QuickUpload.addUploadItem(new DC_FileInformation() {
                        local_file_location = zip_path,
                        delete_after_upload = true,
                        file_name = Path.GetFileName(zip_path),
                        file_size = new FileInfo(zip_path).Length
                    }).startUpload();

                    this.Close();
                });
            }
        }
예제 #3
0
 private void Zip_SaveProgress(object sender, Zip.SaveProgressEventArgs e)
 {
     if (e.BytesTransferred > 0 && e.TotalBytesToTransfer > 0)
     {
         int           progress = (int)Math.Floor((decimal)((e.BytesTransferred * 100) / e.TotalBytesToTransfer));
         MethodInvoker m        = new MethodInvoker(() => progressBar1.Value = progress);
         progressBar1.Invoke(m);
     }
 }
예제 #4
0
 private void Zip_SaveProgress(object sender, Ionic.Zip.SaveProgressEventArgs e) //метод для обновления данных
 {
     if (e.EventType == Ionic.Zip.ZipProgressEventType.Saving_BeforeWriteEntry)  //если поступили новые данные
     {
         progressBarconv.Invoke(new MethodInvoker(delegate                       //обновляем поле новым делегатом
         {
             progressBarconv.Maximum = e.EntriesTotal;                           //максимум-все данные
             progressBarconv.Value   = e.EntriesSaved + 1;                       //текущиая-количество сохраненных
         }
                                                  ));
     }
 }
예제 #5
0
 private void Zip_SaveFileProgress(object sender, Ionic.Zip.SaveProgressEventArgs e)
 {
     if (e.EventType == Ionic.Zip.ZipProgressEventType.Saving_EntryBytesRead)
     {
         progressBar.Invoke(new MethodInvoker(delegate
         {
             progressBar.Maximum = 100;
             progressBar.Value   = (int)((e.BytesTransferred * 100) / e.TotalBytesToTransfer);
             progressBar.Update();
         }));
     }
 }
예제 #6
0
 private void Zip_SaveProgress(object sender, Ionic.Zip.SaveProgressEventArgs e)
 {
     if (e.EventType == Ionic.Zip.ZipProgressEventType.Saving_BeforeWriteEntry)
     {
         progressBar.Invoke(new MethodInvoker(delegate
         {
             progressBar.Maximum = e.EntriesTotal;
             progressBar.Value   = e.EntriesSaved + 1;
             progressBar.Update();
         }));
     }
 }
예제 #7
0
 //To be added to the zip file, so the program may display the progress
 public void SaveProgress(object sender, SaveProgressEventArgs e)
 {
     if (e.EventType == ZipProgressEventType.Saving_BeforeWriteEntry)
     {
         Application.DoEvents();
         Update(String.Format("[{0:0.00}%] {1}", (double)progressBar.Value / (double)progressBar.Maximum * 100, e.CurrentEntry.FileName), true);
     }
     else if (e.EventType == ZipProgressEventType.Saving_EntryBytesRead)
     {
         Application.DoEvents();
         Update(String.Format("[{0:0.00}%] {1}", (double)progressBar.Value / (double)progressBar.Maximum * 100, e.CurrentEntry.FileName), false, e.BytesTransferred / (0.01 * e.TotalBytesToTransfer));
     }
 }
예제 #8
0
 void zip_SaveProgress(object sender, SaveProgressEventArgs e)
 {
     if (e.EventType == ZipProgressEventType.Saving_BeforeWriteEntry)
     {
         zipProgressBar.Value++;
     }
     if (e.EventType == ZipProgressEventType.Saving_Completed)
     {
         zipProgressBar.Visibility = Visibility.Hidden;
         zipProgressOverlay.Visibility = Visibility.Hidden;
         SendMailTab_message.IsEnabled = true;
         SendMailTab_subject.IsEnabled = true;
         SendMailTab_to.IsEnabled = true;
         files.Clear();
         System.IO.Directory.CreateDirectory("Zipped");
         files.Add("Zipped\\test.zip");
         SendMailTab_attachments.Items.Clear();
         SendMailTab_attachments.Items.Add("test.zip");
         MessageBox.Show("done zipping");
     }
 }
예제 #9
0
        void LNSF_SaveProgress(object sender, Ionic.Zip.SaveProgressEventArgs e)
        {
            switch (e.EventType)
            {
            case ZipProgressEventType.Saving_Started:
                _numEntriesSaved = 0;
                _txrx.Send("status saving started...");
                _pb1Set = false;
                break;

            case ZipProgressEventType.Saving_BeforeWriteEntry:
                _numEntriesSaved++;
                if (_numEntriesSaved % 64 == 0)
                {
                    _txrx.Send(String.Format("status Compressing {0}", e.CurrentEntry.FileName));
                }
                if (!_pb1Set)
                {
                    _txrx.Send(String.Format("pb 1 max {0}", e.EntriesTotal));
                    _pb1Set = true;
                }
                break;

            case ZipProgressEventType.Saving_EntryBytesRead:
                Assert.IsTrue(e.BytesTransferred <= e.TotalBytesToTransfer);
                break;

            case ZipProgressEventType.Saving_AfterWriteEntry:
                _txrx.Send("pb 1 step");
                break;

            case ZipProgressEventType.Saving_Completed:
                _txrx.Send("status Save completed");
                _pb1Set = false;
                _txrx.Send("pb 1 max 1");
                _txrx.Send("pb 1 value 1");
                break;
            }
        }
예제 #10
0
        static void ZipSaveCompletionHandler(Object sender,
                                             IZ.SaveProgressEventArgs eventArgs)
        {
            IEnumerable <FileInfo> files =
                creationCacheDirectory.EnumerateFiles("*.fbk");

            for (int i = 0; i < 8; i++)
            {
                try {
                    if (eventArgs.EventType ==
                        IZ.ZipProgressEventType.Saving_Completed)
                    {
                        Thread.Sleep(1000);
                        foreach (FileInfo f in files)
                        {
                            f.Delete();
                        }
                        LinkToCaches(backupArchive.Name);
                        return;
                    }
                } catch (Exception e) {
                    if (i == 7)
                    {
                        SCLP.LogProxy.Log(SCLP.LogLevel.Error,
                                          "Couldn't clear build cache, expect the next backup to be larger than usual.");
                    }
                    else
                    {
                        SCLP.LogProxy.Log(SCLP.LogLevel.Error,
                                          "Build cache clear failed! Waiting 5 seconds for retry...");
                        SCLP.LogProxy.Log(SCLP.LogLevel.Error,
                                          String.Format("Cause reports was: {0}\n", e.Message));
                        Thread.Sleep(5000);
                    }
                }
            }
        }
예제 #11
0
        private void streams_SaveProgress(object sender, SaveProgressEventArgs e)
        {
            string msg;
            switch (e.EventType)
            {
                case ZipProgressEventType.Saving_Started:
                    //_txrx.Send("status saving started...");
                    _pb1Set = false;
                    _numSaving = 1;
                    break;

                case ZipProgressEventType.Saving_BeforeWriteEntry:
                    //_txrx.Send(String.Format("status Compressing {0}", e.CurrentEntry.FileName));
                    if (!_pb1Set)
                    {
                        _txrx.Send(String.Format("pb 1 max {0}", e.EntriesTotal));
                        _pb1Set = true;
                    }
                    _totalToSave = e.EntriesTotal;
                    _pb2Set = false;
                    break;

                case ZipProgressEventType.Saving_EntryBytesRead:
                    if (!_pb2Set)
                    {
                        _txrx.Send(String.Format("pb 2 max {0}", e.TotalBytesToTransfer));
                        _pb2Set = true;
                    }

                    //                     _txrx.Send(String.Format("status Saving entry {0}/{1} :: {2} :: {3}/{4}mb {5:N0}%",
                    //                                              _numSaving, _totalToSave,
                    //                                              e.CurrentEntry.FileName,
                    //                                              e.BytesTransferred/(1024*1024), e.TotalBytesToTransfer/(1024*1024),
                    //                                              ((double)e.BytesTransferred) / (0.01 * e.TotalBytesToTransfer)));
                    msg = String.Format("pb 2 value {0}", e.BytesTransferred);
                    _txrx.Send(msg);
                    //System.Threading.Thread.Sleep(40);
                    break;

                case ZipProgressEventType.Saving_AfterWriteEntry:
                    _txrx.Send("pb 1 step");
                    _numSaving++;
                    break;

                case ZipProgressEventType.Saving_Completed:
                    //_txrx.Send("status Save completed");
                    _pb1Set = false;
                    _pb2Set = false;
                    _txrx.Send("pb 1 max 1");
                    _txrx.Send("pb 1 value 1");
                    break;
            }
        }
예제 #12
0
파일: Events.cs 프로젝트: RainsSoft/Updater
 internal static SaveProgressEventArgs ByteUpdate(string archiveName, ZipEntry entry, Int64 bytesXferred, Int64 totalBytes)
 {
     var x = new SaveProgressEventArgs(archiveName, ZipProgressEventType.Saving_EntryBytesRead);
     x.ArchiveName = archiveName;
     x.CurrentEntry = entry;
     x.BytesTransferred = bytesXferred;
     x.TotalBytesToTransfer = totalBytes;
     return x;
 }
예제 #13
0
 /**
  * Callback for setting progress when saving zip file
  */
 private static void UpdateSaveProgress( object Sender, SaveProgressEventArgs Event )
 {
     if (Event.EventType == ZipProgressEventType.Saving_BeforeWriteEntry)
     {
         if (FilesBeingModifiedToPrintOut.Contains(Event.CurrentEntry.FileName))
         {
             Program.Log(" ... Packaging '{0}'", Event.CurrentEntry.FileName);
         }
     }
 }
        /// <summary>
        /// This is used to report progress as the archive is saved
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        void zip_SaveProgress(object sender, SaveProgressEventArgs e)
        {
            switch(e.EventType)
            {
                case ZipProgressEventType.Saving_Started:
                    Log.LogMessage(MessageImportance.High, "Saving {0}...",
                        e.ArchiveName);
                    break;

                case ZipProgressEventType.Saving_AfterWriteEntry:
                    if(!e.CurrentEntry.FileName.EndsWith("/", StringComparison.Ordinal))
                    {
                        compressedSize += e.CurrentEntry.CompressedSize;
                        uncompressedSize += e.CurrentEntry.UncompressedSize;
                        fileCount++;
                    }
                    else
                        folderCount++;

                    Log.LogMessage(MessageImportance.High, "Saved {0} of {1}: {2}",
                        e.EntriesSaved, e.EntriesTotal, e.CurrentEntry.FileName);
                    break;

                case ZipProgressEventType.Saving_Completed:
                    Log.LogMessage(MessageImportance.High, "Finished saving {0}\r\n" +
                        "Compressed {1} folders, {2} files.  Reduced size by " +
                        "{3:N0} bytes ({4:N0}%).", e.ArchiveName, folderCount,
                        fileCount, uncompressedSize - compressedSize,
                        (uncompressedSize != 0) ? 100.0 - (
                        100.0 * compressedSize / uncompressedSize) : 100.0);
                    break;

                default:
                    break;
            }
        }
예제 #15
0
        private void Zip64SaveProgress(object sender, SaveProgressEventArgs e)
        {
            string msg;
            switch (e.EventType)
            {
                case ZipProgressEventType.Saving_Started:
                    _txrx.Send("status saving started...");
                    _pb1Set = false;
                    _numSaving= 1;
                    break;

                case ZipProgressEventType.Saving_BeforeWriteEntry:
                    _txrx.Send(String.Format("status Compressing {0}", e.CurrentEntry.FileName));
                    _spCycles = 0;
                    if (!_pb1Set)
                    {
                        _txrx.Send(String.Format("pb 1 max {0}", e.EntriesTotal));
                        _pb1Set = true;
                    }
                    _totalToSave = e.EntriesTotal;
                    _pb2Set = false;
                    break;

                case ZipProgressEventType.Saving_EntryBytesRead:
                    _spCycles++;
                    if ((_spCycles % 128) == 0)
                    {
                        if (!_pb2Set)
                        {
                            _txrx.Send(String.Format("pb 2 max {0}", e.TotalBytesToTransfer));
                            _pb2Set = true;
                        }
                        _txrx.Send(String.Format("status Saving entry {0}/{1} :: {2} :: {3}/{4}mb {5:N0}%",
                                                 _numSaving, _totalToSave,
                                                 e.CurrentEntry.FileName,
                                                 e.BytesTransferred/(1024*1024), e.TotalBytesToTransfer/(1024*1024),
                                                 ((double)e.BytesTransferred) / (0.01 * e.TotalBytesToTransfer)));
                        msg = String.Format("pb 2 value {0}", e.BytesTransferred);
                        _txrx.Send(msg);
                    }
                    break;

                case ZipProgressEventType.Saving_AfterWriteEntry:
                    _txrx.Send("test " +  _testTitle); // just in case it was missed
                    _txrx.Send("pb 1 step");
                    _numSaving++;
                    break;

                case ZipProgressEventType.Saving_Completed:
                    _txrx.Send("status Save completed");
                    _pb1Set = false;
                    _pb2Set = false;
                    _txrx.Send("pb 1 max 1");
                    _txrx.Send("pb 1 value 1");
                    break;
            }
        }
예제 #16
0
        public void SaveProgress(object sender, SaveProgressEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new Action<Object, SaveProgressEventArgs>(SaveProgress),  new Object[] { sender, e });
            }
            else
            {
                switch (e.EventType)
                {
                    case ZipProgressEventType.Saving_Started:
                        //Console.WriteLine("pb max {0}", e.EntriesTotal);
                        this.progressBar1.Maximum = e.EntriesTotal;
                        this.progressBar1.Value = 0;
                        this.progressBar1.Minimum = 0;
                        this.progressBar1.Step = 1;
                        break;

                    case ZipProgressEventType.Saving_BeforeWriteEntry:
                        //Console.WriteLine("entry {0}", e.CurrentEntry.FileName);
                        this.label1.Text = e.CurrentEntry.FileName;
                        break;

                    case ZipProgressEventType.Saving_AfterWriteEntry:
                        this.progressBar1.PerformStep();
                        break;
                }
                this.Update();
                Application.DoEvents();
            }
        }
 private void OnSaveEntry(int current, ZipEntry entry, bool before)
 {
     EventHandler<SaveProgressEventArgs> sp = SaveProgress;
     if (sp != null)
     {
         var e = new SaveProgressEventArgs(ArchiveNameForEvent, before, _entries.Count, current, entry);
         sp(this, e);
         if (e.Cancel)
             _saveOperationCanceled = true;
     }
 }
예제 #18
0
        void zip_SaveProgress(object sender, SaveProgressEventArgs e)
        {
            // Do we want to cancel?
            if (ProgressForm.WantCancel)
            {
                e.Cancel = true;
                return;
            }

            // Occurs when a file is being written to the zip
            if (e.EventType == ZipProgressEventType.Saving_BeforeWriteEntry)
            {
                float fpercent = ((float)e.EntriesSaved) / ((float)e.EntriesTotal) * ((float)100.0);
                int percent = (int)Math.Floor(fpercent);
                percent++;
                appWorker.ReportProgress(percent * -1, "Saving " + e.CurrentEntry.FileName);
            }
        }
예제 #19
0
        void SaveProgress(object sender, SaveProgressEventArgs e)
        {
            switch (e.EventType)
            {
                case ZipProgressEventType.Saving_Started:
                    if (_txrx != null)
                    {
                        _txrx.Send("status saving started...");
                        _pb1Set = false;
                        _numSaving= 1;
                    }
                    break;
                case ZipProgressEventType.Saving_BeforeWriteEntry:
                    if (_txrx != null)
                    {
                        _txrx.Send("status Compressing " + e.CurrentEntry.FileName);
                        spCycles = 0;
                        if (!_pb1Set)
                        {
                            _txrx.Send("pb 1 max " + e.EntriesTotal);
                            _pb1Set = true;
                        }
                        _totalToSave = e.EntriesTotal;
                        _pb2Set = false;
                    }
                    break;
                case ZipProgressEventType.Saving_AfterWriteEntry:
                    _progressEventCalls++;
                    TestContext.WriteLine("{0}: {1} ({2}/{3})", e.EventType.ToString(), e.CurrentEntry.FileName, e.EntriesSaved, e.EntriesTotal);
                    if (_cancelIndex == _progressEventCalls)
                    {
                        e.Cancel = true;
                        TestContext.WriteLine("Cancelling...");
                    }
                    if (_txrx != null)
                    {
                        _txrx.Send("pb 1 step");
                        _numSaving++;
                    }
                    break;

                case ZipProgressEventType.Saving_EntryBytesRead:
                    Assert.IsTrue(e.BytesTransferred <= e.TotalBytesToTransfer,
                        "For entry {0}, BytesTransferred is greater than TotalBytesToTransfer: ({1} > {2})",
                        e.CurrentEntry.FileName, e.BytesTransferred, e.TotalBytesToTransfer);
                    maxBytesXferred = e.BytesTransferred;
                    if (_txrx!=null)
                    {
                        spCycles++;
                        if ((spCycles % 128) == 0)
                        {
                            if (!_pb2Set)
                            {
                                _txrx.Send("pb 2 max " + e.TotalBytesToTransfer);
                                _pb2Set = true;
                            }
                            _txrx.Send(String.Format("status Saving entry {0}/{1} :: {2} :: {3}/{4}mb {5:N0}%",
                                                     _numSaving, _totalToSave,
                                                     e.CurrentEntry.FileName,
                                                     e.BytesTransferred/(1024*1024), e.TotalBytesToTransfer/(1024*1024),
                                                     ((double)e.BytesTransferred) / (0.01 * e.TotalBytesToTransfer)));
                            _txrx.Send("pb 2 value " +  e.BytesTransferred);
                        }
                    }
                    break;

                case ZipProgressEventType.Saving_Completed:
                    if (_txrx != null)
                    {
                        _txrx.Send("status Save completed");
                        _pb2Set = false;
                        _txrx.Send("pb 1 max 1");
                        _txrx.Send("pb 1 value 1");
                    }
                    break;

                default:
                    break;
            }
        }
예제 #20
0
 private void StepEntryProgress(SaveProgressEventArgs e)
 {
     if (this.ProgressBar2.InvokeRequired) {
         this.ProgressBar2.Invoke(new SaveEntryProgress(this.StepEntryProgress), new object[] { e });
     } else if (!this._saveCanceled) {
         if ((this.ProgressBar2.Maximum == 1)) {
             long entryMax = e.TotalBytesToTransfer;
             long absoluteMax = 0x7fffffff;
             this._progress2MaxFactor = 0;
             while ((entryMax > absoluteMax)) {
                 entryMax = (entryMax / 2);
                 this._progress2MaxFactor += 1;
             }
             if ((Convert.ToInt32(entryMax) < 0)) {
                 entryMax = (entryMax * -1);
             }
             this.ProgressBar2.Maximum = Convert.ToInt32(entryMax);
         }
         int xferred = Convert.ToInt32((e.BytesTransferred >> this._progress2MaxFactor));
         this.ProgressBar2.Value = ((xferred >= this.ProgressBar2.Maximum) ? this.ProgressBar2.Maximum : xferred);
         base.Update();
         this.lblStatus.Text = string.Format("{0} of {1} files...({2})", (this._nFilesCompleted + 1), this._entriesToZip, e.CurrentEntry.FileName);
     }
 }
예제 #21
0
        // прогресс архивирования
        private void SaveProgress(object sender, SaveProgressEventArgs e)
        {
            if (requireCancellation == true)
            {
                e.Cancel = true;
                return;
            }

            if (e.EventType == ZipProgressEventType.Saving_BeforeWriteEntry)
            {
                if (requireCancellation == false)
                {
                    int value = e.EntriesSaved + 1;
                    int total = e.EntriesTotal;
                    string name = e.CurrentEntry.FileName;

                    PostOnTotalProgress(value, total, name);

                }
            }
            else if (e.EventType == ZipProgressEventType.Saving_EntryBytesRead)
            {
                if (requireCancellation == false)
                {
                    long total = e.TotalBytesToTransfer;
                    long value = e.BytesTransferred;

                    int progress = (int)((value * 100) / total);
                    PostOnCurrentEntryBytesProgress(progress);

                }
            }
        }
 private void OnSaveEvent(ZipProgressEventType eventFlavor)
 {
     if (SaveProgress != null)
     {
         lock (LOCK)
         {
             var e = new SaveProgressEventArgs(ArchiveNameForEvent, eventFlavor);
             SaveProgress(this, e);
             if (e.Cancel)
                 _saveOperationCanceled = true;
         }
     }
 }
 private void OnSaveEntry(int current, ZipEntry entry, bool before)
 {
     if (SaveProgress != null)
     {
         lock (LOCK)
         {
             var e = new SaveProgressEventArgs(ArchiveNameForEvent, before, _entries.Count, current, entry);
             SaveProgress(this, e);
             if (e.Cancel)
                 _saveOperationCanceled = true;
         }
     }
 }
예제 #24
0
파일: Events.cs 프로젝트: RainsSoft/Updater
 internal static SaveProgressEventArgs Started(string archiveName)
 {
     var x = new SaveProgressEventArgs(archiveName, ZipProgressEventType.Saving_Started);
     return x;
 }
예제 #25
0
        private static void SaveProgress(object sender, SaveProgressEventArgs e)
        {
            if (isCanceled)
            {
                e.Cancel = true;
                return;
            }
            if (!wantProgressReports) return;

            switch(e.EventType)
            {
                case ZipProgressEventType.Saving_Started:
                    Console.WriteLine("Saving: {0}", e.ArchiveName);
                    break;

                case ZipProgressEventType.Saving_Completed:
                    justHadByteUpdate= false;
                    Console.WriteLine();
                    Console.WriteLine("Done: {0}", e.ArchiveName);
                    break;

                case ZipProgressEventType.Saving_BeforeWriteEntry:
                    if (justHadByteUpdate)
                        Console.WriteLine();
                    Console.WriteLine("  Writing: {0} ({1}/{2})",
                                      e.CurrentEntry.FileName, e.EntriesSaved+1, e.EntriesTotal);
                    justHadByteUpdate= false;
                    break;

                case ZipProgressEventType.Saving_AfterWriteEntry:
                    break;

                case ZipProgressEventType.Saving_EntryBytesRead:
                    if (justHadByteUpdate)
                        Console.SetCursorPosition(0, Console.CursorTop);
                    Console.Write("     {0}/{1} ({2:N0}%)", e.BytesTransferred, e.TotalBytesToTransfer,
                                  e.BytesTransferred / (0.01 * e.TotalBytesToTransfer ));
                    justHadByteUpdate= true;
                    break;
            }
        }
예제 #26
0
 /// <summary>セーブ処理の進捗表示デリゲート</summary>
 public static void MySaveProgressEventHandler(Object sender, SaveProgressEventArgs e)
 {
     if (e.EventType == ZipProgressEventType.Saving_Started)
     {
         // 書庫の作成を開始
         Debug.WriteLine(string.Format("{0} の作成開始", e.ArchiveName));
     }
     else if (e.EventType == ZipProgressEventType.Saving_BeforeWriteEntry)
     {
         // エントリの書き込み開始
         Debug.WriteLine(string.Format("{0} の書き込み開始", e.CurrentEntry.FileName));
     }
     else if (e.EventType == ZipProgressEventType.Saving_EntryBytesRead)
     {
         // エントリを書き込み中
         Debug.WriteLine(string.Format("{0}/{1} バイト 書き込みました",
             e.BytesTransferred, e.TotalBytesToTransfer));
     }
     else if (e.EventType == ZipProgressEventType.Saving_AfterWriteEntry)
     {
         // エントリの書き込み終了
         Debug.WriteLine(string.Format("{0} の書き込み終了", e.CurrentEntry.FileName));
         Debug.WriteLine(string.Format("{0} 個中 {1} 個のエントリの書き込みが完了しました",
             e.EntriesTotal, e.EntriesSaved));
     }
     else if (e.EventType == ZipProgressEventType.Saving_Completed)
     {
         // 書庫の作成が完了
         Debug.WriteLine(string.Format("{0} の作成終了", e.ArchiveName));
     }
 }
예제 #27
0
        internal static SaveProgressEventArgs Completed(string archiveName)
        {
            var x = new SaveProgressEventArgs(archiveName, ZipProgressEventType.Saving_Completed);

            return(x);
        }
예제 #28
0
        static void HandleZipSaveProgress(object sender, SaveProgressEventArgs e)
        {
            if (e.EventType == ZipProgressEventType.Saving_Started)
            {
                //Console.WriteLine("Saving file: {0}", e.ArchiveName);
                _entriesTotal = e.EntriesTotal;
            }
            else if (e.EventType == ZipProgressEventType.Saving_BeforeWriteEntry)
            {
                _entriesSaved++;
                _entriesTotal = e.EntriesTotal;
            }
            else if (e.EventType == ZipProgressEventType.Saving_EntryBytesRead)
            {
                double percent = (int)(_entriesSaved / (0.01 * _entriesTotal));
                double entrypercent = e.BytesTransferred / (0.01 * e.TotalBytesToTransfer);

                string entry = string.Format("{0:00}%", entrypercent);

                string spaces = "";
                for (int i = 0; i <= 4 - entry.Length; i++)
                {
                    spaces += " ";
                }

                Console.Write("{0}{1}({2:00}%)\r", entry, spaces, percent);
            }
            else if (e.EventType == ZipProgressEventType.Saving_BeforeWriteEntry)
            {
                //Console.WriteLine("{0} ({1}/{2})", e.CurrentEntry.FileName, e.EntriesSaved + 1, e.EntriesTotal);

            }
            else if (e.EventType == ZipProgressEventType.Saving_Completed)
            {
                Console.WriteLine("  Done!         ");
            }
        }
 private void zip_SaveProgress(object sender, SaveProgressEventArgs e)
 {
     #region Calculate process percentile ratio for all transferred bytes
     try
     {
         if (e.TotalBytesToTransfer > 0)
         {
             totalTransferredPercentForCurrentEntry = e.BytesTransferred * 100 / e.TotalBytesToTransfer;
         }
         if (e.EntriesSaved > 0 && e.EntriesTotal > 0)
         {
             totalTransferredPercentForAllEntry = ((double)e.EntriesSaved * 100) / (double)e.EntriesTotal;
         }
         if (e.EventType == Ionic.Zip.ZipProgressEventType.Saving_Completed)
         {
             this.ReportOccurrence(this, new ReportEventArgs("ZipEncryption", "Zip Operate for " + e.ArchiveName + " has been Completed."));
         }
     }
     catch { }
     #endregion
 }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This is called by the Save method on the ZipFile class as the zip file is being
		/// saved to the disk.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void HandleZipSaveProgress(object s, SaveProgressEventArgs e)
		{
			if (_cancelProcess || e.EventType != ZipProgressEventType.Saving_BeforeWriteEntry)
				return;

			string msg;
			if (_progressMessages.TryGetValue(e.CurrentEntry.FileName, out msg))
				DisplayMessage(msg, MessageType.Progress);

			_worker.ReportProgress(e.EntriesSaved + 1, Path.GetFileName(e.CurrentEntry.FileName));
		}
예제 #31
0
 /// <summary>セーブ処理の進捗表示デリゲート</summary>
 public static void MySaveProgressEventHandler(Object sender, SaveProgressEventArgs e)
 {
     if (e.EventType == ZipProgressEventType.Saving_Started)
     {
         // 書庫の作成を開始
         //Debug.WriteLine(string.Format("{0} の作成開始", e.ArchiveName));
         //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call
         Debug.WriteLine(string.Format(ResourceMgr.GetString("I0001"), e.ArchiveName));
     }
     else if (e.EventType == ZipProgressEventType.Saving_BeforeWriteEntry)
     {
         // エントリの書き込み開始
         //Debug.WriteLine(string.Format("{0} の書き込み開始", e.CurrentEntry.FileName));
         //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call
         Debug.WriteLine(string.Format(ResourceMgr.GetString("I0002"), e.CurrentEntry.FileName));
     }
     else if (e.EventType == ZipProgressEventType.Saving_EntryBytesRead)
     {
         // エントリを書き込み中
         //Debug.WriteLine(string.Format("{0}/{1} バイト 書き込みました", e.BytesTransferred, e.TotalBytesToTransfer));
         //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call
         Debug.WriteLine(string.Format(ResourceMgr.GetString("I0003"), e.BytesTransferred, e.TotalBytesToTransfer));
     }
     else if (e.EventType == ZipProgressEventType.Saving_AfterWriteEntry)
     {
         // エントリの書き込み終了
         //Debug.WriteLine(string.Format("{0} の書き込み終了", e.CurrentEntry.FileName));
         //Debug.WriteLine(string.Format("{0} 個中 {1} 個のエントリの書き込みが完了しました", e.EntriesTotal, e.EntriesSaved));
         //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call
         Debug.WriteLine(string.Format(ResourceMgr.GetString("I0004"), e.CurrentEntry.FileName));
         Debug.WriteLine(string.Format(ResourceMgr.GetString("I0005"), e.EntriesTotal, e.EntriesSaved));
             
     }
     else if (e.EventType == ZipProgressEventType.Saving_Completed)
     {
         // 書庫の作成が完了
         //Debug.WriteLine(string.Format("{0} の作成終了", e.ArchiveName));
         
         //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call
         Debug.WriteLine(string.Format(ResourceMgr.GetString("I0006"), e.ArchiveName));
     }
 }
예제 #32
0
 private void StepArchiveProgress(SaveProgressEventArgs e)
 {
     if (this.ProgressBar1.InvokeRequired) {
         this.ProgressBar1.Invoke(new SaveEntryProgress(this.StepArchiveProgress), new object[] { e });
     } else if (!this._saveCanceled) {
         this._nFilesCompleted += 1;
         this.ProgressBar1.PerformStep();
         this._totalBytesAfterCompress = (this._totalBytesAfterCompress + e.CurrentEntry.CompressedSize);
         this._totalBytesBeforeCompress = (this._totalBytesBeforeCompress + e.CurrentEntry.UncompressedSize);
         // progressBar2 is the one dealing with the item being added to the archive
         // if we got this event, then the add of that item (or file) is complete, so we
         // update the progressBar2 appropriately.
         this.ProgressBar2.Value = this.ProgressBar2.Maximum = 1;
         base.Update();
     }
 }
예제 #33
0
 /// <summary>SaveProgressイベント ハンドラ</summary>
 protected void SaveProgressEventHandler(Object sender, SaveProgressEventArgs e)
 {
     //Debug.WriteLine("SaveProgressEventHandler\r\n"
     //    + "sender:" + sender.ToString() + ", " + "e.ArchiveName:" + e.ArchiveName);
 }
예제 #34
0
        private void zip1_SaveProgress(object sender, SaveProgressEventArgs e)
        {
            if (this._saveCanceled) {
                e.Cancel = true;
                return;
            }

            switch (e.EventType) {
                case ZipProgressEventType.Saving_AfterWriteEntry:
                    this.StepArchiveProgress(e);
                    Taskbar.SetProgressValue(e.EntriesSaved, e.EntriesTotal);
                    break; // TODO: might not be correct. Was : Exit Select
                case ZipProgressEventType.Saving_Completed:
                    this.SaveCompleted();
                    break; // TODO: might not be correct. Was : Exit Select
                case ZipProgressEventType.Saving_EntryBytesRead:
                    this.StepEntryProgress(e);
                    break; // TODO: might not be correct. Was : Exit Select
            }
        }
예제 #35
0
        void zip_SaveProgress(object sender, SaveProgressEventArgs e)
        {
            if (e.EventType == ZipProgressEventType.Saving_Completed)
            {

               DialogResult dResult= MessageBox.Show("课件制作成功:\r\n" + e.ArchiveName, "提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                //Process p = new Process("Explorer.exe");
               if (dResult==DialogResult.Yes)
               {
                   Process.Start("Explorer.exe", "/e,/select," + e.ArchiveName);
               }

            }
        }
 private void OnSaveEvent(ZipProgressEventType eventFlavor)
 {
     EventHandler<SaveProgressEventArgs> sp = SaveProgress;
     if (sp != null)
     {
         var e = new SaveProgressEventArgs(ArchiveNameForEvent, eventFlavor);
         sp(this, e);
         if (e.Cancel)
             _saveOperationCanceled = true;
     }
 }
예제 #37
0
        void LF_SaveProgress(object sender, SaveProgressEventArgs e)
        {
            string msg;
            switch (e.EventType)
            {
                case ZipProgressEventType.Saving_Started:
                    _txrx.Send("status saving started...");
                    _pb1Set = false;
                    //_txrx.Send(String.Format("pb1 max {0}", e.EntriesTotal));
                    //_txrx.Send("pb2 max 1");
                    break;

                case ZipProgressEventType.Saving_BeforeWriteEntry:
                    _txrx.Send(String.Format("status Compressing {0}", e.CurrentEntry.FileName));
                    if (!_pb1Set)
                    {
                        _txrx.Send(String.Format("pb 1 max {0}", e.EntriesTotal));
                        _pb1Set = true;
                    }
                    _pb2Set = false;
                    _spCycles = 0;
                    break;

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

                case ZipProgressEventType.Saving_AfterWriteEntry:
                    _txrx.Send("pb 1 step");
                    break;

                case ZipProgressEventType.Saving_Completed:
                    _txrx.Send("status Save completed");
                    _pb1Set = false;
                    _pb2Set = false;
                    _txrx.Send("pb 1 max 1");
                    _txrx.Send("pb 1 value 1");
                    break;
            }
        }