Winify

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 54  →  ?path2? @ 55
/trunk/Winify/MainForm.cs
@@ -155,6 +155,11 @@
 
private async void SettingsForm_Save(object sender, SettingsSavedEventArgs e)
{
// Save the configuration.
Miscellaneous.LaunchOnBootSet(Configuration.LaunchOnBoot);
ChangedConfigurationContinuation.Schedule(TimeSpan.FromSeconds(1),
async () => { await SaveConfiguration(); }, _cancellationToken);
 
// Save the servers.
await Task.WhenAll(SaveServers(e.Servers), SaveAnnouncements(e.Announcements));
 
@@ -192,11 +197,22 @@
return;
}
 
var notification = new ToastForm(
if (Configuration.InfiniteToastDuration)
{
var infiniteToastForm = new ToastForm(
$"{e.Notification.Title} ({e.Notification.Server.Name}/{e.Notification.AppId})",
e.Notification.Message, e.Image);
 
Application.Run(infiniteToastForm);
 
return;
}
 
var toastForm = new ToastForm(
$"{e.Notification.Title} ({e.Notification.Server.Name}/{e.Notification.AppId})",
e.Notification.Message, 5000, e.Image);
e.Notification.Message, Configuration.ToastDuration, e.Image);
 
Application.Run(notification);
Application.Run(toastForm);
}
 
private void SettingsForm_Closing(object sender, CancelEventArgs e)
/trunk/Winify/Settings/SettingsForm.Designer.cs
@@ -38,6 +38,12 @@
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel11 = new System.Windows.Forms.TableLayoutPanel();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.groupBox7 = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel13 = new System.Windows.Forms.TableLayoutPanel();
this.label11 = new System.Windows.Forms.Label();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.label12 = new System.Windows.Forms.Label();
this.checkBox4 = new System.Windows.Forms.CheckBox();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
@@ -70,10 +76,6 @@
this.button3 = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.listBox2 = new System.Windows.Forms.ListBox();
this.tableLayoutPanel8 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel9 = new System.Windows.Forms.TableLayoutPanel();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.tabPage4 = new System.Windows.Forms.TabPage();
this.tableLayoutPanel12 = new System.Windows.Forms.TableLayoutPanel();
this.label7 = new System.Windows.Forms.Label();
@@ -84,6 +86,10 @@
this.textBox3 = new System.Windows.Forms.TextBox();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.label10 = new System.Windows.Forms.Label();
this.tableLayoutPanel8 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel9 = new System.Windows.Forms.TableLayoutPanel();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.flowLayoutPanel2.SuspendLayout();
@@ -90,6 +96,9 @@
this.groupBox3.SuspendLayout();
this.groupBox6.SuspendLayout();
this.tableLayoutPanel11.SuspendLayout();
this.groupBox7.SuspendLayout();
this.tableLayoutPanel13.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.tabPage1.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.groupBox1.SuspendLayout();
@@ -104,10 +113,10 @@
this.tableLayoutPanel4.SuspendLayout();
this.tableLayoutPanel5.SuspendLayout();
this.groupBox4.SuspendLayout();
this.tabPage4.SuspendLayout();
this.tableLayoutPanel12.SuspendLayout();
this.tableLayoutPanel8.SuspendLayout();
this.tableLayoutPanel9.SuspendLayout();
this.tabPage4.SuspendLayout();
this.tableLayoutPanel12.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
@@ -137,6 +146,7 @@
//
this.flowLayoutPanel2.Controls.Add(this.groupBox3);
this.flowLayoutPanel2.Controls.Add(this.groupBox6);
this.flowLayoutPanel2.Controls.Add(this.groupBox7);
this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel2.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
@@ -163,7 +173,6 @@
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "Launch on Windows boot";
this.checkBox1.UseVisualStyleBackColor = true;
this.checkBox1.CheckedChanged += new System.EventHandler(this.CheckBox1_CheckedChanged);
//
// groupBox6
//
@@ -198,8 +207,90 @@
this.checkBox2.TabIndex = 0;
this.checkBox2.Text = "Ignore self-signed certificates";
this.checkBox2.UseVisualStyleBackColor = true;
this.checkBox2.CheckedChanged += new System.EventHandler(this.CheckBox2_CheckedChanged);
//
// groupBox7
//
this.groupBox7.Controls.Add(this.tableLayoutPanel13);
this.groupBox7.Location = new System.Drawing.Point(3, 62);
this.groupBox7.Name = "groupBox7";
this.groupBox7.Size = new System.Drawing.Size(200, 78);
this.groupBox7.TabIndex = 2;
this.groupBox7.TabStop = false;
this.groupBox7.Text = "Default Toast Duration";
//
// tableLayoutPanel13
//
this.tableLayoutPanel13.ColumnCount = 2;
this.tableLayoutPanel13.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel13.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel13.Controls.Add(this.label11, 0, 0);
this.tableLayoutPanel13.Controls.Add(this.numericUpDown1, 1, 0);
this.tableLayoutPanel13.Controls.Add(this.label12, 0, 1);
this.tableLayoutPanel13.Controls.Add(this.checkBox4, 1, 1);
this.tableLayoutPanel13.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel13.Location = new System.Drawing.Point(3, 16);
this.tableLayoutPanel13.Name = "tableLayoutPanel13";
this.tableLayoutPanel13.RowCount = 2;
this.tableLayoutPanel13.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel13.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel13.Size = new System.Drawing.Size(194, 59);
this.tableLayoutPanel13.TabIndex = 0;
//
// label11
//
this.label11.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(3, 8);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(91, 13);
this.label11.TabIndex = 0;
this.label11.Text = "Duration";
//
// numericUpDown1
//
this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.numericUpDown1.Location = new System.Drawing.Point(100, 4);
this.numericUpDown1.Maximum = new decimal(new int[] {
60000,
0,
0,
0});
this.numericUpDown1.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(91, 20);
this.numericUpDown1.TabIndex = 3;
this.numericUpDown1.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// label12
//
this.label12.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(3, 37);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(91, 13);
this.label12.TabIndex = 4;
this.label12.Text = "Infinite Duration";
//
// checkBox4
//
this.checkBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.checkBox4.AutoSize = true;
this.checkBox4.Location = new System.Drawing.Point(100, 35);
this.checkBox4.Name = "checkBox4";
this.checkBox4.Size = new System.Drawing.Size(91, 17);
this.checkBox4.TabIndex = 5;
this.checkBox4.Text = "Enable";
this.checkBox4.UseVisualStyleBackColor = true;
this.checkBox4.CheckStateChanged += new System.EventHandler(this.checkBox4_CheckedStateChanged);
//
// tabPage1
//
this.tabPage1.Controls.Add(this.tableLayoutPanel3);
@@ -580,59 +671,6 @@
this.listBox2.TabIndex = 0;
this.listBox2.SelectedIndexChanged += new System.EventHandler(this.ListBox2_SelectedIndexChanged);
//
// tableLayoutPanel8
//
this.tableLayoutPanel8.ColumnCount = 1;
this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel8.Controls.Add(this.tabControl1, 0, 0);
this.tableLayoutPanel8.Controls.Add(this.tableLayoutPanel9, 0, 1);
this.tableLayoutPanel8.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel8.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel8.Name = "tableLayoutPanel8";
this.tableLayoutPanel8.RowCount = 2;
this.tableLayoutPanel8.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel8.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 42F));
this.tableLayoutPanel8.Size = new System.Drawing.Size(552, 317);
this.tableLayoutPanel8.TabIndex = 1;
//
// tableLayoutPanel9
//
this.tableLayoutPanel9.ColumnCount = 3;
this.tableLayoutPanel9.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel9.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 80F));
this.tableLayoutPanel9.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 80F));
this.tableLayoutPanel9.Controls.Add(this.button5, 1, 0);
this.tableLayoutPanel9.Controls.Add(this.button6, 2, 0);
this.tableLayoutPanel9.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel9.Location = new System.Drawing.Point(3, 278);
this.tableLayoutPanel9.Name = "tableLayoutPanel9";
this.tableLayoutPanel9.RowCount = 1;
this.tableLayoutPanel9.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel9.Size = new System.Drawing.Size(546, 36);
this.tableLayoutPanel9.TabIndex = 1;
//
// button5
//
this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.button5.Location = new System.Drawing.Point(389, 6);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(74, 23);
this.button5.TabIndex = 0;
this.button5.Text = "Save";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.Button5_Click);
//
// button6
//
this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.button6.Location = new System.Drawing.Point(469, 6);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(74, 23);
this.button6.TabIndex = 1;
this.button6.Text = "Cancel";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.Button6_Click);
//
// tabPage4
//
this.tabPage4.Controls.Add(this.tableLayoutPanel12);
@@ -743,6 +781,59 @@
this.label10.TabIndex = 7;
this.label10.Text = "Use a HTTP proxy to establish connections";
//
// tableLayoutPanel8
//
this.tableLayoutPanel8.ColumnCount = 1;
this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel8.Controls.Add(this.tabControl1, 0, 0);
this.tableLayoutPanel8.Controls.Add(this.tableLayoutPanel9, 0, 1);
this.tableLayoutPanel8.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel8.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel8.Name = "tableLayoutPanel8";
this.tableLayoutPanel8.RowCount = 2;
this.tableLayoutPanel8.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel8.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 42F));
this.tableLayoutPanel8.Size = new System.Drawing.Size(552, 317);
this.tableLayoutPanel8.TabIndex = 1;
//
// tableLayoutPanel9
//
this.tableLayoutPanel9.ColumnCount = 3;
this.tableLayoutPanel9.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel9.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 80F));
this.tableLayoutPanel9.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 80F));
this.tableLayoutPanel9.Controls.Add(this.button5, 1, 0);
this.tableLayoutPanel9.Controls.Add(this.button6, 2, 0);
this.tableLayoutPanel9.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel9.Location = new System.Drawing.Point(3, 278);
this.tableLayoutPanel9.Name = "tableLayoutPanel9";
this.tableLayoutPanel9.RowCount = 1;
this.tableLayoutPanel9.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel9.Size = new System.Drawing.Size(546, 36);
this.tableLayoutPanel9.TabIndex = 1;
//
// button5
//
this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.button5.Location = new System.Drawing.Point(389, 6);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(74, 23);
this.button5.TabIndex = 0;
this.button5.Text = "Save";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.Button5_Click);
//
// button6
//
this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.button6.Location = new System.Drawing.Point(469, 6);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(74, 23);
this.button6.TabIndex = 1;
this.button6.Text = "Cancel";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.Button6_Click);
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -761,6 +852,10 @@
this.groupBox6.ResumeLayout(false);
this.tableLayoutPanel11.ResumeLayout(false);
this.tableLayoutPanel11.PerformLayout();
this.groupBox7.ResumeLayout(false);
this.tableLayoutPanel13.ResumeLayout(false);
this.tableLayoutPanel13.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.tabPage1.ResumeLayout(false);
this.tableLayoutPanel3.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
@@ -777,11 +872,11 @@
this.tableLayoutPanel4.ResumeLayout(false);
this.tableLayoutPanel5.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.tableLayoutPanel8.ResumeLayout(false);
this.tableLayoutPanel9.ResumeLayout(false);
this.tabPage4.ResumeLayout(false);
this.tableLayoutPanel12.ResumeLayout(false);
this.tableLayoutPanel12.PerformLayout();
this.tableLayoutPanel8.ResumeLayout(false);
this.tableLayoutPanel9.ResumeLayout(false);
this.ResumeLayout(false);
 
}
@@ -842,5 +937,11 @@
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.CheckBox checkBox3;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.GroupBox groupBox7;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel13;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.CheckBox checkBox4;
}
}
/trunk/Winify/Settings/SettingsForm.cs
@@ -21,11 +21,11 @@
 
private readonly BindingSource _announcementBindingSource;
 
private readonly Announcements.Announcements _announcements;
private Announcements.Announcements _announcements;
 
private readonly BindingSource _serverBindingSource;
 
private readonly Servers.Servers _servers;
private Servers.Servers _servers;
 
private Announcement _announcement;
 
@@ -42,80 +42,29 @@
public SettingsForm()
{
InitializeComponent();
 
Utilities.WindowState.FormTracker.Track(this);
}
 
public SettingsForm(MainForm mainForm) : this()
public SettingsForm(MainForm mainForm, Servers.Servers servers, Announcements.Announcements announcements,
CancellationToken cancellationToken) : this()
{
_mainForm = mainForm;
}
 
public SettingsForm(MainForm mainForm, Servers.Servers servers, Announcements.Announcements announcements,
CancellationToken cancellationToken) : this(mainForm)
{
_servers = servers;
_server = _servers.Server.FirstOrDefault() ?? new Server();
_announcements = announcements;
_cancellationToken = cancellationToken;
 
_serverBindingSource = new BindingSource();
_serverBindingSource.DataSource = _server;
_configurationBindingSource = new BindingSource();
_configurationBindingSource.DataSource = _mainForm.Configuration;
 
_configurationProxyBindingSource = new BindingSource();
_configurationProxyBindingSource.DataSource = _mainForm.Configuration.Proxy;
 
checkBox3.DataBindings.Add(
new Binding("Checked", _configurationProxyBindingSource, nameof(_mainForm.Configuration.Proxy.Enable), true,
DataSourceUpdateMode.OnPropertyChanged));
textBox1.DataBindings.Add(
new Binding("Text", _configurationProxyBindingSource, nameof(_mainForm.Configuration.Proxy.Url), true,
DataSourceUpdateMode.OnPropertyChanged));
textBox2.DataBindings.Add(
new Binding("Text", _configurationProxyBindingSource, nameof(_mainForm.Configuration.Proxy.Username), true,
DataSourceUpdateMode.OnPropertyChanged));
textBox3.DataBindings.Add(
new Binding("Text", _configurationProxyBindingSource, nameof(_mainForm.Configuration.Proxy.Password), true,
DataSourceUpdateMode.OnPropertyChanged));
_serverBindingSource = new BindingSource();
_serverBindingSource.DataSource = _server;
 
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,
DataSourceUpdateMode.OnPropertyChanged));
serverUsernameTextBox.DataBindings.Add(new Binding("Text", _serverBindingSource, nameof(_server.Username),
true,
DataSourceUpdateMode.OnPropertyChanged));
serverPasswordTextBox.DataBindings.Add(new Binding("Text", _serverBindingSource, nameof(_server.Password),
true,
DataSourceUpdateMode.OnPropertyChanged));
 
listBox1.DataSource = _servers.Server;
listBox1.DisplayMember = "Name";
listBox1.DataBindings.Add(new Binding("Text", _servers.Server, "Name", true,
DataSourceUpdateMode.OnPropertyChanged));
 
_announcements = announcements;
_announcement = _announcements.Announcement.FirstOrDefault() ?? new Announcement();
 
_announcementBindingSource = new BindingSource();
_announcementBindingSource.DataSource = _announcement;
 
appIdTextBox.DataBindings.Add(new Binding("Text", _announcementBindingSource, nameof(_announcement.AppId),
true,
DataSourceUpdateMode.OnPropertyChanged));
lingerTimeTextBox.DataBindings.Add(new Binding("Text", _announcementBindingSource,
nameof(_announcement.LingerTime), true,
DataSourceUpdateMode.OnPropertyChanged));
 
listBox2.DataSource = _announcements.Announcement;
listBox2.DisplayMember = "Id";
listBox2.DataBindings.Add(new Binding("Text", _announcements.Announcement, "Id", true,
DataSourceUpdateMode.OnPropertyChanged));
}
 
#endregion
@@ -124,12 +73,7 @@
 
private void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
_mainForm.Configuration.LaunchOnBoot = ((CheckBox)sender).Checked;
 
_mainForm.ChangedConfigurationContinuation.Schedule(TimeSpan.FromSeconds(1),
async () => { await _mainForm.SaveConfiguration(); }, _cancellationToken);
 
Miscellaneous.LaunchOnBootSet(_mainForm.Configuration.LaunchOnBoot);
}
 
private void Button1_Click(object sender, EventArgs e)
@@ -225,19 +169,117 @@
Close();
}
 
private void SettingsForm_Load(object sender, EventArgs e)
#endregion
 
private void checkBox4_CheckedStateChanged(object sender, EventArgs e)
{
checkBox1.Checked = _mainForm.Configuration.LaunchOnBoot;
var checkBox = (CheckBox)sender;
var state = checkBox.Checked;
if (state)
{
ToggleTableRow(tableLayoutPanel13, 0, false);
 
return;
}
 
ToggleTableRow(tableLayoutPanel13, 0, true);
}
 
#endregion
private static void ToggleTableRow(TableLayoutPanel tableLayoutPanel, int row, bool enable)
{
var count = tableLayoutPanel.RowCount;
foreach (var i in Enumerable.Range(0, count))
{
var control = tableLayoutPanel.GetControlFromPosition(i, row);
control.Enabled = enable;
}
}
 
private void CheckBox2_CheckedChanged(object sender, EventArgs e)
private void SettingsForm_Load(object sender, EventArgs e)
{
_mainForm.Configuration.IgnoreSelfSignedCertificates = ((CheckBox)sender).Checked;
// Databindings.
numericUpDown1.DataBindings.Add(new Binding("Value", _configurationBindingSource,
nameof(_mainForm.Configuration.ToastDuration), true,
DataSourceUpdateMode.OnPropertyChanged));
 
_mainForm.ChangedConfigurationContinuation.Schedule(TimeSpan.FromSeconds(1),
async () => { await _mainForm.SaveConfiguration(); }, _cancellationToken);
checkBox4.DataBindings.Add(
new Binding("Checked", _configurationBindingSource, nameof(_mainForm.Configuration.InfiniteToastDuration), true,
DataSourceUpdateMode.OnPropertyChanged));
 
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));
 
checkBox3.DataBindings.Add(
new Binding("Checked", _configurationProxyBindingSource, nameof(_mainForm.Configuration.Proxy.Enable), true,
DataSourceUpdateMode.OnPropertyChanged));
textBox1.DataBindings.Add(
new Binding("Text", _configurationProxyBindingSource, nameof(_mainForm.Configuration.Proxy.Url), true,
DataSourceUpdateMode.OnPropertyChanged));
textBox2.DataBindings.Add(
new Binding("Text", _configurationProxyBindingSource, nameof(_mainForm.Configuration.Proxy.Username), true,
DataSourceUpdateMode.OnPropertyChanged));
textBox3.DataBindings.Add(
new Binding("Text", _configurationProxyBindingSource, nameof(_mainForm.Configuration.Proxy.Password), true,
DataSourceUpdateMode.OnPropertyChanged));
 
switch (_servers?.Server == null)
{
case true:
_servers = new Servers.Servers();
_server = new Server();
_servers.Server.Add(_server);
break;
default:
_server = _servers.Server.FirstOrDefault();
break;
}
 
serverNameTextBox.DataBindings.Add(new Binding("Text", _serverBindingSource, nameof(_server.Name), true,
DataSourceUpdateMode.OnPropertyChanged));
serverUrlTextBox.DataBindings.Add(new Binding("Text", _serverBindingSource, nameof(_server.Url), true,
DataSourceUpdateMode.OnPropertyChanged));
serverUsernameTextBox.DataBindings.Add(new Binding("Text", _serverBindingSource, nameof(_server.Username),
true,
DataSourceUpdateMode.OnPropertyChanged));
serverPasswordTextBox.DataBindings.Add(new Binding("Text", _serverBindingSource, nameof(_server.Password),
true,
DataSourceUpdateMode.OnPropertyChanged));
 
listBox1.DataSource = _servers.Server;
listBox1.DisplayMember = "Name";
listBox1.DataBindings.Add(new Binding("Text", _servers.Server, "Name", true,
DataSourceUpdateMode.OnPropertyChanged));
 
switch (_announcements?.Announcement == null)
{
case true:
_announcements = new Announcements.Announcements();
_announcement = new Announcement();
_announcements.Announcement.Add(_announcement);
break;
default:
_announcement = _announcements.Announcement.FirstOrDefault();
break;
}
 
appIdTextBox.DataBindings.Add(new Binding("Text", _announcementBindingSource, nameof(_announcement.AppId),
true,
DataSourceUpdateMode.OnPropertyChanged));
lingerTimeTextBox.DataBindings.Add(new Binding("Text", _announcementBindingSource,
nameof(_announcement.LingerTime), true,
DataSourceUpdateMode.OnPropertyChanged));
 
listBox2.DataSource = _announcements.Announcement;
listBox2.DisplayMember = "Id";
listBox2.DataBindings.Add(new Binding("Text", _announcements.Announcement, "Id", true,
DataSourceUpdateMode.OnPropertyChanged));
 
// Miscellaneous.
ToggleTableRow(tableLayoutPanel13, 0, !_mainForm.Configuration.InfiniteToastDuration);
}
}
}