Skip to content

Latest commit

 

History

History
56 lines (41 loc) · 2.22 KB

DialogService.md

File metadata and controls

56 lines (41 loc) · 2.22 KB

DialogServices

The DialogService contains some static helper for you to present dialogs

ListDialog

The ListDialog is an easy way to let the user select items from a list of strings.

ListCommand.mp4
[PowerCommandDesign( description: "A demo of the DialogService.List.",
                         example: "list")]
public class ListCommand : CommandBase<PowerCommandsConfiguration>
{
    public ListCommand(string identifier, PowerCommandsConfiguration configuration) : base(identifier, configuration) { }

    public override RunResult Run()
    {
        var selectedItems = DialogService.ListDialog("Which teams participated in the Stanley Cup final season 2022/23?", new() { "New York Rangers", "Colorado Avalanche", "Vegas Knights", "Pittsburgh Penguins", "Florida Panthers", "Detroit Red Wings", "Toronto Maple Leafs" });
        WriteHeadLine("You selected");
        foreach (var item in selectedItems) WriteLine(item);
        if (selectedItems.Count == 2 && selectedItems.Any(t => t == "Vegas Knights") && selectedItems.Any(t => t == "Florida Panthers"))
        {
            WriteSuccessLine("\nYour absolutely right, and Vegas Knights won the Stanley Cup title!");
        }
        else
        {
            WriteFailureLine("\nIncorrect, the participants in the final was Vegas Knights Vs Florida Panthers and Vegas won the Stanley Cup title!");
        }
        return Ok();
    }
}

SecretPromptDialog

The SecretPromptDialog is a helper dialog to collect password, tokens or other sensitive stuff. The input is masked, the user must confirm the secret, and the secret is not logged to the log file. It is very simple to use, just like this.

var password = DialogService.SecretPromptDialog("Enter secret:");

QuestionAnswerDialog and YesNoDialog

This dialog either prompt a question and returns the answer as an string or with the YesNoDialog prompts a question and returns a bool.

Read more about:

Design your Command

Input

PowerCommands Attribute

Back to start