Winify
/trunk/Winify/LogViewForm.cs |
@@ -1,4 +1,5 @@ |
using System.Collections.Specialized; |
using System.Linq; |
using System.Threading; |
using System.Windows.Forms; |
using Winify.Utilities; |
@@ -58,7 +59,7 @@ |
{ |
var line = (string)item; |
|
textBox1.InvokeIfRequired(textbox => { textbox.Text += line; }); |
textBox1.InvokeIfRequired(textbox => { textbox.AppendText(line); }); |
} |
|
break; |
/trunk/Winify/MainForm.cs |
@@ -9,6 +9,7 @@ |
using System.Threading; |
using System.Threading.Tasks; |
using System.Windows.Forms; |
using Microsoft.Win32; |
using NetSparkleUpdater; |
using NetSparkleUpdater.Enums; |
using NetSparkleUpdater.SignatureVerifiers; |
@@ -64,6 +65,8 @@ |
{ |
InitializeComponent(); |
|
SystemEvents.PowerModeChanged += OnPowerModeChanged; |
|
_cancellationTokenSource = new CancellationTokenSource(); |
_cancellationToken = _cancellationTokenSource.Token; |
|
@@ -111,6 +114,31 @@ |
|
#region Event Handlers |
|
private async void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e) |
{ |
switch (e.Mode) |
{ |
case PowerModes.Resume: |
// Refresh connection to gotify server. |
while (_gotifyConnections.TryTake(out var gotifyConnection)) |
{ |
gotifyConnection.GotifyMessage -= GotifyConnectionGotifyMessage; |
await gotifyConnection.Stop(); |
gotifyConnection.Dispose(); |
} |
|
var servers = await LoadServers(); |
foreach (var server in servers.Server) |
{ |
var gotifyConnection = new GotifyConnection(server, Configuration); |
gotifyConnection.GotifyMessage += GotifyConnectionGotifyMessage; |
gotifyConnection.Start(); |
_gotifyConnections.Add(gotifyConnection); |
} |
break; |
} |
} |
|
private async void MainForm_Load(object sender, EventArgs e) |
{ |
Configuration = await LoadConfiguration(); |