private void listView1_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { try { SyncItem newItem = null; string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { if (syncProject.PathIsDirectory(file)) { Dialogs.DirectoryTargetDroppedPathPrompt(this, file); } else if (syncProject.TargetFileExists(file)) { Dialogs.DuplicateTargetDroppedPathPrompt(this, file); } else { newItem = syncProject.AddSyncItem(file, string.Empty); ListviewHelper.CreateListviewItem(listView1, imageList, newItem, true); } } this.itemSyncBox1.CurrentSyncItem = newItem; EnableControls(); } catch (Exception ex) { Dialogs.FileDropError(this, ex); } } }
public static void ReloadListview(ListView listView, ImageList imageList, List <SyncItem> syncItems) { listView.Items.Clear(); foreach (SyncItem item in syncItems) { ListviewHelper.CreateListviewItem(listView, imageList, item); } }
private void AddItem() { listView1.SelectedItems.Clear(); SyncItem newItem = syncProject.AddSyncItem(string.Empty, string.Empty); ListviewHelper.CreateListviewItem(listView1, imageList, newItem, true); this.itemSyncBox1.CurrentSyncItem = newItem; EnableControls(); }