- MyDownloader_src.zip
- ICSharpCode.SharpZipLib.dll
- Interop.SHDocVw.dll
- MyDownloader.App
- MyDownloader.Core
- MyDownloader.Extension
- MyDownloader.IEPlugin
- MyDownloader.sln
- MyDownloader.Spider
- MyDownloader.Tests
- TabStrip.dll
- MyDownloader_demo.zip
- ffmpeg.exe
- ICSharpCode.SharpZipLib.dll
- MyDownloader.App.exe
- MyDownloader.App.exe.config
- MyDownloader.Core.dll
- MyDownloader.Extension.dll
- MyDownloader.Spider.dll
- pthreadGC2.dll
- TabStrip.dll
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using MyDownloader.Spider.Web.Rules;
using MyDownloader.Core;
using MyDownloader.Extension.AutoDownloads;
using MyDownloader.Core.UI;
using MyDownloader.Spider.Web;
namespace MyDownloader.Spider.UI
{
public partial class WebSpider : UserControl
{
public WebSpider()
{
InitializeComponent();
EnterDownloadMode(false);
UpdateInputBasesOnCheckBoxes();
}
Spider siteSpider;
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 EnterDownloadMode(bool downloading)
{
RefreshStatus();
progDownload.Value = 0;
tabParams.Enabled = !downloading;
btnAbort.Enabled = downloading;
btnDownloadSite.Enabled = !downloading;
waitControl1.Visible = downloading;
tmrRefresh.Enabled = downloading;
}
void siteSpider_Aborted(object sender, EventArgs e)
{
this.BeginInvoke((MethodInvoker)delegate() { EnterDownloadMode(false); });
}
void siteSpider_Completed(SpiderContext cntx)
{
this.BeginInvoke((MethodInvoker)delegate() { EnterDownloadMode(false); });
}
private void btnAbort_Click(object sender, EventArgs e)
{
siteSpider.Abort();
}
private void tmrRefresh_Tick(object sender, EventArgs e)
{
RefreshStatus();
}
private void RefreshStatus()
{
float totalVisited;
float totalDownloaded;
if (siteSpider != null)
{
totalVisited = siteSpider.Context.VisitedLocations.Count;
totalDownloaded = siteSpider.Context.CompletedResources.Count;
}
else
{
totalVisited = totalDownloaded = 0;
}
lblTotalFiles.Text = totalVisited.ToString();
lblDownloadedFiles.Text = totalDownloaded.ToString();
try
{
if (totalVisited != 0)
{
progDownload.Value = (int)((totalDownloaded / totalVisited) * 100);
}
else
{
progDownload.Value = 0;
}
}
catch (Exception)
{
}
}
private void check_CheckedChanged(object sender, EventArgs e)
{
UpdateInputBasesOnCheckBoxes();
}
private void UpdateInputBasesOnCheckBoxes()
{
txtExcludeExt.Enabled = chkExcludeExtensions.Checked;
txtExcludeNames.Enabled = chkExcludeNames.Checked;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.