16 private const int DefaultWidth = 520;
17 private const int DefaultHeight = 330;
19 private bool _disposed;
49 string applicationName,
51 string? description =
null,
52 string? copyright =
null,
54 Rectangle? bounds =
null,
55 string? nickname =
null,
57 Uri? hyperlinkUri =
null,
58 string? hyperlinkText =
null)
62 ResolveBounds(view, bounds),
63 $
"About {applicationName}",
64 showCloseButton: true,
65 nickname: nickname ??
"__gondwana_about__")
72 bool hasHyperlinkConfiguration = uriLauncher is not
null ||
73 hyperlinkUri is not
null ||
74 hyperlinkText is not
null;
76 if (hasHyperlinkConfiguration)
78 if (uriLauncher is
null)
80 throw new ArgumentNullException(
82 "A URI launcher is required when configuring the hyperlink.");
85 if (hyperlinkUri is
null)
87 throw new ArgumentNullException(
89 "A hyperlink URI is required when configuring the hyperlink.");
92 if (!hyperlinkUri.IsAbsoluteUri)
94 throw new ArgumentException(
"The hyperlink URI must be absolute.", nameof(hyperlinkUri));
98 Rectangle resolvedBounds = ResolveBounds(view, bounds);
100 int contentTop = resolvedBounds.Top + 52;
101 int contentLeft = resolvedBounds.Left + 24;
103 int contentRightPadding = 24;
105 if (logo is not
null)
107 var logoScreenBounds =
new Rectangle(
120 Logo.ZOrder = 10_002;
126 var headerTextScreenBounds =
new Rectangle(
129 resolvedBounds.Right - contentRightPadding - contentLeft,
135 headerTextScreenBounds,
136 $
"{Nickname}.header").
SetText(applicationName)
137 .
SetFont(SKTypeface.Default, 26f, minSize: 16f)
138 .
SetColors(SKColors.White, SKColors.Transparent)
142 HeaderText.ZOrder = 10_002;
145 var versionTextScreenBounds =
new Rectangle(
148 resolvedBounds.Right - contentRightPadding - contentLeft,
154 versionTextScreenBounds,
155 $
"{Nickname}.version").
SetText($
"Version {version}")
156 .
SetFont(SKTypeface.Default, 15f, minSize: 11f)
157 .
SetColors(
new SKColor(205, 205, 215), SKColors.Transparent)
161 VersionText.ZOrder = 10_002;
164 if (uriLauncher is not
null && hyperlinkUri is not
null)
166 Rectangle hyperlinkBounds =
new(
169 resolvedBounds.Right - contentRightPadding - contentLeft,
177 hyperlinkText ?? hyperlinkUri.ToString(),
179 $
"{Nickname}.hyperlink");
181 Hyperlink.Label.ZOrder = 10_002;
186 hyperlinkBounds.Left - resolvedBounds.Left,
187 hyperlinkBounds.Top - resolvedBounds.Top));
190 var detailsTextScreenBounds =
new Rectangle(
191 resolvedBounds.Left + 24,
193 resolvedBounds.Width - 48,
194 resolvedBounds.Height - 222);
196 string detailText =
string.Join(
197 Environment.NewLine + Environment.NewLine,
198 new[] { description, copyright }
199 .Where(
static value => !
string.IsNullOrWhiteSpace(value)));
204 detailsTextScreenBounds,
205 $
"{Nickname}.details").
SetText(detailText)
206 .
SetFont(SKTypeface.Default, 14f, minSize: 10f)
207 .
SetColors(
new SKColor(225, 225, 232), SKColors.Transparent)
211 DetailsText.ZOrder = 10_002;
214 Rectangle okBounds =
new(
215 resolvedBounds.Right - 116,
216 resolvedBounds.Bottom - 54,
227 Add(
OkButton,
new Vector2(resolvedBounds.Width - 116, resolvedBounds.Height - 54));
230 OkButton.Clicked += OnOkClicked;
233 #endregion constructors
235 #region public properties
287 #endregion public properties
289 #region exposed methods
304 OkButton.Clicked -= OnOkClicked;
309 #endregion exposed methods
311 #region private methods
313 private void OnOkClicked()
318 private static Rectangle ResolveBounds(
View view, Rectangle? bounds)
320 ArgumentNullException.ThrowIfNull(view);
322 if (bounds is not
null)
327 int availableWidth = Math.Max(1, viewport.Width - 40);
328 int availableHeight = Math.Max(1, viewport.Height - 40);
329 int width = Math.Min(DefaultWidth, availableWidth);
330 int height = Math.Min(DefaultHeight, availableHeight);
332 return new Rectangle(
333 viewport.Left + (viewport.Width - width) / 2,
334 viewport.Top + (viewport.Height - height) / 2,
339 #endregion private methods
View? View
Gets the view shared by all children in view mode.
Renders a bitmap or image to a rectangular region with support for scaling modes, source clipping,...
DirectImage SetScaleMode(ScaleMode mode)
Sets how the image is scaled to fit within the destination rectangle.
ScaleMode
Defines how an image is scaled to fit within the destination rectangle.
A retained-mode text drawable with wrapping, multi-line ( ) support, horizontal/vertical alignment,...
TextBlock SetFont(SKTypeface typeface, float size, float? minSize=null)
Sets the font face and size (and optional minimum size for auto-shrink).
TextBlock EnableWrapping(bool enable=true)
Enables or disables word wrapping when laying out paragraphs.
TextBlock SetAlignment(SKTextAlign h, VerticalAlign v)
Sets the horizontal and vertical alignment used when drawing the laid-out lines within the bounds.
VerticalAlign
Vertical alignment options for multi-line text within the control's bounds.
TextBlock SetColors(SKColor fg, SKColor bg)
Sets the foreground (text) and background colors using Skia colors.
TextBlock SetText(string text)
Sets the current text content and rebuilds layout as needed. If no reveal animation is active,...
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...
Viewport Viewport
Gets the viewport that defines the screen-space rectangle, zoom level, and other rendering parameters...
Rectangle TargetRectPx
Screen-space rectangle (in SCREEN / RenderSurface pixels) where this view is drawn....