private void UpdateProgressCurrent(ProgressInfo info) { if (info == null) { ProgressCopiedCurrent = 0D; RemainingTime = TimeSpan.Zero; ProgressState = TaskbarItemProgressState.None; } else if (info.IsError) { ProgressState = TaskbarItemProgressState.Error; } else { var sizeCopiedLatest = (long)info.CurrentValue; var elapsedTimeLatest = info.ElapsedTime; var sizeCopiedToBeCopiedCurrent = _sizeCopiedCurrent + _sizeToBeCopiedCurrent; if ((sizeCopiedLatest <= 0) || (sizeCopiedToBeCopiedCurrent <= 0)) { return; // For just in case } ProgressCopiedCurrent = (double)(_sizeCopiedCurrent + sizeCopiedLatest) * 100D / (double)sizeCopiedToBeCopiedCurrent; RemainingTime = TimeSpan.FromSeconds((double)(_sizeToBeCopiedCurrent - sizeCopiedLatest) * elapsedTimeLatest.TotalSeconds / (double)sizeCopiedLatest); ProgressState = TaskbarItemProgressState.Normal; //Debug.WriteLine($"ProgressCopiedCurrent: {ProgressCopiedCurrent} RemainingTime: {RemainingTime}"); } }
private long _sizeToBeCopiedCurrent; // Total size of items to be copied during current operation internal void UpdateProgress(ProgressInfo info = null) { lock (_updateLocker) { UpdateSize(info); UpdateProgressAll(info); UpdateProgressCurrent(info); } }
private void UpdateProgressAll(ProgressInfo info) { if (_sizeOverall == 0) { ProgressCopiedAll = 0D; } else { var sizeCopiedLatest = (long)(info?.CurrentValue).GetValueOrDefault(); ProgressCopiedAll = (double)(_sizeCopiedAll + sizeCopiedLatest) * 100D / (double)_sizeOverall; //Debug.WriteLine($"ProgressCopiedAll: {ProgressCopiedAll}"); } }
private void UpdateSize(ProgressInfo info) { if ((info != null) && !info.IsFirst) { return; } var checksCopiedCurrent = (info != null); _sizeOverall = 0L; _sizeCopiedAll = 0L; _sizeCopiedCurrent = 0L; _sizeToBeCopiedCurrent = 0L; foreach (var item in FileListCoreView.Cast <FileItemViewModel>()) { switch (item.Status) { case FileStatus.Recycled: break; default: _sizeOverall += item.Size; switch (item.Status) { case FileStatus.Copied: _sizeCopiedAll += item.Size; if (checksCopiedCurrent && (CopyStartTime < item.CopiedTime)) { _sizeCopiedCurrent += item.Size; } break; case FileStatus.ToBeCopied: case FileStatus.Copying: _sizeToBeCopiedCurrent += item.Size; break; } break; } } }
private void UpdateProgressCurrent(ProgressInfo info) { if (info == null) { ProgressCopiedCurrent = 0D; RemainingTime = TimeSpan.Zero; ProgressState = TaskbarItemProgressState.None; } else if (info.IsError) { ProgressState = TaskbarItemProgressState.Error; } else { var sizeCopiedLatest = (long)info.CurrentValue; var elapsedTimeLatest = info.ElapsedTime; var sizeCopiedToBeCopiedCurrent = _sizeCopiedCurrent + _sizeToBeCopiedCurrent; if ((sizeCopiedLatest <= 0) || (sizeCopiedToBeCopiedCurrent <= 0)) return; // For just in case ProgressCopiedCurrent = (double)(_sizeCopiedCurrent + sizeCopiedLatest) * 100D / (double)sizeCopiedToBeCopiedCurrent; RemainingTime = TimeSpan.FromSeconds((double)(_sizeToBeCopiedCurrent - sizeCopiedLatest) * elapsedTimeLatest.TotalSeconds / (double)sizeCopiedLatest); ProgressState = TaskbarItemProgressState.Normal; //Debug.WriteLine("ProgressCopiedCurrent: {0} RemainingTime: {1}", ProgressCopiedCurrent, RemainingTime); } }
private void UpdateProgressAll(ProgressInfo info) { if (_sizeOverall == 0) { ProgressCopiedAll = 0D; } else { var sizeCopiedLatest = (info != null) ? (long)info.CurrentValue : 0L; ProgressCopiedAll = (double)(_sizeCopiedAll + sizeCopiedLatest) * 100D / (double)_sizeOverall; //Debug.WriteLine("ProgressCopiedAll: {0}", ProgressCopiedAll); } }
private void UpdateSize(ProgressInfo info) { if ((info != null) && !info.IsFirst) return; var checksCopiedCurrent = (info != null); _sizeOverall = 0L; _sizeCopiedAll = 0L; _sizeCopiedCurrent = 0L; _sizeToBeCopiedCurrent = 0L; foreach (var item in FileListCoreView.Cast<FileItemViewModel>()) { switch (item.Status) { case FileStatus.Recycled: break; default: _sizeOverall += item.Size; switch (item.Status) { case FileStatus.Copied: _sizeCopiedAll += item.Size; if (checksCopiedCurrent && (CopyStartTime < item.CopiedTime)) _sizeCopiedCurrent += item.Size; break; case FileStatus.ToBeCopied: case FileStatus.Copying: _sizeToBeCopiedCurrent += item.Size; break; } break; } } }