Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AppStyles.cs
1using System.Text;
3using Waher.Events;
5
6namespace NeuroAccessMaui.UI
7{
11 public static class AppStyles
12 {
13 private static readonly SortedDictionary<string, bool> missingStyles = [];
14 private static Timer? timer = null;
15
16 private static double? smallSpacing;
17 private static ControlTemplate? radioButtonTemplate;
18 private static Thickness? smallBottomMargins;
19 private static Thickness? smallTopMargins;
20 private static Thickness? smallLeftMargins;
21 private static Thickness? smallRightMargins;
22 private static Thickness? smallMargins;
23 private static Style? sectionTitleLabelStyle;
24 private static Style? keyLabel;
25 private static Style? valueLabel;
26 private static Style? formattedValueLabel;
27 private static Style? clickableValueLabel;
28 private static Style? infoLabelStyle;
29 private static Style? filledTextButton;
30 private static Style? frameSet;
31 private static Style? frameSubSet;
32 private static Style? clickableFrameSubSet;
33 private static Style? regularCompositePicker;
34 private static Style? regularCompositeEntry;
35 private static Style? regularCompositeEntryBorder;
36 private static Style? regularCompositeDatePicker;
37 private static Style? imageOnlyButton;
38 private static Style? sendFrame;
39 private static Style? receiveFrame;
40 private static Style? requiredFieldMarker;
41 private static Style? requiredFieldMarkerSpan;
42 private static Style? tableCellEven;
43 private static Style? tableCellOdd;
44 private static Style? tableCell;
45 private static Style?[] headers;
46 private static Style? roundedBorder;
47 private static Style? baseCompositeInputView;
48 private static Style? borderSet;
49 private static Style? bottomBarBorder;
50 private static Style? tertiaryButton;
51 private static Style? transparentTemplateButtonBorder;
52 private static Style? transparentTemplateButtonLabel;
53 private static Style? transparentTemplateButtonPath;
54 private static Style? secondaryButton;
55 private static Style? secondaryImageButton;
56 private static Style? neuroIconButton;
57 private static Style? neuroIconButtonDisabled;
58
59 static AppStyles()
60 {
61 Log.Terminating += Log_Terminating;
62 headers = new Style[9];
63 }
64
65 private static Task Log_Terminating(object? sender, EventArgs e)
66 {
67 timer?.Dispose();
68 timer = null;
69
70 return Task.CompletedTask;
71 }
72
79 public static T? TryGetResource<T>(string Name)
80 {
81 if ((Application.Current?.Resources.TryGetValue(Name, out object Value) ?? false) && Value is T TypedValue)
82 return TypedValue;
83 else
84 {
85 lock (missingStyles)
86 {
87 timer?.Dispose();
88 timer = null;
89
90 missingStyles[Name] = true;
91
92 timer = new Timer(LogAlert, null, 1000, Timeout.Infinite);
93 }
94
95 return default;
96 }
97 }
98
99 private static void LogAlert(object? _)
100 {
101 StringBuilder sb = new();
102
103 sb.AppendLine("Missing styles:");
104 sb.AppendLine();
105
106 lock (missingStyles)
107 {
108 foreach (string Key in missingStyles.Keys)
109 {
110 sb.Append("* ");
111 sb.AppendLine(Key);
112 }
113
114 missingStyles.Clear();
115 }
116
117 ServiceRef.LogService.LogAlert(sb.ToString());
118 }
119
120 public static double SmallSpacing
121 {
122 get
123 {
124 smallSpacing ??= TryGetResource<double?>("SmallSpacing");
125 return smallSpacing ?? 0;
126 }
127 }
128
132 public static ControlTemplate RadioButtonTemplate
133 {
134 get
135 {
136 radioButtonTemplate ??= TryGetResource<ControlTemplate>("RadioButtonTemplate");
137 return radioButtonTemplate!;
138 }
139 }
140
144 public static Thickness SmallBottomMargins
145 {
146 get
147 {
148 smallBottomMargins ??= TryGetResource<Thickness>("SmallBottomMargins");
149 return smallBottomMargins.Value;
150 }
151 }
152
156 public static Thickness SmallTopMargins
157 {
158 get
159 {
160 smallTopMargins ??= TryGetResource<Thickness>("SmallTopMargins");
161 return smallTopMargins.Value;
162 }
163 }
164
168 public static Thickness SmallLeftMargins
169 {
170 get
171 {
172 smallLeftMargins ??= TryGetResource<Thickness>("SmallLeftMargins");
173 return smallLeftMargins.Value;
174 }
175 }
176
180 public static Thickness SmallRightMargins
181 {
182 get
183 {
184 smallRightMargins ??= TryGetResource<Thickness>("SmallRightMargins");
185 return smallRightMargins.Value;
186 }
187 }
188
192 public static Thickness SmallMargins
193 {
194 get
195 {
196 smallMargins ??= TryGetResource<Thickness>("SmallMargins");
197 return smallMargins.Value;
198 }
199 }
200
204 public static Style SectionTitleLabel
205 {
206 get
207 {
208 sectionTitleLabelStyle ??= TryGetResource<Style>("SectionTitleLabel");
209 return sectionTitleLabelStyle!;
210 }
211 }
212
216 public static Style KeyLabel
217 {
218 get
219 {
220 keyLabel ??= TryGetResource<Style>("KeyLabel");
221 return keyLabel!;
222 }
223 }
224
228 public static Style ValueLabel
229 {
230 get
231 {
232 valueLabel ??= TryGetResource<Style>("ValueLabel");
233 return valueLabel!;
234 }
235 }
236
240 public static Style FormattedValueLabel
241 {
242 get
243 {
244 formattedValueLabel ??= TryGetResource<Style>("FormattedValueLabel");
245 return formattedValueLabel!;
246 }
247 }
248
252 public static Style ClickableValueLabel
253 {
254 get
255 {
256 clickableValueLabel ??= TryGetResource<Style>("ClickableValueLabel");
257 return clickableValueLabel!;
258 }
259 }
260
264 public static Style InfoLabel
265 {
266 get
267 {
268 infoLabelStyle ??= TryGetResource<Style>("InfoLabel");
269 return infoLabelStyle!;
270 }
271 }
272
276 public static Style FilledTextButton
277 {
278 get
279 {
280 filledTextButton ??= TryGetResource<Style>("FilledTextButton"); // TODO: Remove NoRoundedCorners
281 return filledTextButton!;
282 }
283 }
284
288 public static Style FrameSet
289 {
290 get
291 {
292 frameSet ??= TryGetResource<Style>("FrameSet");
293 return frameSet!;
294 }
295 }
296
300 public static Style FrameSubSet
301 {
302 get
303 {
304 frameSubSet ??= TryGetResource<Style>("FrameSubSet");
305 return frameSubSet!;
306 }
307 }
308
312 public static Style ClickableFrameSubSet
313 {
314 get
315 {
316 clickableFrameSubSet ??= TryGetResource<Style>("ClickableFrameSubSet");
317 return clickableFrameSubSet!;
318 }
319 }
320
324 public static Style RegularCompositeEntry
325 {
326 get
327 {
328 regularCompositeEntry ??= TryGetResource<Style>("RegularCompositeEntry"); // TODO: Remove NoRoundedCorners
329 return regularCompositeEntry!;
330 }
331 }
332
336 public static Style RegularCompositeEntryBorder
337 {
338 get
339 {
340 regularCompositeEntryBorder ??= TryGetResource<Style>("RegularCompositeEntryBorder"); // TODO: Remove NoRoundedCorners
341 return regularCompositeEntryBorder!;
342 }
343 }
344
348 public static Style RegularCompositeDatePicker
349 {
350 get
351 {
352 regularCompositeDatePicker ??= TryGetResource<Style>("RegularCompositeDatePicker");
353 return regularCompositeDatePicker!;
354 }
355 }
356
360 public static Style ImageOnlyButton
361 {
362 get
363 {
364 imageOnlyButton ??= TryGetResource<Style>("ImageOnlyButton");
365 return imageOnlyButton!;
366 }
367 }
368
372 public static Style SecondaryImageButton
373 {
374 get
375 {
376 secondaryImageButton ??= TryGetResource<Style>("SecondaryImageButton");
377 return secondaryImageButton!;
378 }
379 }
380
384 public static Style SendFrame
385 {
386 get
387 {
388 sendFrame ??= TryGetResource<Style>("SendFrame");
389 return sendFrame!;
390 }
391 }
392
396 public static Style ReceiveFrame
397 {
398 get
399 {
400 receiveFrame ??= TryGetResource<Style>("ReceiveFrame");
401 return receiveFrame!;
402 }
403 }
404
408 public static Style RequiredFieldMarker
409 {
410 get
411 {
412 requiredFieldMarker ??= TryGetResource<Style>("RequiredFieldMarker");
413 return requiredFieldMarker!;
414 }
415 }
416
420 public static Style RequiredFieldMarkerSpan
421 {
422 get
423 {
424 requiredFieldMarkerSpan ??= TryGetResource<Style>("RequiredFieldMarkerSpan");
425 return requiredFieldMarkerSpan!;
426 }
427 }
428
432 public static Style TableCellEven
433 {
434 get
435 {
436 tableCellEven ??= TryGetResource<Style>("TableCellEven");
437 return tableCellEven!;
438 }
439 }
440
444 public static Style TableCellOdd
445 {
446 get
447 {
448 tableCellOdd ??= TryGetResource<Style>("TableCellOdd");
449 return tableCellOdd!;
450 }
451 }
452
456 public static Style TableCell
457 {
458 get
459 {
460 tableCell ??= TryGetResource<Style>("TableCell");
461 return tableCell!;
462 }
463 }
464
468 public static Style GetHeaderStyle(int x)
469 {
470 headers[x - 1] ??= TryGetResource<Style>($"Header{x}");
471
472 return headers[x - 1]!;
473 }
474
475 public static Style RoundedBorder
476 {
477 get
478 {
479 roundedBorder ??= TryGetResource<Style>("RoundedBorder");
480 return roundedBorder!;
481 }
482 }
483
487 public static Style RegularCompositePicker
488 {
489 get
490 {
491 regularCompositePicker ??= TryGetResource<Style>("RegularCompositePicker");
492 return regularCompositePicker!;
493 }
494 }
495
499 public static Style BaseCompositeInputView
500 {
501 get
502 {
503 baseCompositeInputView ??= TryGetResource<Style>("BaseCompositeInputView");
504 return baseCompositeInputView!;
505 }
506 }
507
511 public static Style BorderSet
512 {
513 get
514 {
515 borderSet ??= TryGetResource<Style>("BorderSet");
516 return borderSet!;
517 }
518 }
519
523 public static Style BottomBarBorder
524 {
525 get
526 {
527 bottomBarBorder ??= TryGetResource<Style>("BottomBarBorder");
528 return bottomBarBorder!;
529 }
530 }
531
535 public static Style TertiaryButton
536 {
537 get
538 {
539 tertiaryButton ??= TryGetResource<Style>("TertiaryButton");
540 return tertiaryButton!;
541 }
542 }
543
548 {
549 get
550 {
551 transparentTemplateButtonBorder ??= TryGetResource<Style>("TransparentTemplateButtonBorder");
552 return transparentTemplateButtonBorder!;
553 }
554 }
555
560 {
561 get
562 {
563 transparentTemplateButtonLabel ??= TryGetResource<Style>("TransparentTemplateButtonLabel");
564 return transparentTemplateButtonLabel!;
565 }
566 }
567
572 {
573 get
574 {
575 transparentTemplateButtonPath ??= TryGetResource<Style>("TransparentTemplateButtonPath");
576 return transparentTemplateButtonPath!;
577 }
578 }
579
583 public static Style SecondaryButton
584 {
585 get
586 {
587 secondaryButton ??= TryGetResource<Style>("SecondaryButton");
588 return secondaryButton!;
589 }
590 }
591
595 public static Style NeuroIconButton
596 {
597 get
598 {
599 neuroIconButton ??= TryGetResource<Style>("NeuroIconButton");
600 return neuroIconButton!;
601 }
602 }
603
607 public static Style NeuroIconButtonDisabled
608 {
609 get
610 {
611 neuroIconButtonDisabled ??= TryGetResource<Style>("NeuroIconButtonDisabled");
612 return neuroIconButtonDisabled!;
613 }
614 }
615 }
616}
Base class that references services in the app.
Definition: ServiceRef.cs:43
static ILogService LogService
Log service.
Definition: ServiceRef.cs:214
Static class that gives access to app-specific styles
Definition: AppStyles.cs:12
static Style BaseCompositeInputView
Style for base composite input view
Definition: AppStyles.cs:500
static Thickness SmallMargins
Small margins
Definition: AppStyles.cs:193
static Style TransparentTemplateButtonBorder
Style for transparent template button border
Definition: AppStyles.cs:548
static Thickness SmallRightMargins
Right-only small margins
Definition: AppStyles.cs:181
static Style TableCellOdd
Style for odd table cells
Definition: AppStyles.cs:445
static Style BorderSet
Style for border set
Definition: AppStyles.cs:512
static Style TransparentTemplateButtonPath
Style for transparent template button path
Definition: AppStyles.cs:572
static Style RegularCompositeEntry
Style for borders in a regular composte entry control.
Definition: AppStyles.cs:325
static Style ImageOnlyButton
Style for buttons containing only an image.
Definition: AppStyles.cs:361
static Style BottomBarBorder
Style for bottom bar border
Definition: AppStyles.cs:524
static Style TableCell
Style for table cells
Definition: AppStyles.cs:457
static ControlTemplate RadioButtonTemplate
Template for radio buttons
Definition: AppStyles.cs:133
static Style SendFrame
Style for send frames
Definition: AppStyles.cs:385
static Style FrameSubSet
Style for frame subsets.
Definition: AppStyles.cs:301
static Style TransparentTemplateButtonLabel
Style for transparent template button label
Definition: AppStyles.cs:560
static Style SectionTitleLabel
Style of section title labels
Definition: AppStyles.cs:205
static Thickness SmallBottomMargins
Bottom-only small margins
Definition: AppStyles.cs:145
static Style RegularCompositePicker
Style for regular composite pickers
Definition: AppStyles.cs:488
static Style RequiredFieldMarkerSpan
Style for required field marker spans
Definition: AppStyles.cs:421
static Style TableCellEven
Style for even table cells
Definition: AppStyles.cs:433
static Style SecondaryImageButton
Style for secondary image buttons.
Definition: AppStyles.cs:373
static Style ClickableValueLabel
Style of clickable value labels
Definition: AppStyles.cs:253
static Style SecondaryButton
Style for secondary button
Definition: AppStyles.cs:584
static Style ClickableFrameSubSet
Style for clickable frame subsets.
Definition: AppStyles.cs:313
static Style NeuroIconButtonDisabled
Style for NeuroIconButtonDisabled
Definition: AppStyles.cs:608
static Style InfoLabel
Style of information labels
Definition: AppStyles.cs:265
static Style ReceiveFrame
Style for receive frames
Definition: AppStyles.cs:397
static Thickness SmallLeftMargins
Left-only small margins
Definition: AppStyles.cs:169
static Style FrameSet
Style for frame sets.
Definition: AppStyles.cs:289
static Style RegularCompositeEntryBorder
Style for borders in a regular composte entry control.
Definition: AppStyles.cs:337
static ? T TryGetResource< T >(string Name)
Tries to get an embedded resource.
Definition: AppStyles.cs:79
static Thickness SmallTopMargins
Top-only small margins
Definition: AppStyles.cs:157
static Style RegularCompositeDatePicker
Style for CompositeDatePicker controls.
Definition: AppStyles.cs:349
static Style KeyLabel
Style of key labels
Definition: AppStyles.cs:217
static Style ValueLabel
Style of value labels
Definition: AppStyles.cs:229
static Style GetHeaderStyle(int x)
Get style for header of certain size
Definition: AppStyles.cs:468
static Style NeuroIconButton
Style for NeuroIconButton
Definition: AppStyles.cs:596
static Style RequiredFieldMarker
Style for required field marker labels
Definition: AppStyles.cs:409
static Style FormattedValueLabel
Style of formatted value labels
Definition: AppStyles.cs:241
static Style FilledTextButton
Style for filled text buttons.
Definition: AppStyles.cs:277
static Style TertiaryButton
Style for Tertiary Button
Definition: AppStyles.cs:536
Definition: ImplTypes.g.cs:58