Ejemplo n.º 1
0
        public async Task ShowCreatePlaylistDialogAsync()
        {
            var arguments = new TextInputDialogNavigationArguments(
                properties: TextInputDialogProperties.ForNewItem("Playlist name"),
                initialValue: this.MainViewModel.GetProposedPlaylistName(),
                asyncAction: name => this.MainViewModel.CreatePlaylistAsync(name),
                validate: ValidatePlaylistName
                );

            _ = await new PagedContentDialog {
                Title = $"Create playlist"
            }.NavigateAndShowAsync <
                TextInputDialogContent, TextInputDialogNavigationArguments
                >(arguments);

            ValidateResult ValidatePlaylistName(string name)
            {
                if (this.MainViewModel.Playlists.ContainsKey(name))
                {
                    return("A playlist with this name already exists.");
                }

                return(ValidateResult.Ok());
            }
        }
Ejemplo n.º 2
0
 public TextInputDialogNavigationArguments(
     TextInputDialogProperties properties,
     string initialValue,
     Func <string, Task> asyncAction,
     Func <string, ValidateResult>?validate = null
     )
 {
     this.Properties   = properties;
     this.InitialValue = initialValue;
     this.AsyncAction  = asyncAction;
     this.Validate     = validate;
 }
Ejemplo n.º 3
0
        public async Task ShowEditNavigationItemDialogAsync(ComicNavigationItem item)
        {
            if (this.ViewModel is not ComicNavigationItemGridViewModel vm)
            {
                throw new ProgrammerError($"{nameof(this.ShowEditNavigationItemDialogAsync)} should not be called with a work item view model");
            }

            var helper = new EditNavigationItemDialogViewModel(vm, item.Title);

            _ = await new PagedContentDialog {
                Title = $"{vm.NavigationTag.Describe(capitalized: true)}: {item.Title}"
            }
            .NavigateAndShowAsync <TextInputDialogContent, TextInputDialogNavigationArguments>(
                new(
                    properties: TextInputDialogProperties.ForSavingChanges("Name"),
                    initialValue: item.Title,
                    asyncAction: helper.SaveAsync,
                    validate: helper.GetItemTitleInvalidReason
                    )
                );
        }