예제 #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            float totalPercent = 0f;    //总进度
            int   totalSpeed   = 0;     //总速度
            bool  isComplete   = false; //是否完成

            foreach (IntPtr hTask in hTasks)
            {
                //获取一个任务的信息保存在info中
                XL.DownTaskInfo info = new XL.DownTaskInfo();
                var             qq   = XL.XL_QueryTaskInfoEx(hTask, info);
                totalPercent += info.fPercent;
                totalSpeed   += info.nSpeed;

                //如果完成了就把完成标记变成true
                if (info.stat == XL.DOWN_TASK_STATUS.TSC_COMPLETE)
                {
                    isComplete = true;
                }
                else
                {
                    isComplete = false;
                }
            }
            totalPercent = totalPercent / hTasks.Count();   //总进度=所有元素的进度加起来/元素数(完成时的进度为1.0)

            toolStripStatusLabel1.Text  = "下载进度:" + (int)(totalPercent * 100) + "%" + string.Format(",速度{0}", (totalSpeed / 1024.0 / 1024.0).ToString("F2") + "MB/s");
            toolStripProgressBar1.Value = (int)(totalPercent * 100);
            if (isComplete)
            {
                toolStripStatusLabel1.Text    = "下载完成!";
                timer1.Enabled                = false;
                toolStripProgressBar1.Visible = false;
            }
        }
예제 #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            XL.DownTaskInfo taskInfo = new XL.DownTaskInfo();
            var             qq       = XL.XL_QueryTaskInfoEx(ptrDownloadTask, taskInfo);

            Trace?.Invoke("下载进度:" + (int)(taskInfo.fPercent * 100) + "%");

            if (taskInfo.stat == XL.DOWN_TASK_STATUS.TSC_COMPLETE)
            {
                Trace?.Invoke("下载进度:" + "下载成功!");
                timer.Enabled = false;
            }
        }