Winify – Diff between revs 25 and 28

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 25 Rev 28
Line 45... Line 45...
45 rollingInterval: RollingInterval.Day) 45 rollingInterval: RollingInterval.Day)
46 .CreateLogger(); 46 .CreateLogger();
Line 47... Line 47...
47   47  
48 // Upgrade settings if required. 48 // Upgrade settings if required.
49 if (!ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).HasFile) -  
50 { 49 if (!ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).HasFile)
51 if (Properties.Settings.Default.UpdateRequired) 50 if (Properties.Settings.Default.UpdateRequired)
52 { 51 {
53 Properties.Settings.Default.Upgrade(); 52 Properties.Settings.Default.Upgrade();
Line 58... Line 57...
58   57  
59 mutex.ReleaseMutex(); 58 mutex.ReleaseMutex();
60 Process.Start(Application.ExecutablePath); 59 Process.Start(Application.ExecutablePath);
61 Environment.Exit(0); 60 Environment.Exit(0);
62 } -  
Line 63... Line 61...
63 } 61 }
64   62  
65 // Bind to settings changed event. 63 // Bind to settings changed event.
66 Properties.Settings.Default.SettingsLoaded += Default_SettingsLoaded; 64 Properties.Settings.Default.SettingsLoaded += Default_SettingsLoaded;
Line 124... Line 122...
124 { 122 {
125 } 123 }
Line 126... Line 124...
126   124  
127 private async void SettingsToolStripMenuItem_Click(object sender, EventArgs e) 125 private async void SettingsToolStripMenuItem_Click(object sender, EventArgs e)
128 { 126 {
129 if (_settingsForm != null) -  
130 { -  
131 return; -  
Line 132... Line 127...
132 } 127 if (_settingsForm != null) return;
133   128  
Line 134... Line 129...
134 var servers = await LoadServers(); 129 var servers = await LoadServers();
Line 168... Line 163...
168 Task.Factory.StartNew(async () => 163 Task.Factory.StartNew(async () =>
169 { 164 {
170 var announcements = await LoadAnnouncements(); 165 var announcements = await LoadAnnouncements();
Line 171... Line 166...
171   166  
172 foreach (var announcement in announcements.Announcement) -  
173 { 167 foreach (var announcement in announcements.Announcement)
174 if (announcement.AppId == e.Notification.AppId) 168 if (announcement.AppId == e.Notification.AppId)
175 { 169 {
176 var configuredNotification = new Notification( 170 var configuredNotification = new Notification(
177 $"{e.Notification.Title} ({e.Notification.Server.Name}/{e.Notification.AppId})", 171 $"{e.Notification.Title} ({e.Notification.Server.Name}/{e.Notification.AppId})",
Line 181... Line 175...
181   175  
Line 182... Line 176...
182 configuredNotification.Show(); 176 configuredNotification.Show();
183   177  
184 return; -  
Line 185... Line 178...
185 } 178 return;
186 } 179 }
187   180  
188 var notification = new Notification( 181 var notification = new Notification(
Line 194... Line 187...
194 }, CancellationToken.None, TaskCreationOptions.LongRunning, _uiTaskScheduler); 187 }, CancellationToken.None, TaskCreationOptions.LongRunning, _uiTaskScheduler);
195 } 188 }
Line 196... Line 189...
196   189  
197 private void SettingsForm_Closing(object sender, CancelEventArgs e) 190 private void SettingsForm_Closing(object sender, CancelEventArgs e)
198 { 191 {
199 if (_settingsForm == null) -  
200 { -  
201 return; -  
Line 202... Line 192...
202 } 192 if (_settingsForm == null) return;
203   193  
204 _settingsForm.Save -= SettingsForm_Save; 194 _settingsForm.Save -= SettingsForm_Save;
205 _settingsForm.Closing -= SettingsForm_Closing; 195 _settingsForm.Closing -= SettingsForm_Closing;
206 _settingsForm.Dispose(); 196 _settingsForm.Dispose();
Line 207... Line 197...
207 _settingsForm = null; 197 _settingsForm = null;
208 } 198 }
209   199  
210 private void AboutToolStripMenuItem_Click(object sender, EventArgs e) -  
211 { -  
212 if (_aboutForm != null) -  
Line 213... Line 200...
213 { 200 private void AboutToolStripMenuItem_Click(object sender, EventArgs e)
214 return; 201 {
215 } 202 if (_aboutForm != null) return;
216   203  
Line 217... Line 204...
217 _aboutForm = new AboutForm(); 204 _aboutForm = new AboutForm();
218 _aboutForm.Closing += AboutForm_Closing; 205 _aboutForm.Closing += AboutForm_Closing;
219 _aboutForm.Show(); 206 _aboutForm.Show();
220 } -  
221   -  
222 private void AboutForm_Closing(object sender, CancelEventArgs e) -  
Line 223... Line 207...
223 { 207 }
224 if (_aboutForm == null) 208  
225 { 209 private void AboutForm_Closing(object sender, CancelEventArgs e)
226 return; 210 {
Line 248... Line 232...
248 #region Private Methods 232 #region Private Methods
Line 249... Line 233...
249   233  
250 private static async Task SaveAnnouncements(Announcements.Announcements announcements) 234 private static async Task SaveAnnouncements(Announcements.Announcements announcements)
251 { 235 {
252 switch (await ServersSerialization.Serialize(announcements, Constants.AnnouncementsFile, "Announcements", 236 switch (await ServersSerialization.Serialize(announcements, Constants.AnnouncementsFile, "Announcements",
253 "<!ATTLIST Announcements xmlns:xsi CDATA #IMPLIED xsi:noNamespaceSchemaLocation CDATA #IMPLIED>")) 237 "<!ATTLIST Announcements xmlns:xsi CDATA #IMPLIED xsi:noNamespaceSchemaLocation CDATA #IMPLIED>"))
254 { 238 {
255 case SerializationFailure serializationFailure: 239 case SerializationFailure serializationFailure:
256 Log.Warning(serializationFailure.Exception, "Unable to serialize announcements."); 240 Log.Warning(serializationFailure.Exception, "Unable to serialize announcements.");
257 break; 241 break;
Line 273... Line 257...
273   257  
274 @protected.Server.Add(new Server(server.Name, server.Url, server.Username, armored)); 258 @protected.Server.Add(new Server(server.Name, server.Url, server.Username, armored));
Line 275... Line 259...
275 } 259 }
276   260  
277 switch (await ServersSerialization.Serialize(@protected, Constants.ServersFile, "Servers", 261 switch (await ServersSerialization.Serialize(@protected, Constants.ServersFile, "Servers",
278 "<!ATTLIST Servers xmlns:xsi CDATA #IMPLIED xsi:noNamespaceSchemaLocation CDATA #IMPLIED>")) 262 "<!ATTLIST Servers xmlns:xsi CDATA #IMPLIED xsi:noNamespaceSchemaLocation CDATA #IMPLIED>"))
279 { 263 {
280 case SerializationFailure serializationFailure: 264 case SerializationFailure serializationFailure:
281 Log.Warning(serializationFailure.Exception, "Unable to serialize servers."); 265 Log.Warning(serializationFailure.Exception, "Unable to serialize servers.");
282 break; 266 break;
Line 283... Line 267...
283 } 267 }
284 } 268 }
285   269  
286 private static async Task<Announcements.Announcements> LoadAnnouncements() -  
287 { 270 private static async Task<Announcements.Announcements> LoadAnnouncements()
288 if (!Directory.Exists(Constants.UserApplicationDirectory)) -  
Line 289... Line 271...
289 { 271 {
290 Directory.CreateDirectory(Constants.UserApplicationDirectory); 272 if (!Directory.Exists(Constants.UserApplicationDirectory))
291 } 273 Directory.CreateDirectory(Constants.UserApplicationDirectory);
Line 307... Line 289...
307 } 289 }
Line 308... Line 290...
308   290  
309 private static async Task<global::Servers.Servers> LoadServers() 291 private static async Task<global::Servers.Servers> LoadServers()
310 { 292 {
311 if (!Directory.Exists(Constants.UserApplicationDirectory)) -  
312 { 293 if (!Directory.Exists(Constants.UserApplicationDirectory))
313 Directory.CreateDirectory(Constants.UserApplicationDirectory); -  
Line 314... Line 294...
314 } 294 Directory.CreateDirectory(Constants.UserApplicationDirectory);
315   295  
316 var deserializationResult = 296 var deserializationResult =