/// <summary> /// Function to delete a project item. /// </summary> /// <param name="args">The arguments for the command.</param> private async void DoDeleteItemAsync(RecentItemDeleteEventArgs args) { try { if (_messageDisplay.ShowConfirmation(string.Format(Resources.GOREDIT_CONFIRM_DELETE_PROJECT_ITEM, args.Item.FilePath)) == MessageResponse.No) { args.Cancel = true; return; } ShowWaitPanel(string.Format(Resources.GOREDIT_TEXT_DELETING_PROJECT, args.Item.FilePath.Ellipses(40, true))); // We will send the project to the recycle bin so it can be recovered if need be. await Task.Run(() => { if (Directory.Exists(args.Item.FilePath)) { Shell32.SendToRecycleBin(args.Item.FilePath, Shell32.FileOperationFlags.FOF_SILENT | Shell32.FileOperationFlags.FOF_NOCONFIRMATION | Shell32.FileOperationFlags.FOF_WANTNUKEWARNING); } }); Files.Remove(args.Item); } catch (Exception ex) { _messageDisplay.ShowError(ex, string.Format(Resources.GOREDIT_ERR_DELETING_PROJECT_ITEM, args.Item.FilePath)); } finally { HideWaitPanel(); } }
/// <summary>Handles the DeleteItem event of the RecentFiles control.</summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RecentItemDeleteEventArgs"/> instance containing the event data.</param> private void RecentFiles_DeleteItem(object sender, RecentItemDeleteEventArgs e) { if ((DataContext?.DeleteItemCommand == null) || (!DataContext.DeleteItemCommand.CanExecute(e))) { return; } DataContext.DeleteItemCommand.Execute(e); }