Vereinsmeisterschaften  22aa7800eae54b428d40e835886cefe1fdefdfdf
This is a software that can be used to manage the internal competition of the swimming club Illertissen called "Vereinsmeisterschaften".
Loading...
Searching...
No Matches
AnalyticsWidgetBase.cs
1using ControlzEx.Theming;
2using LiveChartsCore.SkiaSharpView.Painting;
3using SkiaSharp;
4using System.ComponentModel;
5using System.Resources;
6using System.Runtime.CompilerServices;
9using System.Windows.Media;
11
13{
14 public abstract class AnalyticsWidgetBase : UserControl, IAnalyticsWidget
15 {
16 #region PropertyChanged
17 public event PropertyChangedEventHandler PropertyChanged;
18
19 protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
20 {
21 if (PropertyChanged != null)
22 {
23 PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
24 }
25 }
26 #endregion
27
28 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
29
34 public virtual string Title
35 {
36 get
37 {
38 ResourceManager rm = new ResourceManager(typeof(Properties.Resources));
39 return rm.GetString($"{this.GetType().Name}Title") ?? "?";
40 }
41 }
42
44 public virtual string Icon { get; } = "\uE9D2";
45
50 public virtual string Info
51 {
52 get
53 {
54 ResourceManager rm = new ResourceManager(typeof(Properties.Tooltips));
55 return rm.GetString($"Tooltip{this.GetType().Name}") ?? "?";
56 }
57 }
58
60 public virtual Geometry IconGeometry { get; } = null;
61
63 public virtual double NormalAnalyticsWidgetWidth { get; } = ANALYTICS_WIDGET_WIDTH_NORMAL;
65 public virtual double NormalAnalyticsWidgetHeight { get; } = ANALYTICS_WIDGET_HEIGHT_NORMAL;
66
68 public double CurrentAnalyticsWidgetWidth => IsMaximized ? double.NaN : NormalAnalyticsWidgetWidth; // use NaN to fill up the complete space
69
71 public double CurrentAnalyticsWidgetHeight => IsMaximized ? double.NaN : NormalAnalyticsWidgetHeight; // use NaN to fill up the complete space
72
73 private bool _isMaximized = false;
75 public bool IsMaximized
76 {
77 get => _isMaximized;
78 set
79 {
80 _isMaximized = value;
81 OnPropertyChanged();
82 OnPropertyChanged(nameof(CurrentAnalyticsWidgetWidth));
83 OnPropertyChanged(nameof(CurrentAnalyticsWidgetHeight));
84 }
85 }
86
88 public virtual void Refresh()
89 {
90 OnPropertyChanged(nameof(AnalyticsAvailable));
91 }
92
93 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
94
95 #region Analytics Module
96
101
105 public bool AnalyticsAvailable => AnalyticsModule?.AnalyticsAvailable ?? false;
106
107 #endregion
108
109 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
110
111 #region Fixed colors
112
113 public static readonly SolidColorPaint COLORPAINT_MALE = new SolidColorPaint(SKColor.Parse("2986cc"));
114 public static readonly SolidColorPaint COLORPAINT_FEMALE = new SolidColorPaint(SKColor.Parse("c90076"));
115 public static readonly SolidColorPaint COLORPAINT_SEPARATORS = new SolidColorPaint(SKColor.Parse("dcdcdc"));
116
117 #endregion
118
119 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
120
121 #region Fixed sizes
122
123 public static readonly double ANALYTICS_WIDGET_WIDTH_NORMAL = 400;
124 public static readonly double ANALYTICS_WIDGET_WIDTH_SMALL = 200;
125 public static readonly double ANALYTICS_WIDGET_HEIGHT_NORMAL = 275;
126 public static readonly double ANALYTICS_WIDGET_LEGEND_TEXTSIZE_DEFAULT = 14;
127 public static readonly double ANALYTICS_WIDGET_AXIS_TEXTSIZE_DEFAULT = 16;
128
129 #endregion
130
131 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
132
133 #region Theme colors
134
139 public SolidColorPaint ColorPaintMahAppsText
140 {
141 get
142 {
143 Brush textBrush = (Brush)ThemeManager.Current.DetectTheme(Application.Current).Resources["MahApps.Brushes.Text"];
144 string textBrushString = (string)new BrushConverter().ConvertTo(textBrush, typeof(string));
145 return new SolidColorPaint(SKColor.Parse(textBrushString));
146 }
147 }
148
153 public SolidColorPaint ColorPaintMahAppsAccent
154 {
155 get
156 {
157 Brush accentBrush = (Brush)ThemeManager.Current.DetectTheme(Application.Current).Resources["MahApps.Brushes.Accent"];
158 string accentBrushString = (string)new BrushConverter().ConvertTo(accentBrush, typeof(string));
159 return new SolidColorPaint(SKColor.Parse(accentBrushString));
160 }
161 }
162
166 public SolidColorPaint ColorPaintMahAppsBackground
167 {
168 get
169 {
170 Brush backgroundBrush = (Brush)ThemeManager.Current.DetectTheme(Application.Current).Resources["MahApps.Brushes.ThemeBackground"];
171 string backgroundBrushString = (string)new BrushConverter().ConvertTo(backgroundBrush, typeof(string));
172 return new SolidColorPaint(SKColor.Parse(backgroundBrushString));
173 }
174 }
175
176 #endregion
177
178 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
179
183 public AnalyticsWidgetBase(IAnalyticsModule analyticsModule)
184 {
185 AnalyticsModule = analyticsModule;
186 ThemeManager.Current.ThemeChanged += (sender, e) =>
187 {
188 OnPropertyChanged(nameof(ColorPaintMahAppsText));
189 OnPropertyChanged(nameof(ColorPaintMahAppsAccent));
190 OnPropertyChanged(nameof(ColorPaintMahAppsBackground));
191 Refresh();
192 };
193 }
194 }
195}
Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
bool IsMaximized
True if the analytics user control is displayed maximized (only one at a time should have this flag s...
double CurrentAnalyticsWidgetWidth
Current Width for the analytics widget.
virtual double NormalAnalyticsWidgetWidth
Normal Width for the analytics widget (this is the default width regardless if the control is maximiz...
SolidColorPaint ColorPaintMahAppsBackground
SolidColorPaint that represents the MahApps.Brushes.ThemeBackground brush.
virtual Geometry IconGeometry
Icon Geometry for this analytics.This is used instead of Icon when Icon is null.
virtual string? Title
Title used for the diagram of the analytics user control.
SolidColorPaint ColorPaintMahAppsAccent
SolidColorPaint that represents the MahApps.Brushes.Accent brush.
double CurrentAnalyticsWidgetHeight
Current Height for the analytics widget.
virtual string Icon
Icon for this analytics.This should be e.g. "\uE787". If this is null, IconGeometry is used.
bool AnalyticsAvailable
Indicating if the analytics module has data.
virtual void Refresh()
Refresh the data displayed in the user control.
IAnalyticsModule AnalyticsModule
Analytics module used by this user control.
SolidColorPaint ColorPaintMahAppsText
SolidColorPaint that represents the MahApps.Brushes.Text brush.
AnalyticsWidgetBase(IAnalyticsModule analyticsModule)
Constructor of the AnalyticsWidgetBase
virtual double NormalAnalyticsWidgetHeight
Normal Height for the analytics widget (this is the default height regardless if the control is maxim...
Interface used for any user control that displays analytics data.