public async Task EditCommandAsync(CommandViewModel viewModel) { switch (viewModel) { case UserCommandViewModel userCommandViewModel: var newCommand = (Command)userCommandViewModel.Command.Clone(); var dialogViewModel = new CommandSettingsViewModel(newCommand); var result = await this.ShowDialogAsync(dialogViewModel); if (result != true) { return; } foreach (var key in userCommandViewModel.Command.Keys) { StorageService.Remove(key.Text); } foreach (var key in newCommand.Keys) { StorageService[key.Text] = newCommand; } var index = UserCommands.IndexOf(userCommandViewModel); UserCommands.Remove(userCommandViewModel); UserCommands.Insert(index, new UserCommandViewModel(newCommand)); break; default: throw new NotImplementedException(); } }
public void DeleteCommand(CommandViewModel viewModel) { switch (viewModel) { case UserCommandViewModel userCommandViewModel: foreach (var key in userCommandViewModel.Command.Keys) { StorageService.Remove(key.Text); } UserCommands.Remove(userCommandViewModel); break; case ProcessViewModel processViewModel: //processViewModel.Process.Cancel(); NotifyOfPropertyChange(nameof(Processes)); break; default: throw new NotImplementedException(); } }