private static void InitializeComponent(Form FormToShowOn)
{
panel1 = new System.Windows.Forms.Panel();
connectButton = new System.Windows.Forms.Button();
networkedCheckbox = new System.Windows.Forms.CheckBox();
ipTextbox = new System.Windows.Forms.TextBox();
ipLabel = new System.Windows.Forms.Label();
nicknameTextbox = new System.Windows.Forms.TextBox();
nicknameLabel = new System.Windows.Forms.Label();
// panel1
//
panel1.BackgroundImage = new Bitmap(Constants.Logo);
panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
panel1.Controls.Add(connectButton);
panel1.Controls.Add(networkedCheckbox);
panel1.Controls.Add(ipTextbox);
panel1.Controls.Add(ipLabel);
panel1.Controls.Add(nicknameTextbox);
panel1.Controls.Add(nicknameLabel);
panel1.Dock = System.Windows.Forms.DockStyle.Fill;
panel1.Location = new System.Drawing.Point(0, 0);
panel1.Name = "panel1";
panel1.Size = new System.Drawing.Size(784, 561);
panel1.TabIndex = 9;
//
// connectButton
//
connectButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
connectButton.BackColor = System.Drawing.Color.LightGray;
connectButton.Font = new System.Drawing.Font("Dimbo", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
connectButton.Location = new System.Drawing.Point(585, 4);
connectButton.Name = "connectButton";
connectButton.Size = new System.Drawing.Size(196, 39);
connectButton.TabIndex = 14;
connectButton.Text = "Connect";
connectButton.UseVisualStyleBackColor = false;
//
// networkedCheckbox
//
networkedCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
networkedCheckbox.AutoSize = true;
networkedCheckbox.BackColor = System.Drawing.Color.Transparent;
networkedCheckbox.Font = new System.Drawing.Font("Dimbo", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
networkedCheckbox.ForeColor = System.Drawing.Color.White;
networkedCheckbox.Location = new System.Drawing.Point(480, 9);
networkedCheckbox.Name = "networkedCheckbox";
networkedCheckbox.Size = new System.Drawing.Size(109, 29);
networkedCheckbox.TabIndex = 11;
networkedCheckbox.Text = "Networked";
networkedCheckbox.UseVisualStyleBackColor = false;
//
// ipTextbox
//
ipTextbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
ipTextbox.Location = new System.Drawing.Point(332, 13);
ipTextbox.Name = "ipTextbox";
ipTextbox.Size = new System.Drawing.Size(142, 20);
ipTextbox.TabIndex = 13;
//
// ipLabel
//
ipLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
ipLabel.AutoSize = true;
ipLabel.BackColor = System.Drawing.Color.Transparent;
ipLabel.Font = new System.Drawing.Font("Dimbo", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
ipLabel.ForeColor = System.Drawing.Color.White;
ipLabel.Location = new System.Drawing.Point(239, 11);
ipLabel.Name = "ipLabel";
ipLabel.Size = new System.Drawing.Size(87, 25);
ipLabel.TabIndex = 12;
ipLabel.Text = "IP Address";
//
// nicknameTextbox
//
nicknameTextbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
nicknameTextbox.Location = new System.Drawing.Point(91, 13);
nicknameTextbox.Name = "nicknameTextbox";
nicknameTextbox.Size = new System.Drawing.Size(142, 20);
nicknameTextbox.TabIndex = 10;
//
// nicknameLabel
//
nicknameLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
nicknameLabel.AutoSize = true;
nicknameLabel.BackColor = System.Drawing.Color.Transparent;
nicknameLabel.Font = new System.Drawing.Font("Dimbo", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
nicknameLabel.ForeColor = System.Drawing.Color.White;
nicknameLabel.Location = new System.Drawing.Point(9, 11);
nicknameLabel.Name = "nicknameLabel";
nicknameLabel.Size = new System.Drawing.Size(76, 25);
nicknameLabel.TabIndex = 9;
nicknameLabel.Text = "Nickname";
nicknameTextbox.AcceptsReturn = true;
connectButton.NotifyDefault(true);
nicknameTextbox.KeyPress += (sender, args) =>
{
if (args.KeyChar == '\t')
{
connectButton.Focus();
}
};
ipTextbox.KeyPress += (sender, args) =>
{
if (args.KeyChar == '\t')
{
nicknameTextbox.Focus();
}
};
ipTextbox.TextChanged += (sender, args) =>
{
Properties.Settings.Default.IP = ipTextbox.Text;
Properties.Settings.Default.Save();
};
networkedCheckbox.CheckedChanged += (sender, args) => { ipTextbox.Enabled = networkedCheckbox.Checked; };
if (ipTextbox.Text == "" && networkedCheckbox.Checked)
{
var ip = Dns.GetHostEntry(Dns.GetHostName());
foreach (var ipAddress in ip.AddressList)
{
if (ipAddress.AddressFamily == AddressFamily.InterNetwork)
{
ipTextbox.Text = ipAddress.ToString();
}
}
}
ipTextbox.Enabled = networkedCheckbox.Checked;
//
// Form1
//
FormToShowOn.Controls.Add(panel1);
int pnum = Process.GetProcessesByName("LeafMeAloneClient").Length;
var positions = new[] { new Vector2(0, 0), new Vector2(800, 0), new Vector2(0, 600), new Vector2(800, 600) };
FormToShowOn.SetDesktopLocation((int)positions[(pnum - 1) % 4].X, (int)positions[(pnum - 1) % 4].Y);
}