private void buttonConnectToIP_Click(object sender, EventArgs e) { string input = InputDialog.OpenDialog("Skriv in det ip du vill ansluta till"); if (input != "" && CheckDataInput.IpAddressCheckFormat(input)) { ConnectToIp(input); } else { MessageBox.Show("Inte en korrekt ip-adress!"); } }
/// <summary> /// Open a dialog without a message /// </summary> /// <returns>A string with the users input</returns> public static string OpenDialog() { var inputDialog = new InputDialog(); inputDialog.Show(); inputDialog.ShowDialog(); if (inputDialog.DialogResult == DialogResult.OK) { return(inputDialog.textBoxInput.Text); } else if (inputDialog.DialogResult == DialogResult.Cancel) { inputDialog.Close(); } return(""); }
/// <summary> /// Open a dialog with a message /// </summary> /// <param name="message">Message for user</param> /// <returns>A string with the users input</returns> public static string OpenDialog(string message) { using (var inputDialog = new InputDialog()) { inputDialog.labelMsg.Text = message; inputDialog.ShowDialog(); if (inputDialog.DialogResult == DialogResult.OK) { return(inputDialog.textBoxInput.Text); } else if (inputDialog.DialogResult == DialogResult.Cancel) { inputDialog.Close(); } return(""); } }