Esempio n. 1
0
        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();
            }
        }