コード例 #1
0
        /// <summary>
        /// 加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UserControl1_Load(object sender, EventArgs e)
        {
            SetButtons(false);
            var mconvert = new SizeConvert();

            this.lblpercent.Text = string.Format("{0}/{1}", mconvert.GetSize(0), mconvert.GetSize(0));
        }
コード例 #2
0
        private void ReFresh(DownStatus status, long size, long currentsize, Exception e)
        {
            switch (status)
            {
            case DownStatus.Downing:
                if (true)
                {
                    var percent = 0;
                    try
                    {
                        if (size > 0)
                        {
                            percent = (int)(((float)currentsize / (float)size) * 100);
                        }
                        if (percent > 100)
                        {
                            percent = 100;
                        }
                    }
                    catch (Exception)
                    {
                    }
                    var mconvert = new SizeConvert();
                    this.lblpercent.Text = string.Format("{0}/{1}", mconvert.GetSize(currentsize), mconvert.GetSize(size));
                    this.barstatus.Value = percent;
                }
                break;

            case DownStatus.Stop:
                if (true)
                {
                    SetButtons(false);
                    if (logTask != null)
                    {
                        logTask(string.Format("任务:{0}异常:{1},堆栈:{2}!", httpurl, e.Message, e.StackTrace));
                    }
                }
                break;

            case DownStatus.Complete:
                if (true)
                {
                    var mconvert = new SizeConvert();
                    this.lblpercent.Text = string.Format("{0}/{1}", mconvert.GetSize(size), mconvert.GetSize(size));
                    this.barstatus.Value = 100;
                    if (logTask != null)
                    {
                        logTask(string.Format("任务:{0}已完成!", httpurl));
                        //标记停止
                        down.Stop();
                    }
                    SetButtons(false);
                }
                break;

            case DownStatus.Deleted:
                if (true)
                {
                    var mconvert = new SizeConvert();
                    this.lblpercent.Text = string.Format("{0}/{1}", mconvert.GetSize(0), mconvert.GetSize(0));
                    if (logTask != null)
                    {
                        logTask(string.Format("任务:{0}临时文件已删除!", httpurl));
                    }
                }
                break;

            default:
                break;
            }
        }