Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17405


Ignore:
Timestamp:
01/21/20 17:14:46 (5 years ago)
Author:
dpiringe
Message:

#3026:

  • added a new way to setup the targeted result types
  • added new ui controls: NumericRangeControl, JsonItemArrayControl, JsonItemDefaultControl
  • redesigned export dialog -> now the user can navigate with a tree view
  • enhanced JsonItemVM
Location:
branches/3026_IntegrationIntoSymSpace
Files:
8 added
17 edited

Legend:

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

    r17404 r17405  
    5050      <HintPath>..\bin\HeuristicLab.Collections-3.3.dll</HintPath>
    5151    </Reference>
     52    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     53      <SpecificVersion>False</SpecificVersion>
     54      <HintPath>..\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
     55    </Reference>
    5256    <Reference Include="HeuristicLab.Core.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    5357      <SpecificVersion>False</SpecificVersion>
     
    8589      <DependentUpon>JsonItemBaseControl.cs</DependentUpon>
    8690    </Compile>
     91    <Compile Include="Shared\NumericRangeControl.cs">
     92      <SubType>UserControl</SubType>
     93    </Compile>
     94    <Compile Include="Shared\NumericRangeControl.Designer.cs">
     95      <DependentUpon>NumericRangeControl.cs</DependentUpon>
     96    </Compile>
    8797    <Compile Include="Views\ExportJsonDialog.cs">
    8898      <SubType>Form</SubType>
     
    92102    </Compile>
    93103    <Compile Include="FileManager.cs" />
     104    <Compile Include="Views\JsonItemArrayControl.cs">
     105      <SubType>UserControl</SubType>
     106    </Compile>
     107    <Compile Include="Views\JsonItemArrayControl.Designer.cs">
     108      <DependentUpon>JsonItemArrayControl.cs</DependentUpon>
     109    </Compile>
    94110    <Compile Include="Views\JsonItemBoolControl.cs">
    95111      <SubType>UserControl</SubType>
     
    97113    <Compile Include="Views\JsonItemBoolControl.Designer.cs">
    98114      <DependentUpon>JsonItemBoolControl.cs</DependentUpon>
     115    </Compile>
     116    <Compile Include="Views\JsonItemDefaultControl.cs">
     117      <SubType>UserControl</SubType>
     118    </Compile>
     119    <Compile Include="Views\JsonItemDefaultControl.Designer.cs">
     120      <DependentUpon>JsonItemDefaultControl.cs</DependentUpon>
    99121    </Compile>
    100122    <Compile Include="Views\JsonItemRangeControl.cs">
     
    135157      <Name>HeuristicLab.Core-3.3</Name>
    136158    </ProjectReference>
     159    <ProjectReference Include="..\HeuristicLab.Data.Views\3.3\HeuristicLab.Data.Views-3.3.csproj">
     160      <Project>{72104A0B-90E7-42F3-9ABE-9BBBADD4B943}</Project>
     161      <Name>HeuristicLab.Data.Views-3.3</Name>
     162    </ProjectReference>
    137163    <ProjectReference Include="..\HeuristicLab.JsonInterface\HeuristicLab.JsonInterface.csproj">
    138164      <Project>{0e3aab5e-f152-44e0-a054-4d9a83ecee08}</Project>
     
    168194      <DependentUpon>JsonItemBaseControl.cs</DependentUpon>
    169195    </EmbeddedResource>
     196    <EmbeddedResource Include="Shared\NumericRangeControl.resx">
     197      <DependentUpon>NumericRangeControl.cs</DependentUpon>
     198    </EmbeddedResource>
    170199    <EmbeddedResource Include="Views\ExportJsonDialog.resx">
    171200      <DependentUpon>ExportJsonDialog.cs</DependentUpon>
     201    </EmbeddedResource>
     202    <EmbeddedResource Include="Views\JsonItemArrayControl.resx">
     203      <DependentUpon>JsonItemArrayControl.cs</DependentUpon>
    172204    </EmbeddedResource>
    173205    <EmbeddedResource Include="Views\JsonItemBoolControl.resx">
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/JsonItemBaseControl.Designer.cs

    r17404 r17405  
    2424    /// </summary>
    2525    private void InitializeComponent() {
    26       this.labelPath = new System.Windows.Forms.Label();
     26      this.labelEnable = new System.Windows.Forms.Label();
    2727      this.checkBoxActive = new System.Windows.Forms.CheckBox();
    28       this.panel1 = new System.Windows.Forms.Panel();
    29       this.label3 = new System.Windows.Forms.Label();
    3028      this.textBoxActualName = new System.Windows.Forms.TextBox();
    3129      this.labelActualName = new System.Windows.Forms.Label();
    3230      this.textBoxName = new System.Windows.Forms.TextBox();
    3331      this.label1 = new System.Windows.Forms.Label();
    34       this.panel1.SuspendLayout();
    3532      this.SuspendLayout();
    3633      //
    37       // labelPath
     34      // labelEnable
    3835      //
    39       this.labelPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     36      this.labelEnable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    4037            | System.Windows.Forms.AnchorStyles.Right)));
    41       this.labelPath.AutoSize = true;
    42       this.labelPath.Location = new System.Drawing.Point(24, 4);
    43       this.labelPath.Name = "labelPath";
    44       this.labelPath.Size = new System.Drawing.Size(29, 13);
    45       this.labelPath.TabIndex = 3;
    46       this.labelPath.Text = "Path";
     38      this.labelEnable.AutoSize = true;
     39      this.labelEnable.Location = new System.Drawing.Point(6, 3);
     40      this.labelEnable.Name = "labelEnable";
     41      this.labelEnable.Size = new System.Drawing.Size(40, 13);
     42      this.labelEnable.TabIndex = 3;
     43      this.labelEnable.Text = "Enable";
    4744      //
    4845      // checkBoxActive
    4946      //
    5047      this.checkBoxActive.AutoSize = true;
    51       this.checkBoxActive.Location = new System.Drawing.Point(3, 3);
     48      this.checkBoxActive.Location = new System.Drawing.Point(92, 3);
    5249      this.checkBoxActive.Name = "checkBoxActive";
    5350      this.checkBoxActive.Size = new System.Drawing.Size(15, 14);
     
    5653      this.checkBoxActive.CheckedChanged += new System.EventHandler(this.checkBoxActive_CheckedChanged);
    5754      //
    58       // panel1
    59       //
    60       this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    61             | System.Windows.Forms.AnchorStyles.Right)));
    62       this.panel1.BackColor = System.Drawing.Color.Gray;
    63       this.panel1.Controls.Add(this.checkBoxActive);
    64       this.panel1.Controls.Add(this.labelPath);
    65       this.panel1.Location = new System.Drawing.Point(0, 0);
    66       this.panel1.Name = "panel1";
    67       this.panel1.Size = new System.Drawing.Size(501, 20);
    68       this.panel1.TabIndex = 4;
    69       //
    70       // label3
    71       //
    72       this.label3.AutoSize = true;
    73       this.label3.Location = new System.Drawing.Point(6, 84);
    74       this.label3.Name = "label3";
    75       this.label3.Size = new System.Drawing.Size(34, 13);
    76       this.label3.TabIndex = 13;
    77       this.label3.Text = "Value";
    78       this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
    79       //
    8055      // textBoxActualName
    8156      //
    8257      this.textBoxActualName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    8358            | System.Windows.Forms.AnchorStyles.Right)));
    84       this.textBoxActualName.Location = new System.Drawing.Point(92, 55);
     59      this.textBoxActualName.Location = new System.Drawing.Point(92, 49);
    8560      this.textBoxActualName.Name = "textBoxActualName";
    86       this.textBoxActualName.Size = new System.Drawing.Size(402, 20);
     61      this.textBoxActualName.Size = new System.Drawing.Size(404, 20);
    8762      this.textBoxActualName.TabIndex = 12;
    8863      this.textBoxActualName.TextChanged += new System.EventHandler(this.textBoxActualName_TextChanged);
     
    9166      //
    9267      this.labelActualName.AutoSize = true;
    93       this.labelActualName.Location = new System.Drawing.Point(6, 58);
     68      this.labelActualName.Location = new System.Drawing.Point(6, 52);
    9469      this.labelActualName.Name = "labelActualName";
    9570      this.labelActualName.Size = new System.Drawing.Size(65, 13);
     
    10277      this.textBoxName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    10378            | System.Windows.Forms.AnchorStyles.Right)));
    104       this.textBoxName.Location = new System.Drawing.Point(92, 29);
     79      this.textBoxName.Location = new System.Drawing.Point(92, 23);
    10580      this.textBoxName.Name = "textBoxName";
    106       this.textBoxName.Size = new System.Drawing.Size(402, 20);
     81      this.textBoxName.ReadOnly = true;
     82      this.textBoxName.Size = new System.Drawing.Size(404, 20);
    10783      this.textBoxName.TabIndex = 10;
    10884      this.textBoxName.TextChanged += new System.EventHandler(this.textBoxName_TextChanged);
     
    11187      //
    11288      this.label1.AutoSize = true;
    113       this.label1.Location = new System.Drawing.Point(6, 32);
     89      this.label1.Location = new System.Drawing.Point(6, 26);
    11490      this.label1.Name = "label1";
    11591      this.label1.Size = new System.Drawing.Size(35, 13);
     
    12298      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    12399      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    124       this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    125       this.Controls.Add(this.label3);
     100      this.Controls.Add(this.labelEnable);
     101      this.Controls.Add(this.checkBoxActive);
    126102      this.Controls.Add(this.textBoxActualName);
    127103      this.Controls.Add(this.labelActualName);
    128104      this.Controls.Add(this.textBoxName);
    129105      this.Controls.Add(this.label1);
    130       this.Controls.Add(this.panel1);
    131106      this.Name = "JsonItemBaseControl";
    132107      this.Padding = new System.Windows.Forms.Padding(3);
    133       this.Size = new System.Drawing.Size(500, 152);
    134       this.panel1.ResumeLayout(false);
    135       this.panel1.PerformLayout();
     108      this.Size = new System.Drawing.Size(502, 154);
    136109      this.ResumeLayout(false);
    137110      this.PerformLayout();
     
    141114    #endregion
    142115
    143     private System.Windows.Forms.Label labelPath;
     116    private System.Windows.Forms.Label labelEnable;
    144117    private System.Windows.Forms.CheckBox checkBoxActive;
    145     private System.Windows.Forms.Panel panel1;
    146     private System.Windows.Forms.Label label3;
    147118    private System.Windows.Forms.TextBox textBoxActualName;
    148119    private System.Windows.Forms.Label labelActualName;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/JsonItemBaseControl.cs

    r17404 r17405  
    2020      InitializeComponent();
    2121      VM = vm;
    22       labelPath.Text = VM.Item.Path;
    2322      checkBoxActive.Checked = VM.Selected;
    2423      textBoxName.Text = VM.Item.Name;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVM.cs

    r17404 r17405  
    77
    88namespace HeuristicLab.JsonInterface.OptimizerIntegration {
     9  public delegate void OnSelectionChangeHandler(JsonItemVM sender, bool selection);
     10  public delegate void OnChildAddedHandler(JsonItemVM sender, JsonItemVM child);
     11
    912  public class JsonItemVM {
    1013    public JsonItem Item { get; set; }
    1114
    12     public bool Selected { get; set; } = true;
     15    private IList<JsonItemVM> children = new List<JsonItemVM>();
     16    public IEnumerable<JsonItemVM> Children {
     17      get => children;
     18    }
     19
     20    public JsonItemVM Parent { get; set; }
     21
     22    private bool selected = true;
     23    public bool Selected {
     24      get => selected;
     25      set {
     26        selected = value;
     27        OnSelectionChange?.Invoke(this, Selected);
     28      }
     29    }
     30
     31    public event OnSelectionChangeHandler OnSelectionChange;
     32    public event OnChildAddedHandler OnChildAdded;
    1333
    1434    public JsonItemVM(JsonItem item) {
    1535      this.Item = item;
    1636    }
     37
     38    public void AddChild(JsonItemVM vm) {
     39      children.Add(vm);
     40      vm.Parent = this;
     41      OnChildAdded?.Invoke(this, vm);
     42    }
    1743  }
    1844}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.Designer.cs

    r17404 r17405  
    2727      this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
    2828      this.exportButton = new System.Windows.Forms.Button();
    29       this.tabel = new System.Windows.Forms.TableLayoutPanel();
     29      this.treeView = new System.Windows.Forms.TreeView();
     30      this.groupBoxDetails = new System.Windows.Forms.GroupBox();
     31      this.panel = new System.Windows.Forms.Panel();
    3032      this.jsonItemBindingSource = new System.Windows.Forms.BindingSource(this.components);
     33      this.groupBoxDetails.SuspendLayout();
    3134      ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).BeginInit();
    3235      this.SuspendLayout();
     
    4144      //
    4245      this.exportButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    43       this.exportButton.Location = new System.Drawing.Point(397, 515);
     46      this.exportButton.Location = new System.Drawing.Point(801, 687);
    4447      this.exportButton.Name = "exportButton";
    4548      this.exportButton.Size = new System.Drawing.Size(121, 34);
     
    4952      this.exportButton.Click += new System.EventHandler(this.exportButton_Click);
    5053      //
    51       // tabel
     54      // treeView
    5255      //
    53       this.tabel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     56      this.treeView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     57            | System.Windows.Forms.AnchorStyles.Left)));
     58      this.treeView.Location = new System.Drawing.Point(12, 12);
     59      this.treeView.Name = "treeView";
     60      this.treeView.Size = new System.Drawing.Size(342, 669);
     61      this.treeView.TabIndex = 3;
     62      this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect);
     63      //
     64      // groupBoxDetails
     65      //
     66      this.groupBoxDetails.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    5467            | System.Windows.Forms.AnchorStyles.Left)
    5568            | System.Windows.Forms.AnchorStyles.Right)));
    56       this.tabel.AutoScroll = true;
    57       this.tabel.BackColor = System.Drawing.SystemColors.Control;
    58       this.tabel.ColumnCount = 1;
    59       this.tabel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
    60       this.tabel.Location = new System.Drawing.Point(12, 12);
    61       this.tabel.Name = "tabel";
    62       this.tabel.RowCount = 1;
    63       this.tabel.RowStyles.Add(new System.Windows.Forms.RowStyle());
    64       this.tabel.Size = new System.Drawing.Size(506, 497);
    65       this.tabel.TabIndex = 2;
     69      this.groupBoxDetails.Controls.Add(this.panel);
     70      this.groupBoxDetails.Location = new System.Drawing.Point(360, 12);
     71      this.groupBoxDetails.Name = "groupBoxDetails";
     72      this.groupBoxDetails.Size = new System.Drawing.Size(562, 669);
     73      this.groupBoxDetails.TabIndex = 4;
     74      this.groupBoxDetails.TabStop = false;
     75      this.groupBoxDetails.Text = "Details";
     76      //
     77      // panel
     78      //
     79      this.panel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     80            | System.Windows.Forms.AnchorStyles.Left)
     81            | System.Windows.Forms.AnchorStyles.Right)));
     82      this.panel.AutoScroll = true;
     83      this.panel.Location = new System.Drawing.Point(7, 20);
     84      this.panel.Name = "panel";
     85      this.panel.Size = new System.Drawing.Size(549, 643);
     86      this.panel.TabIndex = 0;
    6687      //
    6788      // jsonItemBindingSource
     
    7394      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    7495      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    75       this.ClientSize = new System.Drawing.Size(530, 561);
     96      this.ClientSize = new System.Drawing.Size(934, 733);
     97      this.Controls.Add(this.groupBoxDetails);
     98      this.Controls.Add(this.treeView);
    7699      this.Controls.Add(this.exportButton);
    77       this.Controls.Add(this.tabel);
    78100      this.Name = "ExportJsonDialog";
    79101      this.RightToLeft = System.Windows.Forms.RightToLeft.No;
    80102      this.ShowIcon = false;
    81103      this.Text = "Export Json";
     104      this.groupBoxDetails.ResumeLayout(false);
    82105      ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).EndInit();
    83106      this.ResumeLayout(false);
     
    91114    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
    92115    private System.Windows.Forms.Button exportButton;
    93     private System.Windows.Forms.TableLayoutPanel tabel;
     116    private System.Windows.Forms.TreeView treeView;
     117    private System.Windows.Forms.GroupBox groupBoxDetails;
     118    private System.Windows.Forms.Panel panel;
    94119  }
    95120}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs

    r17404 r17405  
    1717    private IContent content;
    1818    private static SaveFileDialog saveFileDialog;
    19 
     19    private IDictionary<int, UserControl> ctrlCollection = new Dictionary<int, UserControl>();
     20    private JsonItem root;
     21    private IOptimizer optimizer;
    2022    private IList<JsonItemVM> vms;
    2123    private JCGenerator generator = new JCGenerator();
     
    2527        content = value;
    2628
    27         IEnumerable<JsonItem> items = generator.FetchJsonItems(content as IOptimizer);
     29        //IEnumerable<JsonItem> items = generator.FetchJsonItems(content as IOptimizer);
    2830        vms = new List<JsonItemVM>();
    29         tabel.Controls.Clear();
     31        treeView.Nodes.Clear();
    3032
    31         foreach (var item in items) {
    32           if (!(item is UnsupportedJsonItem) && item.Value != null && item.Range != null) {
    33             JsonItemVM vm = new JsonItemVM(item);
    34             vms.Add(vm);
    35             UserControl control = null;
    36             if(item.Value is string) {
    37               control = new JsonItemValidValuesControl(vm);
    38             } else if (item.Value is bool) {
    39               control = new JsonItemBoolControl(vm);
    40             } else if (item.Value is int) {
    41               control = new JsonItemValueControl(vm, false);
    42             } else if (item.Value is double) {
    43               control = new JsonItemValueControl(vm, true);
    44             } else if (item.Value is Array) {
    45               if(((Array)item.Value).GetValue(0) is int)
    46                 control = new JsonItemRangeControl(vm, false);
    47               else if (((Array)item.Value).GetValue(0) is double)
    48                 control = new JsonItemRangeControl(vm, true);
    49             }
    50             if (control != null) {
    51               control.Anchor = AnchorStyles.Left | AnchorStyles.Right;
    52               tabel.Controls.Add(control);
    53             }
    54           }
    55         }
     33        optimizer = content as IOptimizer;
     34        root = JsonItemConverter.Extract(optimizer);
     35        TreeNode parent = new TreeNode(root.Name);
     36        BuildTreeNode(parent, root);
     37        treeView.Nodes.Add(parent);
    5638      }
    5739    }
     
    6244
    6345    private void exportButton_Click(object sender, EventArgs e) {
    64       IList<JsonItem> items = new List<JsonItem>();
    65 
    6646      foreach(var x in vms) {
    67         if (x.Selected)
    68           items.Add(x.Item);
     47        if (!x.Selected) {
     48          x.Item.Parent.Children.Remove(x.Item);
     49        }
    6950      }
    7051
     
    8061
    8162      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
    82         File.WriteAllText(saveFileDialog.FileName, generator.GenerateTemplate(items));
     63        File.WriteAllText(saveFileDialog.FileName, generator.GenerateTemplate(root, optimizer));
    8364      }
    8465
    8566      this.Close();
    8667    }
     68
     69    private JsonItemVM BuildTreeNode(TreeNode node, JsonItem item) {
     70      JsonItemVM vm = new JsonItemVM(item);
     71
     72      vms.Add(vm);
     73      ctrlCollection.Add(node.GetHashCode(), GenerateControl(vm));
     74      if (item.Children != null) {
     75        foreach (var c in item.Children) {
     76          if (IsDrawableItem(c)) {
     77            if (c is ResultItem) {
     78
     79            } else {
     80              TreeNode childNode = new TreeNode(c.Name);
     81              node.Nodes.Add(childNode);
     82              vm.AddChild(BuildTreeNode(childNode, c));
     83            }
     84          }
     85        }
     86      }
     87     
     88      return vm;
     89    }
     90
     91    private bool IsDrawableItem(JsonItem item) {
     92      bool b = false;
     93      if (item.Children != null) {
     94        foreach (var c in item.Children) {
     95          b = b || IsDrawableItem(c);
     96        }
     97      }
     98     
     99      return b || (item.Value != null || item.Range != null || item.ActualName != null);
     100    }
     101   
     102    private void treeView_AfterSelect(object sender, TreeViewEventArgs e) {
     103      if(ctrlCollection.TryGetValue(treeView.SelectedNode.GetHashCode(), out UserControl ctrl)) {
     104        panel.Controls.Clear();
     105        if (ctrl != null) {
     106          panel.Controls.Add(ctrl);
     107        }
     108        panel.Refresh();
     109      }
     110    }
     111
     112    private UserControl GenerateControl(JsonItemVM vm) {
     113      JsonItem item = vm.Item;
     114      UserControl control = null;
     115      if (!(item is UnsupportedJsonItem)) {
     116        if (item.Value is string && item.Range != null) {
     117          control = new JsonItemValidValuesControl(vm);
     118        } else if (item.Value is bool && item.Range != null) {
     119          control = new JsonItemBoolControl(vm);
     120        } else if (item.Value is int && item.Range != null) {
     121          control = new JsonItemValueControl(vm, false);
     122        } else if (item.Value is double && item.Range != null) {
     123          control = new JsonItemValueControl(vm, true);
     124        } else if (item.Value is Array) {
     125          Array arr = (Array)item.Value;
     126          if (arr.Length == 2 && arr.GetValue(0) is int && item.Range != null)
     127            control = new JsonItemRangeControl(vm, false);
     128          else if (arr.Length == 2 && arr.GetValue(0) is double && item.Range != null)
     129            control = new JsonItemRangeControl(vm, true);
     130          else if (arr.Rank == 1 && arr.GetValue(0) is double) {
     131            control = new JsonItemArrayControl(vm);
     132          }
     133        } else {
     134          control = new JsonItemBaseControl(vm);
     135        }
     136        if (control != null) {
     137          control.Dock = DockStyle.Fill;
     138          control.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
     139        }
     140      }
     141      return control;
     142    }
    87143  }
    88144}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemBoolControl.Designer.cs

    r17404 r17405  
    2525    private void InitializeComponent() {
    2626      this.checkBoxValue = new System.Windows.Forms.CheckBox();
     27      this.label2 = new System.Windows.Forms.Label();
    2728      this.SuspendLayout();
    2829      //
     
    3233            | System.Windows.Forms.AnchorStyles.Right)));
    3334      this.checkBoxValue.AutoSize = true;
    34       this.checkBoxValue.Location = new System.Drawing.Point(92, 84);
     35      this.checkBoxValue.Location = new System.Drawing.Point(92, 75);
    3536      this.checkBoxValue.Name = "checkBoxValue";
    3637      this.checkBoxValue.Size = new System.Drawing.Size(15, 14);
     
    3940      this.checkBoxValue.CheckStateChanged += new System.EventHandler(this.checkBoxValue_CheckStateChanged);
    4041      //
     42      // label2
     43      //
     44      this.label2.AutoSize = true;
     45      this.label2.Location = new System.Drawing.Point(6, 75);
     46      this.label2.Name = "label2";
     47      this.label2.Size = new System.Drawing.Size(34, 13);
     48      this.label2.TabIndex = 20;
     49      this.label2.Text = "Value";
     50      //
    4151      // JsonItemBoolControl
    4252      //
     
    4454      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    4555      this.BackColor = System.Drawing.SystemColors.Control;
     56      this.Controls.Add(this.label2);
    4657      this.Controls.Add(this.checkBoxValue);
    4758      this.Name = "JsonItemBoolControl";
    4859      this.Size = new System.Drawing.Size(500, 105);
    4960      this.Controls.SetChildIndex(this.checkBoxValue, 0);
     61      this.Controls.SetChildIndex(this.label2, 0);
    5062      this.ResumeLayout(false);
    5163      this.PerformLayout();
     
    5567    #endregion
    5668    private System.Windows.Forms.CheckBox checkBoxValue;
     69    private System.Windows.Forms.Label label2;
    5770  }
    5871}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemRangeControl.Designer.cs

    r17404 r17405  
    2929      this.label4 = new System.Windows.Forms.Label();
    3030      this.label2 = new System.Windows.Forms.Label();
    31       this.textBoxRangeTo = new System.Windows.Forms.TextBox();
    32       this.textBoxRangeFrom = new System.Windows.Forms.TextBox();
    33       this.label5 = new System.Windows.Forms.Label();
    34       this.label6 = new System.Windows.Forms.Label();
    35       this.groupBox2 = new System.Windows.Forms.GroupBox();
     31      this.numericRangeControl1 = new HeuristicLab.JsonInterface.OptimizerIntegration.Shared.NumericRangeControl();
    3632      this.groupBox1.SuspendLayout();
    37       this.groupBox2.SuspendLayout();
    3833      this.SuspendLayout();
    3934      //
     
    4641      this.groupBox1.Controls.Add(this.label4);
    4742      this.groupBox1.Controls.Add(this.label2);
    48       this.groupBox1.Location = new System.Drawing.Point(9, 81);
     43      this.groupBox1.Location = new System.Drawing.Point(9, 75);
    4944      this.groupBox1.Name = "groupBox1";
    5045      this.groupBox1.Size = new System.Drawing.Size(487, 64);
     
    9388      this.label2.Text = "From";
    9489      //
    95       // textBoxRangeTo
     90      // numericRangeControl1
    9691      //
    97       this.textBoxRangeTo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    98             | System.Windows.Forms.AnchorStyles.Right)));
    99       this.textBoxRangeTo.Location = new System.Drawing.Point(249, 36);
    100       this.textBoxRangeTo.Name = "textBoxRangeTo";
    101       this.textBoxRangeTo.Size = new System.Drawing.Size(230, 20);
    102       this.textBoxRangeTo.TabIndex = 3;
    103       this.textBoxRangeTo.Leave += new System.EventHandler(this.textBoxRangeTo_Leave);
    104       //
    105       // textBoxRangeFrom
    106       //
    107       this.textBoxRangeFrom.Location = new System.Drawing.Point(10, 36);
    108       this.textBoxRangeFrom.Name = "textBoxRangeFrom";
    109       this.textBoxRangeFrom.Size = new System.Drawing.Size(230, 20);
    110       this.textBoxRangeFrom.TabIndex = 2;
    111       this.textBoxRangeFrom.Leave += new System.EventHandler(this.textBoxRangeFrom_Leave);
    112       //
    113       // label5
    114       //
    115       this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    116             | System.Windows.Forms.AnchorStyles.Right)));
    117       this.label5.AutoSize = true;
    118       this.label5.Location = new System.Drawing.Point(246, 20);
    119       this.label5.Name = "label5";
    120       this.label5.Size = new System.Drawing.Size(20, 13);
    121       this.label5.TabIndex = 1;
    122       this.label5.Text = "To";
    123       //
    124       // label6
    125       //
    126       this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    127             | System.Windows.Forms.AnchorStyles.Right)));
    128       this.label6.AutoSize = true;
    129       this.label6.Location = new System.Drawing.Point(7, 20);
    130       this.label6.Name = "label6";
    131       this.label6.Size = new System.Drawing.Size(30, 13);
    132       this.label6.TabIndex = 0;
    133       this.label6.Text = "From";
    134       //
    135       // groupBox2
    136       //
    137       this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    138             | System.Windows.Forms.AnchorStyles.Right)));
    139       this.groupBox2.Controls.Add(this.textBoxRangeTo);
    140       this.groupBox2.Controls.Add(this.textBoxRangeFrom);
    141       this.groupBox2.Controls.Add(this.label5);
    142       this.groupBox2.Controls.Add(this.label6);
    143       this.groupBox2.Location = new System.Drawing.Point(9, 151);
    144       this.groupBox2.Name = "groupBox2";
    145       this.groupBox2.Size = new System.Drawing.Size(487, 64);
    146       this.groupBox2.TabIndex = 18;
    147       this.groupBox2.TabStop = false;
    148       this.groupBox2.Text = "Range";
     92      this.numericRangeControl1.Location = new System.Drawing.Point(9, 145);
     93      this.numericRangeControl1.Name = "numericRangeControl1";
     94      this.numericRangeControl1.Size = new System.Drawing.Size(487, 112);
     95      this.numericRangeControl1.TabIndex = 18;
     96      this.numericRangeControl1.Load += new System.EventHandler(this.numericRangeControl1_Load);
    14997      //
    15098      // JsonItemRangeControl
     
    152100      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    153101      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    154       this.Controls.Add(this.groupBox2);
     102      this.Controls.Add(this.numericRangeControl1);
    155103      this.Controls.Add(this.groupBox1);
    156104      this.Name = "JsonItemRangeControl";
    157       this.Size = new System.Drawing.Size(500, 220);
     105      this.Size = new System.Drawing.Size(500, 262);
    158106      this.Controls.SetChildIndex(this.groupBox1, 0);
    159       this.Controls.SetChildIndex(this.groupBox2, 0);
     107      this.Controls.SetChildIndex(this.numericRangeControl1, 0);
    160108      this.groupBox1.ResumeLayout(false);
    161109      this.groupBox1.PerformLayout();
    162       this.groupBox2.ResumeLayout(false);
    163       this.groupBox2.PerformLayout();
    164110      this.ResumeLayout(false);
    165111      this.PerformLayout();
     
    174120    private System.Windows.Forms.Label label4;
    175121    private System.Windows.Forms.Label label2;
    176     private System.Windows.Forms.TextBox textBoxRangeTo;
    177     private System.Windows.Forms.TextBox textBoxRangeFrom;
    178     private System.Windows.Forms.Label label5;
    179     private System.Windows.Forms.Label label6;
    180     private System.Windows.Forms.GroupBox groupBox2;
     122    private Shared.NumericRangeControl numericRangeControl1;
    181123  }
    182124}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemRangeControl.cs

    r17404 r17405  
    3535
    3636    private void SetValue() {
    37       if (!string.IsNullOrWhiteSpace(textBoxRangeFrom.Text))
     37      if (!string.IsNullOrWhiteSpace(textBoxValueFrom.Text))
    3838        value[0] = Parse(textBoxValueFrom.Text);
    3939      else
    4040        value[0] = ((Array)VM.Item.Value).GetValue(0);
    4141
    42       if (!string.IsNullOrWhiteSpace(textBoxRangeTo.Text))
     42      if (!string.IsNullOrWhiteSpace(textBoxValueTo.Text))
    4343        value[1] = Parse(textBoxValueTo.Text);
    4444      else
     
    4646      VM.Item.Value = value;
    4747    }
    48 
    49     private void SetRange() {
    50       if (!string.IsNullOrWhiteSpace(textBoxRangeFrom.Text))
    51         range[0] = Parse(textBoxRangeFrom.Text);
    52       else
    53         range[0] = VM.Item.Range.First();
    54 
    55       if (!string.IsNullOrWhiteSpace(textBoxRangeTo.Text))
    56         range[1] = Parse(textBoxRangeTo.Text);
    57       else
    58         range[1] = VM.Item.Range.Last();
    59       VM.Item.Range = range;
    60     }
    61 
     48   
    6249    private void textBoxValueFrom_Leave(object sender, EventArgs e) {
    6350      SetValue();
     
    6855    }
    6956
    70     private void textBoxRangeFrom_Leave(object sender, EventArgs e) {
    71       SetRange();
    72     }
    73 
    74     private void textBoxRangeTo_Leave(object sender, EventArgs e) {
    75       SetRange();
     57    private void numericRangeControl1_Load(object sender, EventArgs e) {
     58      numericRangeControl1.IsDouble = isDouble;
     59      numericRangeControl1.VM = VM;
    7660    }
    7761  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.Designer.cs

    r17404 r17405  
    2424    /// </summary>
    2525    private void InitializeComponent() {
    26       this.textBoxAdd = new System.Windows.Forms.TextBox();
    2726      this.tableOptions = new System.Windows.Forms.TableLayoutPanel();
    28       this.buttonAdd = new System.Windows.Forms.Button();
    29       this.groupBox1 = new System.Windows.Forms.GroupBox();
    30       this.panel2 = new System.Windows.Forms.Panel();
     27      this.groupBoxRange = new System.Windows.Forms.GroupBox();
    3128      this.comboBoxValues = new System.Windows.Forms.ComboBox();
    32       this.tableOptions.SuspendLayout();
    33       this.groupBox1.SuspendLayout();
    34       this.panel2.SuspendLayout();
     29      this.label2 = new System.Windows.Forms.Label();
     30      this.groupBoxRange.SuspendLayout();
    3531      this.SuspendLayout();
    36       //
    37       // textBoxAdd
    38       //
    39       this.textBoxAdd.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    40             | System.Windows.Forms.AnchorStyles.Right)));
    41       this.textBoxAdd.Location = new System.Drawing.Point(3, 3);
    42       this.textBoxAdd.Name = "textBoxAdd";
    43       this.textBoxAdd.Size = new System.Drawing.Size(420, 20);
    44       this.textBoxAdd.TabIndex = 10;
    4532      //
    4633      // tableOptions
    4734      //
    48       this.tableOptions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     35      this.tableOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     36            | System.Windows.Forms.AnchorStyles.Left)
    4937            | System.Windows.Forms.AnchorStyles.Right)));
    5038      this.tableOptions.AutoSize = true;
    5139      this.tableOptions.ColumnCount = 2;
     40      this.tableOptions.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    5241      this.tableOptions.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
    53       this.tableOptions.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 43F));
    54       this.tableOptions.Controls.Add(this.textBoxAdd, 0, 0);
    55       this.tableOptions.Controls.Add(this.buttonAdd, 1, 0);
    56       this.tableOptions.Location = new System.Drawing.Point(3, 3);
     42      this.tableOptions.Location = new System.Drawing.Point(6, 19);
    5743      this.tableOptions.Name = "tableOptions";
    5844      this.tableOptions.RowCount = 1;
    5945      this.tableOptions.RowStyles.Add(new System.Windows.Forms.RowStyle());
    60       this.tableOptions.Size = new System.Drawing.Size(469, 73);
     46      this.tableOptions.Size = new System.Drawing.Size(478, 151);
    6147      this.tableOptions.TabIndex = 12;
    6248      //
    63       // buttonAdd
     49      // groupBoxRange
    6450      //
    65       this.buttonAdd.Location = new System.Drawing.Point(446, 3);
    66       this.buttonAdd.Name = "buttonAdd";
    67       this.buttonAdd.Size = new System.Drawing.Size(20, 20);
    68       this.buttonAdd.TabIndex = 12;
    69       this.buttonAdd.Text = "+";
    70       this.buttonAdd.UseVisualStyleBackColor = true;
    71       this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
    72       //
    73       // groupBox1
    74       //
    75       this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    76             | System.Windows.Forms.AnchorStyles.Right)));
    77       this.groupBox1.Controls.Add(this.panel2);
    78       this.groupBox1.Location = new System.Drawing.Point(6, 107);
    79       this.groupBox1.Name = "groupBox1";
    80       this.groupBox1.Size = new System.Drawing.Size(488, 104);
    81       this.groupBox1.TabIndex = 14;
    82       this.groupBox1.TabStop = false;
    83       this.groupBox1.Text = "Range";
    84       //
    85       // panel2
    86       //
    87       this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     51      this.groupBoxRange.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    8852            | System.Windows.Forms.AnchorStyles.Left)
    8953            | System.Windows.Forms.AnchorStyles.Right)));
    90       this.panel2.AutoScroll = true;
    91       this.panel2.Controls.Add(this.tableOptions);
    92       this.panel2.Location = new System.Drawing.Point(7, 20);
    93       this.panel2.Name = "panel2";
    94       this.panel2.Size = new System.Drawing.Size(475, 78);
    95       this.panel2.TabIndex = 0;
     54      this.groupBoxRange.AutoSize = true;
     55      this.groupBoxRange.Controls.Add(this.tableOptions);
     56      this.groupBoxRange.Location = new System.Drawing.Point(6, 108);
     57      this.groupBoxRange.Name = "groupBoxRange";
     58      this.groupBoxRange.Size = new System.Drawing.Size(490, 176);
     59      this.groupBoxRange.TabIndex = 14;
     60      this.groupBoxRange.TabStop = false;
     61      this.groupBoxRange.Text = "Range";
    9662      //
    9763      // comboBoxValues
     
    10167      this.comboBoxValues.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    10268      this.comboBoxValues.FormattingEnabled = true;
    103       this.comboBoxValues.Location = new System.Drawing.Point(92, 81);
     69      this.comboBoxValues.Location = new System.Drawing.Point(92, 75);
    10470      this.comboBoxValues.Name = "comboBoxValues";
    105       this.comboBoxValues.Size = new System.Drawing.Size(402, 21);
     71      this.comboBoxValues.Size = new System.Drawing.Size(404, 21);
    10672      this.comboBoxValues.TabIndex = 15;
     73      //
     74      // label2
     75      //
     76      this.label2.AutoSize = true;
     77      this.label2.Location = new System.Drawing.Point(6, 78);
     78      this.label2.Name = "label2";
     79      this.label2.Size = new System.Drawing.Size(34, 13);
     80      this.label2.TabIndex = 16;
     81      this.label2.Text = "Value";
    10782      //
    10883      // JsonItemValidValuesControl
     
    11085      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    11186      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     87      this.AutoSize = true;
     88      this.Controls.Add(this.label2);
    11289      this.Controls.Add(this.comboBoxValues);
    113       this.Controls.Add(this.groupBox1);
     90      this.Controls.Add(this.groupBoxRange);
    11491      this.ForeColor = System.Drawing.Color.Black;
    11592      this.Name = "JsonItemValidValuesControl";
    116       this.Size = new System.Drawing.Size(500, 217);
     93      this.Size = new System.Drawing.Size(500, 290);
    11794      this.Load += new System.EventHandler(this.JsonItemValidValuesControl_Load);
    118       this.Controls.SetChildIndex(this.groupBox1, 0);
     95      this.Controls.SetChildIndex(this.groupBoxRange, 0);
    11996      this.Controls.SetChildIndex(this.comboBoxValues, 0);
    120       this.tableOptions.ResumeLayout(false);
    121       this.tableOptions.PerformLayout();
    122       this.groupBox1.ResumeLayout(false);
    123       this.panel2.ResumeLayout(false);
    124       this.panel2.PerformLayout();
     97      this.Controls.SetChildIndex(this.label2, 0);
     98      this.groupBoxRange.ResumeLayout(false);
     99      this.groupBoxRange.PerformLayout();
    125100      this.ResumeLayout(false);
    126101      this.PerformLayout();
     
    129104
    130105    #endregion
    131     private System.Windows.Forms.TextBox textBoxAdd;
    132     private System.Windows.Forms.Button buttonAdd;
    133106    private System.Windows.Forms.TableLayoutPanel tableOptions;
    134     private System.Windows.Forms.GroupBox groupBox1;
    135     private System.Windows.Forms.Panel panel2;
     107    private System.Windows.Forms.GroupBox groupBoxRange;
    136108    private System.Windows.Forms.ComboBox comboBoxValues;
     109    private System.Windows.Forms.Label label2;
    137110  }
    138111}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.cs

    r17404 r17405  
    2121        }
    2222      }
     23
    2324    }
    2425
    2526    private void AddOption(string opt) {
    26       comboBoxValues.Items.Add(opt);
     27      AddComboOption(opt);
    2728      TextBox tb = new TextBox();
    2829      tb.Text = opt;
     
    3031      tb.Size = new Size(420, 20);
    3132      tb.ReadOnly = true;
    32       Button btn = new Button();
    33       btn.Text = "-";
    34       btn.Size = new Size(20, 20);
    35       btn.Click += (o, args) => {
    36         tableOptions.Controls.Remove(tb);
    37         tableOptions.Controls.Remove(btn);
    38         comboBoxValues.Items.Remove(tb.Text);
    39         IList<string> items = new List<string>();
    40         foreach(var i in comboBoxValues.Items) {
    41           items.Add((string)i);
    42         }
    43         VM.Item.Range = items;
    44         tableOptions.Refresh();
     33
     34      CheckBox checkBox = new CheckBox();
     35      checkBox.Checked = true;
     36     
     37      checkBox.CheckStateChanged += (o, args) => {
     38        if (checkBox.Checked)
     39          AddComboOption(opt);
     40        else
     41          RemoveComboOption(opt);
    4542      };
     43      tableOptions.Controls.Add(checkBox);
    4644      tableOptions.Controls.Add(tb);
    47       tableOptions.Controls.Add(btn);
    4845    }
    4946
    50     private void buttonAdd_Click(object sender, EventArgs e) {
    51       string newOption = textBoxAdd.Text;
    52       if (string.IsNullOrWhiteSpace(newOption)) return;
    53       textBoxAdd.Text = "";
    54       AddOption(newOption);
     47    private void AddComboOption(string opt) {
     48      comboBoxValues.Items.Add(opt);
     49      IList<string> items = new List<string>();
     50      foreach (var i in comboBoxValues.Items) {
     51        items.Add((string)i);
     52      }
     53      VM.Item.Range = items;
     54      tableOptions.Refresh();
    5555    }
    5656
     57    private void RemoveComboOption(string opt) {
     58      comboBoxValues.Items.Remove(opt);
     59      IList<string> items = new List<string>();
     60      foreach (var i in comboBoxValues.Items) {
     61        items.Add((string)i);
     62      }
     63      VM.Item.Range = items;
     64      tableOptions.Refresh();
     65    }
     66   
    5767    private void comboBoxValues_SelectedValueChanged(object sender, EventArgs e) {
    5868      VM.Item.Value = (string)comboBoxValues.SelectedItem;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValueControl.Designer.cs

    r17404 r17405  
    2525    private void InitializeComponent() {
    2626      this.textBoxValue = new System.Windows.Forms.TextBox();
    27       this.groupBox1 = new System.Windows.Forms.GroupBox();
    28       this.textBoxTo = new System.Windows.Forms.TextBox();
    29       this.textBoxFrom = new System.Windows.Forms.TextBox();
    30       this.label4 = new System.Windows.Forms.Label();
    3127      this.label2 = new System.Windows.Forms.Label();
    32       this.groupBox1.SuspendLayout();
     28      this.numericRangeControl1 = new HeuristicLab.JsonInterface.OptimizerIntegration.Shared.NumericRangeControl();
    3329      this.SuspendLayout();
    3430      //
     
    3733      this.textBoxValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    3834            | System.Windows.Forms.AnchorStyles.Right)));
    39       this.textBoxValue.Location = new System.Drawing.Point(92, 81);
     35      this.textBoxValue.Location = new System.Drawing.Point(92, 75);
    4036      this.textBoxValue.Name = "textBoxValue";
    41       this.textBoxValue.Size = new System.Drawing.Size(402, 20);
     37      this.textBoxValue.Size = new System.Drawing.Size(404, 20);
    4238      this.textBoxValue.TabIndex = 14;
    4339      this.textBoxValue.Leave += new System.EventHandler(this.textBoxValue_Leave);
    4440      //
    45       // groupBox1
    46       //
    47       this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    48             | System.Windows.Forms.AnchorStyles.Right)));
    49       this.groupBox1.Controls.Add(this.textBoxTo);
    50       this.groupBox1.Controls.Add(this.textBoxFrom);
    51       this.groupBox1.Controls.Add(this.label4);
    52       this.groupBox1.Controls.Add(this.label2);
    53       this.groupBox1.Location = new System.Drawing.Point(9, 107);
    54       this.groupBox1.Name = "groupBox1";
    55       this.groupBox1.Size = new System.Drawing.Size(487, 64);
    56       this.groupBox1.TabIndex = 15;
    57       this.groupBox1.TabStop = false;
    58       this.groupBox1.Text = "Range";
    59       //
    60       // textBoxTo
    61       //
    62       this.textBoxTo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    63             | System.Windows.Forms.AnchorStyles.Right)));
    64       this.textBoxTo.Location = new System.Drawing.Point(249, 36);
    65       this.textBoxTo.Name = "textBoxTo";
    66       this.textBoxTo.Size = new System.Drawing.Size(230, 20);
    67       this.textBoxTo.TabIndex = 3;
    68       this.textBoxTo.Leave += new System.EventHandler(this.textBoxTo_Leave);
    69       //
    70       // textBoxFrom
    71       //
    72       this.textBoxFrom.Location = new System.Drawing.Point(10, 36);
    73       this.textBoxFrom.Name = "textBoxFrom";
    74       this.textBoxFrom.Size = new System.Drawing.Size(230, 20);
    75       this.textBoxFrom.TabIndex = 2;
    76       this.textBoxFrom.Leave += new System.EventHandler(this.textBoxFrom_Leave);
    77       //
    78       // label4
    79       //
    80       this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    81             | System.Windows.Forms.AnchorStyles.Right)));
    82       this.label4.AutoSize = true;
    83       this.label4.Location = new System.Drawing.Point(246, 20);
    84       this.label4.Name = "label4";
    85       this.label4.Size = new System.Drawing.Size(20, 13);
    86       this.label4.TabIndex = 1;
    87       this.label4.Text = "To";
    88       //
    8941      // label2
    9042      //
    91       this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    92             | System.Windows.Forms.AnchorStyles.Right)));
    9343      this.label2.AutoSize = true;
    94       this.label2.Location = new System.Drawing.Point(7, 20);
     44      this.label2.Location = new System.Drawing.Point(6, 78);
    9545      this.label2.Name = "label2";
    96       this.label2.Size = new System.Drawing.Size(30, 13);
    97       this.label2.TabIndex = 0;
    98       this.label2.Text = "From";
     46      this.label2.Size = new System.Drawing.Size(34, 13);
     47      this.label2.TabIndex = 15;
     48      this.label2.Text = "Value";
     49      //
     50      // numericRangeControl1
     51      //
     52      this.numericRangeControl1.IsDouble = false;
     53      this.numericRangeControl1.Location = new System.Drawing.Point(9, 101);
     54      this.numericRangeControl1.Name = "numericRangeControl1";
     55      this.numericRangeControl1.Size = new System.Drawing.Size(487, 112);
     56      this.numericRangeControl1.TabIndex = 16;
     57      this.numericRangeControl1.VM = null;
     58      this.numericRangeControl1.Load += new System.EventHandler(this.numericRangeControl1_Load);
    9959      //
    10060      // JsonItemValueControl
     
    10262      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    10363      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    104       this.Controls.Add(this.groupBox1);
     64      this.Controls.Add(this.numericRangeControl1);
     65      this.Controls.Add(this.label2);
    10566      this.Controls.Add(this.textBoxValue);
    10667      this.Name = "JsonItemValueControl";
    107       this.Size = new System.Drawing.Size(500, 177);
     68      this.Size = new System.Drawing.Size(500, 220);
    10869      this.Controls.SetChildIndex(this.textBoxValue, 0);
    109       this.Controls.SetChildIndex(this.groupBox1, 0);
    110       this.groupBox1.ResumeLayout(false);
    111       this.groupBox1.PerformLayout();
     70      this.Controls.SetChildIndex(this.label2, 0);
     71      this.Controls.SetChildIndex(this.numericRangeControl1, 0);
    11272      this.ResumeLayout(false);
    11373      this.PerformLayout();
     
    11878
    11979    private System.Windows.Forms.TextBox textBoxValue;
    120     private System.Windows.Forms.GroupBox groupBox1;
    121     private System.Windows.Forms.TextBox textBoxTo;
    122     private System.Windows.Forms.TextBox textBoxFrom;
    123     private System.Windows.Forms.Label label4;
    12480    private System.Windows.Forms.Label label2;
     81    private Shared.NumericRangeControl numericRangeControl1;
    12582  }
    12683}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValueControl.cs

    r17404 r17405  
    1919      this.isDouble = isDouble;
    2020      textBoxValue.Text = VM.Item.Value.ToString();
    21       textBoxFrom.Text = VM.Item.Range.First().ToString();
    22       textBoxTo.Text = VM.Item.Range.Last().ToString();
    2321      range[0] = VM.Item.Range.First();
    2422      range[1] = VM.Item.Range.Last();
     
    2725    private object Parse(string s) {
    2826      if (isDouble) {
    29         if (s == "-1,79769313486232E+308") return double.MinValue;
    30         if (s == "1,79769313486232E+308") return double.MaxValue;
    3127        return double.Parse(s.Replace(",", "."), NumberStyles.Any, CultureInfo.InvariantCulture);
    3228      }
     
    3430    }
    3531
    36     private void SetRange() {
    37       if (!string.IsNullOrWhiteSpace(textBoxFrom.Text))
    38         range[0] = Parse(textBoxFrom.Text);
    39       else
    40         range[0] = VM.Item.Range.First();
    41 
    42       if (!string.IsNullOrWhiteSpace(textBoxTo.Text))
    43         range[1] = Parse(textBoxTo.Text);
    44       else
    45         range[1] = VM.Item.Range.Last();
    46       VM.Item.Range = range;
    47     }
    48 
    49     private void textBoxTo_Leave(object sender, EventArgs e) {
    50       SetRange();
    51     }
    52 
    53     private void textBoxFrom_Leave(object sender, EventArgs e) {
    54       SetRange();
    55     }
    5632
    5733    private void textBoxValue_Leave(object sender, EventArgs e) {
     
    5935        VM.Item.Value = Parse(textBoxValue.Text);
    6036    }
     37
     38    private void numericRangeControl1_Load(object sender, EventArgs e) {
     39      numericRangeControl1.IsDouble = isDouble;
     40      numericRangeControl1.VM = VM;
     41    }
    6142  }
    6243}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Constants.cs

    r17395 r17405  
    1616    internal const string HLFileLocation = "HLFileLocation";
    1717    internal const string Parameters = "Parameters";
     18    internal const string ActivatedResults = "ActivatedResults";
    1819
    1920    internal const string Template = @"{
     
    2324        '" + HLFileLocation + @"':''
    2425      },
    25       '" + Parameters + @"': []
     26      '" + Parameters + @"': [],
     27      '" + ActivatedResults + @"': []
    2628    }";
    2729  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs

    r17395 r17405  
    2424      base.Populate(value, item, root);
    2525      IAlgorithm algorithm = value as IAlgorithm;
     26      foreach(var res in algorithm.Results) {
     27        item.AddChilds(new ResultItem() {
     28          Name = res.Name,
     29          Value = true,
     30          Range = new object[] { true, false }
     31        });
     32      }
    2633      item.AddChilds(root.Extract(algorithm.Problem, root));
    2734    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj

    r17395 r17405  
    6666    <Compile Include="Converters\ValueLookupParameterConverter.cs" />
    6767    <Compile Include="Converters\ValueRangeConverter.cs" />
     68    <Compile Include="ResultItem.cs" />
    6869    <Compile Include="SingleLineArrayJsonWriter.cs" />
    6970    <Compile Include="Extensions\TypeExtensions.cs" />
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JCGenerator.cs

    r17404 r17405  
    2020    private IOptimizer Optimizer { get; set; }
    2121
     22   
    2223    public string GenerateTemplate(IOptimizer optimizer) {
    2324      // data container
     
    3334      // which have parameters aswell
    3435      AddIItem(optimizer);
    35 
    3636      // save the JArray with JsonItems (= IParameterizedItems)
    3737      Template[Constants.Parameters] = JArrayItems;
     
    4545      Template[Constants.Metadata][Constants.HLFileLocation] = @"C:\Workspace\template.hl";
    4646
     47      JArray ResultItems = new JArray();
     48
    4749      JArrayItems = new JArray();
    4850      foreach (var item in items) {
    49         JArrayItems.Add(Serialize(item));
     51        if (item is ResultItem)
     52          ResultItems.Add(Serialize(item));
     53        else
     54          JArrayItems.Add(Serialize(item));
    5055      }
    5156      Template[Constants.Parameters] = JArrayItems;
     57      Template[Constants.ActivatedResults] = ResultItems;
     58
     59      // serialize template and return string
     60      return SingleLineArrayJsonWriter.Serialize(Template);
     61    }
     62
     63    public string GenerateTemplate(JsonItem rootItem, IOptimizer optimizer) {
     64      // data container
     65      Template = JObject.Parse(Constants.Template);
     66      JsonItems = new List<JsonItem>();
     67
     68      // extract JsonItem, save the name in the metadata section of the
     69      // template and save it an JArray incl. all parameters of the JsonItem,
     70      // which have parameters aswell
     71      Template[Constants.Metadata][Constants.Optimizer] = optimizer.Name;
     72      PopulateJsonItems(rootItem);
     73
     74      ProtoBufSerializer serializer = new ProtoBufSerializer();
     75      serializer.Serialize(Optimizer, @"C:\Workspace\template.hl");
     76      Template[Constants.Metadata][Constants.HLFileLocation] = @"C:\Workspace\template.hl";
     77
     78      JArray ResultItems = new JArray();
     79
     80      JArrayItems = new JArray();
     81      foreach (var item in JsonItems) {
     82        if (item is ResultItem)
     83          ResultItems.Add(Serialize(item));
     84        else
     85          JArrayItems.Add(Serialize(item));
     86      }
     87      Template[Constants.Parameters] = JArrayItems;
     88      Template[Constants.ActivatedResults] = ResultItems;
    5289
    5390      // serialize template and return string
     
    81118    private void PopulateJsonItems(JsonItem item) {
    82119      IEnumerable<JsonItem> tmpParameter = item.Children;
    83 
    84       if (item.Value != null || item.Range != null) {
     120     
     121      if (item.Value != null || item.Range != null || item is ResultItem || item.ActualName != null) {
    85122        JsonItems.Add(item);
    86123      }
Note: See TracChangeset for help on using the changeset viewer.