Winify – Rev
?pathlinks?
using System;
using System.Linq;
using System.Windows.Forms;
using Servers;
using Winify.Properties;
using Winify.Utilities;
namespace Winify
{
public partial class SettingsForm : Form
{
#region Private Delegates, Events, Enums, Properties, Indexers and Fields
private readonly global::Servers.Servers _servers;
#endregion
#region Constructors, Destructors and Finalizers
private SettingsForm()
{
InitializeComponent();
}
public SettingsForm(global::Servers.Servers servers) : this()
{
_servers = servers;
listBox1.DataSource = _servers.Server;
listBox1.DisplayMember = "Name";
listBox1.DataBindings.Add(new Binding("Text", _servers.Server, "Name", true,
DataSourceUpdateMode.OnPropertyChanged));
}
#endregion
#region Event Handlers
private void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
Settings.Default.LaunchOnBoot = ((CheckBox) sender).Checked;
Miscellaneous.LaunchOnBootSet(Settings.Default.LaunchOnBoot);
}
private void Button1_Click(object sender, EventArgs e)
{
var name = serverNameTextBox.Text;
var url = serverUrlTextBox.Text;
var username = serverUsernameTextBox.Text;
var password = serverPasswordTextBox.Text;
if (string.IsNullOrEmpty(name) ||
string.IsNullOrEmpty(url) ||
string.IsNullOrEmpty(username) ||
string.IsNullOrEmpty(password))
{
return;
}
var server = new Server(name, url, username, password);
if (_servers.Server.Any(servers => servers.Name == server.Name))
{
return;
}
_servers.Server.Add(server);
}
private void Button2_Click(object sender, EventArgs e)
{
listBox1.InvokeIfRequired(listBox =>
{
var item = listBox.SelectedItem;
_servers.Server.Remove((Server) item);
});
}
private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
var listBox = (ListBox) sender;
if (listBox.SelectedIndex == -1)
{
serverNameTextBox.Text = string.Empty;
serverUrlTextBox.Text = string.Empty;
serverUsernameTextBox.Text = string.Empty;
serverPasswordTextBox.Text = string.Empty;
return;
}
var server = (Server) listBox.SelectedItem;
serverNameTextBox.Text = server.Name;
serverUrlTextBox.Text = server.Url;
serverUsernameTextBox.Text = server.Username;
serverPasswordTextBox.Text = server.Password;
}
#endregion
}
}
Generated by GNU Enscript 1.6.5.90.