Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/27/20 15:53:26 (5 years ago)
Author:
dpiringe
Message:

#3026:

  • added error output for failed runner initialization
  • reorganised some final view models
  • TargetedJsonItemType (in JsonItemVMBase) now automatically returns the type of the defined JsonItem
  • code cleanup
  • refactored RegressionProblemDataConverter
  • added lots of comments
  • added new view for StringArrayJsonItem
  • added new UI component for concrete restricted items and used it in JsonItemConcreteItemArrayControl and JsonItemValidValuesControl
Location:
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration
Files:
8 added
11 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/HeuristicLab.JsonInterface.OptimizerIntegration.csproj

    r17471 r17519  
    108108    </Compile>
    109109    <Compile Include="ViewModels\ArrayValueVM.cs" />
     110    <Compile Include="ViewModels\DoubleVMs.cs" />
     111    <Compile Include="ViewModels\IntVMs.cs" />
    110112    <Compile Include="ViewModels\JsonItemVMBase.cs" />
    111113    <Compile Include="ViewModels\LookupJsonItemVM.cs" />
     
    117119    <Compile Include="ViewModels\StringValueVM.cs" />
    118120    <Compile Include="ViewModels\ValueLookupJsonItemVM.cs" />
     121    <Compile Include="Shared\ConcreteItemsRestrictor.cs">
     122      <SubType>UserControl</SubType>
     123    </Compile>
     124    <Compile Include="Shared\ConcreteItemsRestrictor.Designer.cs">
     125      <DependentUpon>ConcreteItemsRestrictor.cs</DependentUpon>
     126    </Compile>
    119127    <Compile Include="Views\ExportJsonDialog.cs">
    120128      <SubType>Form</SubType>
     
    124132    </Compile>
    125133    <Compile Include="FileManager.cs" />
     134    <Compile Include="Views\JsonItemConcreteItemArrayControl.cs">
     135      <SubType>UserControl</SubType>
     136    </Compile>
     137    <Compile Include="Views\JsonItemConcreteItemArrayControl.Designer.cs">
     138      <DependentUpon>JsonItemConcreteItemArrayControl.cs</DependentUpon>
     139    </Compile>
    126140    <Compile Include="Views\JsonItemMultiValueControl.cs">
    127141      <SubType>UserControl</SubType>
     
    224238      <DependentUpon>NumericRangeControl.cs</DependentUpon>
    225239    </EmbeddedResource>
     240    <EmbeddedResource Include="Shared\ConcreteItemsRestrictor.resx">
     241      <DependentUpon>ConcreteItemsRestrictor.cs</DependentUpon>
     242    </EmbeddedResource>
    226243    <EmbeddedResource Include="Views\ExportJsonDialog.resx">
    227244      <DependentUpon>ExportJsonDialog.cs</DependentUpon>
     245    </EmbeddedResource>
     246    <EmbeddedResource Include="Views\JsonItemConcreteItemArrayControl.resx">
     247      <DependentUpon>JsonItemConcreteItemArrayControl.cs</DependentUpon>
    228248    </EmbeddedResource>
    229249    <EmbeddedResource Include="Views\JsonItemMultiValueControl.resx">
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ArrayValueVM.cs

    r17484 r17519  
    99namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    1010
    11   public class DoubleArrayValueVM : ArrayValueVM<double, DoubleArrayJsonItem> {
    12     public override Type TargetedJsonItemType => typeof(DoubleArrayJsonItem);
     11 
    1312
    14     protected override double MinTypeValue => double.MinValue;
    1513
    16     protected override double MaxTypeValue => double.MaxValue;
    1714
    18     public override UserControl Control =>
    19       new JsonItemDoubleArrayValueControl(this);
    20    
    21     public override double[] Value {
    22       get => Item.Value;
    23       set {
    24         Item.Value = value;
    25         OnPropertyChange(this, nameof(Value));
    26       }
    27     }
    28   }
    29 
    30   public class IntArrayValueVM : ArrayValueVM<int, IntArrayJsonItem> {
    31     public override Type TargetedJsonItemType => typeof(IntArrayJsonItem);
     15  /*
     16  public class StringArrayValueVM : ArrayValueVM<int, IntArrayJsonItem> {
     17    public override Type TargetedJsonItemType => typeof(StringArrayJsonItem);
    3218
    3319    protected override int MinTypeValue => int.MinValue;
     
    3723    public override UserControl Control =>
    3824      new JsonItemBaseControl(this, new JsonItemIntArrayValueControl(this));
    39    
     25
    4026    public override int[] Value {
    4127      get => Item.Value;
     
    4632    }
    4733  }
     34  */
     35
    4836
    4937  public abstract class ArrayValueVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType>, IArrayJsonItemVM
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs

    r17477 r17519  
    99
    1010namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    11   public abstract class JsonItemVMBase<JsonItemType> : IJsonItemVM<JsonItemType>
     11  public abstract class JsonItemVMBase<JsonItemType> : IJsonItemVM<JsonItemType> //TODO: RENAME, oder vlt JsonItems direkt als VM?
    1212    where JsonItemType : class, IJsonItem
    1313  {
     
    5858    }
    5959
    60     public abstract Type TargetedJsonItemType { get; }
     60    public virtual Type TargetedJsonItemType => typeof(JsonItemType);
    6161    public abstract UserControl Control { get; }
    6262
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/LookupJsonItemVM.cs

    r17473 r17519  
    88namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    99  public class LookupJsonItemVM : JsonItemVMBase<LookupJsonItem>, ILookupJsonItemVM {
    10     public override Type TargetedJsonItemType => typeof(LookupJsonItem);
    1110
    1211    public override UserControl Control => new LookupJsonItemControl(this);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/MatrixValueVM.cs

    r17484 r17519  
    99namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    1010
    11   public class DoubleMatrixValueVM : MatrixValueVM<double, DoubleMatrixJsonItem> {
    12     public override Type TargetedJsonItemType => typeof(DoubleMatrixJsonItem);
    13     public override UserControl Control =>
    14       new JsonItemDoubleMatrixValueControl(this);
    15 
    16     public override double[][] Value {
    17       get => Item.Value;
    18       set {
    19         Item.Value = value;
    20         OnPropertyChange(this, nameof(Value));
    21       }
    22     }
    23 
    24     protected override double MinTypeValue => double.MinValue;
    25 
    26     protected override double MaxTypeValue => double.MaxValue;
    27   }
    2811
    2912  public abstract class MatrixValueVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType>, IMatrixJsonItemVM
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs

    r17473 r17519  
    88
    99namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    10 
    11   public class IntRangeVM : RangeVM<int, IntRangeJsonItem> {
    12     public override Type TargetedJsonItemType => typeof(IntRangeJsonItem);
    13 
    14     protected override int MinTypeValue => int.MinValue;
    15 
    16     protected override int MaxTypeValue => int.MaxValue;
    17 
    18     public override UserControl Control =>
    19       new JsonItemRangeControl(this);
    20   }
    21 
    22   public class DoubleRangeVM : RangeVM<double, DoubleRangeJsonItem> {
    23     public override Type TargetedJsonItemType => typeof(DoubleRangeJsonItem);
    24 
    25     protected override double MinTypeValue => double.MinValue;
    26 
    27     protected override double MaxTypeValue => double.MaxValue;
    28 
    29     public override UserControl Control =>
    30       new JsonItemRangeControl(this);
    31   }
    3210
    3311  public abstract class RangeVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType>
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/SingleValueVM.cs

    r17473 r17519  
    88
    99namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    10   public class IntValueVM : SingleValueVM<int, IntJsonItem> {
    11     public override Type TargetedJsonItemType => typeof(IntJsonItem);
    12 
    13     protected override int MinTypeValue => int.MinValue;
    14     protected override int MaxTypeValue => int.MaxValue;
    15 
    16     public override UserControl Control =>
    17       new JsonItemIntValueControl(this);
    18   }
    19 
    20   public class DoubleValueVM : SingleValueVM<double, DoubleJsonItem> {
    21     public override Type TargetedJsonItemType => typeof(DoubleJsonItem);
    22 
    23     protected override double MinTypeValue => double.MinValue;
    24     protected override double MaxTypeValue => double.MaxValue;
    25 
    26     public override UserControl Control =>
    27        new JsonItemDoubleValueControl(this);
    28   }
    2910
    3011  public class BoolValueVM : JsonItemVMBase<BoolJsonItem> {
    31     public override Type TargetedJsonItemType => typeof(BoolJsonItem);
    3212
    3313    public bool Value {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/StringValueVM.cs

    r17473 r17519  
    99namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    1010  public class StringValueVM : JsonItemVMBase<StringJsonItem> {
    11     public override Type TargetedJsonItemType => typeof(StringJsonItem);
    1211    public override UserControl Control =>
    1312       new JsonItemValidValuesControl(this);
     
    3736      }
    3837    }
     38  }
    3939
     40  public class StringArrayVM : JsonItemVMBase<StringArrayJsonItem> {
     41    public override UserControl Control =>
     42       new JsonItemConcreteItemArrayControl(this);
     43
     44    public string[] Value {
     45      get => Item.Value;
     46      set {
     47        Item.Value = value;
     48        OnPropertyChange(this, nameof(Value));
     49      }
     50    }
     51
     52    public IEnumerable<string> Range {
     53      get => Item.ConcreteRestrictedItems;
     54      set {
     55        Item.ConcreteRestrictedItems = value;
     56        OnPropertyChange(this, nameof(Range));
     57      }
     58    }
    4059  }
    4160}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemMultiValueControl.cs

    r17485 r17519  
    8080      int cols = matrix.Length;
    8181      int rows = matrix.Max(x => x.Length);
    82 
     82     
    8383      Matrix = matrix;
    8484      Columns = cols;
     
    250250                                            typeof(T),
    251251                                            System.Globalization.CultureInfo.InvariantCulture);
    252       //Save(Matrix[e.ColumnIndex][e.RowIndex], e.ColumnIndex, e.RowIndex);
    253252      Save();
    254253    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.Designer.cs

    r17471 r17519  
    2525    private void InitializeComponent() {
    2626      this.components = new System.ComponentModel.Container();
    27       this.tableOptions = new System.Windows.Forms.TableLayoutPanel();
    2827      this.comboBoxValues = new System.Windows.Forms.ComboBox();
    2928      this.label2 = new System.Windows.Forms.Label();
    3029      this.groupBoxRange = new System.Windows.Forms.GroupBox();
     30      this.concreteItemsRestrictor = new HeuristicLab.JsonInterface.OptimizerIntegration.ConcreteItemsRestrictor();
    3131      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    3232      this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
     
    3737      this.tableLayoutPanel2.SuspendLayout();
    3838      this.SuspendLayout();
    39       //
    40       // tableOptions
    41       //
    42       this.tableOptions.AutoScroll = true;
    43       this.tableOptions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
    44       this.tableOptions.ColumnCount = 2;
    45       this.tableOptions.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    46       this.tableOptions.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
    47       this.tableOptions.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    48       this.tableOptions.Dock = System.Windows.Forms.DockStyle.Fill;
    49       this.tableOptions.Location = new System.Drawing.Point(3, 16);
    50       this.tableOptions.Name = "tableOptions";
    51       this.tableOptions.RowCount = 1;
    52       this.tableOptions.RowStyles.Add(new System.Windows.Forms.RowStyle());
    53       this.tableOptions.Size = new System.Drawing.Size(494, 217);
    54       this.tableOptions.TabIndex = 12;
    5539      //
    5640      // comboBoxValues
     
    7963      // groupBoxRange
    8064      //
    81       this.groupBoxRange.Controls.Add(this.tableOptions);
     65      this.groupBoxRange.Controls.Add(this.concreteItemsRestrictor);
    8266      this.groupBoxRange.Dock = System.Windows.Forms.DockStyle.Fill;
    8367      this.groupBoxRange.Location = new System.Drawing.Point(0, 22);
     
    8872      this.groupBoxRange.TabStop = false;
    8973      this.groupBoxRange.Text = "Range";
     74      //
     75      // concreteItemsRestrictor
     76      //
     77      this.concreteItemsRestrictor.Dock = System.Windows.Forms.DockStyle.Fill;
     78      this.concreteItemsRestrictor.Location = new System.Drawing.Point(3, 16);
     79      this.concreteItemsRestrictor.Margin = new System.Windows.Forms.Padding(0);
     80      this.concreteItemsRestrictor.Name = "concreteItemsRestrictor";
     81      this.concreteItemsRestrictor.Size = new System.Drawing.Size(494, 217);
     82      this.concreteItemsRestrictor.TabIndex = 0;
    9083      //
    9184      // errorProvider
     
    122115      this.tableLayoutPanel2.RowCount = 1;
    123116      this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
    124       this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
     117      this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 22F));
    125118      this.tableLayoutPanel2.Size = new System.Drawing.Size(500, 22);
    126119      this.tableLayoutPanel2.TabIndex = 19;
     
    146139
    147140    #endregion
    148     private System.Windows.Forms.TableLayoutPanel tableOptions;
    149141    private System.Windows.Forms.ComboBox comboBoxValues;
    150142    private System.Windows.Forms.Label label2;
     
    153145    private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
    154146    private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
     147    private ConcreteItemsRestrictor concreteItemsRestrictor;
    155148  }
    156149}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.cs

    r17473 r17519  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.ComponentModel;
     1using System.Collections.Generic;
    42using System.Drawing;
    5 using System.Data;
    63using System.Linq;
    7 using System.Text;
    8 using System.Threading.Tasks;
    94using System.Windows.Forms;
    105
     
    1813      VM = vm;
    1914      if (VM.Item.ConcreteRestrictedItems != null) {
    20         foreach (var i in VM.Item.ConcreteRestrictedItems)
    21           SetupOption(i);
     15        concreteItemsRestrictor.OnChecked += AddComboOption;
     16        concreteItemsRestrictor.OnUnchecked += RemoveComboOption;
     17        concreteItemsRestrictor.Init(VM.Item.ConcreteRestrictedItems);
    2218        comboBoxValues.DataBindings.Add("SelectedItem", VM, nameof(StringValueVM.Value));
    2319      } else {
    24         comboBoxValues.Hide();
    2520        groupBoxRange.Hide();
    2621        TextBox tb = new TextBox();
    27         this.Controls.Add(tb);
     22        tableLayoutPanel2.Controls.Remove(comboBoxValues);
     23        tableLayoutPanel2.Controls.Add(tb, 1, 0);
     24
    2825        tb.Location = comboBoxValues.Location;
    29         tb.Size = comboBoxValues.Size;
    30         tb.Anchor = comboBoxValues.Anchor;
    31         tb.Dock = comboBoxValues.Dock;
     26        tb.Margin = new Padding(0);
     27        tb.Size = new Size(comboBoxValues.Size.Width, 20);
     28        tb.Anchor = AnchorStyles.Top | AnchorStyles.Left;
     29        tb.Dock = DockStyle.Fill;
     30
    3231        tb.DataBindings.Add("Text", VM, nameof(StringValueVM.Value));
    3332        tb.Show();
    3433      }
    3534    }
    36    
    37     private void SetupOption(string opt) {
    38       AddComboOption(opt);
    39       TextBox tb = new TextBox();
    40       tb.Text = opt;
    41       //tb.Size = new Size()
    42       tb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
    43       //tb.Dock = DockStyle.Right | DockStyle.Left;
    44       tb.ReadOnly = true;
    4535
    46       CheckBox checkBox = new CheckBox();
    47       checkBox.Checked = true;
    48      
    49       checkBox.CheckStateChanged += (o, args) => {
    50         if (checkBox.Checked)
    51           AddComboOption(opt);
    52         else
    53           RemoveComboOption(opt);
    54       };
    55       tableOptions.Controls.Add(checkBox);
    56       tableOptions.Controls.Add(tb);
    57     }
    58 
    59     private void AddComboOption(string opt) {
     36    private void AddComboOption(object opt) {
    6037      comboBoxValues.Items.Add(opt);
    6138      IList<string> items = new List<string>();
     
    6340        items.Add((string)i);
    6441      }
    65       ((StringValueVM)VM).Range = items;
     42      VM.Range = items;
    6643      comboBoxValues.Enabled = true;
    67       tableOptions.Refresh();
    6844    }
    6945
    70     private void RemoveComboOption(string opt) {
     46    private void RemoveComboOption(object opt) {
    7147      comboBoxValues.Items.Remove(opt);
    7248      IList<string> items = new List<string>();
     
    7450        items.Add((string)i);
    7551      }
    76       ((StringValueVM)VM).Range = items;
    77       if (((StringValueVM)VM).Range.Count() <= 0) {
     52      VM.Range = items;
     53      if (VM.Range.Count() <= 0) {
    7854        comboBoxValues.Enabled = false;
    7955        comboBoxValues.SelectedIndex = -1;
    8056      }
    81       tableOptions.Refresh();
    8257    }
    8358  }
Note: See TracChangeset for help on using the changeset viewer.