private void ShortcutGenerator_DoWork(object sender, DoWorkEventArgs e) { var targetDir = SharedRoutines.GetWslShortcutDirectoryPath(); EnsureDirectoryCreate(targetDir, false); var arg = e.Argument as BackgroundWorkerArgument <DistroProperties[]>; if (arg?.Argument == null) { return; } // Shorcut file may not have icon due to missing icon cache var result = new Dictionary <string, string>(); e.Result = new BackgroundWorkerResult <Dictionary <string, string> >(arg.HasTriggeredByUser, result); foreach (var eachItem in arg.Argument) { var targetFilePath = Path.Combine(targetDir, eachItem.DistroName + ".lnk"); var creationResult = CreateDistroShortcut(eachItem, targetFilePath); if (!creationResult) { result.Add(eachItem.DistroName, targetFilePath); } } }
private void DistroListView_ItemDrag(object sender, ItemDragEventArgs e) { var targetDir = SharedRoutines.GetWslShortcutDirectoryPath(); EnsureDirectoryCreate(targetDir, false); var filesToDrag = new List <string>(); foreach (var eachItem in DistroListView.SelectedItems) { var eachDistro = (DistroProperties)eachItem; var targetPath = Path.Combine(targetDir, eachDistro.DistroName + ".lnk"); if (!File.Exists(targetDir)) { CreateDistroShortcut(eachDistro, targetPath); } if (File.Exists(targetPath)) { filesToDrag.Add(targetPath); } } if (filesToDrag.Count > 0) { this.DistroListView.DoDragDrop( new DataObject(DataFormats.FileDrop, filesToDrag.ToArray()), DragDropEffects.Copy); } }