Last change
on this file was
17924,
checked in by dpiringe, 3 years ago
|
#3026
- renamed ResultFormatter to ResultFormatters
- adjusted some UI components (changed margins/paddings/sizes of some controls)
|
File size:
1.2 KB
|
Line | |
---|
1 | using System.ComponentModel;
|
---|
2 | using System.Windows.Forms;
|
---|
3 |
|
---|
4 | namespace 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, 2);
|
---|
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.