Skip to content

Instantly share code, notes, and snippets.

@JakeGinnivan
Created August 19, 2012 12:06
Show Gist options
  • Select an option

  • Save JakeGinnivan/3394532 to your computer and use it in GitHub Desktop.

Select an option

Save JakeGinnivan/3394532 to your computer and use it in GitHub Desktop.
var save = new ButtonExtras(ButtonType.Custom, "Save", "Saves this modified post to your blog");
var saveAs = new ButtonExtras(ButtonType.Custom, "Save As", "Saves this blog post as a local markdown file");
var publish = new ButtonExtras(ButtonType.Custom, "Publish As", "Publishes this post to another blog, or as another post");
dialogService.ShowConfirmationWithCancel("Markpad", "What do you want to do?", "", save, saveAs, publish);
if (save.WasClicked)
return base.Publish();
if (saveAs.WasClicked)
return SaveAs();
if (publish.WasClicked)
return DocumentFactory.PublishDocument(this);
return TaskEx.FromResult<IMarkpadDocument>(this);
}
@distantcam
Copy link
Copy Markdown

        var save = new ButtonExtras(ButtonType.OK, "Save", "Saves this modified post to your blog");
        var saveAs = new ButtonExtras(ButtonType.Yes, "Save As", "Saves this blog post as a local markdown file");
        var publish = new ButtonExtras(ButtonType.Retry, "Publish As", "Publishes this post to another blog, or as another post");
        var result = dialogService.ShowConfirmationWithCancel("Markpad", "What do you want to do?", "", save, saveAs, publish);

        switch (result)
        {
            case DialogMessageResult.OK:
                return base.Publish();
            case DialogMessageResult.Yes:
                return SaveAs();
            case DialogMessageResult.Retry:
                return DocumentFactory.PublishDocument(this);
        }

        return TaskEx.FromResult<IMarkpadDocument>(this);
    }

Currently the dialogservice call doesn't return the dialog result. It consumes it and changes it to a bool. This scenario was thought of, but not fully implemented.

Also the dialog service was a bit of an experiment on my part and you're suffering the consequences of a poorly thought out API surface. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment