private void StorageEventHandler(Storage storage, Storage.StatRestore stat) { Int64 MaxPoints = 0; Int64 Points = 0; Int64 FilePoint = 4096; Int64 BytePoint = 1; if (stat.Item is ICount) { MaxPoints += ((ICount)stat.Item).Count() * FilePoint; Points += stat.NumFiles * FilePoint; } if (stat.Item is ISize) { MaxPoints += ((ISize)stat.Item).Size() * BytePoint; Points += stat.SizeFiles * BytePoint; } if (DateTime.Now.Subtract(OldSwowTime).TotalMilliseconds < 0) { OldSwowTime = DateTime.Now; } if (DateTime.Now.Subtract(OldSwowTime).TotalMilliseconds > 1000) { statusProgress.Maximum = 1000; statusProgress.Value = (int)(Points * 1000 / MaxPoints); statusProgress.Minimum = 0; OldSwowTime = DateTime.Now; Application.DoEvents(); } }
private void menuFileRestore_Click(object sender, EventArgs e) { var dlg = new CommonOpenFileDialog(); dlg.IsFolderPicker = true; if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { var stat = new Storage.StatRestore(); stat.Item = this.restoreItem; stat.OnChange += StorageEventHandler; this.Enabled = false; statusProgress.Visible = true; this.storage.RestoreAll(this.restoreItem, Path.Combine(dlg.FileName, this.restoreItem.Name()), stat); statusProgress.Visible = false; this.Enabled = true; } }