Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17446


Ignore:
Timestamp:
02/20/20 16:58:03 (4 years ago)
Author:
dpiringe
Message:

#3026:

  • made interfaces for array/matrix JsonItems and for their VMs aswell (IArrayJsonItem, IArrayJsonItemVM, IMatrixJsonItem, IMatrixJsonItemVM), incl. base classes (ArrayJsonItemBase, ArrayValueVM, MatrixJsonItemBase, MatrixValueVM)
  • changed inheritance structure for already existing array/matrix JsonItems -> they inherit now from new base array/matrix base classes
  • added input elements to configure the size of an matrix or array in JsonItemMultiValueControl (incl. VM binding and validation)
  • splitted file JsonItems.cs into separate files for their corresponding types (IntJsonItems.cs, DoubleJsonItems.cs, BoolJsonItems.cs, StringJsonItem.cs, DateTimeJsonItem.cs)
  • changed location of deserialization of json values from JsonTemplateInstantiator into IJsonItem (implemented in JsonItem and set to virtual, overridden in MatrixJsonItemBase and ArrayJsonItemBase)
  • added new CLI argument StringArgument
  • some little UI improvements (location fixes, anchor fixes, ...)
Location:
branches/3026_IntegrationIntoSymSpace
Files:
16 added
1 deleted
22 edited

Legend:

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

    r17431 r17446  
    7878  </ItemGroup>
    7979  <ItemGroup>
     80    <Compile Include="Interfaces\IArrayJsonItemVM.cs" />
     81    <Compile Include="Interfaces\IJsonItemVM.cs" />
     82    <Compile Include="Interfaces\IMatrixJsonItemVM.cs" />
    8083    <Compile Include="Properties\Resources.Designer.cs">
    8184      <AutoGen>True</AutoGen>
     
    100103    <Compile Include="ViewModels\RangedValueBaseVM.cs" />
    101104    <Compile Include="ViewModels\RangeVM.cs" />
     105    <Compile Include="ViewModels\ResultItemVM.cs" />
    102106    <Compile Include="ViewModels\SingleValueVM.cs" />
    103107    <Compile Include="ViewModels\StringValueVM.cs" />
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/JsonItemBaseControl.cs

    r17444 r17446  
    1111namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    1212  public partial class JsonItemBaseControl : UserControl {
    13     protected JsonItemVMBase VM { get; set; }
     13    protected IJsonItemVM VM { get; set; }
    1414
    1515    private JsonItemBaseControl() {
     
    1717    }
    1818   
    19     public JsonItemBaseControl(JsonItemVMBase vm) {
     19    public JsonItemBaseControl(IJsonItemVM vm) {
    2020      InitializeComponent();
    2121      VM = vm;
    2222
    23       checkBoxActive.DataBindings.Add("Checked", VM, nameof(JsonItemVMBase.Selected),
     23      checkBoxActive.DataBindings.Add("Checked", VM, nameof(IJsonItemVM.Selected),
    2424        false, DataSourceUpdateMode.OnPropertyChanged);
    25       textBoxName.DataBindings.Add("Text", VM, nameof(JsonItemVMBase.Name));
    26       textBoxDescription.DataBindings.Add("Text", VM, nameof(JsonItemVMBase.Description));
    27       textBoxActualName.DataBindings.Add("Text", VM, nameof(JsonItemVMBase.ActualName));
     25      textBoxName.DataBindings.Add("Text", VM, nameof(IJsonItemVM.Name));
     26      textBoxDescription.DataBindings.Add("Text", VM, nameof(IJsonItemVM.Description));
     27      textBoxActualName.DataBindings.Add("Text", VM, nameof(IJsonItemVM.ActualName));
    2828
    2929      if (string.IsNullOrWhiteSpace(VM.Item.ActualName))
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/NumericRangeControl.Designer.cs

    r17444 r17446  
    2626      this.components = new System.ComponentModel.Container();
    2727      this.textBoxFrom = new System.Windows.Forms.TextBox();
    28       this.label6 = new System.Windows.Forms.Label();
    2928      this.groupBox2 = new System.Windows.Forms.GroupBox();
    3029      this.checkBoxTo = new System.Windows.Forms.CheckBox();
    3130      this.textBoxTo = new System.Windows.Forms.TextBox();
    32       this.label1 = new System.Windows.Forms.Label();
    3331      this.checkBoxFrom = new System.Windows.Forms.CheckBox();
    3432      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
     
    4947      this.textBoxFrom.Validating += new System.ComponentModel.CancelEventHandler(this.textBoxFrom_Validating);
    5048      //
    51       // label6
    52       //
    53       this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    54             | System.Windows.Forms.AnchorStyles.Right)));
    55       this.label6.AutoSize = true;
    56       this.label6.Location = new System.Drawing.Point(31, 21);
    57       this.label6.Name = "label6";
    58       this.label6.Size = new System.Drawing.Size(30, 13);
    59       this.label6.TabIndex = 0;
    60       this.label6.Text = "From";
    61       //
    6249      // groupBox2
    6350      //
    6451      this.groupBox2.Controls.Add(this.checkBoxTo);
    6552      this.groupBox2.Controls.Add(this.textBoxTo);
    66       this.groupBox2.Controls.Add(this.label1);
    6753      this.groupBox2.Controls.Add(this.checkBoxFrom);
    6854      this.groupBox2.Controls.Add(this.textBoxFrom);
    69       this.groupBox2.Controls.Add(this.label6);
    7055      this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
    7156      this.groupBox2.Location = new System.Drawing.Point(0, 0);
     
    7964      //
    8065      this.checkBoxTo.AutoSize = true;
    81       this.checkBoxTo.Location = new System.Drawing.Point(10, 46);
     66      this.checkBoxTo.Location = new System.Drawing.Point(9, 45);
    8267      this.checkBoxTo.Name = "checkBoxTo";
    83       this.checkBoxTo.Size = new System.Drawing.Size(15, 14);
     68      this.checkBoxTo.Size = new System.Drawing.Size(42, 17);
    8469      this.checkBoxTo.TabIndex = 7;
     70      this.checkBoxTo.Text = "To:";
    8571      this.checkBoxTo.UseVisualStyleBackColor = true;
    8672      //
     
    9783      this.textBoxTo.Validating += new System.ComponentModel.CancelEventHandler(this.textBoxTo_Validating);
    9884      //
    99       // label1
    100       //
    101       this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    102             | System.Windows.Forms.AnchorStyles.Right)));
    103       this.label1.AutoSize = true;
    104       this.label1.Location = new System.Drawing.Point(31, 46);
    105       this.label1.Name = "label1";
    106       this.label1.Size = new System.Drawing.Size(20, 13);
    107       this.label1.TabIndex = 5;
    108       this.label1.Text = "To";
    109       //
    11085      // checkBoxFrom
    11186      //
    11287      this.checkBoxFrom.AutoSize = true;
    113       this.checkBoxFrom.Location = new System.Drawing.Point(10, 20);
     88      this.checkBoxFrom.Location = new System.Drawing.Point(9, 19);
    11489      this.checkBoxFrom.Name = "checkBoxFrom";
    115       this.checkBoxFrom.Size = new System.Drawing.Size(15, 14);
     90      this.checkBoxFrom.Size = new System.Drawing.Size(52, 17);
    11691      this.checkBoxFrom.TabIndex = 4;
     92      this.checkBoxFrom.Text = "From:";
    11793      this.checkBoxFrom.UseVisualStyleBackColor = true;
    11894      //
     
    138114    #endregion
    139115    private System.Windows.Forms.TextBox textBoxFrom;
    140     private System.Windows.Forms.Label label6;
    141116    private System.Windows.Forms.GroupBox groupBox2;
    142117    private System.Windows.Forms.CheckBox checkBoxTo;
    143118    private System.Windows.Forms.TextBox textBoxTo;
    144     private System.Windows.Forms.Label label1;
    145119    private System.Windows.Forms.CheckBox checkBoxFrom;
    146120    private System.Windows.Forms.ErrorProvider errorProvider;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ArrayValueVM.cs

    r17433 r17446  
    88namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    99
    10   public class DoubleArrayValueVM : ArrayValueVM<double> {
     10  public class DoubleArrayValueVM : ArrayValueVM<double, DoubleArrayJsonItem> {
    1111    public override Type JsonItemType => typeof(DoubleArrayJsonItem);
    1212
     
    1515    protected override double MaxTypeValue => double.MaxValue;
    1616
    17     public override JsonItemBaseControl GetControl() =>
     17    public override JsonItemBaseControl Control =>
    1818      new JsonItemDoubleArrayValueControl(this);
    1919   
     
    2727  }
    2828
    29   public class IntArrayValueVM : ArrayValueVM<int> {
     29  public class IntArrayValueVM : ArrayValueVM<int, IntArrayJsonItem> {
    3030    public override Type JsonItemType => typeof(IntArrayJsonItem);
    3131
     
    3434    protected override int MaxTypeValue => int.MaxValue;
    3535
    36     public override JsonItemBaseControl GetControl() =>
     36    public override JsonItemBaseControl Control =>
    3737      new JsonItemIntArrayValueControl(this);
    3838   
     
    4646  }
    4747
    48   public abstract class ArrayValueVM<T> : RangedValueBaseVM<T> {
     48  public abstract class ArrayValueVM<T, JsonItemType> : RangedValueBaseVM<T>, IArrayJsonItemVM
     49    where JsonItemType : IArrayJsonItem {
    4950   
    5051    public ArrayValueVM() { }
    5152
    52     public void SetIndexValue(object obj, int index) {
     53    public void SetIndexValue(T data, int index) {
    5354      T[] tmp = Value;
    5455      if(index >= tmp.Length) { // increasing array
     
    5758        tmp = newArr;
    5859      }
    59       tmp[index] = (T)Convert.ChangeType(obj, typeof(T));
     60      tmp[index] = data;
    6061      Value = tmp;
    6162    }
    6263
    6364    public abstract T[] Value { get; set; }
     65    public bool Resizable {
     66      get => ((IArrayJsonItem)Item).Resizable;
     67      set {
     68        ((IArrayJsonItem)Item).Resizable = value;
     69        OnPropertyChange(this, nameof(IArrayJsonItemVM.Resizable));
     70      }
     71    }
    6472  }
    6573}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs

    r17444 r17446  
    99
    1010namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    11   public class JsonItemVMBase : INotifyPropertyChanged, IDisposable {
     11  public class JsonItemVMBase : IJsonItemVM {
    1212    public event PropertyChangedEventHandler PropertyChanged;
    1313    public event Action ItemChanged;
     
    7878    }
    7979
    80     public virtual JsonItemBaseControl GetControl() {
    81       return new JsonItemBaseControl(this);
    82     }
    83 
     80    public virtual JsonItemBaseControl Control => new JsonItemBaseControl(this);
     81   
    8482    #region IDisposable Support
    8583    private bool disposedValue = false; // To detect redundant calls
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/MatrixValueVM.cs

    r17433 r17446  
    88namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    99
    10   public class DoubleMatrixValueVM : MatrixValueVM<double> {
     10  public class DoubleMatrixValueVM : MatrixValueVM<double, DoubleMatrixJsonItem> {
    1111    public override Type JsonItemType => typeof(DoubleMatrixJsonItem);
    12     public override JsonItemBaseControl GetControl() =>
     12    public override JsonItemBaseControl Control =>
    1313      new JsonItemDoubleMatrixValueControl(this);
    1414
     
    2626  }
    2727
    28   public abstract class MatrixValueVM<T> : RangedValueBaseVM<T> {
     28  public abstract class MatrixValueVM<T, JsonItemType> : RangedValueBaseVM<T>, IMatrixJsonItemVM
     29    where JsonItemType : IMatrixJsonItem {
     30    public abstract T[][] Value { get; set; }
     31    public bool RowsResizable {
     32      get => ((IMatrixJsonItem)Item).RowsResizable;
     33      set {
     34        ((IMatrixJsonItem)Item).RowsResizable = value;
     35        OnPropertyChange(this, nameof(RowsResizable));
     36      }
     37    }
    2938
    30     public MatrixValueVM() {}
    31     public void SetCellValue(object obj, int col, int row) {
     39    public bool ColumnsResizable {
     40      get => ((IMatrixJsonItem)Item).ColumnsResizable;
     41      set {
     42        ((IMatrixJsonItem)Item).ColumnsResizable = value;
     43        OnPropertyChange(this, nameof(ColumnsResizable));
     44      }
     45    }
     46
     47    public void SetCellValue(T data, int row, int col) {
     48     
    3249      T[][] tmp = Value;
    3350     
     51      // increase y
    3452      if (row >= tmp.Length) { // increasing array
    3553        T[][] newArr = new T[row + 1][];
     
    3856        tmp = newArr;
    3957      }
     58
     59      // increase x
    4060      for(int i = 0; i < tmp.Length; ++i) {
    4161        if(col >= tmp[i].Length) {
     
    4565        }
    4666      }
    47       tmp[row][col] = (T)Convert.ChangeType(obj.ToString().Replace(",","."),
    48                                             typeof(T),
    49                                             System.Globalization.CultureInfo.InvariantCulture);
     67
     68      tmp[row][col] = data;
    5069      Value = tmp;
    5170    }
    52 
    53     public abstract T[][] Value { get; set; }
    54 
    5571  }
    5672}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs

    r17420 r17446  
    1515    protected override int MaxTypeValue => int.MaxValue;
    1616
    17     public override JsonItemBaseControl GetControl() =>
     17    public override JsonItemBaseControl Control =>
    1818      new JsonItemRangeControl(this);
    1919  }
     
    2626    protected override double MaxTypeValue => double.MaxValue;
    2727
    28     public override JsonItemBaseControl GetControl() =>
     28    public override JsonItemBaseControl Control =>
    2929      new JsonItemRangeControl(this);
    3030  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/SingleValueVM.cs

    r17443 r17446  
    1414    protected override int MaxTypeValue => int.MaxValue;
    1515
    16     public override JsonItemBaseControl GetControl() =>
     16    public override JsonItemBaseControl Control =>
    1717      new JsonItemIntValueControl(this);
    1818  }
     
    2424    protected override double MaxTypeValue => double.MaxValue;
    2525
    26     public override JsonItemBaseControl GetControl() =>
     26    public override JsonItemBaseControl Control =>
    2727       new JsonItemDoubleValueControl(this);
    2828  }
     
    3434    protected override bool MaxTypeValue => true;
    3535
    36     public override JsonItemBaseControl GetControl() =>
     36    public override JsonItemBaseControl Control =>
    3737       new JsonItemBoolControl(this);
    3838  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/StringValueVM.cs

    r17443 r17446  
    88  public class StringValueVM : JsonItemVMBase {
    99    public override Type JsonItemType => typeof(StringJsonItem);
    10     public override JsonItemBaseControl GetControl() =>
     10    public override JsonItemBaseControl Control =>
    1111       new JsonItemValidValuesControl(this);
    1212
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.Designer.cs

    r17444 r17446  
    2929      this.treeView = new System.Windows.Forms.TreeView();
    3030      this.groupBoxDetails = new System.Windows.Forms.GroupBox();
    31       this.panel = new System.Windows.Forms.Panel();
     31      this.panelParameterDetails = new System.Windows.Forms.Panel();
    3232      this.resultItems = new System.Windows.Forms.CheckedListBox();
    33       this.groupBox2 = new System.Windows.Forms.GroupBox();
    3433      this.groupBox3 = new System.Windows.Forms.GroupBox();
    3534      this.treeViewResults = new System.Windows.Forms.TreeView();
     
    4140      this.textBoxTemplateName = new System.Windows.Forms.TextBox();
    4241      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
     42      this.splitContainer1 = new System.Windows.Forms.SplitContainer();
     43      this.groupBox = new System.Windows.Forms.GroupBox();
     44      this.panelResultDetails = new System.Windows.Forms.Panel();
    4345      this.jsonItemBindingSource = new System.Windows.Forms.BindingSource(this.components);
    4446      this.groupBoxDetails.SuspendLayout();
    45       this.groupBox2.SuspendLayout();
    4647      this.groupBox3.SuspendLayout();
    4748      ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
     
    5354      this.tabPage2.SuspendLayout();
    5455      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     56      ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
     57      this.splitContainer1.Panel1.SuspendLayout();
     58      this.splitContainer1.Panel2.SuspendLayout();
     59      this.splitContainer1.SuspendLayout();
     60      this.groupBox.SuspendLayout();
    5561      ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).BeginInit();
    5662      this.SuspendLayout();
     
    6571      //
    6672      this.exportButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    67       this.exportButton.Location = new System.Drawing.Point(629, 578);
     73      this.exportButton.Location = new System.Drawing.Point(630, 575);
    6874      this.exportButton.Name = "exportButton";
    6975      this.exportButton.Size = new System.Drawing.Size(191, 29);
     
    7581      // treeView
    7682      //
    77       this.treeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    78             | System.Windows.Forms.AnchorStyles.Left)
    79             | System.Windows.Forms.AnchorStyles.Right)));
    8083      this.treeView.CheckBoxes = true;
    81       this.treeView.Location = new System.Drawing.Point(6, 19);
     84      this.treeView.Dock = System.Windows.Forms.DockStyle.Fill;
     85      this.treeView.Location = new System.Drawing.Point(0, 6);
    8286      this.treeView.Name = "treeView";
    83       this.treeView.Size = new System.Drawing.Size(352, 471);
     87      this.treeView.Size = new System.Drawing.Size(370, 493);
    8488      this.treeView.TabIndex = 3;
    8589      this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect);
     
    8791      // groupBoxDetails
    8892      //
    89       this.groupBoxDetails.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    90             | System.Windows.Forms.AnchorStyles.Left)
    91             | System.Windows.Forms.AnchorStyles.Right)));
    92       this.groupBoxDetails.Controls.Add(this.panel);
    93       this.groupBoxDetails.Location = new System.Drawing.Point(3, 0);
     93      this.groupBoxDetails.Controls.Add(this.panelParameterDetails);
     94      this.groupBoxDetails.Dock = System.Windows.Forms.DockStyle.Fill;
     95      this.groupBoxDetails.Location = new System.Drawing.Point(0, 0);
    9496      this.groupBoxDetails.Name = "groupBoxDetails";
    95       this.groupBoxDetails.Size = new System.Drawing.Size(415, 496);
     97      this.groupBoxDetails.Size = new System.Drawing.Size(422, 499);
    9698      this.groupBoxDetails.TabIndex = 4;
    9799      this.groupBoxDetails.TabStop = false;
    98100      this.groupBoxDetails.Text = "Details";
    99101      //
    100       // panel
    101       //
    102       this.panel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    103             | System.Windows.Forms.AnchorStyles.Left)
    104             | System.Windows.Forms.AnchorStyles.Right)));
    105       this.panel.AutoScroll = true;
    106       this.panel.Location = new System.Drawing.Point(7, 20);
    107       this.panel.Name = "panel";
    108       this.panel.Size = new System.Drawing.Size(402, 470);
    109       this.panel.TabIndex = 0;
     102      // panelParameterDetails
     103      //
     104      this.panelParameterDetails.AutoScroll = true;
     105      this.panelParameterDetails.Dock = System.Windows.Forms.DockStyle.Fill;
     106      this.panelParameterDetails.Location = new System.Drawing.Point(3, 16);
     107      this.panelParameterDetails.Name = "panelParameterDetails";
     108      this.panelParameterDetails.Size = new System.Drawing.Size(416, 480);
     109      this.panelParameterDetails.TabIndex = 0;
    110110      //
    111111      // resultItems
    112112      //
    113       this.resultItems.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    114             | System.Windows.Forms.AnchorStyles.Left)
    115             | System.Windows.Forms.AnchorStyles.Right)));
     113      this.resultItems.Dock = System.Windows.Forms.DockStyle.Fill;
    116114      this.resultItems.FormattingEnabled = true;
    117       this.resultItems.Location = new System.Drawing.Point(6, 364);
     115      this.resultItems.Location = new System.Drawing.Point(0, 6);
    118116      this.resultItems.Name = "resultItems";
    119       this.resultItems.Size = new System.Drawing.Size(777, 124);
     117      this.resultItems.Size = new System.Drawing.Size(373, 393);
    120118      this.resultItems.TabIndex = 5;
    121       //
    122       // groupBox2
    123       //
    124       this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    125             | System.Windows.Forms.AnchorStyles.Left)
    126             | System.Windows.Forms.AnchorStyles.Right)));
    127       this.groupBox2.Controls.Add(this.treeView);
    128       this.groupBox2.Location = new System.Drawing.Point(0, 0);
    129       this.groupBox2.Name = "groupBox2";
    130       this.groupBox2.Size = new System.Drawing.Size(364, 496);
    131       this.groupBox2.TabIndex = 6;
    132       this.groupBox2.TabStop = false;
    133       this.groupBox2.Text = "Elements";
     119      this.resultItems.SelectedValueChanged += new System.EventHandler(this.resultItems_SelectedValueChanged);
    134120      //
    135121      // groupBox3
     
    138124            | System.Windows.Forms.AnchorStyles.Left)
    139125            | System.Windows.Forms.AnchorStyles.Right)));
     126      this.groupBox3.Controls.Add(this.splitContainer1);
    140127      this.groupBox3.Controls.Add(this.treeViewResults);
    141       this.groupBox3.Controls.Add(this.resultItems);
    142128      this.groupBox3.Location = new System.Drawing.Point(6, 6);
    143129      this.groupBox3.Name = "groupBox3";
    144       this.groupBox3.Size = new System.Drawing.Size(789, 496);
     130      this.groupBox3.Size = new System.Drawing.Size(790, 493);
    145131      this.groupBox3.TabIndex = 7;
    146132      this.groupBox3.TabStop = false;
     
    152138      this.treeViewResults.Location = new System.Drawing.Point(6, 19);
    153139      this.treeViewResults.Name = "treeViewResults";
    154       this.treeViewResults.Size = new System.Drawing.Size(777, 339);
     140      this.treeViewResults.Size = new System.Drawing.Size(777, 63);
    155141      this.treeViewResults.TabIndex = 6;
    156142      //
    157143      // splitContainer2
    158144      //
    159       this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    160             | System.Windows.Forms.AnchorStyles.Left)
    161             | System.Windows.Forms.AnchorStyles.Right)));
    162       this.splitContainer2.Location = new System.Drawing.Point(6, 6);
     145      this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
     146      this.splitContainer2.Location = new System.Drawing.Point(3, 3);
    163147      this.splitContainer2.Name = "splitContainer2";
    164148      //
    165149      // splitContainer2.Panel1
    166150      //
    167       this.splitContainer2.Panel1.Controls.Add(this.groupBox2);
     151      this.splitContainer2.Panel1.Controls.Add(this.treeView);
     152      this.splitContainer2.Panel1.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
    168153      //
    169154      // splitContainer2.Panel2
    170155      //
    171156      this.splitContainer2.Panel2.Controls.Add(this.groupBoxDetails);
    172       this.splitContainer2.Size = new System.Drawing.Size(789, 496);
    173       this.splitContainer2.SplitterDistance = 367;
     157      this.splitContainer2.Size = new System.Drawing.Size(796, 499);
     158      this.splitContainer2.SplitterDistance = 370;
    174159      this.splitContainer2.TabIndex = 9;
    175160      //
     
    184169      this.tabControl1.Name = "tabControl1";
    185170      this.tabControl1.SelectedIndex = 0;
    186       this.tabControl1.Size = new System.Drawing.Size(809, 534);
     171      this.tabControl1.Size = new System.Drawing.Size(810, 531);
    187172      this.tabControl1.TabIndex = 10;
    188173      //
     
    193178      this.tabPage1.Name = "tabPage1";
    194179      this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
    195       this.tabPage1.Size = new System.Drawing.Size(801, 508);
     180      this.tabPage1.Size = new System.Drawing.Size(802, 505);
    196181      this.tabPage1.TabIndex = 0;
    197182      this.tabPage1.Text = "Parameters";
     
    204189      this.tabPage2.Name = "tabPage2";
    205190      this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
    206       this.tabPage2.Size = new System.Drawing.Size(801, 508);
     191      this.tabPage2.Size = new System.Drawing.Size(802, 505);
    207192      this.tabPage2.TabIndex = 1;
    208193      this.tabPage2.Text = "Results";
     
    225210      this.textBoxTemplateName.Location = new System.Drawing.Point(100, 12);
    226211      this.textBoxTemplateName.Name = "textBoxTemplateName";
    227       this.textBoxTemplateName.Size = new System.Drawing.Size(720, 20);
     212      this.textBoxTemplateName.Size = new System.Drawing.Size(721, 20);
    228213      this.textBoxTemplateName.TabIndex = 12;
    229214      this.textBoxTemplateName.Text = "Template";
     
    235220      this.errorProvider.ContainerControl = this;
    236221      //
     222      // splitContainer1
     223      //
     224      this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     225            | System.Windows.Forms.AnchorStyles.Left)
     226            | System.Windows.Forms.AnchorStyles.Right)));
     227      this.splitContainer1.Location = new System.Drawing.Point(6, 88);
     228      this.splitContainer1.Name = "splitContainer1";
     229      //
     230      // splitContainer1.Panel1
     231      //
     232      this.splitContainer1.Panel1.Controls.Add(this.resultItems);
     233      this.splitContainer1.Panel1.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
     234      //
     235      // splitContainer1.Panel2
     236      //
     237      this.splitContainer1.Panel2.Controls.Add(this.groupBox);
     238      this.splitContainer1.Size = new System.Drawing.Size(778, 399);
     239      this.splitContainer1.SplitterDistance = 373;
     240      this.splitContainer1.TabIndex = 7;
     241      //
     242      // groupBox
     243      //
     244      this.groupBox.Controls.Add(this.panelResultDetails);
     245      this.groupBox.Dock = System.Windows.Forms.DockStyle.Fill;
     246      this.groupBox.Location = new System.Drawing.Point(0, 0);
     247      this.groupBox.Name = "groupBox";
     248      this.groupBox.Size = new System.Drawing.Size(401, 399);
     249      this.groupBox.TabIndex = 5;
     250      this.groupBox.TabStop = false;
     251      this.groupBox.Text = "Details";
     252      //
     253      // panelResultDetails
     254      //
     255      this.panelResultDetails.AutoScroll = true;
     256      this.panelResultDetails.Dock = System.Windows.Forms.DockStyle.Fill;
     257      this.panelResultDetails.Location = new System.Drawing.Point(3, 16);
     258      this.panelResultDetails.Name = "panelResultDetails";
     259      this.panelResultDetails.Size = new System.Drawing.Size(395, 380);
     260      this.panelResultDetails.TabIndex = 0;
     261      //
    237262      // jsonItemBindingSource
    238263      //
     
    243268      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    244269      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    245       this.ClientSize = new System.Drawing.Size(833, 619);
     270      this.ClientSize = new System.Drawing.Size(834, 616);
    246271      this.Controls.Add(this.textBoxTemplateName);
    247272      this.Controls.Add(this.label1);
     
    253278      this.Text = "Export Json";
    254279      this.groupBoxDetails.ResumeLayout(false);
    255       this.groupBox2.ResumeLayout(false);
    256280      this.groupBox3.ResumeLayout(false);
    257281      this.splitContainer2.Panel1.ResumeLayout(false);
     
    263287      this.tabPage2.ResumeLayout(false);
    264288      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
     289      this.splitContainer1.Panel1.ResumeLayout(false);
     290      this.splitContainer1.Panel2.ResumeLayout(false);
     291      ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
     292      this.splitContainer1.ResumeLayout(false);
     293      this.groupBox.ResumeLayout(false);
    265294      ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).EndInit();
    266295      this.ResumeLayout(false);
     
    277306    private System.Windows.Forms.TreeView treeView;
    278307    private System.Windows.Forms.GroupBox groupBoxDetails;
    279     private System.Windows.Forms.Panel panel;
     308    private System.Windows.Forms.Panel panelParameterDetails;
    280309    private System.Windows.Forms.CheckedListBox resultItems;
    281     private System.Windows.Forms.GroupBox groupBox2;
    282310    private System.Windows.Forms.GroupBox groupBox3;
    283311    private System.Windows.Forms.SplitContainer splitContainer2;
     
    289317    private System.Windows.Forms.TextBox textBoxTemplateName;
    290318    private System.Windows.Forms.ErrorProvider errorProvider;
     319    private System.Windows.Forms.SplitContainer splitContainer1;
     320    private System.Windows.Forms.GroupBox groupBox;
     321    private System.Windows.Forms.Panel panelResultDetails;
    291322  }
    292323}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs

    r17444 r17446  
    1818    private static FolderBrowserDialog FolderBrowserDialog { get; set; }
    1919    private IDictionary<int, UserControl> Hash2Control { get; set; } = new Dictionary<int, UserControl>();
    20     private IDictionary<TreeNode, JsonItemVMBase> Node2VM { get; set; } = new Dictionary<TreeNode, JsonItemVMBase>();
     20    private IDictionary<TreeNode, IJsonItemVM> Node2VM { get; set; } = new Dictionary<TreeNode, IJsonItemVM>();
    2121    private IJsonItem Root { get; set; }
    2222    private IOptimizer Optimizer { get; set; }
    23     private IList<JsonItemVMBase> VMs { get; set; }
     23    private IList<IJsonItemVM> VMs { get; set; }
    2424    private JCGenerator Generator { get; set; } = new JCGenerator();
    2525    private IDictionary<string, IJsonItem> ResultItems { get; set; } = new Dictionary<string, IJsonItem>();
     
    3131        content = value;
    3232
    33         VMs = new List<JsonItemVMBase>();
     33        VMs = new List<IJsonItemVM>();
    3434        treeView.Nodes.Clear();
    3535        ResultItems.Clear();
     
    4949    private void TreeView_AfterCheck(object sender, TreeViewEventArgs e) {
    5050      if (e.Action != TreeViewAction.Unknown) {
    51         if (Node2VM.TryGetValue(e.Node, out JsonItemVMBase vm)) {
     51        if (Node2VM.TryGetValue(e.Node, out IJsonItemVM vm)) {
    5252          vm.Selected = e.Node.Checked;
    5353        }
     
    7272    private void exportButton_Click(object sender, EventArgs e) {
    7373      foreach (var x in VMs) {
    74         if (!x.Selected) {
     74        if (!(x is ResultItemVM) && !x.Selected) {
    7575          x.Item.Parent.Children.Remove(x.Item);
    7676        }
     
    104104        if (FolderBrowserDialog.ShowDialog() == DialogResult.OK) {
    105105          Generator.GenerateTemplate(FolderBrowserDialog.SelectedPath, textBoxTemplateName.Text, Optimizer, Root);
     106          Close();
    106107        }
    107 
    108         Close();
    109108      }
    110109    }
    111110
    112111    private void BuildTreeNode(TreeNode node, IJsonItem item) {
     112      RegisterItem(node, item);
     113      if (item.Children != null) {
     114        foreach (var c in item.Children) {
     115          if (IsDrawableItem(c)) {
     116            if (c is ResultItem) {
     117              resultItems.Items.Add(c.Name, true);
     118              ResultItems.Add(c.Name, c);
     119              TreeNode childNode = new TreeNode(c.Name);
     120              treeViewResults.Nodes.Add(childNode);
     121              RegisterItem(childNode, c);
     122              //Hash2Control.Add(c.GetHashCode(), new JsonItemBaseControl(new JsonItemVMBase() { Item = c }));
     123            } else {
     124              TreeNode childNode = new TreeNode(c.Name);
     125              node.Nodes.Add(childNode);
     126              BuildTreeNode(childNode, c);
     127            }
     128          }
     129        }
     130      }
     131    }
     132
     133    private void RegisterItem(TreeNode node, IJsonItem item) {
    113134      if (JI2VM.TryGetValue(item.GetType(), out Type vmType)) {
    114         JsonItemVMBase vm = (JsonItemVMBase)Activator.CreateInstance(vmType);
    115         VMs.Add(vm);
     135        IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType);
     136
    116137        vm.Item = item;
    117138        vm.TreeNode = node;
    118139        vm.TreeView = treeView;
     140        node.Checked = vm.Selected;
     141
     142        VMs.Add(vm);
    119143        Node2VM.Add(node, vm);
    120         node.Checked = vm.Selected;
    121         UserControl control = vm.GetControl();
     144        UserControl control = vm.Control;
    122145        Hash2Control.Add(node.GetHashCode(), control);
    123         if (item.Children != null) {
    124           foreach (var c in item.Children) {
    125             if (IsDrawableItem(c)) {
    126               if (c is ResultItem) {
    127                 resultItems.Items.Add(c.Name, true);
    128                
    129                 ResultItems.Add(c.Name, c);
    130               } else {
    131                 TreeNode childNode = new TreeNode(c.Name);
    132                 node.Nodes.Add(childNode);
    133                 BuildTreeNode(childNode, c);
    134               }
    135             }
    136           }
    137         }
    138146      }
    139147    }
     
    152160    private void treeView_AfterSelect(object sender, TreeViewEventArgs e) {
    153161      if(Hash2Control.TryGetValue(treeView.SelectedNode.GetHashCode(), out UserControl control)) {
    154         panel.Controls.Clear();
    155         if (control != null) {
    156           panel.Controls.Add(control);
    157           control.Width = panel.Width;
    158           control.Height = panel.Height;
    159           control.Dock = DockStyle.Fill;
    160           control.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
    161         }
    162         panel.Refresh();
     162        SetControlOnPanel(control, panelParameterDetails);
    163163      }
    164164    }
     
    172172      }
    173173    }
     174
     175    private void resultItems_SelectedValueChanged(object sender, EventArgs e) {
     176      if(ResultItems.TryGetValue(resultItems.SelectedItem.ToString(), out IJsonItem item) &&
     177        Hash2Control.TryGetValue(item.GetHashCode(), out UserControl control)) {
     178        SetControlOnPanel(control, panelResultDetails);
     179      }
     180    }
     181
     182    private void SetControlOnPanel(UserControl control, Panel panel) {
     183      panel.Controls.Clear();
     184      if (control != null) {
     185        panel.Controls.Add(control);
     186        control.Width = panel.Width;
     187        control.Height = panel.Height;
     188        control.Dock = DockStyle.Fill;
     189        control.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
     190      }
     191      panel.Refresh();
     192    }
    174193  }
    175194}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemBoolControl.Designer.cs

    r17443 r17446  
    2626      this.checkBoxValue = new System.Windows.Forms.CheckBox();
    2727      this.label2 = new System.Windows.Forms.Label();
     28      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    2829      this.SuspendLayout();
    2930      //
     
    4243      //
    4344      this.label2.AutoSize = true;
    44       this.label2.Location = new System.Drawing.Point(6, 101);
     45      this.label2.Location = new System.Drawing.Point(6, 102);
    4546      this.label2.Name = "label2";
    4647      this.label2.Size = new System.Drawing.Size(34, 13);
     
    5455      this.Controls.Add(this.label2);
    5556      this.Controls.Add(this.checkBoxValue);
     57      this.errorProvider.SetIconAlignment(this, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    5658      this.Name = "JsonItemBoolControl";
    57       this.Size = new System.Drawing.Size(500, 140);
     59      this.Size = new System.Drawing.Size(500, 121);
    5860      this.Controls.SetChildIndex(this.checkBoxValue, 0);
    5961      this.Controls.SetChildIndex(this.label2, 0);
     62      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    6063      this.ResumeLayout(false);
    6164      this.PerformLayout();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemBoolControl.resx

    r17404 r17446  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     121    <value>17, 17</value>
     122  </metadata>
    120123</root>
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemMultiValueControl.Designer.cs

    r17433 r17446  
    2626      this.dataGridView = new System.Windows.Forms.DataGridView();
    2727      this.numericRangeControl1 = new HeuristicLab.JsonInterface.OptimizerIntegration.NumericRangeControl();
     28      this.groupBox1 = new System.Windows.Forms.GroupBox();
     29      this.textBoxRows = new System.Windows.Forms.TextBox();
     30      this.checkBoxColumns = new System.Windows.Forms.CheckBox();
     31      this.checkBoxRows = new System.Windows.Forms.CheckBox();
     32      this.textBoxColumns = new System.Windows.Forms.TextBox();
     33      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    2834      ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
     35      this.groupBox1.SuspendLayout();
    2936      this.SuspendLayout();
    3037      //
    3138      // dataGridView
    3239      //
     40      this.dataGridView.AllowUserToAddRows = false;
     41      this.dataGridView.AllowUserToDeleteRows = false;
     42      this.dataGridView.AllowUserToResizeColumns = false;
     43      this.dataGridView.AllowUserToResizeRows = false;
    3344      this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    3445            | System.Windows.Forms.AnchorStyles.Left)
    3546            | System.Windows.Forms.AnchorStyles.Right)));
    3647      this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
    37       this.dataGridView.Location = new System.Drawing.Point(9, 101);
     48      this.dataGridView.Location = new System.Drawing.Point(6, 67);
    3849      this.dataGridView.Name = "dataGridView";
    39       this.dataGridView.Size = new System.Drawing.Size(487, 208);
     50      this.dataGridView.Size = new System.Drawing.Size(473, 192);
    4051      this.dataGridView.TabIndex = 13;
    4152      //
     
    4455      this.numericRangeControl1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
    4556            | System.Windows.Forms.AnchorStyles.Right)));
    46       this.numericRangeControl1.Location = new System.Drawing.Point(9, 315);
     57      this.numericRangeControl1.Location = new System.Drawing.Point(9, 372);
    4758      this.numericRangeControl1.Name = "numericRangeControl1";
    48       this.numericRangeControl1.Size = new System.Drawing.Size(487, 128);
     59      this.numericRangeControl1.Size = new System.Drawing.Size(487, 71);
    4960      this.numericRangeControl1.TabIndex = 14;
     61      //
     62      // groupBox1
     63      //
     64      this.groupBox1.Controls.Add(this.textBoxColumns);
     65      this.groupBox1.Controls.Add(this.textBoxRows);
     66      this.groupBox1.Controls.Add(this.checkBoxColumns);
     67      this.groupBox1.Controls.Add(this.checkBoxRows);
     68      this.groupBox1.Controls.Add(this.dataGridView);
     69      this.groupBox1.Location = new System.Drawing.Point(9, 101);
     70      this.groupBox1.Name = "groupBox1";
     71      this.groupBox1.Size = new System.Drawing.Size(485, 265);
     72      this.groupBox1.TabIndex = 15;
     73      this.groupBox1.TabStop = false;
     74      this.groupBox1.Text = "Value";
     75      this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     76            | System.Windows.Forms.AnchorStyles.Left)
     77            | System.Windows.Forms.AnchorStyles.Right)));
     78      //
     79      // textBoxRows
     80      //
     81      this.textBoxRows.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     82            | System.Windows.Forms.AnchorStyles.Right)));
     83      this.errorProvider.SetIconAlignment(this.textBoxRows, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
     84      this.textBoxRows.Location = new System.Drawing.Point(83, 17);
     85      this.textBoxRows.Name = "textBoxRows";
     86      this.textBoxRows.ReadOnly = true;
     87      this.textBoxRows.Size = new System.Drawing.Size(396, 20);
     88      this.textBoxRows.TabIndex = 16;
     89      this.textBoxRows.TextChanged += new System.EventHandler(this.textBoxRows_TextChanged);
     90      this.textBoxRows.Validating += new System.ComponentModel.CancelEventHandler(this.textBoxRows_Validating);
     91      //
     92      // checkBoxColumns
     93      //
     94      this.checkBoxColumns.AutoSize = true;
     95      this.checkBoxColumns.Location = new System.Drawing.Point(7, 43);
     96      this.checkBoxColumns.Name = "checkBoxColumns";
     97      this.checkBoxColumns.Size = new System.Drawing.Size(69, 17);
     98      this.checkBoxColumns.TabIndex = 15;
     99      this.checkBoxColumns.Text = "Columns:";
     100      this.checkBoxColumns.UseVisualStyleBackColor = true;
     101      //
     102      // checkBoxRows
     103      //
     104      this.checkBoxRows.AutoSize = true;
     105      this.checkBoxRows.Location = new System.Drawing.Point(7, 20);
     106      this.checkBoxRows.Name = "checkBoxRows";
     107      this.checkBoxRows.Size = new System.Drawing.Size(56, 17);
     108      this.checkBoxRows.TabIndex = 14;
     109      this.checkBoxRows.Text = "Rows:";
     110      this.checkBoxRows.UseVisualStyleBackColor = true;
     111      //
     112      // textBoxColumns
     113      //
     114      this.textBoxColumns.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     115            | System.Windows.Forms.AnchorStyles.Right)));
     116      this.errorProvider.SetIconAlignment(this.textBoxColumns, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
     117      this.textBoxColumns.Location = new System.Drawing.Point(83, 43);
     118      this.textBoxColumns.Name = "textBoxColumns";
     119      this.textBoxColumns.ReadOnly = true;
     120      this.textBoxColumns.Size = new System.Drawing.Size(396, 20);
     121      this.textBoxColumns.TabIndex = 17;
     122      this.textBoxColumns.TextChanged += new System.EventHandler(this.textBoxColumns_TextChanged);
     123      this.textBoxColumns.Validating += new System.ComponentModel.CancelEventHandler(this.textBoxColumns_Validating);
    50124      //
    51125      // JsonItemMultiValueControl
     
    53127      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    54128      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     129      this.Controls.Add(this.groupBox1);
    55130      this.Controls.Add(this.numericRangeControl1);
    56       this.Controls.Add(this.dataGridView);
     131      this.errorProvider.SetIconAlignment(this, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    57132      this.Name = "JsonItemMultiValueControl";
    58133      this.Size = new System.Drawing.Size(502, 449);
    59       this.Controls.SetChildIndex(this.dataGridView, 0);
    60134      this.Controls.SetChildIndex(this.numericRangeControl1, 0);
     135      this.Controls.SetChildIndex(this.groupBox1, 0);
     136      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    61137      ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
     138      this.groupBox1.ResumeLayout(false);
     139      this.groupBox1.PerformLayout();
    62140      this.ResumeLayout(false);
    63141      this.PerformLayout();
     
    69147    private System.Windows.Forms.DataGridView dataGridView;
    70148    private NumericRangeControl numericRangeControl1;
     149    private System.Windows.Forms.GroupBox groupBox1;
     150    private System.Windows.Forms.CheckBox checkBoxColumns;
     151    private System.Windows.Forms.CheckBox checkBoxRows;
     152    private System.Windows.Forms.TextBox textBoxRows;
     153    private System.Windows.Forms.TextBox textBoxColumns;
    71154  }
    72155}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemMultiValueControl.cs

    r17433 r17446  
    1414
    1515    public JsonItemDoubleMatrixValueControl(DoubleMatrixValueVM vm) : base(vm, vm.Value) { }
    16     protected override void SaveCellData(object data, int col, int row) {
     16    protected override void SaveCellData(double data, int row, int col) {
    1717      DoubleMatrixValueVM vm = VM as DoubleMatrixValueVM;
    18       vm.SetCellValue(data, col, row);
     18      vm.SetCellValue(data, row, col);
    1919    }
    2020  }
     
    2323    public JsonItemIntArrayValueControl(IntArrayValueVM vm) : base(vm, vm.Value) { }
    2424
    25     protected override void SaveCellData(object data, int col, int row) {
     25    protected override void SaveCellData(int data, int row, int col) {
    2626      IntArrayValueVM vm = VM as IntArrayValueVM;
    2727      vm.SetIndexValue(data, row);
     
    3232    public JsonItemDoubleArrayValueControl(DoubleArrayValueVM vm) : base(vm, vm.Value) { }
    3333
    34     protected override void SaveCellData(object data, int col, int row) {
     34    protected override void SaveCellData(double data, int row, int col) {
    3535      DoubleArrayValueVM vm = VM as DoubleArrayValueVM;
    3636      vm.SetIndexValue(data, row);
     
    4040  public abstract partial class JsonItemMultiValueControl<T> : JsonItemBaseControl {
    4141    protected NumericRangeControl NumericRangeControl { get; set; }
    42 
    43     public JsonItemMultiValueControl(JsonItemVMBase vm, T[][] matrix) : base(vm) {
     42    private int _rows;
     43    private int Rows {
     44      get => _rows;
     45      set {
     46        _rows = value;
     47        RefreshMatrix();
     48      }
     49    }
     50
     51    private int _cols;
     52    private int Columns {
     53      get => _cols;
     54      set {
     55        _cols = value;
     56        RefreshMatrix();
     57      }
     58    }
     59
     60    private T[][] Matrix { get; set; }
     61
     62    public JsonItemMultiValueControl(IMatrixJsonItemVM vm, T[][] matrix) : base(vm) {
    4463      InitializeComponent();
     64
     65      checkBoxRows.DataBindings.Add("Checked", vm, nameof(IMatrixJsonItemVM.RowsResizable));
     66      checkBoxColumns.DataBindings.Add("Checked", vm, nameof(IMatrixJsonItemVM.ColumnsResizable));
     67
    4568      int rows = matrix.Length;
    4669      int cols = matrix.Max(x => x.Length);
    4770
    48       // columns must added first
    49       for (int c = 0; c < cols; ++c) {
    50         dataGridView.Columns.Add($"Column {c}", $"Column {c}");
    51       }
    52 
    53       dataGridView.Rows.Add(rows);
    54       for (int c = 0; c < cols; ++c) {
    55         for(int r = 0; r < rows; ++r) {
    56           dataGridView[c, r].Value = matrix[r][c];
    57         }
    58       }
    59 
     71      Matrix = matrix;
     72      _cols = cols;
     73      _rows = rows;
     74      RefreshMatrix();
     75      InitSizeConfiguration(rows, cols);
    6076      dataGridView.CellEndEdit += DataGridView_CellEndEdit;
    6177      InitRangeBinding();
    6278    }
    63 
    64     public JsonItemMultiValueControl(JsonItemVMBase vm, T[] array) : base(vm) {
     79   
     80    public JsonItemMultiValueControl(IArrayJsonItemVM vm, T[] array) : base(vm) {
    6581      InitializeComponent();
     82
     83      checkBoxRows.DataBindings.Add("Checked", vm, nameof(IArrayJsonItemVM.Resizable));
     84
    6685      int length = array.Length;
    6786
    68       dataGridView.Columns.Add("Value", "Value");
    69       dataGridView.Rows.Add(length);
    70       for(int i = 0; i < length; ++i) {
    71         dataGridView[0, i].Value = array[i];
    72       }
     87      Matrix = new T[array.Length][];
     88      for (int r = 0; r < length; ++r) {
     89        Matrix[r] = new T[1];
     90        Matrix[r][0] = array[r];
     91      }
     92
     93      _cols = 1;
     94      _rows = length;
     95      RefreshMatrix();
     96
     97      InitSizeConfiguration(length, null);
    7398      dataGridView.CellEndEdit += DataGridView_CellEndEdit;
    7499      InitRangeBinding();
    75100    }
    76 
    77     private void DataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) {
    78       SaveCellData(dataGridView[e.ColumnIndex, e.RowIndex].Value, e.ColumnIndex, e.RowIndex);
    79     }
    80 
    81     protected abstract void SaveCellData(object data, int col, int row);
     101   
     102    protected abstract void SaveCellData(T data, int row, int col);
     103
     104    private void InitSizeConfiguration(int? rows, int? columns) {
     105      if(rows != null) {
     106        checkBoxRows.CheckedChanged += CheckBoxRows_CheckedChanged;
     107        textBoxRows.Text = rows.ToString();
     108      } else {
     109        checkBoxRows.Enabled = false;
     110        textBoxRows.ReadOnly = true;
     111      }
     112
     113      if (columns != null) {
     114        checkBoxColumns.CheckedChanged += CheckBoxColumns_CheckedChanged;
     115        textBoxColumns.Text = columns.ToString();
     116      } else {
     117        checkBoxColumns.Enabled = false;
     118        textBoxColumns.ReadOnly = true;
     119      }
     120    }
     121
     122    private void RefreshMatrix() {
     123      dataGridView.Rows.Clear();
     124      dataGridView.Columns.Clear();
     125
     126      T[][] tmp = Matrix;
     127      Matrix = new T[Rows][];
     128
     129      // columns must added first
     130      for(int c = 0; c < Columns; ++c) {
     131        dataGridView.Columns.Add($"Column {c}", $"Column {c}");
     132      }
     133
     134      for (int r = 0; r < Rows; ++r) {
     135        T[] newCol = new T[Columns];
     136        if(r < tmp.Length)
     137          Array.Copy(tmp[r], 0, newCol, 0, Math.Min(tmp[r].Length, Columns));
     138        Matrix[r] = newCol;
     139      }
     140
     141      if(Rows > 0 && Columns > 0) {
     142        dataGridView.Rows.Add(Rows);
     143        for (int c = 0; c < Columns; ++c) {
     144          for (int r = 0; r < Rows; ++r) {
     145            //col and row is switched for dataGridView
     146            dataGridView[c, r].Value = Matrix[r][c];
     147            dataGridView.Rows[r].HeaderCell.Value = $"Row {r}";
     148          }
     149        }
     150      }
     151      dataGridView.RowHeadersWidth = 100;
     152    }
    82153
    83154    private void InitRangeBinding() {
     
    90161        false, DataSourceUpdateMode.OnPropertyChanged);
    91162    }
     163
     164    private void textBoxRows_Validating(object sender, CancelEventArgs e) {
     165      if (string.IsNullOrWhiteSpace(textBoxRows.Text)) {
     166        errorProvider.SetError(textBoxRows, "'Rows' must not be empty.");
     167        e.Cancel = true;
     168      } else if (!int.TryParse(textBoxRows.Text, out int r)) {
     169        errorProvider.SetError(textBoxRows, "Value of 'Rows' must be an integer.");
     170        e.Cancel = true;
     171      } else if (r == 0) {
     172        errorProvider.SetError(textBoxRows, "Value of 'Rows' must be an integer larger than 0.");
     173        e.Cancel = true;
     174      } else {
     175        errorProvider.SetError(textBoxRows, null);
     176      }
     177    }
     178
     179    private void textBoxColumns_Validating(object sender, CancelEventArgs e) {
     180      if (string.IsNullOrWhiteSpace(textBoxColumns.Text)) {
     181        errorProvider.SetError(textBoxColumns, "'Columns' must not be empty.");
     182        e.Cancel = true;
     183      } else if (!int.TryParse(textBoxColumns.Text, out int r)) {
     184        errorProvider.SetError(textBoxColumns, "Value of 'Columns' must be an integer.");
     185        e.Cancel = true;
     186      } else if (r == 0) {
     187        errorProvider.SetError(textBoxColumns, "Value of 'Columns' must be an integer larger than 0.");
     188        e.Cancel = true;
     189      } else {
     190        errorProvider.SetError(textBoxColumns, null);
     191      }
     192    }
     193   
     194    private void textBoxRows_TextChanged(object sender, EventArgs e) {
     195      if(int.TryParse(textBoxRows.Text, out int r)) {
     196        Rows = r;
     197      }
     198    }
     199
     200    private void textBoxColumns_TextChanged(object sender, EventArgs e) {
     201      if (int.TryParse(textBoxColumns.Text, out int c)) {
     202        Columns = c;
     203      }
     204    }
     205
     206    private void CheckBoxColumns_CheckedChanged(object sender, EventArgs e) {
     207      textBoxColumns.ReadOnly = !checkBoxColumns.Checked;
     208    }
     209
     210    private void CheckBoxRows_CheckedChanged(object sender, EventArgs e) {
     211      textBoxRows.ReadOnly = !checkBoxRows.Checked;
     212    }
     213
     214    private void DataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) {
     215      object val = dataGridView[e.ColumnIndex, e.RowIndex].Value;
     216      Matrix[e.RowIndex][e.ColumnIndex] = (T)Convert.ChangeType(val.ToString().Replace(",", "."),
     217                                            typeof(T),
     218                                            System.Globalization.CultureInfo.InvariantCulture);
     219      SaveCellData(Matrix[e.RowIndex][e.ColumnIndex], e.RowIndex, e.ColumnIndex);
     220    }
    92221  }
    93222}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemMultiValueControl.resx

    r17431 r17446  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     121    <value>17, 17</value>
     122  </metadata>
    120123</root>
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.Designer.cs

    r17443 r17446  
    3535      this.tableOptions.AutoScroll = true;
    3636      this.tableOptions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
    37       this.tableOptions.BackColor = System.Drawing.SystemColors.Control;
    3837      this.tableOptions.ColumnCount = 2;
    3938      this.tableOptions.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj

    r17439 r17446  
    6767    <Compile Include="Converters\ValueLookupParameterConverter.cs" />
    6868    <Compile Include="Converters\ValueRangeConverter.cs" />
     69    <Compile Include="Interfaces\IArrayJsonItem.cs" />
    6970    <Compile Include="Interfaces\IJsonItem.cs" />
    7071    <Compile Include="Interfaces\IJsonItemValidator.cs" />
     72    <Compile Include="Interfaces\IMatrixJsonItem.cs" />
     73    <Compile Include="Models\ArrayJsonItemBase.cs" />
     74    <Compile Include="Models\BoolJsonItems.cs" />
     75    <Compile Include="Models\DateTimeJsonItem.cs" />
     76    <Compile Include="Models\DoubleJsonItems.cs" />
    7177    <Compile Include="Models\GenericJsonItem.cs" />
     78    <Compile Include="Models\IntJsonItems.cs" />
    7279    <Compile Include="Models\JsonItem.cs" />
    73     <Compile Include="Models\JsonItems.cs" />
     80    <Compile Include="Models\MatrixJsonItemBase.cs" />
    7481    <Compile Include="Models\ResultItem.cs" />
     82    <Compile Include="Models\StringJsonItem.cs" />
    7583    <Compile Include="Models\UnsupportedJsonItem.cs" />
    7684    <Compile Include="SingleLineArrayJsonWriter.cs" />
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItem.cs

    r17444 r17446  
    55using System.Threading.Tasks;
    66using Newtonsoft.Json;
     7using Newtonsoft.Json.Linq;
    78
    89namespace HeuristicLab.JsonInterface {
     
    4546    /// </summary>
    4647    void LoosenPath();
     48
     49    void SetFromJObject(JObject jObject);
    4750  }
    4851}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs

    r17442 r17446  
    5151
    5252      // extract metadata information
    53       string optimizerName = instData.Template[Constants.Metadata][Constants.TemplateName].ToString();
    5453      string hLFileLocation = Path.GetFullPath(instData.Template[Constants.Metadata][Constants.HLFileLocation].ToString());
    5554
     
    7877
    7978    #region Helper
    80 
    81     private static object GetValueFromJObject(JObject obj) =>
    82       obj[nameof(IJsonItem.Value)]?.ToObject<object>();
    83 
    8479    private static IEnumerable<string> CollectResults(InstData instData) {
    8580      IList<string> res = new List<string>();
     
    107102          else old = tmp;
    108103        }
    109         tmp.Value = GetValueFromJObject(obj);
    110         tmp.Range = obj[nameof(IJsonItem.Range)]?.ToObject<object[]>();
    111         tmp.ActualName = obj[nameof(IJsonItem.ActualName)]?.ToString();
     104        tmp.SetFromJObject(obj);
    112105        instData.Objects.Add(tmp.Path, tmp);
    113106      }
     
    120113        // override default value
    121114        if (instData.Objects.TryGetValue(path, out IJsonItem param)) {
    122           param.Value = GetValueFromJObject(obj);
    123           // override ActualName (for LookupParameters)
    124           if (param.ActualName != null)
    125             param.ActualName = obj[nameof(IJsonItem.ActualName)]?.ToString();
     115          // save range from template
     116          IEnumerable<object> tmpRange = param.Range;
     117          param.SetFromJObject(obj);
     118          // set range from template
     119          param.Range = tmpRange;
    126120        } else throw new InvalidDataException($"No parameter with path='{path}' defined!");
    127121      }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/JsonItem.cs

    r17444 r17446  
    55using System.Text;
    66using Newtonsoft.Json;
     7using Newtonsoft.Json.Linq;
    78
    89namespace HeuristicLab.JsonInterface {
     
    114115    public void FixatePath() => fixedPath = Path;
    115116    public void LoosenPath() => fixedPath = "";
     117
     118    public virtual void SetFromJObject(JObject jObject) {
     119      Value = jObject[nameof(IJsonItem.Value)]?.ToObject<object>();
     120      Range = jObject[nameof(IJsonItem.Range)]?.ToObject<object[]>();
     121      ActualName = jObject[nameof(IJsonItem.ActualName)]?.ToString();
     122    }
    116123    #endregion
    117124
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/BestTSPSolutionAnalyzer.cs

    r17180 r17446  
    5656      get { return (LookupParameter<PathTSPTour>)Parameters["BestSolution"]; }
    5757    }
    58     public ValueLookupParameter<ResultCollection> ResultsParameter {
    59       get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
    60     }
     58    //public ValueLookupParameter<ResultCollection> ResultsParameter {
     59    //  get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
     60    //}
    6161    public LookupParameter<DoubleValue> BestKnownQualityParameter {
    6262      get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
     
    6464    public LookupParameter<Permutation> BestKnownSolutionParameter {
    6565      get { return (LookupParameter<Permutation>)Parameters["BestKnownSolution"]; }
     66    }
     67    public IResultParameter<PathTSPTour> BestSolutionResultParameter {
     68      get { return (IResultParameter<PathTSPTour>)Parameters["Best TSP Solution"]; }
     69    }
     70
     71
     72    [StorableHook(HookType.AfterDeserialization)]
     73    private void AfterDeserialization() {
     74      // BackwardsCompatibility3.3
     75      #region Backwards compatible code, remove with 3.4
     76      if (!Parameters.ContainsKey("Best TSP Solution")) {
     77        Parameters.Add(new ResultParameter<PathTSPTour>("Best TSP Solution", "The best TSP solution found so far."));
     78      }
     79      #endregion
    6680    }
    6781
     
    7993      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the TSP solutions which should be analyzed."));
    8094      Parameters.Add(new LookupParameter<PathTSPTour>("BestSolution", "The best TSP solution."));
    81       Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best TSP solution should be stored."));
     95      //Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best TSP solution should be stored."));
    8296      Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this TSP instance."));
    8397      Parameters.Add(new LookupParameter<Permutation>("BestKnownSolution", "The best known solution of this TSP instance."));
     98      Parameters.Add(new ResultParameter<PathTSPTour>("Best TSP Solution", "The best TSP solution found so far."));
    8499
    85100      MaximizationParameter.Hidden = true;
     
    88103      QualityParameter.Hidden = true;
    89104      BestSolutionParameter.Hidden = true;
    90       ResultsParameter.Hidden = true;
     105      //ResultsParameter.Hidden = true;
    91106      BestKnownQualityParameter.Hidden = true;
    92107      BestKnownSolutionParameter.Hidden = true;
     
    97112      ItemArray<Permutation> permutations = PermutationParameter.ActualValue;
    98113      ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
    99       ResultCollection results = ResultsParameter.ActualValue;
     114      //ResultCollection results = ResultsParameter.ActualValue;
    100115      bool max = MaximizationParameter.ActualValue.Value;
    101116      DoubleValue bestKnownQuality = BestKnownQualityParameter.ActualValue;
     
    117132        tour = new PathTSPTour(coordinates, (Permutation)permutations[i].Clone(), new DoubleValue(qualities[i].Value));
    118133        BestSolutionParameter.ActualValue = tour;
    119         results.Add(new Result("Best TSP Solution", tour));
     134        BestSolutionResultParameter.ActualValue = tour;
     135        //results.Add(new Result("Best TSP Solution", tour));
    120136      } else {
    121137        if (max && tour.Quality.Value < qualities[i].Value ||
Note: See TracChangeset for help on using the changeset viewer.