Esempio n. 1
0
 public FormAddProxy(AcDownProxy proxy)
 {
     if (proxy != null)
     p = proxy;
      else
     proxy = new AcDownProxy();
      InitializeComponent();
 }
Esempio n. 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            //保存设置
             Config.setting.DownSub = chkDownSub.Checked;
             Config.setting.OpenFolderAfterComplete = chkOpenFolder.Checked;
             Config.setting.PlaySound = chkPlaySound.Checked;
             if (chkCustomSound.Checked)
             {
            Config.setting.SoundFile = txtCustomSound.Text;
             }
             else
             {
            Config.setting.SoundFile = "";
             }
             Config.setting.ParseRelated = chkParseRelated.Checked;
             Config.setting.CacheSize = (Int32)numCacheSize.Value;
             Config.setting.SavePath = txtSavePath.Text;
             Config.setting.EnableLog = chkEnableLog.Checked;
             Config.setting.WatchClipboardEnabled = chkWatch.Checked;
             Config.setting.DeleteTaskAndFile = chkDeleteFile.Checked;
            Config.setting.EnableExtractCache = chkEnableExtractCache.Checked;
             Config.setting.EnableWindows7Feature = chkEnableWin7.Checked;
             Config.setting.HideWhenClose = chkHideWhenClose.Checked;
             Config.setting.MaxRunningTaskCount = cboMaxRunningCount.SelectedIndex + 1;
             Config.setting.SearchQuery = txtSearchText.Text;
             Config.setting.RefreshInfoInterval = (Int32)udRefreshInfo.Value;
            Config.setting.ToolFormTimeout = (Int32)udToolFormTimeout.Value;
             Config.setting.NetworkTimeout = (Int32)udNetworkTimeout.Value;
             Config.setting.EnableCheckUpdate = chkEnableCheckUpdate.Checked;
             if (rdoChannelStable.Checked)
            Config.setting.CheckUpdateDocument = "stable";
             if (rdoChannelDevelop.Checked)
            Config.setting.CheckUpdateDocument = "develop";
             if (rdoChannelCustom.Checked)
            Config.setting.CheckUpdateDocument = txtUpdateDocument.Text;
             Config.setting.RetryTimes = (Int32)udRetryTimes.Value;
             Config.setting.RetryWaitingTime = (Int32)udRetryWatingTime.Value * 1000;

             //插件设置

             //代理服务器设置
             List<AcDownProxy> proxys = new List<AcDownProxy>();
             foreach (ListViewItem item in lsvProxy.Items)
             {
            AcDownProxy proxy = new AcDownProxy();
            proxy.Name = item.SubItems[0].Text;
            proxy.Address = item.SubItems[1].Text;
            proxy.Port = int.Parse(item.SubItems[2].Text);
            proxy.Username = item.SubItems[3].Text;
            proxy.Password = item.SubItems[4].Text;
            proxys.Add(proxy);
             }
             Config.setting.Proxy_Settings = proxys.ToArray();
             //保存设置
             Config.SaveSettings();
             this.Close();
        }
Esempio n. 3
0
 //修改代理服务器
 private void btnProxyModify_Click(object sender, EventArgs e)
 {
     if (lsvProxy.SelectedIndices.Count > 0)
      {
     //选择的代理服务器
     int selected = lsvProxy.SelectedIndices[0];
     //生成新的AcDownProxy对象
     AcDownProxy proxy = new AcDownProxy();
     proxy.Name = lsvProxy.Items[selected].SubItems[0].Text;
     proxy.Address = lsvProxy.Items[selected].SubItems[1].Text;
     proxy.Port = int.Parse(lsvProxy.Items[selected].SubItems[2].Text);
     proxy.Username = lsvProxy.Items[selected].SubItems[3].Text;
     proxy.Password = lsvProxy.Items[selected].SubItems[4].Text;
     //显示修改窗体
     FormAddProxy frm = new FormAddProxy(proxy);
     frm.ShowDialog();
     //重新加载
     if (!string.IsNullOrEmpty(proxy.Name))
     {
        lsvProxy.Items[selected] = new ListViewItem(new string[]
        {
           proxy.Name,
           proxy.Address,
           proxy.Port.ToString() ,
           proxy.Username,
           proxy.Password
        });
     }
      }
 }
Esempio n. 4
0
 private void btnProxyAdd_Click(object sender, EventArgs e)
 {
     AcDownProxy proxy = new AcDownProxy();
      FormAddProxy frm = new FormAddProxy(proxy);
      frm.ShowDialog();
      if (!string.IsNullOrEmpty(proxy.Name))
      {
     lsvProxy.Items.Add(new ListViewItem(new string[]
     {
        proxy.Name,
        proxy.Address,
        proxy.Port.ToString() ,
        proxy.Username,
        proxy.Password
     }));
      }
 }
Esempio n. 5
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            var s = new XmlSerializer(typeof(string));
            var b = new XmlSerializer(typeof(bool));
            var l = new XmlSerializer(typeof(List <AutoAnswer>));

            if (reader.IsEmptyElement || !reader.Read())
            {
                return;
            }
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                reader.ReadStartElement("TaskInfo");

                //taskid
                reader.ReadStartElement("TaskId");
                TaskId = new Guid((string)s.Deserialize(reader));
                reader.ReadEndElement();

                //plugin name
                reader.ReadStartElement("PluginName");
                PluginName = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //url
                reader.ReadStartElement("Url");
                Url = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //title
                reader.ReadStartElement("Title");
                Title = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //Status
                reader.ReadStartElement("Status");
                Status = (DownloadStatus)Enum.Parse(typeof(DownloadStatus), (string)s.Deserialize(reader), true);
                reader.ReadEndElement();

                //createtime
                reader.ReadStartElement("CreateTime");
                CreateTime = DateTime.Parse((string)s.Deserialize(reader));
                reader.ReadEndElement();

                //finishtime
                if (reader.IsStartElement("FinishTime"))
                {
                    reader.ReadStartElement("FinishTime");
                    FinishTime = DateTime.Parse((string)s.Deserialize(reader));
                    reader.ReadEndElement();
                }

                //savedirectory
                reader.ReadStartElement("SaveDirectory");
                SaveDirectory = new DirectoryInfo((string)s.Deserialize(reader));
                reader.ReadEndElement();

                //partcount
                reader.ReadStartElement("PartCount");
                PartCount = Int32.Parse((string)s.Deserialize(reader));
                reader.ReadEndElement();

                //currentpart
                reader.ReadStartElement("CurrentPart");
                CurrentPart = Int32.Parse((string)s.Deserialize(reader));
                reader.ReadEndElement();

                //is be added
                reader.ReadStartElement("IsBeAdded");
                IsBeAdded = (bool)b.Deserialize(reader);
                reader.ReadEndElement();

                //partialfinished
                reader.ReadStartElement("PartialFinished");
                PartialFinished = (bool)b.Deserialize(reader);
                reader.ReadEndElement();

                //partialfinished detail
                reader.ReadStartElement("PartialFinishedDetail");
                PartialFinishedDetail = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //autoanswer
                reader.ReadStartElement("AutoAnswers");
                this.AutoAnswer = (List <AutoAnswer>)l.Deserialize(reader);
                reader.ReadEndElement();

                //extract cache
                reader.ReadStartElement("ExtractCache");
                ExtractCache = (bool)b.Deserialize(reader);
                reader.ReadEndElement();

                //filepath
                reader.ReadStartElement("Files");
                FilePath = new List <string>();
                while (reader.IsStartElement("File"))
                {
                    reader.ReadStartElement("File");
                    FilePath.Add((string)s.Deserialize(reader));
                    reader.ReadEndElement();
                }
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    reader.ReadEndElement();
                }

                //subfilepath
                SubFilePath = new List <string>();
                reader.ReadStartElement("SubFiles");

                while (reader.IsStartElement("SubFile"))
                {
                    reader.ReadStartElement("SubFile");
                    SubFilePath.Add((string)s.Deserialize(reader));
                    reader.ReadEndElement();
                }
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    reader.ReadEndElement();
                }



                //DownloadType
                reader.ReadStartElement("DownloadType");
                DownloadTypes = (DownloadType)Enum.Parse(typeof(DownloadType), (string)s.Deserialize(reader), true);
                reader.ReadEndElement();

                //proxy
                XmlSerializer sProxy = new XmlSerializer(typeof(AcDownProxy));
                reader.ReadStartElement("Proxy");
                AcDownProxy pxy = (AcDownProxy)sProxy.Deserialize(reader);
                if (pxy.Address == "" && pxy.Port == 0)
                {
                    Proxy = null;
                }
                else
                {
                    Proxy = pxy.ToWebProxy();
                }
                reader.ReadEndElement();

                //sourceUrl
                reader.ReadStartElement("SourceUrl");
                SourceUrl = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //Comment
                reader.ReadStartElement("Comment");
                Comment = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //Hash
                reader.ReadStartElement("Hash");
                _hash = (string)s.Deserialize(reader);
                reader.ReadEndElement();

                //Progress
                reader.ReadStartElement("Progress");

                if (!double.TryParse((string)s.Deserialize(reader), out _progress))
                {
                    _progress = 0;
                }
                if (_progress > 1.0)
                {
                    _progress = 1.0;
                }
                if (_progress < 0.0)
                {
                    _progress = 0;
                }
                if (double.IsNaN(_progress))
                {
                    _progress = 0;
                }
                reader.ReadEndElement();

                //settings
                reader.ReadStartElement("Settings");
                if (!reader.IsEmptyElement)
                {
                    XmlSerializer sSettings = new XmlSerializer(typeof(SerializableDictionary <string, string>));
                    Settings = (SerializableDictionary <string, string>)sSettings.Deserialize(reader);
                }
                else
                {
                    Settings = new SerializableDictionary <string, string>();
                    reader.Read();
                }
                reader.ReadEndElement();

                //结束读取
                reader.ReadEndElement();
                reader.MoveToContent();
            }
            reader.ReadEndElement();
        }
Esempio n. 6
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     p = null;
      this.Close();
 }