Exemple #1
0
        /// <summary>
        /// 添加任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //判断是否是“粘贴并添加”
            if (txtInput.Text.Trim() == "" && Clipboard.ContainsText())             //如果文本框为空则为“粘贴并添加”
            {
                txtInput.Text = Clipboard.GetText();
            }


            string url = txtInput.Text;

            this.Cursor = Cursors.WaitCursor;

            IPlugin selectedPlugin = null;

            //如果有可用插件
            if (supportedPlugins.Count > 0)
            {
                selectedPlugin = supportedPlugins[cboPlugins.SelectedIndex];

                //取得此url的hash
                string hash = selectedPlugin.GetHash(url);
                //检查是否有已经在进行的相同任务
                foreach (TaskInfo task in _taskMgr.TaskInfos)
                {
                    if (hash == task.Hash)
                    {
                        toolTip.Show("当前任务已经存在", txtInput, 4000);
                        this.Cursor = Cursors.Default;
                        return;
                    }
                }
                try
                {
                    //取得[代理设置]
                    AcDownProxy selectedProxy = null;
                    if (Config.setting.Proxy_Settings != null)
                    {
                        foreach (AcDownProxy item in Config.setting.Proxy_Settings)
                        {
                            if (item.Name == cboProxy.SelectedItem.ToString())
                            {
                                selectedProxy = item;
                            }
                        }
                    }

                    //取得[AutoAnswer设置]
                    List <AutoAnswer> aa = new List <AutoAnswer>();
                    if (chkAutoAnswer.Checked)
                    {
                        if (selectedPlugin.Feature.ContainsKey("AutoAnswer"))
                        {
                            aa = (List <AutoAnswer>)selectedPlugin.Feature["AutoAnswer"];
                            if (aa.Count > 0)
                            {
                                FormAutoAnswer faa = new FormAutoAnswer(aa);
                                faa.TopMost = this.TopMost;
                                var result = faa.ShowDialog();
                                if (result == System.Windows.Forms.DialogResult.Cancel)
                                {
                                    this.Cursor = Cursors.Default;
                                    return;
                                }
                            }
                        }
                    }

                    //添加任务
                    TaskInfo task = _taskMgr.AddTask(selectedPlugin,
                                                     url,
                                                     (selectedProxy == null) ? null : selectedProxy.ToWebProxy());
                    //设置[保存目录]
                    task.SaveDirectory = new DirectoryInfo(txtPath.Text);
                    //设置[字幕]
                    DownloadSubtitleType ds = DownloadSubtitleType.DownloadSubtitle;
                    if (cboDownSub.SelectedIndex == 1)
                    {
                        ds = DownloadSubtitleType.DontDownloadSubtitle;
                    }
                    if (cboDownSub.SelectedIndex == 2)
                    {
                        ds = DownloadSubtitleType.DownloadSubtitleOnly;
                    }
                    task.DownSub = ds;
                    //设置[提取浏览器缓存]
                    task.ExtractCache = chkExtractCache.Checked;
                    //设置[解析关联视频]
                    task.ParseRelated = chkParseRelated.Checked;
                    //设置[自动应答]
                    task.AutoAnswer = aa;
                    //设置注释
                    task.Comment = txtComment.Text;


                    //开始下载
                    _taskMgr.StartTask(task);


                    this.Cursor = Cursors.Default;
                    this.Close();
                }
                catch (Exception ex)
                {
                    Logging.Add(ex);
                    toolTip.Show("新建任务出现错误:\n" + ex.Message, btnAdd, 4000);
                }
            }
            else
            {
                toolTip.Show("您所输入的网络地址(URL)不符合规则。\n没有支持解析此网址的插件,请您检查后重新输入", txtInput, 3000);
                txtInput.SelectAll();
            }
            this.Cursor = Cursors.Default;
        }
Exemple #2
0
		/// <summary>
		/// 添加任务
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnAdd_Click(object sender, EventArgs e)
		{
			string url = txtInput.Text;
			this.Cursor = Cursors.WaitCursor;

			IPlugin selectedPlugin = null;

			//如果有可用插件
			if (supportedPlugins.Count > 0)
			{

				selectedPlugin = supportedPlugins[cboPlugins.SelectedIndex];

				//取得此url的hash
				string hash = selectedPlugin.GetHash(url);
				//检查是否有已经在进行的相同任务
				foreach (TaskInfo task in CoreManager.TaskManager.TaskInfos)
				{
					if (hash.Equals(task.Hash, StringComparison.InvariantCultureIgnoreCase))
					{
						toolTip.Show("当前任务已经存在", txtInput, 4000);
						this.Cursor = Cursors.Default;
						return;
					}
				}
				try
				{
					//取得[代理设置]
					WebProxy selectedProxy = null;
					if (cboProxy.SelectedIndex == 0) //IE设置
						//将WebProxy设置为null可以使用默认IE设置
						//与WebRequest.DefaultWebProxy的区别在于设置为null时不会自动检测代理设置
						//详情请见 http://msdn.microsoft.com/en-us/library/fze2ytx2.aspx
						selectedProxy = null;
					else if (cboProxy.SelectedIndex == 1) //直接连接
						selectedProxy = new WebProxy();
					else if (CoreManager.ConfigManager.Settings.Proxy_Settings != null)
					{
						foreach (AcDownProxy item in CoreManager.ConfigManager.Settings.Proxy_Settings)
						{
							if (item.Name == cboProxy.SelectedItem.ToString())
							{
								selectedProxy = item.ToWebProxy();
								break;
							}
						}
					}

					//取得[AutoAnswer设置]
					List<AutoAnswer> aa = new List<AutoAnswer>();
					if (chkAutoAnswer.Checked)
					{
						if (selectedPlugin.Feature != null)
						{
							if (selectedPlugin.Feature.ContainsKey("AutoAnswer"))
							{
								aa = (List<AutoAnswer>)selectedPlugin.Feature["AutoAnswer"];
								if (aa.Count > 0)
								{
									FormAutoAnswer faa = new FormAutoAnswer(aa);
									faa.TopMost = this.TopMost;
									var result = faa.ShowDialog();
									if (result == System.Windows.Forms.DialogResult.Cancel)
									{
										this.Cursor = Cursors.Default;
										return;
									}
								}
							}
						}
					}

					//添加任务
					TaskInfo task = CoreManager.TaskManager.AddTask(selectedPlugin, url.Trim(), selectedProxy);
					//设置[保存目录]
					task.SaveDirectory = new DirectoryInfo(cboPath.Text);
					//设置[下载类型]
					DownloadType ds = DownloadType.None;
					if (lstDownloadType.GetItemChecked(0))
						ds = ds | DownloadType.Video;
					if (lstDownloadType.GetItemChecked(1))
						ds = ds | DownloadType.Audio;
					if (lstDownloadType.GetItemChecked(2))
						ds = ds | DownloadType.Picture;
					if (lstDownloadType.GetItemChecked(3))
						ds = ds | DownloadType.Text;
					if (lstDownloadType.GetItemChecked(4))
						ds = ds | DownloadType.Subtitle;
					if (lstDownloadType.GetItemChecked(5))
						ds = ds | DownloadType.Comment;
					task.DownloadTypes = ds;
					//设置[提取浏览器缓存]
					task.ExtractCache = chkExtractCache.Checked;
					//设置[解析关联视频]
					task.ParseRelated = chkParseRelated.Checked;
					//设置[自动应答]
					task.AutoAnswer = aa;
					//设置注释
					task.Comment = txtComment.Text;


					//开始下载
					CoreManager.TaskManager.StartTask(task);


					this.Cursor = Cursors.Default;
					this.Close();
				}
				catch (Exception ex)
				{
					Logging.Add(ex);
					toolTip.Show("新建任务出现错误:\n" + ex.Message, btnAdd, 4000);
				}
			}
			else
			{
				toolTip.Show("您所输入的网络地址(URL)不符合规则。\n没有支持解析此网址的插件,请您检查后重新输入", txtInput, 3000);
				txtInput.SelectAll();
			}
			this.Cursor = Cursors.Default;

		}
Exemple #3
0
        /// <summary>
        /// 添加任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string url = txtInput.Text;

            this.Cursor = Cursors.WaitCursor;

            IPlugin selectedPlugin = null;

            //如果有可用插件
            if (supportedPlugins.Count > 0)
            {
                selectedPlugin = supportedPlugins[cboPlugins.SelectedIndex];

                //取得此url的hash
                string hash = selectedPlugin.GetHash(url);
                //检查是否有已经在进行的相同任务
                foreach (TaskInfo task in CoreManager.TaskManager.TaskInfos)
                {
                    if (hash.Equals(task.Hash, StringComparison.InvariantCultureIgnoreCase))
                    {
                        toolTip.Show("当前任务已经存在", txtInput, 4000);
                        this.Cursor = Cursors.Default;
                        return;
                    }
                }
                try
                {
                    //取得[代理设置]
                    WebProxy selectedProxy = null;
                    if (cboProxy.SelectedIndex == 0)                     //IE设置
                    //将WebProxy设置为null可以使用默认IE设置
                    //与WebRequest.DefaultWebProxy的区别在于设置为null时不会自动检测代理设置
                    //详情请见 http://msdn.microsoft.com/en-us/library/fze2ytx2.aspx
                    {
                        selectedProxy = null;
                    }
                    else if (cboProxy.SelectedIndex == 1)                     //直接连接
                    {
                        selectedProxy = new WebProxy();
                    }
                    else if (CoreManager.ConfigManager.Settings.Proxy_Settings != null)
                    {
                        foreach (AcDownProxy item in CoreManager.ConfigManager.Settings.Proxy_Settings)
                        {
                            if (item.Name == cboProxy.SelectedItem.ToString())
                            {
                                selectedProxy = item.ToWebProxy();
                                break;
                            }
                        }
                    }

                    //取得[AutoAnswer设置]
                    List <AutoAnswer> aa = new List <AutoAnswer>();
                    if (chkAutoAnswer.Checked)
                    {
                        if (selectedPlugin.Feature != null)
                        {
                            if (selectedPlugin.Feature.ContainsKey("AutoAnswer"))
                            {
                                aa = (List <AutoAnswer>)selectedPlugin.Feature["AutoAnswer"];
                                if (aa.Count > 0)
                                {
                                    FormAutoAnswer faa = new FormAutoAnswer(aa);
                                    faa.TopMost = this.TopMost;
                                    var result = faa.ShowDialog();
                                    if (result == System.Windows.Forms.DialogResult.Cancel)
                                    {
                                        this.Cursor = Cursors.Default;
                                        return;
                                    }
                                }
                            }
                        }
                    }

                    //添加任务
                    TaskInfo task = CoreManager.TaskManager.AddTask(selectedPlugin, url.Trim(), selectedProxy);
                    //设置[保存目录]
                    task.SaveDirectory = new DirectoryInfo(cboPath.Text);
                    //设置[下载类型]
                    DownloadType ds = DownloadType.None;
                    if (lstDownloadType.GetItemChecked(0))
                    {
                        ds = ds | DownloadType.Video;
                    }
                    if (lstDownloadType.GetItemChecked(1))
                    {
                        ds = ds | DownloadType.Audio;
                    }
                    if (lstDownloadType.GetItemChecked(2))
                    {
                        ds = ds | DownloadType.Picture;
                    }
                    if (lstDownloadType.GetItemChecked(3))
                    {
                        ds = ds | DownloadType.Text;
                    }
                    if (lstDownloadType.GetItemChecked(4))
                    {
                        ds = ds | DownloadType.Subtitle;
                    }
                    if (lstDownloadType.GetItemChecked(5))
                    {
                        ds = ds | DownloadType.Comment;
                    }
                    task.DownloadTypes = ds;
                    //设置[提取浏览器缓存]
                    task.ExtractCache = chkExtractCache.Checked;
                    //设置[解析关联视频]
                    task.ParseRelated = chkParseRelated.Checked;
                    //设置[自动应答]
                    task.AutoAnswer = aa;
                    //设置注释
                    task.Comment = txtComment.Text;


                    //开始下载
                    CoreManager.TaskManager.StartTask(task);


                    this.Cursor = Cursors.Default;
                    this.Close();
                }
                catch (Exception ex)
                {
                    Logging.Add(ex);
                    toolTip.Show("新建任务出现错误:\n" + ex.Message, btnAdd, 4000);
                }
            }
            else
            {
                toolTip.Show("您所输入的网络地址(URL)不符合规则。\n没有支持解析此网址的插件,请您检查后重新输入", txtInput, 3000);
                txtInput.SelectAll();
            }
            this.Cursor = Cursors.Default;
        }
Exemple #4
0
        /// <summary>
        /// 添加任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //判断是否是“粘贴并添加”
            if (txtInput.Text.Trim() == "" && Clipboard.ContainsText()) //如果文本框为空则为“粘贴并添加”
            {
                txtInput.Text = Clipboard.GetText();
            }

            string url = txtInput.Text;
            this.Cursor = Cursors.WaitCursor;

            IPlugin selectedPlugin = null;

            //如果有可用插件
            if (supportedPlugins.Count > 0)
            {

                selectedPlugin = supportedPlugins[cboPlugins.SelectedIndex];

                //取得此url的hash
                string hash = selectedPlugin.GetHash(url);
                //检查是否有已经在进行的相同任务
                foreach (TaskInfo task in _taskMgr.TaskInfos)
                {
                    if (hash == task.Hash)
                    {
                        toolTip.Show("当前任务已经存在", txtInput, 4000);
                        this.Cursor = Cursors.Default;
                        return;
                    }
                }
                try
                {
                    //取得[代理设置]
                    AcDownProxy selectedProxy = null;
                    if (Config.setting.Proxy_Settings != null)
                    {
                        foreach (AcDownProxy item in Config.setting.Proxy_Settings)
                        {
                            if (item.Name == cboProxy.SelectedItem.ToString())
                                selectedProxy = item;
                        }
                    }

                    //取得[AutoAnswer设置]
                    List<AutoAnswer> aa = new List<AutoAnswer>();
                    if (chkAutoAnswer.Checked)
                    {
                        if (selectedPlugin.Feature.ContainsKey("AutoAnswer"))
                        {
                            aa = (List<AutoAnswer>)selectedPlugin.Feature["AutoAnswer"];
                            if (aa.Count > 0)
                            {
                                FormAutoAnswer faa = new FormAutoAnswer(aa);
                                faa.TopMost = this.TopMost;
                                var result = faa.ShowDialog();
                                if (result == System.Windows.Forms.DialogResult.Cancel)
                                {
                                    this.Cursor = Cursors.Default;
                                    return;
                                }
                            }
                        }
                    }

                    //添加任务
                    TaskInfo task = _taskMgr.AddTask(selectedPlugin,
                                                                url,
                                                                (selectedProxy == null) ? null : selectedProxy.ToWebProxy());
                    //设置[保存目录]
                    task.SaveDirectory = new DirectoryInfo(txtPath.Text);
                    //设置[字幕]
                    DownloadSubtitleType ds = DownloadSubtitleType.DownloadSubtitle;
                    if (cboDownSub.SelectedIndex == 1) ds = DownloadSubtitleType.DontDownloadSubtitle;
                    if (cboDownSub.SelectedIndex == 2) ds = DownloadSubtitleType.DownloadSubtitleOnly;
                    task.DownSub = ds;
                    //设置[提取浏览器缓存]
                    task.ExtractCache = chkExtractCache.Checked;
                    //设置[解析关联视频]
                    task.ParseRelated = chkParseRelated.Checked;
                    //设置[自动应答]
                    task.AutoAnswer = aa;
                    //设置注释
                    task.Comment = txtComment.Text;

                    //开始下载
                    _taskMgr.StartTask(task);

                    this.Cursor = Cursors.Default;
                    this.Close();
                }
                catch (Exception ex)
                {
                    Logging.Add(ex);
                    toolTip.Show("新建任务出现错误:\n" + ex.Message, btnAdd, 4000);
                }
            }
            else
            {
                toolTip.Show("您所输入的网络地址(URL)不符合规则。\n没有支持解析此网址的插件,请您检查后重新输入", txtInput, 3000);
                txtInput.SelectAll();
            }
            this.Cursor = Cursors.Default;
        }