Winify – Rev 6
?pathlinks?
using System.Collections.Generic;
namespace Winify.Gotify
{
public class GotifyConnectionManager
{
#region Private Delegates, Events, Enums, Properties, Indexers and Fields
private readonly List<GotifyConnection> _gotifyConnections;
#endregion
#region Constructors, Destructors and Finalizers
public GotifyConnectionManager()
{
_gotifyConnections = new List<GotifyConnection>();
}
#endregion
#region Event Handlers
private static void Connection_GotifyNotification(object sender, GotifyNotificationEventArgs e)
{
var notification = new NotificationForm(e.Image, e.Notification.Title, e.Notification.Message, 5000);
notification.ShowDialog();
}
#endregion
#region Public Methods
public void UpdateServers(Servers.Servers servers)
{
// Update connections.
var removeConnections = new List<GotifyConnection>();
foreach (var gotifyConnection in _gotifyConnections)
{
gotifyConnection.GotifyNotification -= Connection_GotifyNotification;
gotifyConnection.Stop();
gotifyConnection.Dispose();
removeConnections.Add(gotifyConnection);
}
foreach (var connection in removeConnections)
{
_gotifyConnections.Remove(connection);
}
foreach (var server in servers.Server)
{
var connection = new GotifyConnection();
connection.Start(server.Username, server.Password, server.Host, server.Port);
connection.GotifyNotification += Connection_GotifyNotification;
_gotifyConnections.Add(connection);
}
}
#endregion
}
}
Generated by GNU Enscript 1.6.5.90.