/* * public static DownloadWindow Register(WebClient client, String downloadLocation) * { * DownloadWindow downloadWindow; * * if (instances == null) * { * downloadWindow = new DownloadWindow(client, downloadLocation); * instances = new List<DownloadWindow>(); * instances.Add(downloadWindow); * return downloadWindow; * } * else if ((downloadWindow = instances.Find(c => c.client == client && c.downloadLocation == downloadLocation)) != null) * return downloadWindow; * else * { * downloadWindow = new DownloadWindow(client, downloadLocation); * instances.Add(downloadWindow); * return downloadWindow; * } * } */ public void Download(/*TaggedWebClient client, */ FileExplorerWindow.LinkInfo linkInfo, CancellationTokenSource cts, bool open) { string path = System.Web.HttpUtility.UrlDecode((Path.Combine(downloadLocation, linkInfo.Url.Substring(1).Replace("/", "\\")))); Directory.CreateDirectory(Path.GetDirectoryName(path)); if (linkInfo.Size != null && linkInfo.Size.Equals("Directory")) { List <FileExplorerWindow.LinkInfo> directoryFiles = FileExplorerWindow.GetDirectoryFiles((new FileExplorerWindow.HttpInfo(httpClient, linkInfo, user, cts))); foreach (FileExplorerWindow.LinkInfo newLinkInfo in directoryFiles) { Download(/*FileExplorerWindow.CreateClient(linkInfo.BaseAddress, user), */ newLinkInfo, cts, false); } } else { TaggedWebClient client = FileExplorerWindow.CreateClient(linkInfo.BaseInfo.BaseAddress, user); clients.Add(client); FileDownloadForm Form2 = new FileDownloadForm(client, linkInfo); //client.Tag = Form2; client.Tag = path; Form2.MdiParent = this; flowLayoutPanel1.Controls.Add(Form2); Form2.Show(); client.DownloadFileCompleted += Client_DownloadFileCompleted; client.DownloadFileAsync(new Uri(linkInfo.FullAddress), path, open); downloadCount++; this.Show(); } }
public FileDownloadForm(WebClient client, FileExplorerWindow.LinkInfo linkInfo) { InitializeComponent(); textBox1.AppendText("Downloading: " + linkInfo.Name); if (linkInfo.Size != null) { textBox1.AppendText(Environment.NewLine + "\t(Size: " + linkInfo.Size + ")"); } //WebClient webClient = new WebClient(); client.DownloadProgressChanged += (s, e) => { progressBar1.Value = e.ProgressPercentage; }; client.DownloadFileCompleted += (s, e) => { progressBar1.Visible = false; if (e.Error != null) { textBox2.Text = "ERROR: " + e.Error.Message.Replace("The remote server returned an error: ", ""); textBox2.Visible = true; } else { this.Close(); } // any other code to process the file }; }
//private readonly FileExplorerWindow.UrlLocation baseAddress; public AdvancedFindForm(FileExplorerWindow.LinkInfo linkInfo) { InitializeComponent(); if (linkInfo == null) { MessageBox.Show("Link Information Cannot be Empty...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } //baseAddress = linkInfo.BaseInfo; if (linkInfo.FileExt == "Directory") { textBox1.Text = linkInfo.Url; textBox2.Text = ".*"; } else { textBox1.Text = linkInfo.ParentAddress; textBox2.Text = linkInfo.Name; } }
public AddBookmarkWindow(FileExplorerWindow.LinkInfo linkInfo) { InitializeComponent(); createFolderContextMenu = new ContextMenu( new MenuItem[] { new MenuItem("Create Folder", (x, y) => { CreateFolder(); }), new MenuItem("-"), new MenuItem("Select All", (x, y) => { SelectAll(); }), new MenuItem("Select None", (x, y) => { SelectNone(); }), new MenuItem("-"), new MenuItem("Delete Selected", (x, y) => { DeleteSelected(); }) }); folderContextMenu = new ContextMenu( new MenuItem[] { new MenuItem("Create Folder", (x, y) => { CreateFolder(); }), new MenuItem("Edit", (x, y) => { Edit(); }), new MenuItem("Delete", (x, y) => { Delete(true); }), new MenuItem("-"), new MenuItem("Select All", (x, y) => { SelectAll(); }), new MenuItem("Select None", (x, y) => { SelectNone(); }), new MenuItem("-"), new MenuItem("Delete Selected", (x, y) => { DeleteSelected(); }) }); shortcutContextMenu = new ContextMenu( new MenuItem[] { new MenuItem("Edit", (x, y) => { Edit(); }), new MenuItem("Delete", (x, y) => { Delete(false); }), new MenuItem("-"), new MenuItem("Select All", (x, y) => { SelectAll(); }), new MenuItem("Select None", (x, y) => { SelectNone(); }), new MenuItem("-"), new MenuItem("Delete Selected", (x, y) => { DeleteSelected(); }) }); selectedContextMenu = new ContextMenu( new MenuItem[] { new MenuItem("Select All", (x, y) => { SelectAll(); }), new MenuItem("Select None", (x, y) => { SelectNone(); }), new MenuItem("-"), new MenuItem("Delete Selected", (x, y) => { DeleteSelected(); }) }); /* * var urlLocations = FileExplorerWindow.GetLocations(); * * if (urlLocations.Count <= 0) * { * MessageBox.Show("Found No Valid Locations...", "No Locations"); * this.Close(); * return; * } * * urlLocations.Sort((a, b) => a.Index.CompareTo(b.Index)); * * serviceComboBox.Items.AddRange(urlLocations.ToArray()); * * int index = urlLocations.FindIndex((x) => x.BaseAddress == linkInfo.BaseInfo); * * serviceComboBox.SelectedIndex = index; */ NameTextBox.Text = linkInfo.Name; addressTextBox.Text = linkInfo.ToString(); serviceComboBox.Items.Add(linkInfo.BaseInfo); serviceComboBox.SelectedIndex = 0; bookmarksFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Trailblazer101", "ESUFileExplorer", "Bookmarks", linkInfo.BaseInfo.Name /*urlLocations[index].Name*/); if (!Directory.Exists(bookmarksFolder)) { Directory.CreateDirectory(bookmarksFolder); } //serviceComboBox.SelectedIndex = 0; treeView1.ContextMenu = selectedContextMenu; treeView1.ImageList = new ImageList(); treeView1.ImageList.Images.Add("folder", Properties.Icons.folder); treeView1.ImageList.Images.Add("create_folder", Properties.Icons.create_folder); treeView1.ImageList.Images.Add("shortcut", Properties.Icons.shortcut); treeView1.ImageList.ColorDepth = ColorDepth.Depth32Bit; treeView1.ImageList.ImageSize = new Size(24, 24); AddCreateFolderNode(); treeView1.Nodes.AddRange(GetItemsTreeView(bookmarksFolder, folderContextMenu, shortcutContextMenu)); treeView1.TreeViewNodeSorter = new TreeNodeComparer(SortOrder.Ascending); treeView1.Sort(); this.Load += AddBookmarkWindow_Load; this.FormClosing += AddBookmarkWindow_FormClosing; treeView1.BeforeCheck += TreeView1_BeforeCheck; treeView1.AfterCheck += TreeView1_AfterCheck; treeView1.AfterLabelEdit += TreeView1_AfterLabelEdit; treeView1.NodeMouseDoubleClick += TreeView1_NodeMouseDoubleClick; }