Class UIToolView
Represents the root ui definition of a IGuiTool.
Implements
Inherited Members
Namespace: DevToys.Api
Assembly: DevToys.Api.dll
Syntax
public class UIToolView : INotifyPropertyChanged
Constructors
UIToolView()
Creates a new instance of the UIToolView class.
Declaration
public UIToolView()
UIToolView(IUIElement?)
Creates a new instance of the UIToolView class.
Declaration
public UIToolView(IUIElement? rootElement)
Parameters
| Type | Name | Description |
|---|---|---|
| IUIElement | rootElement | The root element of the tool's UI. |
UIToolView(bool)
Creates a new instance of the UIToolView class.
Declaration
public UIToolView(bool isScrollable)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isScrollable | Indicates whether the UI of the tool is scrollable or should fits to the window boundaries. |
UIToolView(bool, IUIElement?)
Creates a new instance of the UIToolView class.
Declaration
public UIToolView(bool isScrollable, IUIElement? rootElement)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isScrollable | Indicates whether the UI of the tool is scrollable or should fits to the window boundaries. |
| IUIElement | rootElement | The root element of the tool's UI. |
Properties
CurrentOpenedDialog
Gets the UIDialog currently opened. Only one at a time can be opened.
Declaration
public UIDialog? CurrentOpenedDialog { get; }
Property Value
| Type | Description |
|---|---|
| UIDialog |
IsScrollable
Gets whether the UI of the tool is scrollable or should fits to the window boundaries. Default is true.
Declaration
public bool IsScrollable { get; }
Property Value
| Type | Description |
|---|---|
| bool |
RootElement
Gets the root element of the tool's UI.
Declaration
public IUIElement? RootElement { get; }
Property Value
| Type | Description |
|---|---|
| IUIElement |
Methods
GetChildElementById(string)
Gets the first child element with the specified id.
Declaration
public IUIElement? GetChildElementById(string id)
Parameters
| Type | Name | Description |
|---|---|---|
| string | id | The id of a child element. |
Returns
| Type | Description |
|---|---|
| IUIElement | Returns null if the element could not be found. If many elements have the name id, this method returns the first it finds |
Remarks
This method is recursive and navigate through each element in the UI. It can be slow depending on the complexity of the UI. Be cautious when using it.
OnPropertyChanged(string?)
Raises the property changed event for the specified property.
Declaration
protected void OnPropertyChanged(string? propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | propertyName | The name of the property. Automatically inferred if not provided. |
OpenDialogAsync(IUIElement, IUIElement?, bool)
Shows the dialog box in the UI. Only one dialog can be opened at a time.
Declaration
public Task<UIDialog> OpenDialogAsync(IUIElement dialogContent, IUIElement? footerContent, bool isDismissible = false)
Parameters
| Type | Name | Description |
|---|---|---|
| IUIElement | dialogContent | The element to display in the dialog. |
| IUIElement | footerContent | The element to display in the dialog footer. |
| bool | isDismissible | Indicates whether the dialog can be closed by clicking outside of the dialog. |
Returns
| Type | Description |
|---|---|
| Task<UIDialog> | An instance of the opened dialog. |
OpenDialogAsync(IUIElement, bool)
Shows the dialog box in the UI. Only one dialog can be opened at a time.
Declaration
public Task<UIDialog> OpenDialogAsync(IUIElement dialogContent, bool isDismissible = false)
Parameters
| Type | Name | Description |
|---|---|---|
| IUIElement | dialogContent | The element to display in the dialog. |
| bool | isDismissible | Indicates whether the dialog can be closed by clicking outside of the dialog. |
Returns
| Type | Description |
|---|---|
| Task<UIDialog> | An instance of the opened dialog. |
SetPropertyValue<T>(ref T, T, EventHandler?, string?)
Sets the property value and raises the property changed event if the value has changed.
Declaration
protected void SetPropertyValue<T>(ref T field, T value, EventHandler? propertyChangedEventHandler, string? propertyName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| T | field | The reference to the field storing the property value. |
| T | value | The new value to set. |
| EventHandler | propertyChangedEventHandler | The event handler to raise the property changed event. |
| string | propertyName | The name of the property. Automatically inferred if not provided. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the property. |
Events
CurrentOpenedDialogChanged
Raised when CurrentOpenedDialog changed.
Declaration
public event EventHandler? CurrentOpenedDialogChanged
Event Type
| Type | Description |
|---|---|
| EventHandler |
IsScrollableChanged
Raised when IsScrollable changed.
Declaration
public event EventHandler? IsScrollableChanged
Event Type
| Type | Description |
|---|---|
| EventHandler |
PropertyChanged
Raised when a property value changes.
Declaration
public event PropertyChangedEventHandler? PropertyChanged
Event Type
| Type | Description |
|---|---|
| PropertyChangedEventHandler |
RootElementChanged
Raised when RootElement changed.
Declaration
public event EventHandler? RootElementChanged
Event Type
| Type | Description |
|---|---|
| EventHandler |