Passa al contenuto principale

Class PromptFramework

Namespace: TecnoPack.Interactivity
Assembly: CO0002_Templ_FlowpackHMI_V00_26_M.dll

High-level API for prompting users via console and system dialogs. Wraps ScriptBuilder and ConsoleLauncher into friendly methods.

public static class PromptFramework

Inheritance

object ← PromptFramework

Methods

AskConfirm(string, string)

Prompts for a Yes/No confirmation.

public static bool AskConfirm(string tempFolder, string message)

Parameters

tempFolder string

Temporary working folder.

message string

Confirmation message.

Returns

bool

true for Yes, false for No or failure.

AskMultipleOptions(string, string, string[])

Prompts the user to select one or more options from a set.

public static string[] AskMultipleOptions(string tempFolder, string message, string[] options)

Parameters

tempFolder string

Temporary working folder.

message string

Message displayed above the options.

options string[]

List of options.

Returns

string[]

An array of selected options (possibly empty).

AskNumber(string, string, double?, double?)

Prompts for a numeric value with optional bounds checking.

public static string AskNumber(string tempFolder, string message, double? min = null, double? max = null)

Parameters

tempFolder string

Temporary working folder.

message string

Prompt message.

min double?

Optional minimum (inclusive). Use null for unbounded.

max double?

Optional maximum (inclusive). Use null for unbounded.

Returns

string

The numeric value as string (to avoid locale issues), or null.

AskOpenFile(string, string, string, string)

Opens an Open File dialog via PowerShell and returns the selected path.

public static string AskOpenFile(string tempFolder, string title = "Open File", string filter = "All files (*.*)|*.*", string initialDirectory = null)

Parameters

tempFolder string

Temporary working folder.

title string

Dialog title.

filter string

File filter (e.g. "Text files (.txt)|.txt|All files (.)|.").

initialDirectory string

Optional initial directory.

Returns

string

Selected file path, or null if canceled.

AskPassword(string, string)

Prompts for a password (masked input).

public static string AskPassword(string tempFolder, string message)

Parameters

tempFolder string

Temporary working folder.

message string

Prompt message.

Returns

string

The password in plain text (use with care), or null on failure.

Remarks

Internally uses PowerShell to mask input, then writes result to output file.

AskSaveFile(string, string, string, string, string)

Opens a Save File dialog via PowerShell and returns the target path.

public static string AskSaveFile(string tempFolder, string title = "Save File", string filter = "All files (*.*)|*.*", string initialDirectory = null, string defaultFileName = null)

Parameters

tempFolder string

Temporary working folder.

title string

Dialog title.

filter string

File filter (e.g. "Text files (.txt)|.txt").

initialDirectory string

Optional initial directory.

defaultFileName string

Optional default file name.

Returns

string

Selected file path, or null if canceled.

AskSingleOption(string, string, string[])

Prompts the user to select one option from a set.

public static string AskSingleOption(string tempFolder, string message, string[] options)

Parameters

tempFolder string

Temporary working folder.

message string

Message displayed above the options.

options string[]

Non-empty list of options.

Returns

string

The selected option, or null if nothing selected or failure.

AskText(string, string, string, bool)

Prompts the user for free-form text via console.

public static string AskText(string tempFolder, string message, string defaultValue = null, bool allowEmpty = true)

Parameters

tempFolder string

Temporary working folder for batch execution.

message string

Prompt message to display.

defaultValue string

Optional default value shown to the user.

allowEmpty bool

If true, accepts empty input.

Returns

string

The user input (possibly empty), or null on failure.

  • Methods
    • AskConfirm(string, string)
    • AskMultipleOptions(string, string, string[])
    • AskNumber(string, string, double?, double?)
    • AskOpenFile(string, string, string, string)
    • AskPassword(string, string)
    • AskSaveFile(string, string, string, string, string)
    • AskSingleOption(string, string, string[])
    • AskText(string, string, string, bool)