16 private Color _normalColor = Color.FromArgb(
22 private Color _hoverColor = Color.FromArgb(
28 private Color _pressedColor = Color.FromArgb(
54 string? nickname =
null)
61 Background = CreateBackground(renderSurfaceHost, view, bounds);
69 CompleteInitialization();
85 string? nickname =
null)
92 Background = CreateBackground(renderSurfaceHost, sceneLayer, bounds);
100 CompleteInitialization();
103 #endregion constructors
105 #region public properties
117 #endregion public properties
119 #region public methods
144 _normalColor = normal;
146 _pressedColor = pressed;
148 UpdateBackgroundColor(normal);
160 Label.SetColors(color, Color.Transparent);
172 Background.ZOrder = zOrder;
173 Label.ZOrder = zOrder + 1;
189 #endregion public methods
191 #region protected methods
196 base.OnPointerEnter(args);
197 UpdateBackgroundColor(_hoverColor);
203 base.OnPointerLeave(args);
204 UpdateBackgroundColor(_normalColor);
210 base.OnPointerDown(args);
213 UpdateBackgroundColor(_pressedColor);
219 base.OnPointerUp(args);
220 UpdateBackgroundColor(_hoverColor);
226 base.OnPointerClick(args);
238 base.OnKeyboardInput(args);
246 if (args.
Key is not 13 and not 32)
253 #endregion protected methods
255 #region private methods
257 private void UpdateBackgroundColor(Color color)
267 private void CompleteInitialization()
285 $
"{Nickname}.background").
SetFilled(
true)
303 $
"{Nickname}.background").
SetFilled(
true)
314 private static TextBlock CreateLabel(
315 RenderSurfaceHostBase host,
320 return new TextBlock(host, view, bounds).SetText(text)
321 .SetFont(SKTypeface.Default, 16f, minSize: 10f)
322 .SetColors(SKColors.White, SKColors.Transparent)
323 .SetAlignment(SKTextAlign.Center, TextBlock.VerticalAlign.Center)
324 .EnableWrapping(
false);
327 private static TextBlock CreateLabel(
328 RenderSurfaceHostBase host,
333 return new TextBlock(
337 worldBounds: bounds).SetText(text)
338 .SetFont(SKTypeface.Default, 16f, minSize: 10f)
339 .SetColors(SKColors.White, SKColors.Transparent)
340 .SetAlignment(SKTextAlign.Center, TextBlock.VerticalAlign.Center)
341 .EnableWrapping(
false);
344 #endregion private methods
SceneLayer? SceneLayer
Gets the scene layer shared by all children in scene-layer mode.
View? View
Gets the view shared by all children in view mode.
virtual DirectComposite Add(IDirectCompositeChild child, bool keepCurrentOffset=true, Vector2? explicitLocalOffsetPx=null)
Adds a composite-compatible direct drawable as a child.
Vector2 GetPosition()
Gets the current position of this direct drawing in pixel coordinates.
void SetPosition(Vector2 p)
Sets the position of this direct drawing to the specified pixel coordinates.
Renders a configurable rectangle with support for fill, border, rounded corners, dash patterns,...
DirectRectangle SetFilled(bool isFilled)
Sets whether the rectangle interior is filled with the base color (or pattern).
DirectRectangle SetBorderColor(Color color)
Sets a distinct border (stroke) color, independent of the fill color.
DirectRectangle SetColor(Color color)
Sets the base color used for both fill and stroke (unless a distinct border color is specified).
DirectRectangle SetStrokeWidth(float width)
Sets the width (thickness) of the rectangle's stroke (outline) in pixels.
DirectRectangle SetCornerRadius(float radius)
Sets the radius for rounded corners in pixels.
A retained-mode text drawable with wrapping, multi-line ( ) support, horizontal/vertical alignment,...
Represents a base class for hosting a render surface, providing functionality for managing rendering ...
Represents a rendered view of a scene, combining a camera position with a viewport configuration to c...
Represents a single layer within a Scene, containing a grid of tiles and supporting various coordinat...
DirectDrawingMode
Specifies where direct drawing operations are applied within the rendering pipeline.