示例#1
0
        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}");
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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}");
            }
        }
示例#4
0
        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;
                }
            }
        }
示例#5
0
		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);
			}
		}
示例#6
0
		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);
			}
		}
示例#7
0
		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;
				}
			}
		}
示例#8
0
		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);
			}
		}