Class Window
- Namespace
- Myra.Graphics2D.UI
- Assembly
- Myra.dll
A draggable window widget with a title bar and optional close button.
public class Window : ContentControl, IItemWithId, INotifyAttachedPropertyChanged, IContent
- Inheritance
-
Window
- Implements
- Derived
- Inherited Members
Constructors
Window(Stylesheet, string)
Initializes a new instance of the Window class with the specified stylesheet and style.
public Window(Stylesheet stylesheet, string styleName = "")
Parameters
stylesheetStylesheetThe stylesheet to use for applying the style.
styleNamestringThe name of the style to apply. Defaults to the default stylesheet style.
Window(string)
Initializes a new instance of the Window class with the specified style.
public Window(string styleName = "")
Parameters
styleNamestringThe name of the style to apply. Defaults to the default stylesheet style.
Properties
CloseButton
Gets the close button displayed in the window's title bar.
[Browsable(false)]
public Button CloseButton { get; }
Property Value
CloseKey
Gets or sets the key that closes the window, or null for no key-based close.
public Keys? CloseKey { get; set; }
Property Value
- Keys?
Content
Gets or sets the widget displayed as the window's content.
[Browsable(false)]
public override Widget Content { get; set; }
Property Value
DragDirection
Gets or sets the direction in which the window can be dragged.
public override DragDirection DragDirection { get; set; }
Property Value
HorizontalAlignment
Gets or sets the horizontal alignment of the window.
public override HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
Result
Gets or sets a boolean result value for modal dialog operations.
[Browsable(false)]
public bool Result { get; set; }
Property Value
Title
Gets or sets the title text displayed in the window's title bar.
public string Title { get; set; }
Property Value
TitleFont
Gets or sets the font used to render the title text.
[StylePropertyPath("TitleStyle/Font")]
public SpriteFontBase TitleFont { get; set; }
Property Value
- SpriteFontBase
TitlePanel
Gets the panel containing the title and close button.
[Browsable(false)]
public HorizontalStackPanel TitlePanel { get; }
Property Value
TitleTextColor
Gets or sets the color of the title text.
[StylePropertyPath("TitleStyle/TextColor")]
public Color TitleTextColor { get; set; }
Property Value
- Color
VerticalAlignment
Gets or sets the vertical alignment of the window.
public override VerticalAlignment VerticalAlignment { get; set; }
Property Value
Methods
ApplyStyle(WidgetStyle)
Applies the specified widget style to this window.
protected override void ApplyStyle(WidgetStyle style)
Parameters
styleWidgetStyleThe widget style to apply.
CenterOnDesktop()
Centers the window on the desktop.
public void CenterOnDesktop()
Close()
Closes the window and raises the Closing and Closed events.
public virtual void Close()
CopyFrom(Widget)
Copies the properties from another window widget.
protected override void CopyFrom(Widget w)
Parameters
wWidgetThe source window widget to copy from.
InternalArrange()
Arranges the window and centers it on the desktop if it hasn't been manually placed.
protected override void InternalArrange()
OnKeyDown(Keys)
Handles keyboard input, closing the window if the CloseKey is pressed.
public override void OnKeyDown(Keys k)
Parameters
kKeysThe key being pressed.
OnTouchDown()
Handles touch down events and brings the window to the front.
public override void OnTouchDown()
Show(Desktop, Point?)
Shows the window on the specified desktop as a non-modal window.
public void Show(Desktop desktop, Point? position = null)
Parameters
desktopDesktopThe desktop to display the window on.
positionPoint?Optional position for the window. If null, the window will be centered.
ShowModal(Desktop, Point?)
Shows the window on the specified desktop as a modal dialog that blocks interaction with other widgets.
public void ShowModal(Desktop desktop, Point? position = null)
Parameters
desktopDesktopThe desktop to display the window on.
positionPoint?Optional position for the window. If null, the window will be centered.
Events
Closed
Occurs after the window has been closed.
public event MyraEventHandler Closed
Event Type
Closing
Occurs before the window is closed. Set Cancel to true to prevent closing.
public event MyraEventHandler<CancellableEventArgs> Closing