Ejemplo n.º 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}");
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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}");
            }
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 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);
			}
		}
Ejemplo n.º 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);
			}
		}
Ejemplo n.º 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;
				}
			}
		}
Ejemplo n.º 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);
			}
		}