private void button1_Click(object sender, EventArgs e) { try { 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); DialogResult = DialogResult.None; return; } } catch { DialogResult = DialogResult.None; MessageBox.Show("Unknow error, please check your input data.", AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void NewFileDownload(string fileName, string url, string location, int segments) { ResourceLocation rl = new ResourceLocation(); rl.Authenticate = false; rl.URL = url; rl.BindProtocolProviderType(); if (rl.ProtocolProviderType != null) { string localFile = string.Empty; if (segments > Settings.Default.MaxSegments) { segments = Settings.Default.MaxSegments; } if (segments < 1) { segments = 1; } localFile = GetLocalFile(fileName, url, location); Downloader download = WebAutomation.DownloadManager.DownloadManager.Instance.Add( rl, null, localFile, segments, false); } }
private void btnOk_Click(object o, ResponseArgs args) { if (args.ResponseId != ResponseType.Ok) { Destroy(); return; } try { rl = new ResourceLocation(); rl.URL = Url.ToString(); rl.Authenticate = HasAuth; if (HasAuth) { rl.Login = Username; rl.Password = Password; } rl.BindProtocolProviderType(); if (rl.ProtocolProviderType == null) { GtkUtils.ShowMessageBox(null, "Invalid URL format, please check the location field.", MessageType.Error); rl = null; return; } Destroy(); } catch (Exception) { rl = null; GtkUtils.ShowMessageBox(null, "Not recognized URL type.", MessageType.Error); Destroy(); } }
private void LoadZIP() { checkableTreeView1.Nodes.Clear(); ResourceLocation rl = this.DownloadLocation; rl.BindProtocolProviderType(); if (rl.ProtocolProviderType == null) { chkChooseZIP.Checked = false; MessageBox.Show("Invalid URL format, please check the location field.", AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ReleaseZIPThread(); zipReaderThread = new Thread( delegate(object state) { ZipRemoteFile zipFile = new ZipRemoteFile((ResourceLocation)state); try { if (zipFile.Load()) { this.BeginInvoke((MethodInvoker) delegate() { DisplayZIPOnTree(zipFile); waitControl1.Visible = false; }); } else { this.BeginInvoke((MethodInvoker) delegate() { waitControl1.Visible = false; MessageBox.Show("Unable to load ZIP contents.", AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); }); } } catch (Exception ex) { this.BeginInvoke((MethodInvoker) delegate() { waitControl1.Visible = false; MessageBox.Show("Unable to load ZIP contents: " + ex.Message, AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); }); } } ); waitControl1.Visible = true; zipReaderThread.Start(rl); }
private void btnOK_Click(object sender, EventArgs e) { try { ResourceLocation rl = this.DownloadLocation; 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); DialogResult = DialogResult.None; return; } ResourceLocation[] mirrors = this.Mirrors; if (mirrors != null && mirrors.Length > 0) { foreach (ResourceLocation mirrorRl in mirrors) { mirrorRl.BindProtocolProviderType(); if (mirrorRl.ProtocolProviderType == null) { MessageBox.Show("Invalid mirror URL format, please check the mirror URLs.", AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; return; } } } if (chkChooseZIP.Checked) { AddDownloadsFromZip(checkableTreeView1.Nodes, mirrors); } else { Downloader download = DownloadManager.Instance.Add( rl, mirrors, this.LocalFile, this.Segments, this.StartNow); } Close(); } catch (Exception) { DialogResult = DialogResult.None; MessageBox.Show("Unknow error, please check your input data.", AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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 btnOK_Click(object sender, EventArgs e) { string SaveFilePath = string.Empty; folderpath = GlobalPreferences.DownloadsFolder; if (folderpath != string.Empty) { if (folderpath.EndsWith("\\")) { SaveFilePath = folderpath + txtFilename.Text; } else { SaveFilePath = folderpath + "\\" + txtFilename.Text; } } else { System.Windows.Forms.FolderBrowserDialog f = new FolderBrowserDialog(); f.Description = "Please select the folder where you want the file to be saved."; if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SaveFilePath = f.SelectedPath + "\\" + txtFilename.Text; } else { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; return; } } this.LocalFile = SaveFilePath; try { ResourceLocation rl = this.DownloadLocation; 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); DialogResult = DialogResult.None; return; } ResourceLocation[] mirrors = this.Mirrors; if (mirrors != null && mirrors.Length > 0) { foreach (ResourceLocation mirrorRl in mirrors) { mirrorRl.BindProtocolProviderType(); if (mirrorRl.ProtocolProviderType == null) { MessageBox.Show("Invalid mirror URL format, please check the mirror URLs.", AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; return; } } } Downloader download = DownloadManager.Instance.Add( rl, mirrors, this.LocalFile, this.Segments, this.StartNow); Close(); } catch (Exception) { DialogResult = DialogResult.None; MessageBox.Show("Unknow error, please check your input data.", AppManager.Instance.Application.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }