Winify

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 43  →  ?path2? @ 44
/trunk/Winify/AboutForm.cs
@@ -9,6 +9,8 @@
public AboutForm()
{
InitializeComponent();
 
Utilities.WindowState.FormTracker.Track(this);
}
 
#endregion
/trunk/Winify/Gotify/GotifyApplication.cs
@@ -6,14 +6,11 @@
{
#region Public Enums, Properties and Fields
 
[JsonProperty(PropertyName = "id")]
public int Id { get; set; }
[JsonProperty(PropertyName = "id")] public int Id { get; set; }
 
[JsonProperty(PropertyName = "token")]
public string Token { get; set; }
[JsonProperty(PropertyName = "token")] public string Token { get; set; }
 
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
[JsonProperty(PropertyName = "name")] public string Name { get; set; }
 
[JsonProperty(PropertyName = "description")]
public string Description { get; set; }
@@ -21,8 +18,7 @@
[JsonProperty(PropertyName = "internal")]
public bool Internal { get; set; }
 
[JsonProperty(PropertyName = "image")]
public string Image { get; set; }
[JsonProperty(PropertyName = "image")] public string Image { get; set; }
 
#endregion
}
/trunk/Winify/Gotify/GotifyConnection.cs
@@ -3,7 +3,6 @@
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -10,7 +9,9 @@
using Newtonsoft.Json;
using Serilog;
using Servers;
using ClientWebSocket = System.Net.WebSockets.Managed.ClientWebSocket;
using WebSocketSharp;
using Configuration = Configuration.Configuration;
using ErrorEventArgs = WebSocketSharp.ErrorEventArgs;
 
namespace Winify.Gotify
{
@@ -34,34 +35,57 @@
 
private HttpClient _httpClient;
 
private readonly string _auth;
 
private readonly Uri _webSocketsUri;
 
private readonly Uri _httpUri;
private WebSocket _webSocketSharp;
private readonly global::Configuration.Configuration _configuration;
 
#endregion
 
#region Constructors, Destructors and Finalizers
 
public GotifyConnection()
private GotifyConnection()
{
_httpClient = new HttpClient();
 
}
 
public GotifyConnection(Server server) : this()
public GotifyConnection(Server server, global::Configuration.Configuration configuration) : this()
{
_server = server;
_configuration = configuration;
 
_auth = Convert.ToBase64String(Encoding.Default.GetBytes($"{_server.Username}:{_server.Password}"));
_httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Basic", _auth);
var httpClientHandler = new HttpClientHandler();
_httpClient = new HttpClient(httpClientHandler);
if (_configuration.IgnoreSelfSignedCertificates)
{
httpClientHandler.ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
}
 
_httpClient = new HttpClient(httpClientHandler)
{
DefaultRequestHeaders =
{
Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(Encoding.Default.GetBytes($"{_server.Username}:{_server.Password}")))
}
};
 
if (Uri.TryCreate(_server.Url, UriKind.Absolute, out _httpUri))
{
// Build the web sockets URI.
var webSocketsUriBuilder = new UriBuilder(_httpUri);
webSocketsUriBuilder.Scheme = "ws";
switch (webSocketsUriBuilder.Scheme.ToUpperInvariant())
{
case "HTTP":
webSocketsUriBuilder.Scheme = "ws";
break;
case "HTTPS":
webSocketsUriBuilder.Scheme = "wss";
break;
}
 
webSocketsUriBuilder.Path = Path.Combine(webSocketsUriBuilder.Path, "stream");
_webSocketsUri = webSocketsUriBuilder.Uri;
}
@@ -75,6 +99,9 @@
_cancellationTokenSource = null;
}
 
_webSocketSharp.Close();
_webSocketSharp = null;
 
_httpClient.Dispose();
_httpClient = null;
}
@@ -88,99 +115,136 @@
_cancellationTokenSource = new CancellationTokenSource();
_cancellationToken = _cancellationTokenSource.Token;
 
Connect();
 
_runTask = Run(_cancellationToken);
}
 
public void Stop()
private void Connect()
{
if (_cancellationTokenSource != null)
_webSocketSharp = new WebSocket(_webSocketsUri.AbsoluteUri);
_webSocketSharp.SetCredentials(_server.Username, _server.Password, true);
if (_configuration.IgnoreSelfSignedCertificates)
{
_cancellationTokenSource.Cancel();
_webSocketSharp.SslConfiguration.ServerCertificateValidationCallback +=
(sender, certificate, chain, errors) => true;
}
 
_webSocketSharp.OnMessage += WebSocketSharp_OnMessage;
_webSocketSharp.OnError += WebSocketSharp_OnError;
_webSocketSharp.OnOpen += WebSocketSharp_OnOpen;
_webSocketSharp.OnClose += WebSocketSharp_OnClose;
_webSocketSharp.ConnectAsync();
}
 
#endregion
private void WebSocketSharp_OnClose(object sender, CloseEventArgs e)
{
Log.Information($"Connection to server closed with reason: {e.Reason}");
}
 
#region Private Methods
private void WebSocketSharp_OnOpen(object sender, EventArgs e)
{
Log.Information("Connection to server is now open.");
}
 
private async Task Run(CancellationToken cancellationToken)
private async void WebSocketSharp_OnError(object sender, ErrorEventArgs e)
{
try
if (_cancellationToken.IsCancellationRequested)
{
do
{
try
{
using (var webSocketClient = new ClientWebSocket())
{
webSocketClient.Options.SetRequestHeader("Authorization", $"Basic {_auth}");
Stop();
return;
}
 
await webSocketClient.ConnectAsync(_webSocketsUri, cancellationToken);
await Task.Delay(TimeSpan.FromSeconds(1), _cancellationToken);
Log.Information("Reconnecting to websocket server.");
 
do
{
var payload = new ArraySegment<byte>(new byte[1024]);
Connect();
}
 
var result = await webSocketClient.ReceiveAsync(payload, cancellationToken);
private async void WebSocketSharp_OnMessage(object sender, MessageEventArgs e)
{
if (e.RawData.Length == 0)
{
Log.Warning($"Empty message received from server.");
return;
}
 
if (result.Count == 0)
{
continue;
}
var message = Encoding.UTF8.GetString(e.RawData, 0, e.RawData.Length);
 
if (payload.Array == null || payload.Count == 0)
{
continue;
}
GotifyNotification gotifyNotification;
 
var message = Encoding.UTF8.GetString(payload.Array, 0, payload.Count);
try
{
gotifyNotification = JsonConvert.DeserializeObject<GotifyNotification>(message);
}
catch (JsonSerializationException exception)
{
Log.Warning($"Could not deserialize notification: {exception.Message}");
return;
}
 
var gotifyNotification = JsonConvert.DeserializeObject<GotifyNotification>(message);
if (gotifyNotification == null)
{
Log.Warning($"Could not deserialize gotify notification: {message}");
 
if (gotifyNotification == null)
{
Log.Warning($"Could not deserialize gotify notification: {message}");
return;
}
 
continue;
}
gotifyNotification.Server = _server;
 
gotifyNotification.Server = _server;
if (!Uri.TryCreate(Path.Combine($"{_httpUri}", "application"), UriKind.Absolute,
out var applicationUri))
{
Log.Warning($"Could not build an URI to an application.");
return;
}
 
if (!Uri.TryCreate(Path.Combine($"{_httpUri}", "application"), UriKind.Absolute,
out var applicationUri))
{
continue;
}
using (var imageStream =
await RetrieveGotifyApplicationImage(gotifyNotification.AppId, applicationUri, _cancellationToken))
{
if (imageStream == null)
{
Log.Warning("Could not find any application image for notification.");
return;
}
 
var image = await RetrieveGotifyApplicationImage(gotifyNotification.AppId,
applicationUri, cancellationToken);
var image = Image.FromStream(imageStream);
 
GotifyNotification?.Invoke(this,
new GotifyNotificationEventArgs(gotifyNotification, image));
GotifyNotification?.Invoke(this,
new GotifyNotificationEventArgs(gotifyNotification, image));
}
 
Log.Debug($"Notification message received: {gotifyNotification.Message}");
} while (!cancellationToken.IsCancellationRequested);
}
}
catch (Exception ex) when (ex is WebSocketException || ex is HttpRequestException)
{
// Reconnect
Log.Warning($"Unable to connect to gotify server: {ex.Message}");
Log.Debug($"Notification message received: {gotifyNotification.Message}");
}
 
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
}
public void Stop()
{
if (_cancellationTokenSource != null) _cancellationTokenSource.Cancel();
}
 
#endregion
 
#region Private Methods
 
private async Task Run(CancellationToken cancellationToken)
{
try
{
do
{
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
} while (!cancellationToken.IsCancellationRequested);
}
catch (Exception ex) when (ex is OperationCanceledException || ex is ObjectDisposedException)
catch (Exception exception) when (exception is OperationCanceledException || exception is ObjectDisposedException)
{
}
catch (Exception ex)
catch (Exception exception)
{
Log.Warning(ex, "Failure running connection loop.");
Log.Warning(exception, "Failure running connection loop.");
}
}
 
private async Task<Image> RetrieveGotifyApplicationImage(int appId, Uri applicationUri,
private async Task<Stream> RetrieveGotifyApplicationImage(int appId, Uri applicationUri,
CancellationToken cancellationToken)
{
var applicationResponse = await _httpClient.GetAsync(applicationUri, cancellationToken);
@@ -187,35 +251,37 @@
 
var applications = await applicationResponse.Content.ReadAsStringAsync();
 
var gotifyApplications =
JsonConvert.DeserializeObject<GotifyApplication[]>(applications);
GotifyApplication[] gotifyApplications;
try
{
gotifyApplications =
JsonConvert.DeserializeObject<GotifyApplication[]>(applications);
}
catch (JsonSerializationException exception)
{
Log.Warning($"Could not deserialize the list of applications from the server: {exception.Message}");
 
if (gotifyApplications == null)
{
return null;
}
 
foreach (var application in gotifyApplications)
{
if (application.Id != appId)
{
continue;
}
if (application.Id != appId) continue;
 
if (!Uri.TryCreate(Path.Combine($"{_httpUri}", $"{application.Image}"), UriKind.Absolute,
out var applicationImageUri))
{
Log.Warning("Could not build URL path to application icon.");
continue;
}
 
var imageResponse = await _httpClient.GetAsync(applicationImageUri, cancellationToken);
 
using (var memoryStream = new MemoryStream())
{
await imageResponse.Content.CopyToAsync(memoryStream);
var memoryStream = new MemoryStream();
 
return Image.FromStream(memoryStream);
}
await imageResponse.Content.CopyToAsync(memoryStream);
 
return memoryStream;
}
 
return null;
/trunk/Winify/Gotify/GotifyNotification.cs
@@ -12,26 +12,21 @@
{
#region Public Enums, Properties and Fields
 
[JsonProperty(PropertyName = "id")]
public int Id { get; set; }
[JsonProperty(PropertyName = "id")] public int Id { get; set; }
 
[JsonProperty(PropertyName = "appid")]
public int AppId { get; set; }
[JsonProperty(PropertyName = "appid")] public int AppId { get; set; }
 
[JsonProperty(PropertyName = "message")]
public string Message { get; set; }
 
[JsonProperty(PropertyName = "title")]
public string Title { get; set; }
[JsonProperty(PropertyName = "title")] public string Title { get; set; }
 
[JsonProperty(PropertyName = "priority")]
public int Priority { get; set; }
 
[JsonProperty(PropertyName = "date")]
public DateTime Date { get; set; }
[JsonProperty(PropertyName = "date")] public DateTime Date { get; set; }
 
[JsonIgnore]
public Server Server { get; set; }
[JsonIgnore] public Server Server { get; set; }
 
#endregion
}
/trunk/Winify/LogViewForm.cs
@@ -1,7 +1,6 @@
using System.Collections.Specialized;
using System.Threading;
using System.Windows.Forms;
using Winify;
using Winify.Utilities;
 
namespace Winify
@@ -17,6 +16,8 @@
public LogViewForm()
{
InitializeComponent();
 
Utilities.WindowState.FormTracker.Track(this);
}
 
public LogViewForm(MainForm mainForm) : this()
@@ -40,10 +41,7 @@
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
if (disposing && components != null) components.Dispose();
 
_memorySink.Events.CollectionChanged -= Events_CollectionChanged;
 
/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;
}
}
}
/trunk/Winify/Settings/SettingsForm.Designer.cs
@@ -71,6 +71,9 @@
this.tableLayoutPanel9 = new System.Windows.Forms.TableLayoutPanel();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.tableLayoutPanel11 = new System.Windows.Forms.TableLayoutPanel();
this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.flowLayoutPanel2.SuspendLayout();
@@ -91,6 +94,8 @@
this.groupBox4.SuspendLayout();
this.tableLayoutPanel8.SuspendLayout();
this.tableLayoutPanel9.SuspendLayout();
this.groupBox6.SuspendLayout();
this.tableLayoutPanel11.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
@@ -118,6 +123,7 @@
// flowLayoutPanel2
//
this.flowLayoutPanel2.Controls.Add(this.groupBox3);
this.flowLayoutPanel2.Controls.Add(this.groupBox6);
this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel2.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
@@ -381,7 +387,7 @@
this.tableLayoutPanel7.Name = "tableLayoutPanel7";
this.tableLayoutPanel7.RowCount = 1;
this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 241F));
this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 243F));
this.tableLayoutPanel7.Size = new System.Drawing.Size(538, 243);
this.tableLayoutPanel7.TabIndex = 0;
//
@@ -579,6 +585,41 @@
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.Button6_Click);
//
// groupBox6
//
this.groupBox6.Controls.Add(this.tableLayoutPanel11);
this.groupBox6.Location = new System.Drawing.Point(262, 3);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(200, 53);
this.groupBox6.TabIndex = 1;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "Miscellaneous";
//
// checkBox2
//
this.checkBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(3, 8);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(188, 17);
this.checkBox2.TabIndex = 0;
this.checkBox2.Text = "Ignore self-signed certificates";
this.checkBox2.UseVisualStyleBackColor = true;
this.checkBox2.CheckedChanged += new System.EventHandler(this.CheckBox2_CheckedChanged);
//
// tableLayoutPanel11
//
this.tableLayoutPanel11.ColumnCount = 1;
this.tableLayoutPanel11.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel11.Controls.Add(this.checkBox2, 0, 0);
this.tableLayoutPanel11.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel11.Location = new System.Drawing.Point(3, 16);
this.tableLayoutPanel11.Name = "tableLayoutPanel11";
this.tableLayoutPanel11.RowCount = 1;
this.tableLayoutPanel11.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel11.Size = new System.Drawing.Size(194, 34);
this.tableLayoutPanel11.TabIndex = 0;
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -612,6 +653,9 @@
this.groupBox4.ResumeLayout(false);
this.tableLayoutPanel8.ResumeLayout(false);
this.tableLayoutPanel9.ResumeLayout(false);
this.groupBox6.ResumeLayout(false);
this.tableLayoutPanel11.ResumeLayout(false);
this.tableLayoutPanel11.PerformLayout();
this.ResumeLayout(false);
 
}
@@ -659,5 +703,8 @@
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel9;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel11;
private System.Windows.Forms.CheckBox checkBox2;
}
}
/trunk/Winify/Settings/SettingsForm.cs
@@ -31,6 +31,7 @@
private Server _server;
private readonly MainForm _mainForm;
private readonly CancellationToken _cancellationToken;
private readonly BindingSource _configurationBindingSource;
 
#endregion
 
@@ -39,6 +40,8 @@
public SettingsForm()
{
InitializeComponent();
 
Utilities.WindowState.FormTracker.Track(this);
}
 
public SettingsForm(MainForm mainForm) : this()
@@ -55,7 +58,15 @@
 
_serverBindingSource = new BindingSource();
_serverBindingSource.DataSource = _server;
_configurationBindingSource = new BindingSource();
_configurationBindingSource.DataSource = _mainForm.Configuration;
 
checkBox1.DataBindings.Add(new Binding("Checked", _configurationBindingSource,
nameof(_mainForm.Configuration.LaunchOnBoot), true, DataSourceUpdateMode.OnPropertyChanged));
 
checkBox2.DataBindings.Add(new Binding("Checked", _configurationBindingSource,
nameof(_mainForm.Configuration.IgnoreSelfSignedCertificates), true, DataSourceUpdateMode.OnPropertyChanged));
 
serverNameTextBox.DataBindings.Add(new Binding("Text", _serverBindingSource, nameof(_server.Name), true,
DataSourceUpdateMode.OnPropertyChanged));
serverUrlTextBox.DataBindings.Add(new Binding("Text", _serverBindingSource, nameof(_server.Url), true,
@@ -122,10 +133,7 @@
 
private void Button2_Click(object sender, EventArgs e)
{
if (listBox1.SelectedItem is Server server)
{
_servers.Server.Remove(server);
}
if (listBox1.SelectedItem is Server server) _servers.Server.Remove(server);
}
 
private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
@@ -142,24 +150,15 @@
 
private void Button3_Click(object sender, EventArgs e)
{
if (listBox2.SelectedItem is Announcement announcement)
{
_announcements.Announcement.Remove(announcement);
}
if (listBox2.SelectedItem is Announcement announcement) _announcements.Announcement.Remove(announcement);
}
 
private void Button4_Click(object sender, EventArgs e)
{
var announcement = new Announcement();
if (int.TryParse(appIdTextBox.Text, out var appId))
{
announcement.AppId = appId;
}
if (int.TryParse(appIdTextBox.Text, out var appId)) announcement.AppId = appId;
 
if (int.TryParse(lingerTimeTextBox.Text, out var lingerTime))
{
announcement.LingerTime = lingerTime;
}
if (int.TryParse(lingerTimeTextBox.Text, out var lingerTime)) announcement.LingerTime = lingerTime;
 
_announcements.Announcement.Add(announcement);
 
@@ -198,5 +197,13 @@
}
 
#endregion
 
private void CheckBox2_CheckedChanged(object sender, EventArgs e)
{
_mainForm.Configuration.IgnoreSelfSignedCertificates = ((CheckBox)sender).Checked;
 
_mainForm.ChangedConfigurationContinuation.Schedule(TimeSpan.FromSeconds(1),
async () => { await _mainForm.SaveConfiguration(); }, _cancellationToken);
}
}
}
/trunk/Winify/Utilities/LogMemorySink.cs
@@ -18,10 +18,7 @@
 
public void Emit(LogEvent logEvent)
{
if (logEvent == null)
{
throw new ArgumentNullException(nameof(logEvent));
}
if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
 
using (var stringWriter = new StringWriter())
{
/trunk/Winify/Utilities/Serialization/Serialization.cs
@@ -61,9 +61,7 @@
using (var stringWriter = new StringWriter(stringBuilder))
{
while (await xmlReader.ReadAsync())
{
await stringWriter.WriteAsync(await xmlReader.ReadOuterXmlAsync());
}
}
 
using (var stringReader = new StringReader(stringBuilder.ToString()))
/trunk/Winify/Utilities/WindowState.cs
@@ -0,0 +1,20 @@
using System.Windows.Forms;
using Jot;
 
namespace Winify.Utilities
{
public static class WindowState
{
// expose the tracker instance
public static Tracker FormTracker = new Tracker();
 
static WindowState()
{
// tell Jot how to track Window objects
FormTracker.Configure<Form>()
.Id(w => w.Name)
.Properties(w => new { w.Height, w.Width, w.Left, w.Top, w.WindowState })
.PersistOn(nameof(Form.FormClosed));
}
}
}
/trunk/Winify/Winify.csproj
@@ -58,74 +58,34 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\packages\NetSparkleUpdater.UI.WinForms.NetFramework.2.1.3\lib\net452\BouncyCastle.Crypto.dll</HintPath>
<HintPath>..\packages\NetSparkleUpdater.UI.WinForms.NetFramework.2.2.3\lib\net452\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="NetSparkle, Version=2.1.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NetSparkleUpdater.SparkleUpdater.2.1.3\lib\net452\NetSparkle.dll</HintPath>
<Reference Include="Jot, Version=2.1.17.0, Culture=neutral, PublicKeyToken=6b498f69c5f88322, processorArchitecture=MSIL">
<HintPath>..\packages\Jot.2.1.17\lib\netstandard2.0\Jot.dll</HintPath>
</Reference>
<Reference Include="NetSparkle, Version=2.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NetSparkleUpdater.SparkleUpdater.2.2.3\lib\net452\NetSparkle.dll</HintPath>
</Reference>
<Reference Include="NetSparkleUpdater.UI.WinForms, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NetSparkleUpdater.UI.WinForms.NetFramework.2.1.3\lib\net452\NetSparkleUpdater.UI.WinForms.dll</HintPath>
<HintPath>..\packages\NetSparkleUpdater.UI.WinForms.NetFramework.2.2.3\lib\net452\NetSparkleUpdater.UI.WinForms.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\NetSparkleUpdater.UI.WinForms.NetFramework.2.1.3\lib\net452\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\NetSparkleUpdater.UI.WinForms.NetFramework.2.2.3\lib\net452\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\packages\Serilog.2.10.0\lib\net46\Serilog.dll</HintPath>
<HintPath>..\packages\Serilog.3.0.1\lib\net471\Serilog.dll</HintPath>
</Reference>
<Reference Include="Serilog.Sinks.File, Version=5.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\packages\Serilog.Sinks.File.5.0.0\lib\net45\Serilog.Sinks.File.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.WebSockets.Client.Managed, Version=1.0.22.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.WebSockets.Client.Managed.1.0.22\lib\net45\System.Net.WebSockets.Client.Managed.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Windows" />
<Reference Include="System.Xaml" />
<Reference Include="Microsoft.CSharp" />
@@ -133,6 +93,9 @@
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="websocket-sharp, Version=1.0.2.59611, Culture=neutral, PublicKeyToken=5660b08a1845a91e, processorArchitecture=MSIL">
<HintPath>..\packages\WebSocketSharp.1.0.3-rc11\lib\websocket-sharp.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
@@ -184,6 +147,7 @@
<Compile Include="Utilities\Serialization\SerializationFailure.cs" />
<Compile Include="Utilities\Serialization\SerializationState.cs" />
<Compile Include="Utilities\Serialization\SerializationSuccess.cs" />
<Compile Include="Utilities\WindowState.cs" />
<EmbeddedResource Include="AboutForm.resx">
<DependentUpon>AboutForm.cs</DependentUpon>
</EmbeddedResource>
@@ -206,6 +170,7 @@
<EmbeddedResource Include="Settings\SettingsForm.resx">
<DependentUpon>SettingsForm.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Resources\winify.psd" />
</ItemGroup>
/trunk/Winify/app.config
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
 
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
/trunk/Winify/packages.config
@@ -1,20 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
 
<packages>
<package id="NetSparkleUpdater.SparkleUpdater" version="2.1.3" targetFramework="net472" />
<package id="NetSparkleUpdater.UI.WinForms.NetFramework" version="2.1.3" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="Jot" version="2.1.17" targetFramework="net472" />
<package id="NetSparkleUpdater.SparkleUpdater" version="2.2.3" targetFramework="net472" />
<package id="NetSparkleUpdater.UI.WinForms.NetFramework" version="2.2.3" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
<package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net472" />
<package id="Serilog" version="2.10.0" targetFramework="net472" />
<package id="Serilog" version="3.0.1" targetFramework="net472" />
<package id="Serilog.Sinks.File" version="5.0.0" targetFramework="net472" />
<package id="System.Buffers" version="4.4.0" targetFramework="net472" />
<package id="System.IO" version="4.3.0" targetFramework="net472" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net472" />
<package id="System.Net.WebSockets.Client.Managed" version="1.0.22" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net472" />
<package id="System.Runtime" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net472" />
<package id="WebSocketSharp" version="1.0.3-rc11" targetFramework="net472" />
</packages>