Exemple #1
0
        public void updateState()
        {
            DownloadManager manager = EditorBase.mDownloadManager;
            FileWrap        file    = manager.getCurDownloadingFile();

            if (file != null && file.getFileName() != CommonDefine.VERSION && file.getFileName() != CommonDefine.FILELIST)
            {
                // 当前进度
                float percent = file.getTotalSize() > 0 ? (float)file.getCurSize() / (float)file.getTotalSize() : 0.0f;
                mCurFileProgress.Value  = percent * mCurFileProgress.Maximum;
                mCurFilePercent.Content = StringUtility.floatToString((float)mCurFileProgress.Value, 2) + "%";
                float curSize   = file.getCurSize() / 1024.0f;
                float totalSize = file.getTotalSize() / 1024.0f;
                mCurSizeLabel.Content = StringUtility.floatToString(MathUtility.KBToMBOrG(curSize), 3) + StringUtility.unitConversion(curSize) + "/" + StringUtility.floatToString(MathUtility.KBToMBOrG(totalSize), 3) + StringUtility.unitConversion(totalSize);
                // 总文件体积
                float downLoadTotalSize = manager.getTotalSize() / 1024.0f;
                mTotalSizeLabel.Content = StringUtility.floatToString(MathUtility.KBToMBOrG(downLoadTotalSize), 3) + StringUtility.unitConversion(downLoadTotalSize);
                // 当前下载速度
                float curDownLoadSpeed = manager.getCurSpeed() / 1024.0f;
                mCurSpeedLabel.Content = StringUtility.floatToString(MathUtility.KBToMBOrG(curDownLoadSpeed), 3) + StringUtility.unitConversion(curDownLoadSpeed) + "/S";
                // 总进度
                float totalPercent = (float)manager.getDownloadedSize() / manager.getTotalSize();
                mTotalProgress.Value        = totalPercent * mTotalProgress.Maximum;
                mTotalFileCountText.Content = StringUtility.intToString(manager.getDownloadedCount()) + "/" + StringUtility.intToString(manager.getTotalCount());
                mTotalPercent.Content       = StringUtility.floatToString((float)mTotalProgress.Value, 2) + "%";
                // 预计剩余时间
                int hours = 0, minutes = 0, seconds = 0;
                MathUtility.secondsToHoursMinutesSeconds((int)manager.getRemainTime(), ref hours, ref minutes, ref seconds);
                string timeString = StringUtility.intToString(hours, 2) + "小时" + StringUtility.intToString(minutes, 2) + "分" + StringUtility.intToString(seconds, 2) + "秒";
                mTotalTimeLabel.Content = timeString;
            }
        }
Exemple #2
0
 public long getDownloadedSize()
 {
     return(mDownloadedSize + mCurDownloading.getCurSize());
 }