Korero – Rev 2
?pathlinks?
using System;
using System.Windows.Forms;
using Korero.Communication;
using Korero.Properties;
using Korero.Utilities;
namespace Korero
{
public partial class SettingsForm : Form
{
#region Private Delegates, Events, Enums, Properties, Indexers and Fields
private readonly MqttCommunication _mqttCommunication;
#endregion
#region Constructors, Destructors and Finalizers
public SettingsForm()
{
InitializeComponent();
}
public SettingsForm(MqttCommunication mqttCommunication) : this()
{
_mqttCommunication = mqttCommunication;
switch (_mqttCommunication.IsConnected)
{
case true:
corradeConnectionStatusLabel.Text = "Connected.";
break;
default:
corradeConnectionStatusLabel.Text = "Disconnected.";
break;
}
_mqttCommunication.Connected += MqttCommunication_Connected;
_mqttCommunication.Disconnected += MqttCommunication_Disconnected;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <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();
}
_mqttCommunication.Connected -= MqttCommunication_Connected;
_mqttCommunication.Disconnected -= MqttCommunication_Disconnected;
base.Dispose(disposing);
}
#endregion
#region Event Handlers
private void SettingsForm_Load(object sender, EventArgs e)
{
Utilities.WindowState.FormTracker.Track(this);
}
private void MqttCommunication_Disconnected(object sender, MqttDisconnectedEventArgs e)
{
corradeConnectionStatusLabel.InvokeIfRequired(label => { label.Text = "Connection failed..."; });
}
private void MqttCommunication_Connected(object sender, MqttConnectedEventArgs e)
{
corradeConnectionStatusLabel.InvokeIfRequired(label => { label.Text = "Connection works!"; });
}
private void CheckBox2_CheckedChanged(object sender, EventArgs e)
{
Settings.Default.LaunchOnBoot = ((CheckBox) sender).Checked;
Miscellaneous.LaunchOnBootSet(Settings.Default.LaunchOnBoot);
}
private void Button1_Click(object sender, EventArgs e)
{
_mqttCommunication.Restart();
}
private void PictureBox1_Click(object sender, EventArgs e)
{
var result = colorDialog1.ShowDialog();
if (result == DialogResult.OK)
{
Settings.Default.MapDotColor = colorDialog1.Color;
}
}
private void Button2_Click(object sender, EventArgs e)
{
var result = fontDialog1.ShowDialog();
if (result == DialogResult.OK)
{
Settings.Default.NotificationTitleFont = fontDialog1.Font;
}
}
private void Button3_Click(object sender, EventArgs e)
{
var result = fontDialog2.ShowDialog();
if (result == DialogResult.OK)
{
Settings.Default.NotificationBodyFont = fontDialog2.Font;
}
}
#endregion
}
}
Generated by GNU Enscript 1.6.5.90.