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); }
private static void InitializeComponent() { // Create a new instance of the form. frmInputDialog = new Form(); lblPrompt = new Label(); btnOK = new Button(); btnCancel = new Button(); txtInput = new TextBox(); frmInputDialog.SuspendLayout(); // // lblPrompt // lblPrompt.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right))); lblPrompt.BackColor = SystemColors.Control; lblPrompt.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((Byte)(0))); lblPrompt.Location = new Point(12, 9); lblPrompt.Name = "lblPrompt"; lblPrompt.Size = new Size(302, 82); lblPrompt.TabIndex = 3; // // btnOK // btnOK.DialogResult = DialogResult.OK; btnOK.FlatStyle = FlatStyle.Standard; btnOK.Location = new Point(326, 8); btnOK.Name = "btnOK"; btnOK.Size = new Size(64, 24); btnOK.TabIndex = 1; btnOK.Text = "&OK"; btnOK.Click += new EventHandler(btnOK_Click); btnOK.NotifyDefault(true); // // btnCancel // btnCancel.DialogResult = DialogResult.Cancel; btnCancel.FlatStyle = FlatStyle.Standard; btnCancel.Location = new Point(326, 40); btnCancel.Name = "btnCancel"; btnCancel.Size = new Size(64, 24); btnCancel.TabIndex = 2; btnCancel.Text = "&Cancel"; btnCancel.Click += new EventHandler(btnCancel_Click); // // txtInput // txtInput.Location = new Point(8, 100); txtInput.Name = "txtInput"; txtInput.Size = new Size(379, 20); txtInput.TabIndex = 0; txtInput.Text = ""; // // InputBoxDialog // frmInputDialog.AutoScaleBaseSize = new Size(5, 13); frmInputDialog.ClientSize = new Size(398, 128); frmInputDialog.Controls.Add(txtInput); frmInputDialog.Controls.Add(btnCancel); frmInputDialog.Controls.Add(btnOK); frmInputDialog.Controls.Add(lblPrompt); frmInputDialog.FormBorderStyle = FormBorderStyle.FixedDialog; frmInputDialog.MaximizeBox = false; frmInputDialog.MinimizeBox = false; frmInputDialog.Name = "InputBoxDialog"; frmInputDialog.ResumeLayout(false); frmInputDialog.AcceptButton = btnOK; frmInputDialog.CancelButton = btnCancel; frmInputDialog.Icon = _owner.Icon; }
public void NotifyDefault(bool value) { btMain.NotifyDefault(value); }