using System; using System.Windows.Forms; using HeuristicLab.Core; using HeuristicLab.Core.Views; using HeuristicLab.MainForm; using HeuristicLab.PluginInfrastructure; namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views { [View("Constrained Item List View")] [Content(typeof(ConstrainedItemList<>), IsDefaultView = true)] public sealed partial class ConstrainedItemListView : ItemListView where T : class, IItem { public new ConstrainedItemList Content { get { return (ConstrainedItemList)base.Content; } set { base.Content = value; } } public ConstrainedItemListView() { InitializeComponent(); } protected override T CreateItem() { if (typeSelectorDialog == null) { typeSelectorDialog = new TypeSelectorDialog(); typeSelectorDialog.Caption = "Select Item"; typeSelectorDialog.TypeSelector.Caption = "Available Items"; typeSelectorDialog.TypeSelector.Configure(Content.Type, false, true); } if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { try { return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); } catch (Exception ex) { ErrorHandling.ShowErrorDialog(this, ex); } } return null; } } }