public void addItemToFileBrowser(string name, string size, Serveur.Controllers.FrmFileManagerController.PathType type, int imageIndex) { try { ListViewItem lvi = new ListViewItem(new string[] { name, size, (type != Serveur.Controllers.FrmFileManagerController.PathType.Back) ? type.ToString() : string.Empty }) { Tag = type, ImageIndex = imageIndex }; lvDirectory.Invoke((MethodInvoker) delegate { lvDirectory.Items.Add(lvi); }); } catch (InvalidOperationException) { } }
private void lvDirectory_DoubleClick(object sender, EventArgs e) { if (_client != null && _client.value != null && lvDirectory.SelectedItems.Count > 0) { Serveur.Controllers.FrmFileManagerController.PathType type = (Serveur.Controllers.FrmFileManagerController.PathType)lvDirectory.SelectedItems[0].Tag; switch (type) { case Serveur.Controllers.FrmFileManagerController.PathType.Back: Serveur.Controllers.FrmFileManagerController.navigateUp(_client); Serveur.Controllers.FrmFileManagerController.refreshDirectory(_client); break; case Serveur.Controllers.FrmFileManagerController.PathType.Directory: setCurrentDir(Serveur.Controllers.FrmFileManagerController.getAbsolutePath(lvDirectory.SelectedItems[0].SubItems[0].Text)); Serveur.Controllers.FrmFileManagerController.refreshDirectory(_client); break; } } }
private void downloadToolStripMenuItem_Click(object sender, EventArgs e) { foreach (ListViewItem files in lvDirectory.SelectedItems) { Serveur.Controllers.FrmFileManagerController.PathType type = (Serveur.Controllers.FrmFileManagerController.PathType)files.Tag; if (type == Serveur.Controllers.FrmFileManagerController.PathType.File) { string path = Serveur.Controllers.FrmFileManagerController.getAbsolutePath(files.SubItems[0].Text); int uniqId = Serveur.Controllers.FrmFileManagerController.getNewTransferId(files.Index); if (_client != null) { new DoDownloadFile(path, uniqId).Execute(_client); addTransfer(uniqId, "Download", "Pending...", files.SubItems[0].Text); } } } }