16 private Color _normalColor = Color.FromArgb(255, 60, 60, 68);
17 private Color _hoverColor = Color.FromArgb(255, 78, 78, 88);
18 private Color _pressedColor = Color.FromArgb(255, 42, 42, 48);
39 string? nickname =
null)
42 Background = CreateBackground(renderSurfaceHost, view, bounds);
43 Label = CreateLabel(renderSurfaceHost, view, bounds, text);
45 CompleteInitialization();
60 string? nickname =
null)
63 Background = CreateBackground(renderSurfaceHost, sceneLayer, bounds);
64 Label = CreateLabel(renderSurfaceHost, sceneLayer, bounds, text);
66 CompleteInitialization();
69 #endregion constructors
71 #region public properties
83 #endregion public properties
85 #region public methods
109 _normalColor = normal;
111 _pressedColor = pressed;
113 UpdateBackgroundColor(normal);
125 Label.SetColors(color, Color.Transparent);
137 Background.ZOrder = zOrder;
138 Label.ZOrder = zOrder + 1;
154 #endregion public methods
156 #region protected methods
161 base.OnPointerEnter(args);
162 UpdateBackgroundColor(_hoverColor);
168 base.OnPointerLeave(args);
169 UpdateBackgroundColor(_normalColor);
175 base.OnPointerDown(args);
178 UpdateBackgroundColor(_pressedColor);
184 base.OnPointerUp(args);
185 UpdateBackgroundColor(_hoverColor);
191 base.OnPointerClick(args);
203 base.OnKeyboardInput(args);
211 if (args.
Key is not 13 and not 32)
218 #endregion protected methods
220 #region private methods
222 private void UpdateBackgroundColor(Color color)
232 private void CompleteInitialization()
249 $
"{Nickname}.background").
SetFilled(
true)
261 $
"{Nickname}.background").
SetFilled(
true)
267 private static TextBlock CreateLabel(RenderSurfaceHostBase host,
View view, Rectangle bounds,
string text)
269 return new TextBlock(host, view, bounds).SetText(text)
270 .SetFont(SKTypeface.Default, 16f, minSize: 10f)
271 .SetColors(SKColors.White, SKColors.Transparent)
272 .SetAlignment(SKTextAlign.Center, TextBlock.VerticalAlign.Center)
273 .EnableWrapping(
false);
276 private static TextBlock CreateLabel(RenderSurfaceHostBase host,
SceneLayer layer, Rectangle bounds,
string text)
278 return new TextBlock(host,
281 worldBounds: bounds).SetText(text)
282 .SetFont(SKTypeface.Default, 16f, minSize: 10f)
283 .SetColors(SKColors.White, SKColors.Transparent)
284 .SetAlignment(SKTextAlign.Center, TextBlock.VerticalAlign.Center)
285 .EnableWrapping(
false);
288 #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.