Ejemplo n.º 1
0
        private void UpdateProgress(ProgressInfo info)
        {
            IsUpdated = true;

            int sizeCopiedLatest  = 0;
            var elapsedTimeLatest = TimeSpan.Zero;

            if (info != null)
            {
                sizeCopiedLatest  = info.CurrentValue;
                elapsedTimeLatest = info.ElapsedTime;
            }

            var fileListBuff = FileListCoreView.Cast <FileItemViewModel>().ToArray();

            var sizeTotal = fileListBuff
                            .Where(x => (x.Status != FileStatus.Recycled))
                            .Sum(x => (long)x.Size);

            var sizeCopied = fileListBuff
                             .Where(x => (x.Status == FileStatus.Copied))
                             .Sum(x => (long)x.Size);

            if (sizeTotal == 0)
            {
                ProgressCopiedAll = 0D;
            }
            else
            {
                ProgressCopiedAll = (double)(sizeCopied + sizeCopiedLatest) * 100D / (double)sizeTotal;

                //Debug.WriteLine("ProgressCopiedAll: {0}", ProgressCopiedAll);
            }

            var sizeCopiedCurrent = fileListBuff
                                    .Where(x => (x.Status == FileStatus.Copied) && (Op.CopyStartTime < x.CopiedTime))
                                    .Sum(x => (long)x.Size);

            var sizeToBeCopied = fileListBuff
                                 .Where(x => (x.Status == FileStatus.ToBeCopied) || (x.Status == FileStatus.Copying))
                                 .Sum(x => (long)x.Size);

            if (sizeToBeCopied == 0)
            {
                ProgressCopiedCurrent = 0D;
                RemainingTime         = TimeSpan.Zero;
            }
            else if (sizeCopiedLatest > 0)
            {
                ProgressCopiedCurrent = (double)(sizeCopiedCurrent + sizeCopiedLatest) * 100D / (double)(sizeCopiedCurrent + sizeToBeCopied);
                RemainingTime         = TimeSpan.FromSeconds((double)(sizeToBeCopied - sizeCopiedLatest) * elapsedTimeLatest.TotalSeconds / (double)sizeCopiedLatest);

                //Debug.WriteLine("ProgressCopiedCurrent: {0} RemainingTime: {1}", ProgressCopiedCurrent, RemainingTime);
            }
        }
Ejemplo n.º 2
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;
                }
            }
        }