public static string Prompt(string question, string title, string defaultValue = "", InputType inputType = InputType.Text) { NewWindow inst = new NewWindow(question, title, defaultValue, inputType); inst.ShowDialog(); if (inst.DialogResult == true) { return(inst.ResponseText); } return(null); }
private void New_Button_Click(object sender, RoutedEventArgs e) { string NewFriend = NewWindow.Prompt("Enter the name of the new friend:", "New Friend", inputType: NewWindow.InputType.Text); if (!String.IsNullOrEmpty(NewFriend)) { if (Friend.fList.Contains(NewFriend)) { do { NewFriend = NewWindow.Prompt("That name is already in use \nEnter the name of the new friend", "New Friend", inputType: NewWindow.InputType.Text); } while (Friend.fList.Contains(NewFriend)); } if (!String.IsNullOrEmpty(NewFriend)) { friendDict.Add(NewFriend, new Friend(NewFriend)); LB1.Items.Refresh(); } } }