private void onDropdownCopierSur(object sender, EventArgs e) { ToolStripMenuItem dropDown = (ToolStripMenuItem)sender; dropDown.DropDownItems.Clear(); IEnumerable <DriveInfo> devices = DriveInfo.GetDrives().Where(d => (d.DriveType == DriveType.Removable) && (d.IsReady)); if (devices?.Count() > 0) { dropDown.Enabled = true; foreach (DriveInfo drive in devices) { ToolStripLabel item = new ToolStripLabel(drive.VolumeLabel + " [" + drive.RootDirectory + "]"); item.Tag = drive; item.Enabled = true; item.Image = DestinationCopie.GetFileIcon(drive.Name).ToBitmap(); item.AutoSize = false; item.Alignment = ToolStripItemAlignment.Left; item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; item.ImageAlign = ContentAlignment.MiddleLeft; item.Size = new Size(item.Image.Width * 2 + 100, item.Image.Height); item.Click += onClickItemCopierSur; dropDown.DropDownItems.Add(item); } } else { dropDown.Enabled = false; } }
async private void onFilmContextMenuLireCopierSurCle(object sender, EventArgs e) { Film selected = getSelectedFilm(); if (selected == null) { return; } DestinationCopie dlg = new DestinationCopie(); dlg.film = selected; if (dlg.ShowDialog(this) == DialogResult.OK) { string source = selected.Chemin; string destination = Path.Combine(dlg.destinationDevice.RootDirectory.FullName, Path.GetFileName(source)); // Lancer la copie _copieFichiers.ajoute(selected.Titre, source, destination); } }