Exemple #1
0
        private async Task ShowAddBookmarkDialogue()
        {
            var addContent = new EditBookmarkDialogue();

            var addDialogue = new ContentDialog
            {
                Title                  = "Add favourite",
                Content                = addContent,
                PrimaryButtonText      = "Save",
                SecondaryButtonText    = "Cancel",
                IsPrimaryButtonEnabled = false
            };

            // Disables the Save button if the URL is empty.
            addContent.TextChanged += delegate(object sender2, TextChangedEventArgs e2)
            {
                addDialogue.IsPrimaryButtonEnabled = !string.IsNullOrWhiteSpace((sender2 as TextBox).Text);
            };

            var result = await addDialogue.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                LibraryHandler.Bookmarks.Add(new Bookmark(addContent.SiteName.Text, addContent.SiteUrl.Text, DateTime.UtcNow));
                RefreshBookmarks();
            }
        }
Exemple #2
0
        private async Task ShowEditBookmarkDialogue(Bookmark bookmark)
        {
            if (bookmark == null)
            {
                return;
            }

            var editContent = new EditBookmarkDialogue();

            editContent.SiteName.Text = bookmark.Name;
            editContent.SiteUrl.Text  = bookmark.URI;

            var editDialogue = new ContentDialog
            {
                Title               = "Edit favourite",
                Content             = editContent,
                PrimaryButtonText   = "Save",
                SecondaryButtonText = "Cancel"
            };

            // Disables the Save button if the URL is empty.
            editContent.TextChanged += delegate(object sender2, TextChangedEventArgs e2)
            {
                editDialogue.IsPrimaryButtonEnabled = !string.IsNullOrWhiteSpace((sender2 as TextBox).Text);
            };

            var result = await editDialogue.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                bookmark.Name = editContent.SiteName.Text;
                bookmark.URI  = editContent.SiteUrl.Text;
                RefreshBookmarks();
                await LibraryHandler.SaveBookmarksToDevice();
            }
        }