Winify – Diff between revs 22 and 24
?pathlinks?
Rev 22 | Rev 24 | |||
---|---|---|---|---|
Line 2... | Line 2... | |||
2 | using System.Collections.Specialized; |
2 | using System.Collections.Specialized; |
|
3 | using System.ComponentModel; |
3 | using System.ComponentModel; |
|
4 | using System.Configuration; |
4 | using System.Configuration; |
|
5 | using System.Diagnostics; |
5 | using System.Diagnostics; |
|
6 | using System.IO; |
6 | using System.IO; |
|
- | 7 | using System.Linq; |
||
7 | using System.Text; |
8 | using System.Text; |
|
8 | using System.Threading; |
9 | using System.Threading; |
|
9 | using System.Threading.Tasks; |
10 | using System.Threading.Tasks; |
|
10 | using System.Windows.Forms; |
11 | using System.Windows.Forms; |
|
11 | using AutoUpdaterDotNET; |
12 | using AutoUpdaterDotNET; |
|
12 | using Serilog; |
13 | using Serilog; |
|
13 | using Servers; |
14 | using Servers; |
|
- | 15 | using ToastNotifications; |
||
14 | using Winify.Gotify; |
16 | using Winify.Gotify; |
|
15 | using Winify.Properties; |
17 | using Winify.Properties; |
|
16 | using Winify.Servers.Serialization; |
18 | using Winify.Servers.Serialization; |
|
17 | using Winify.Utilities; |
19 | using Winify.Utilities; |
|
Line 24... | Line 26... | |||
24 | |
26 | |
|
Line 25... | Line 27... | |||
25 | private readonly Announcements.Announcements _announcements; |
27 | private readonly Announcements.Announcements _announcements; |
|
Line 26... | Line 28... | |||
26 | |
28 | |
|
Line 27... | Line 29... | |||
27 | private readonly global::Servers.Servers _servers; |
29 | private readonly global::Servers.Servers _servers; |
|
Line 28... | Line 30... | |||
28 | |
30 | |
|
Line 29... | Line -... | |||
29 | private readonly TaskScheduler _taskScheduler; |
- | ||
30 | |
- | ||
31 | private AboutForm _aboutForm; |
31 | private readonly TaskScheduler _uiTaskScheduler; |
|
Line 32... | Line 32... | |||
32 | |
32 | |
|
Line 33... | Line 33... | |||
33 | private GotifyConnectionManager _gotifyConnectionManager; |
33 | private AboutForm _aboutForm; |
|
Line 73... | Line 73... | |||
73 | Settings.Default.PropertyChanged += Default_PropertyChanged; |
73 | Settings.Default.PropertyChanged += Default_PropertyChanged; |
|
Line 74... | Line 74... | |||
74 | |
74 | |
|
75 | _servers = new global::Servers.Servers(); |
75 | _servers = new global::Servers.Servers(); |
|
76 | _servers.Server.CollectionChanged += Server_CollectionChanged; |
76 | _servers.Server.CollectionChanged += Server_CollectionChanged; |
|
77 | _servers.Server.ListChanged += Server_ListChanged; |
77 | _servers.Server.ListChanged += Server_ListChanged; |
|
78 | _announcements = new global::Announcements.Announcements(); |
78 | _announcements = new Announcements.Announcements(); |
|
79 | _announcements.Announcement.CollectionChanged += Announcements_CollectionChanged; |
79 | _announcements.Announcement.CollectionChanged += Announcements_CollectionChanged; |
|
Line 80... | Line 80... | |||
80 | _announcements.Announcement.ListChanged += Announcement_ListChanged; |
80 | _announcements.Announcement.ListChanged += Announcement_ListChanged; |
|
81 | |
- | ||
82 | _taskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); |
- | ||
Line 83... | Line 81... | |||
83 | |
81 | |
|
84 | _notificationManager = new NotificationManager(_taskScheduler); |
82 | _uiTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); |
|
Line 85... | Line 83... | |||
85 | |
83 | |
|
Line 127... | Line 125... | |||
127 | |
125 | |
|
128 | _gotifyConnectionManager.GotifyNotification -= GotifyConnectionManager_GotifyNotification; |
126 | _gotifyConnectionManager.GotifyNotification -= GotifyConnectionManager_GotifyNotification; |
|
129 | _gotifyConnectionManager?.Dispose(); |
127 | _gotifyConnectionManager?.Dispose(); |
|
Line 130... | Line -... | |||
130 | _gotifyConnectionManager = null; |
- | ||
131 | |
- | ||
132 | _notificationManager?.Dispose(); |
- | ||
133 | _notificationManager = null; |
128 | _gotifyConnectionManager = null; |
|
134 | |
129 | |
|
Line 135... | Line 130... | |||
135 | components.Dispose(); |
130 | components.Dispose(); |
|
136 | } |
131 | } |
|
Line 157... | Line 152... | |||
157 | await SaveAnnouncements(); |
152 | await SaveAnnouncements(); |
|
158 | } |
153 | } |
|
Line 159... | Line 154... | |||
159 | |
154 | |
|
160 | private void GotifyConnectionManager_GotifyNotification(object sender, GotifyNotificationEventArgs e) |
155 | private void GotifyConnectionManager_GotifyNotification(object sender, GotifyNotificationEventArgs e) |
|
- | 156 | { |
||
- | 157 | Task.Factory.StartNew(() => |
||
161 | { |
158 | { |
|
- | 159 | foreach (var announcement in _announcements.Announcement) |
||
- | 160 | { |
||
- | 161 | if (announcement.AppId == e.Notification.AppId) |
||
- | 162 | { |
||
- | 163 | var configuredNotification = new Notification($"{e.Notification.Title} ({e.Notification.Server.Name}/{e.Notification.AppId})", |
||
- | 164 | e.Notification.Message, announcement.LingerTime, e.Image, FormAnimator.AnimationMethod.Slide, |
||
- | 165 | FormAnimator.AnimationDirection.Up); |
||
- | 166 | |
||
- | 167 | configuredNotification.Show(); |
||
- | 168 | |
||
- | 169 | return; |
||
- | 170 | } |
||
- | 171 | } |
||
- | 172 | |
||
- | 173 | var notification = new Notification($"{e.Notification.Title} ({e.Notification.Server.Name}/{e.Notification.AppId})", |
||
- | 174 | e.Notification.Message, 5000, e.Image, FormAnimator.AnimationMethod.Slide, |
||
- | 175 | FormAnimator.AnimationDirection.Up); |
||
- | 176 | |
||
- | 177 | notification.Show(); |
||
162 | _notificationManager.ShowNotification(e, _announcements); |
178 | }, CancellationToken.None, TaskCreationOptions.None, _uiTaskScheduler); |
|
Line 163... | Line 179... | |||
163 | } |
179 | } |
|
164 | |
180 | |
|
165 | private async void Server_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) |
181 | private async void Server_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) |