/trunk/Winify/MainForm.cs |
@@ -24,6 +24,24 @@ |
{ |
public partial class MainForm : Form |
{ |
private void LogViewToolStripMenuItem_Click(object sender, EventArgs e) |
{ |
if (_logViewForm != null) return; |
|
_logViewForm = new LogViewForm(this, _memorySink, _cancellationToken); |
_logViewForm.Closing += LogViewForm_Closing; |
_logViewForm.Show(); |
} |
|
private void LogViewForm_Closing(object sender, CancelEventArgs e) |
{ |
if (_logViewForm == null) return; |
|
_logViewForm.Closing -= LogViewForm_Closing; |
_logViewForm.Close(); |
_logViewForm = null; |
} |
|
#region Public Enums, Properties and Fields |
|
public Configuration.Configuration Configuration { get; set; } |
@@ -112,7 +130,7 @@ |
_gotifyConnections = new ConcurrentBag<GotifyConnection>(); |
foreach (var server in servers.Server) |
{ |
var gotifyConnection = new GotifyConnection(server); |
var gotifyConnection = new GotifyConnection(server, Configuration); |
gotifyConnection.GotifyNotification += GotifyConnection_GotifyNotification; |
gotifyConnection.Start(); |
_gotifyConnections.Add(gotifyConnection); |
@@ -149,7 +167,7 @@ |
|
foreach (var server in e.Servers.Server) |
{ |
var gotifyConnection = new GotifyConnection(server); |
var gotifyConnection = new GotifyConnection(server, Configuration); |
gotifyConnection.GotifyNotification += GotifyConnection_GotifyNotification; |
gotifyConnection.Start(); |
_gotifyConnections.Add(gotifyConnection); |
@@ -161,7 +179,6 @@ |
var announcements = await LoadAnnouncements(); |
|
foreach (var announcement in announcements.Announcement) |
{ |
if (announcement.AppId == e.Notification.AppId) |
{ |
var configuredNotification = new ToastForm( |
@@ -168,25 +185,21 @@ |
$"{e.Notification.Title} ({e.Notification.Server.Name}/{e.Notification.AppId})", |
e.Notification.Message, announcement.LingerTime, e.Image); |
|
configuredNotification.Show(); |
Application.Run(configuredNotification); |
|
return; |
} |
} |
|
var notification = new ToastForm( |
$"{e.Notification.Title} ({e.Notification.Server.Name}/{e.Notification.AppId})", |
e.Notification.Message, 5000, e.Image); |
|
notification.Show(); |
Application.Run(notification); |
} |
|
private void SettingsForm_Closing(object sender, CancelEventArgs e) |
{ |
if (_settingsForm == null) |
{ |
return; |
} |
if (_settingsForm == null) return; |
|
_settingsForm.Save -= SettingsForm_Save; |
_settingsForm.Closing -= SettingsForm_Closing; |
@@ -196,10 +209,7 @@ |
|
private void AboutToolStripMenuItem_Click(object sender, EventArgs e) |
{ |
if (_aboutForm != null) |
{ |
return; |
} |
if (_aboutForm != null) return; |
|
_aboutForm = new AboutForm(); |
_aboutForm.Closing += AboutForm_Closing; |
@@ -208,10 +218,7 @@ |
|
private void AboutForm_Closing(object sender, CancelEventArgs e) |
{ |
if (_aboutForm == null) |
{ |
return; |
} |
if (_aboutForm == null) return; |
|
_aboutForm.Closing -= AboutForm_Closing; |
_aboutForm.Dispose(); |
@@ -386,29 +393,5 @@ |
} |
|
#endregion |
|
private void LogViewToolStripMenuItem_Click(object sender, EventArgs e) |
{ |
if (_logViewForm != null) |
{ |
return; |
} |
|
_logViewForm = new LogViewForm(this, _memorySink, _cancellationToken); |
_logViewForm.Closing += LogViewForm_Closing; |
_logViewForm.Show(); |
} |
|
private void LogViewForm_Closing(object sender, CancelEventArgs e) |
{ |
if (_logViewForm == null) |
{ |
return; |
} |
|
_logViewForm.Closing -= LogViewForm_Closing; |
_logViewForm.Close(); |
_logViewForm = null; |
} |
} |
} |