Class Dialog
- Namespace
- PluginUI
- Assembly
- PluginUI.dll
Modal dialog drawn inside the host window: title, body element and a row of buttons. Enter chooses the default button, Escape the cancel button. Plug-in editors cannot rely on native modal windows (they would block the DAW), so dialogs are popups: the rest of the editor is dimmed and inert while one is open.
public class Dialog : Popup
- Inheritance
-
Dialog
- Derived
- Inherited Members
Examples
Dialog.ShowMessage(host, "Reset preset", "Discard your changes?", MessageBoxButtons.YesNo,
r => { if (r == MessageBoxResult.Yes) ResetPreset(); });
Constructors
Dialog()
Creates an empty dialog (add a body with Content and buttons with AddButton(string, object?, bool, bool)).
public Dialog()
Dialog(string?, UIElement?)
Creates a dialog with a title and a body.
public Dialog(string? title, UIElement? body = null)
Parameters
Properties
ButtonCaptions
Captions of the buttons added with AddButton(string, object?, bool, bool), from left to right.
public IReadOnlyList<string> ButtonCaptions { get; }
Property Value
Content
Body element (hides Content: the dialog manages its own children).
[Browsable(false)]
public UIElement? Content { get; set; }
Property Value
DialogWidth
Preferred width of the dialog.
public float DialogWidth { get; set; }
Property Value
Result
Result chosen by the user (null until a button is chosen).
[Browsable(false)]
public object? Result { get; }
Property Value
Title
Title (null = none).
public string? Title { get; set; }
Property Value
Methods
AddButton(string, object?, bool, bool)
Adds a button (fluent). The default button reacts to Enter, the cancel button to Escape.
public Dialog AddButton(string text, object? result, bool isDefault = false, bool isCancel = false)
Parameters
Returns
ArrangeOverride(Rect)
Arranges children inside the final bounds.
protected override void ArrangeOverride(Rect bounds)
Parameters
boundsRect
Close(object?)
Chooses a result and closes the dialog.
public void Close(object? result)
Parameters
resultobject
MeasureOverride(Size)
Natural size of the content for the available size (margins excluded).
protected override Size MeasureOverride(Size available)
Parameters
availableSize
Returns
OnAttached()
Called when the element joins a host (subscribe to external events here).
protected override void OnAttached()
OnKeyDown(KeyEventArgs)
Keyboard routed to the popup when CapturesKeyboard is set; Escape closes by default.
protected override void OnKeyDown(KeyEventArgs e)
Parameters
OnRender(DrawingContext)
Draws the element (below its children).
protected override void OnRender(DrawingContext dc)
Parameters
ShowMessage(UIHost, string, string, MessageBoxButtons, Action<MessageBoxResult>?)
Shows a message box. Returns the dialog (already open).
public static Dialog ShowMessage(UIHost host, string title, string message, MessageBoxButtons buttons = MessageBoxButtons.OK, Action<MessageBoxResult>? callback = null)
Parameters
hostUIHosttitlestringmessagestringbuttonsMessageBoxButtonscallbackAction<MessageBoxResult>
Returns
Events
ResultChosen
Raised when a button is chosen (before the dialog closes).
public event Action<Dialog, object?>? ResultChosen