public static string ShowForm(string caption, string text, string value = null) { var form = new PromptForm { Text = caption, }; form.lblText.Text = text; form.tbValue.Text = value; form.StartPosition = FormStartPosition.CenterParent; return(form.ShowDialog() == DialogResult.OK ? form.tbValue.Text : null); }
private bool GetUserName() { while (true) { userName = PromptForm.ShowForm("ChatSignalR", "Enter user name:", $"TestUser{new Random().Next(1, 99999)}"); if (userName == null) { return(false); } else if (userName != string.Empty) { tbUserName.Text = userName; tbMessage.Focus(); return(true); } } }