private string InputText(string sTitle, string sInstructions, string sDefaultValue = "") { try { using (var inputForm = new InputText()) { inputForm.Title = sTitle; inputForm.Instructions = sInstructions; inputForm.Input = sDefaultValue; if (inputForm.ShowDialog() == DialogResult.OK) { return(inputForm.Input); } return(sDefaultValue); } } catch { } return(string.Empty); }
/// <summary> /// adds the currently selected process to the favorites (by window title text) /// </summary> private void byTheWindowTitleTextregexToolStripMenuItem_Click(object sender, EventArgs e) { if (this.lstProcesses.SelectedItem == null) return; ProcessDetails pd = ((ProcessDetails)this.lstProcesses.SelectedItem); if (!pd.Manageable) return; //TODO move to controller if (controller.Favorites.CanAdd(pd.WindowTitle)) { InputText it = new InputText(); it.Text = "Add to favorites by regex string"; it.Input = pd.WindowTitle; it.Instructions = "Regex string (reference is in the Help menu)"; it.ShowDialog(); if (it.DialogResult != DialogResult.OK) return; Favorites.Favorite fav = new Favorites.Favorite(); fav.Kind = Favorites.Favorite.FavoriteKinds.ByRegexString; fav.SearchText = it.Input; controller.Favorites.Add(fav); } }