source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemBaseControl.cs @ 17843

Last change on this file since 17843 was 17843, checked in by dpiringe, 8 weeks ago

#3026

  • removed property ConvertableType from all converters
  • removed the option to fixate or loosen the path of JsonItems (obsolete)
  • added a abstract formatter SymbolicRegressionSolutionFormatterBase as base formatter for ISymbolicRegressionSolution
  • unified the construction of exporter controls
  • code cleanup
File size: 1.2 KB
Line 
1using System.ComponentModel;
2using System.Windows.Forms;
3
4namespace HeuristicLab.JsonInterface.OptimizerIntegration {
5  public partial class JsonItemBaseControl : UserControl {
6    protected IJsonItemVM VM { get; set; }
7
8    private JsonItemBaseControl() {
9      InitializeComponent();
10    }
11
12    protected JsonItemBaseControl(IJsonItemVM vm, UserControl control) {
13      InitializeComponent();
14      VM = vm;
15      if (control != null) {
16        control.Margin = new Padding() { All = 0 };
17        tableLayoutPanel1.Controls.Add(control, 0, 1);
18        control.Dock = DockStyle.Fill;
19      }
20      textBoxName.DataBindings.Add("Text", VM, nameof(IJsonItemVM.Name));
21      textBoxDescription.DataBindings.Add("Text", VM, nameof(IJsonItemVM.Description));
22    }
23
24    private void textBoxName_Validating(object sender, CancelEventArgs e) {
25      if(string.IsNullOrWhiteSpace(textBoxName.Text)) {
26        errorProvider.SetError(textBoxName, "Name must not be empty.");
27        e.Cancel = true;
28      } else {
29        errorProvider.SetError(textBoxName, null);
30      }
31    }
32
33    public static JsonItemBaseControl Create(IJsonItemVM vm, UserControl control) => new JsonItemBaseControl(vm, control);
34  }
35}
Note: See TracBrowser for help on using the repository browser.