/// <summary> /// Prompts the user to select a template. /// </summary> /// <param name="engine">The engine.</param> /// <returns>A template or null if the user cancelled.</returns> public static Template Prompt(Engine engine, string title) { string templateName = null; var templates = All().ToList(); System.Windows.Application.Current.Dispatcher.Invoke(() => { var dialog = new Dialogs.ComboBoxInputDialog(null, title ?? "Select Template") { Items = templates, Required = true }; if (dialog.ShowDialog() == false) { templateName = null; } else { templateName = dialog.SelectedValue; } }); if (templateName == null) { return(null); } return(new Template(engine, templateName)); }
/// <summary> /// Prompts the user to select an instance. /// </summary> /// <param name="engine">The engine.</param> /// <param name="title">The title of the dialog.</param> /// <returns>An instance or null if the user cancelled.</returns> public static Instance Prompt(Engine engine, string title) { string instanceName = null; var instances = All().ToList(); System.Windows.Application.Current.Dispatcher.Invoke(() => { var dialog = new Dialogs.ComboBoxInputDialog(null, title); dialog.Items = instances; dialog.Required = true; if (dialog.ShowDialog() == false) { instanceName = null; } else { instanceName = dialog.SelectedValue; } }); return(new Instance(engine, instanceName)); }