openuds/udsService/udsgui/forms/Config.cs
Adolfo Gómez a84159aa68 * Now working with Visual Studios Express 2012
* Added support for logging inside broker
* Added support for informing the machine where the connection has been originated
2012-12-12 12:46:45 +00:00

73 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Resources;
using System.Text;
using System.Windows.Forms;
using log4net;
namespace uds.gui.forms
{
public partial class Config : Form
{
private static ILog logger = LogManager.GetLogger(typeof(config));
public Config()
{
InitializeComponent();
}
private void Config_Load(object sender, EventArgs e)
{
brokerAddress.Text = config.broker;
useSecureConnection.SelectedIndex = config.ssl ? 0 : 1;
if (Info.Computer.IsUserAdministrator() == false)
{
MessageBox.Show(Lang.AdminNeeded, Lang.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
Close();
return;
}
}
private void cancelButton_Click(object sender, EventArgs e)
{
Close();
}
private void testConnectionButton_Click(object sender, EventArgs e)
{
rpc.Initialize(brokerAddress.Text, useSecureConnection.SelectedIndex == 0);
if (rpc.Manager.Test() == false)
{
MessageBox.Show(Lang.ConnectionError, Lang.ConnectionTest, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show(Lang.ConnectionOK, Lang.ConnectionTest, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
private void acceptButton_Click(object sender, EventArgs e)
{
config.broker = brokerAddress.Text;
config.ssl = useSecureConnection.SelectedIndex == 0;
rpc.Initialize(config.broker, config.ssl);
if (rpc.Manager.Test() == false)
{
if (MessageBox.Show(Lang.ConnetionNotAvailable, Lang.ConnectionTest, MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.Cancel)
return;
}
else
logger.Info("Saved new broker configuration");
config.SaveConfig();
Close();
}
}
}