[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 | using System.Globalization;
|
---|
| 11 |
|
---|
| 12 | namespace HeuristicLab.JsonInterface.OptimizerIntegration {
|
---|
[17433] | 13 |
|
---|
[17410] | 14 | public class JsonItemIntValueControl : JsonItemValueControl {
|
---|
[17443] | 15 |
|
---|
[17411] | 16 | #region Overriden Properties
|
---|
| 17 | protected override string ValuePropertyId => nameof(IntValueVM.Value);
|
---|
| 18 | #endregion
|
---|
[17443] | 19 |
|
---|
[17411] | 20 | public JsonItemIntValueControl(IntValueVM vm) : base(vm) {
|
---|
| 21 | Init();
|
---|
| 22 | }
|
---|
[17410] | 23 | }
|
---|
| 24 |
|
---|
| 25 | public class JsonItemDoubleValueControl : JsonItemValueControl {
|
---|
[17443] | 26 |
|
---|
[17411] | 27 | #region Overriden Properties
|
---|
| 28 | protected override string ValuePropertyId => nameof(DoubleValueVM.Value);
|
---|
| 29 | #endregion
|
---|
[17471] | 30 |
|
---|
[17411] | 31 | public JsonItemDoubleValueControl(DoubleValueVM vm) : base(vm) {
|
---|
| 32 | Init();
|
---|
[17404] | 33 | }
|
---|
[17410] | 34 | }
|
---|
[17433] | 35 |
|
---|
[17464] | 36 | public abstract partial class JsonItemValueControl : UserControl {
|
---|
[17411] | 37 | #region Protected Properties
|
---|
[17464] | 38 | protected IJsonItemVM VM { get; set; }
|
---|
[17411] | 39 | protected TextBox TBValue { get; set; }
|
---|
| 40 | protected NumericRangeControl NumericRangeControl { get; set; }
|
---|
| 41 | #endregion
|
---|
[17410] | 42 |
|
---|
[17411] | 43 | #region Abstract Properties
|
---|
| 44 | protected abstract string ValuePropertyId { get; }
|
---|
| 45 | #endregion
|
---|
| 46 |
|
---|
[17471] | 47 | public JsonItemValueControl() {
|
---|
[17410] | 48 | InitializeComponent();
|
---|
[17471] | 49 | }
|
---|
| 50 |
|
---|
| 51 | public JsonItemValueControl(IJsonItemVM vm) {
|
---|
| 52 | InitializeComponent();
|
---|
[17464] | 53 | VM = vm;
|
---|
[17411] | 54 | TBValue = textBoxValue;
|
---|
| 55 | NumericRangeControl = numericRangeControl1;
|
---|
[17404] | 56 | }
|
---|
[17443] | 57 |
|
---|
[17444] | 58 | protected void Init() {
|
---|
[17464] | 59 | TBValue.DataBindings.Add("Text", VM, ValuePropertyId);
|
---|
[17473] | 60 | NumericRangeControl.TBMinRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.MinRange));
|
---|
| 61 | NumericRangeControl.TBMaxRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.MaxRange));
|
---|
| 62 | NumericRangeControl.EnableMinRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMinRange),
|
---|
[17411] | 63 | false, DataSourceUpdateMode.OnPropertyChanged);
|
---|
[17473] | 64 | NumericRangeControl.EnableMaxRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMaxRange),
|
---|
[17411] | 65 | false, DataSourceUpdateMode.OnPropertyChanged);
|
---|
| 66 | }
|
---|
| 67 |
|
---|
[17444] | 68 | private void textBoxValue_Validating(object sender, CancelEventArgs e) {
|
---|
| 69 | if (string.IsNullOrWhiteSpace(textBoxValue.Text)) {
|
---|
| 70 | errorProvider.SetError(textBoxValue, "Value must not be empty.");
|
---|
| 71 | e.Cancel = true;
|
---|
| 72 | } else {
|
---|
| 73 | errorProvider.SetError(textBoxValue, null);
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
[17404] | 76 | }
|
---|
| 77 | }
|
---|