HamBook – Blame information for rev 12
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
12 | office | 1 | using Configuration.Annotations; |
2 | using System; |
||
3 | using System.Collections.Concurrent; |
||
4 | using System.Collections.Generic; |
||
5 | using System.Collections.ObjectModel; |
||
6 | using System.ComponentModel; |
||
7 | using System.Linq; |
||
8 | using System.Runtime.CompilerServices; |
||
9 | using System.Text; |
||
10 | using System.Threading.Tasks; |
||
11 | |||
12 | namespace Configuration |
||
13 | { |
||
14 | public class Notifications : INotifyPropertyChanged |
||
15 | { |
||
16 | |||
17 | private NotificationState[] _notificationState = new NotificationState[] |
||
18 | { |
||
19 | new NotificationState() { Type = NotificationType.SignalScanDetect, Enabled = false, LingerTime = 1000 }, |
||
20 | }; |
||
21 | |||
22 | public NotificationState[] State |
||
23 | { |
||
24 | get => _notificationState; |
||
25 | set |
||
26 | { |
||
27 | if (value == _notificationState) |
||
28 | { |
||
29 | return; |
||
30 | } |
||
31 | |||
32 | _notificationState = value; |
||
33 | OnPropertyChanged(); |
||
34 | } |
||
35 | } |
||
36 | |||
37 | public Notifications() |
||
38 | { |
||
39 | if (_notificationStates.Count == 0) |
||
40 | { |
||
41 | foreach (var state in _notificationState) |
||
42 | { |
||
43 | _notificationStates.TryAdd(state.Type, state); |
||
44 | } |
||
45 | } |
||
46 | } |
||
47 | |||
48 | public bool TryGetNotificationState(NotificationType notificationType, out NotificationState notificationState) |
||
49 | { |
||
50 | return _notificationStates.TryGetValue(notificationType, out notificationState); |
||
51 | } |
||
52 | |||
53 | private static ConcurrentDictionary<NotificationType, NotificationState> _notificationStates = new ConcurrentDictionary<NotificationType, NotificationState>(); |
||
54 | |||
55 | public event PropertyChangedEventHandler PropertyChanged; |
||
56 | |||
57 | [NotifyPropertyChangedInvocator] |
||
58 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) |
||
59 | { |
||
60 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
||
61 | } |
||
62 | } |
||
63 | } |