private void btnDownloadSite_Click(object sender, EventArgs e) { ResourceLocation rl = this.location1.ResourceLocation; rl.BindProtocolProviderType(); if (rl.ProtocolProviderType == null) { MessageBox.Show("Invalid URL format, please check the location field.", AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } AutoDownloadsExtension scheduler; scheduler = (AutoDownloadsExtension)AppManager.Instance.Application.GetExtensionByType(typeof(AutoDownloadsExtension)); if (!scheduler.Active) { using (StartAutoDownloadsForm startAd = new StartAutoDownloadsForm()) { if (startAd.ShowDialog() == DialogResult.Yes) { startAd.ScheduledDownloadEnabler.ApplySettings(); } } if (!scheduler.Active) { return; } } SpiderContext spiderCntx = new SpiderContext( folderBrowser1.Folder, rl.URL); spiderCntx.NamingRules.Add( new BaseLocationNamingRule(chkImagesFromExternal.Checked, chkResourcesFromExternal.Checked)); if (chkExcludeExtensions.Checked) { spiderCntx.NamingRules.Add(new ExcludeExtensionNamingRule(txtExcludeExt.Text.Split(','))); } if (chkExcludeNames.Checked) { spiderCntx.NamingRules.Add(new ExcludeNameNamingRule(txtExcludeNames.Text.Split(','))); } if (numDownloadDepth.Value > 0) { spiderCntx.NamingRules.Add(new MaxDepthNamingRule((int)numDownloadDepth.Value)); } if (chkRemoveCompleted.Checked) { spiderCntx.ResourceCompleted += delegate(SpiderContext cntx, ISpiderResource resource) { DownloadManager.Instance.ClearEnded(); }; } siteSpider = new Spider(spiderCntx, new WebSpiderResourceFactory()); siteSpider.Completed += new CompletedEventHandler(siteSpider_Completed); siteSpider.Aborted += new EventHandler(siteSpider_Aborted); siteSpider.BeginLookup(); EnterDownloadMode(true); }
private void btnDownloadSite_Click(object sender, EventArgs e) { ResourceLocation rl = this.location1.ResourceLocation; rl.BindProtocolProviderType(); if (rl.ProtocolProviderType == null) { MessageBox.Show("Invalid URL format, please check the location field.", AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } AutoDownloadsExtension scheduler; scheduler = (AutoDownloadsExtension)AppManager.Instance.Application.GetExtensionByType(typeof(AutoDownloadsExtension)); if (! scheduler.Active) { using (StartAutoDownloadsForm startAd = new StartAutoDownloadsForm()) { if (startAd.ShowDialog() == DialogResult.Yes) { startAd.ScheduledDownloadEnabler.ApplySettings(); } } if (!scheduler.Active) { return; } } SpiderContext spiderCntx = new SpiderContext( folderBrowser1.Folder, rl.URL); spiderCntx.NamingRules.Add( new BaseLocationNamingRule(chkImagesFromExternal.Checked, chkResourcesFromExternal.Checked)); if (chkExcludeExtensions.Checked) { spiderCntx.NamingRules.Add(new ExcludeExtensionNamingRule(txtExcludeExt.Text.Split(','))); } if (chkExcludeNames.Checked) { spiderCntx.NamingRules.Add(new ExcludeNameNamingRule(txtExcludeNames.Text.Split(','))); } if (numDownloadDepth.Value > 0) { spiderCntx.NamingRules.Add(new MaxDepthNamingRule((int)numDownloadDepth.Value)); } if (chkRemoveCompleted.Checked) { spiderCntx.ResourceCompleted += delegate(SpiderContext cntx, ISpiderResource resource) { DownloadManager.Instance.ClearEnded(); }; } siteSpider = new Spider(spiderCntx, new WebSpiderResourceFactory()); siteSpider.Completed += new CompletedEventHandler(siteSpider_Completed); siteSpider.Aborted += new EventHandler(siteSpider_Aborted); siteSpider.BeginLookup(); EnterDownloadMode(true); }