Last change
on this file since 17829 was
17829,
checked in by dpiringe, 3 years ago
|
#3026
- moved JsonItems from Models to JsonItems
- moved WinForms controls from Shared to Views
|
File size:
1.4 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Data;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using System.Threading.Tasks;
|
---|
9 | using System.Windows.Forms;
|
---|
10 |
|
---|
11 | namespace HeuristicLab.JsonInterface.OptimizerIntegration {
|
---|
12 | public partial class JsonItemBaseControl : UserControl {
|
---|
13 | protected IJsonItemVM VM { get; set; }
|
---|
14 |
|
---|
15 | private JsonItemBaseControl() {
|
---|
16 | InitializeComponent();
|
---|
17 | }
|
---|
18 |
|
---|
19 | public JsonItemBaseControl(IJsonItemVM vm) {
|
---|
20 | InitializeComponent();
|
---|
21 | VM = vm;
|
---|
22 | Init();
|
---|
23 | }
|
---|
24 |
|
---|
25 | public JsonItemBaseControl(IJsonItemVM vm, UserControl control) {
|
---|
26 | InitializeComponent();
|
---|
27 | VM = vm;
|
---|
28 | if(control != null) {
|
---|
29 | control.Margin = new Padding() { All = 0 };
|
---|
30 | tableLayoutPanel1.Controls.Add(control, 0, 1);
|
---|
31 | control.Dock = DockStyle.Fill;
|
---|
32 | }
|
---|
33 | Init();
|
---|
34 | }
|
---|
35 |
|
---|
36 | private void Init() {
|
---|
37 | textBoxName.DataBindings.Add("Text", VM, nameof(IJsonItemVM.Name));
|
---|
38 | textBoxDescription.DataBindings.Add("Text", VM, nameof(IJsonItemVM.Description));
|
---|
39 | }
|
---|
40 |
|
---|
41 | private void textBoxName_Validating(object sender, CancelEventArgs e) {
|
---|
42 | if(string.IsNullOrWhiteSpace(textBoxName.Text)) {
|
---|
43 | errorProvider.SetError(textBoxName, "Name must not be empty.");
|
---|
44 | e.Cancel = true;
|
---|
45 | } else {
|
---|
46 | errorProvider.SetError(textBoxName, null);
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
50 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.