Пример #1
0
        /// <summary>
        /// 打开文件夹
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btnopen_Click(object sender, EventArgs e)
        {
            var httpurl      = this.txthttpurl.Text.Trim();
            var saverootpath = this.txtsaverootpath.Text.Trim();

            var down = new MultiDownload(0, httpurl, saverootpath);

            var savepath = down.SavePath;

            //文件不存在时,打开文件夹
            if (File.Exists(savepath) == false)
            {
                savepath = saverootpath;
            }
            Func.OpenFileDirectory(savepath);
        }
Пример #2
0
        /// <summary>
        /// 开始任务
        /// </summary>
        public void NewTask(string httpurl, string saverootpath)
        {
            this.httpurl      = httpurl;
            this.saverootpath = saverootpath;

            var threadNum = int.Parse(ConfigurationManager.AppSettings["ThreahNum"].ToString());

            if (threadNum <= 0)
            {
                threadNum = 1;
            }
            down          = new MultiDownload(threadNum, httpurl, saverootpath);
            down.Reading -= Down_mReading;
            down.Reading += Down_mReading;

            SetButtons(false);
            this.txthttpurl.Text = httpurl;

            //开始任务
            this.BeginInvoke(new Action(Start));
        }
Пример #3
0
        /// <summary>
        /// 新建任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnNew_Click(object sender, EventArgs e)
        {
            var httpurl      = this.txthttpurl.Text.Trim();
            var saverootpath = this.txtsaverootpath.Text.Trim();

            var down    = new MultiDownload(0, httpurl, saverootpath);
            var msg     = "";
            var isvalid = down.IsValid(out msg);

            if (isvalid == false)
            {
                MessageBox.Show(msg);
                this.txthttpurl.Focus();
                return;
            }
            if (newTask != null)
            {
                newTask(httpurl, saverootpath);
            }
            this.Close();
        }