/// <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> /// Function to unload the selected plug in assemblies. /// </summary> private void DoUnloadPlugInAssemblies() { try { IReadOnlyList <CodecSetting> selected = SelectedCodecs.ToArray(); IReadOnlyList <GorgonSpriteCodecPlugIn> plugIns = selected.Select(item => item.PlugIn).ToArray(); MessageResponse response = MessageResponse.None; if (plugIns.Count == 0) { return; } foreach (GorgonSpriteCodecPlugIn plugIn in plugIns) { if ((response != MessageResponse.YesToAll) && (response != MessageResponse.NoToAll)) { response = _messageDisplay.ShowConfirmation(string.Format(Resources.GORSPR_CONFIRM_REMOVE_CODECS, Path.GetFileName(plugIn.PlugInPath)), toAll: plugIns.Count > 1); } if (response == MessageResponse.NoToAll) { return; } _busyService.SetBusy(); if (response == MessageResponse.No) { continue; } _codecs.RemoveCodecPlugIn(plugIn); foreach (CodecSetting setting in selected) { SelectedCodecs.Remove(setting); CodecPlugInPaths.Remove(setting); } _busyService.SetIdle(); } // Store the settings now. DoWriteSettings(); } catch (Exception ex) { _messageDisplay.ShowError(ex, Resources.GORSPR_ERR_CANNOT_UNLOAD_CODECS); } finally { _busyService.SetIdle(); } }