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
|
Rev | Line | |
---|
[17404] | 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 {
|
---|
[17446] | 13 | protected IJsonItemVM VM { get; set; }
|
---|
[17404] | 14 |
|
---|
| 15 | private JsonItemBaseControl() {
|
---|
| 16 | InitializeComponent();
|
---|
| 17 | }
|
---|
[17443] | 18 |
|
---|
[17446] | 19 | public JsonItemBaseControl(IJsonItemVM vm) {
|
---|
[17404] | 20 | InitializeComponent();
|
---|
| 21 | VM = vm;
|
---|
[17464] | 22 | Init();
|
---|
| 23 | }
|
---|
[17410] | 24 |
|
---|
[17464] | 25 | public JsonItemBaseControl(IJsonItemVM vm, UserControl control) {
|
---|
| 26 | InitializeComponent();
|
---|
| 27 | VM = vm;
|
---|
[17828] | 28 | if(control != null) {
|
---|
| 29 | control.Margin = new Padding() { All = 0 };
|
---|
| 30 | tableLayoutPanel1.Controls.Add(control, 0, 1);
|
---|
| 31 | control.Dock = DockStyle.Fill;
|
---|
| 32 | }
|
---|
[17464] | 33 | Init();
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | private void Init() {
|
---|
[17446] | 37 | textBoxName.DataBindings.Add("Text", VM, nameof(IJsonItemVM.Name));
|
---|
| 38 | textBoxDescription.DataBindings.Add("Text", VM, nameof(IJsonItemVM.Description));
|
---|
[17404] | 39 | }
|
---|
[17444] | 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 | }
|
---|
[17404] | 49 | }
|
---|
| 50 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.