Example #1
0
        public void OpenConfig(string path)
        {
            if (bIsStartWork)
            {
                StopWork();
            }

            linkList.Clear();
            imageList.Clear();
            workList.Clear();
            downloadList.Clear();
            listgroupmap.Clear();

            listView1.Groups.Clear();
            listView1.Items.Clear();

            listView1.View = View.Details;

            listView1.SetGroupState(ListViewGroupState.Collapsible);

            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open, FileAccess.Read);

            config = (DownloadConfig)formatter.Deserialize(stream);
            stream.Close();

            labelInfo.Text = config.workUrl;

            CurrentConfigPath = path;

            FileInfo fi = new FileInfo(path);

            this.Text = fi.Name + " - WebDownload";
        }
Example #2
0
 private void Wizard_Load(object sender, EventArgs e)
 {
     if (EditMode)
     {
         DownloadConfig  config = null;
         BinaryFormatter bf     = new BinaryFormatter();
         using (FileStream fs = new FileStream(savepath, FileMode.Open, FileAccess.Read))
         {
             config = (DownloadConfig)bf.Deserialize(fs);
             fs.Close();
         }
         textBoxStartUrl.Text      = config.workUrl;
         textBoxBaseUrl.Text       = config.baseUrl;
         textBoxTitleKeyWords.Text = config.TitleKeyWords;
         textBoxURLKeyWords.Text   = config.UrlKeyWords;
         checkBoxOnlyCur.Checked   = config.OnlyCurPage;
         checkBoxUseCache.Checked  = config.useCache;
         listBox1.Items.Clear();
         listBox1.Items.AddRange(config.pageSplit.ToArray());
     }
 }
Example #3
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            DownloadConfig conf = new DownloadConfig();

            conf.workUrl  = textBoxStartUrl.Text;
            conf.baseUrl  = textBoxBaseUrl.Text;
            conf.useCache = checkBoxUseCache.Checked;
            foreach (var item in listBox1.Items)
            {
                conf.pageSplit.Add(item.ToString());
            }
            conf.savepath      = "";
            conf.cachepath     = "cache\\" + conf.workUrl;
            conf.cachepath     = conf.cachepath.Replace(":", "_");
            conf.cachepath     = conf.cachepath.Replace("/", "_");
            conf.TitleKeyWords = textBoxTitleKeyWords.Text;
            conf.UrlKeyWords   = textBoxURLKeyWords.Text;
            conf.OnlyCurPage   = checkBoxOnlyCur.Checked;

            if (!EditMode)
            {
                SaveFileDialog save = new SaveFileDialog();
                save.DefaultExt   = "conf";
                save.Filter       = "config files(*.conf)|*.conf|All files(*.*)|*.*";
                save.AddExtension = true;
                if (DialogResult.OK == save.ShowDialog())
                {
                    savepath = save.FileName;
                }
            }

            if (!string.IsNullOrWhiteSpace(savepath))
            {
                BinaryFormatter bf     = new BinaryFormatter();
                FileStream      stream = new FileStream(savepath, FileMode.Create, FileAccess.Write);
                bf.Serialize(stream, conf);
                stream.Close();
            }
        }
Example #4
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            DownloadConfig conf = new DownloadConfig();
            conf.workUrl = textBoxStartUrl.Text;
            conf.baseUrl = textBoxBaseUrl.Text;
            conf.useCache = checkBoxUseCache.Checked;
            foreach (var item in listBox1.Items)
            {
                conf.pageSplit.Add(item.ToString());
            }
            conf.savepath = "";
            conf.cachepath = "cache\\" + conf.workUrl;
            conf.cachepath = conf.cachepath.Replace(":", "_");
            conf.cachepath = conf.cachepath.Replace("/", "_");
            conf.TitleKeyWords = textBoxTitleKeyWords.Text;
            conf.UrlKeyWords = textBoxURLKeyWords.Text;
            conf.OnlyCurPage = checkBoxOnlyCur.Checked;

            if( !EditMode )
            {
                SaveFileDialog save = new SaveFileDialog();
                save.DefaultExt = "conf";
                save.Filter = "config files(*.conf)|*.conf|All files(*.*)|*.*";
                save.AddExtension = true;
                if( DialogResult.OK == save.ShowDialog())
                    savepath = save.FileName;
            }

            if( !string.IsNullOrWhiteSpace(savepath))
            {
                BinaryFormatter bf = new BinaryFormatter();
                FileStream stream = new FileStream(savepath, FileMode.Create, FileAccess.Write);
                bf.Serialize(stream, conf);
                stream.Close();
            }
        }
Example #5
0
        public void OpenConfig(string path)
        {
            if (bIsStartWork)
                StopWork();

            linkList.Clear();
            imageList.Clear();
            workList.Clear();
            downloadList.Clear();
            listgroupmap.Clear();

            listView1.Groups.Clear();
            listView1.Items.Clear();

            listView1.View = View.Details;

            listView1.SetGroupState(ListViewGroupState.Collapsible);

            BinaryFormatter formatter = new BinaryFormatter();
            FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read);
            config = (DownloadConfig)formatter.Deserialize(stream);
            stream.Close();

            labelInfo.Text = config.workUrl;

            CurrentConfigPath = path;

            FileInfo fi = new FileInfo(path);
            this.Text = fi.Name + " - WebDownload";
        }