public AddServerDialog(Manager manager, ServerWindow parent, int index, bool edit, string name, string address)
: base(manager)
{
//Are we editing a server or adding one (They use same dialog)
Edit = edit;
Index = index;
ServerList = parent;
//Setup the window
Text = Edit ? "Edit Server" : "Add Server";
TopPanel.Visible = false;
Resizable = false;
Width = 250;
Height = 180;
Center();
//Add controls
NameLbl = new Label(manager) { Left = 8, Top = 8, Text = "Name:", Width = this.ClientWidth - 16 };
NameLbl.Init();
Add(NameLbl);
NameTxt = new TextBox(manager) { Left = 8, Top = NameLbl.Bottom + 4, Width = this.ClientWidth - 16 };
NameTxt.Init();
NameTxt.Text = name;
NameTxt.TextChanged += NameTxt_TextChanged;
Add(NameTxt);
AddressLbl = new Label(manager) { Left = 8, Top = NameTxt.Bottom + 8,
Text = string.Format("Address: (Default port is {0})", Bricklayer.Common.GlobalSettings.DefaultPort),
Width = this.ClientWidth - 16 };
AddressLbl.Init();
Add(AddressLbl);
AddressTxt = new TextBox(manager) { Left = 8, Top = AddressLbl.Bottom + 4, Width = this.ClientWidth - 16 };
AddressTxt.Init();
AddressTxt.Text = address;
AddressTxt.TextChanged += AddressTxt_TextChanged;
Add(AddressTxt);
SaveBtn = new Button(manager) { Top = 8, Text = Edit ? "Save" : "Add", };
SaveBtn.Init();
SaveBtn.Left = (Width / 2) - (SaveBtn.Width / 2);
SaveBtn.Click += SaveBtn_Click;
SaveBtn.Enabled = false;
BottomPanel.Add(SaveBtn);
if (Edit)
Validate(); //Validate existing text
}