Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/03/20 15:13:35 (4 years ago)
Author:
dpiringe
Message:

#3026:

  • added initial VM (ArrayValueVM) and control for array values (JsonItemArrayValueControl)
  • new types of JsonItems for better type safety:
    • for arrays: DoubleArrayJsonItem, IntArrayJsonItem, BoolArrayJsonItem
    • for matrix: DoubleMatrixJsonItem, IntMatrixJsonItem, BoolMatrixJsonItem
  • refactored ValueTypeArrayConverter and ValueTypeMatrixConverter -> better type safety with new JsonItems
  • enhanced StringValueVM and implemented JsonItemValidValuesControl with MVVM architecture
  • the VM of JsonItemBaseControl is now protected (was private)
  • improved JsonItem<V,R> -> now handles JTokens correctly
Location:
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration
Files:
3 added
7 edited

Legend:

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

    r17411 r17417  
    7878  </ItemGroup>
    7979  <ItemGroup>
    80     <Compile Include="Interfaces\IJsonItemValueParser.cs" />
    81     <Compile Include="Parser\JsonItemDoubleValueParser.cs" />
    82     <Compile Include="Parser\JsonItemIntValueParser.cs" />
    8380    <Compile Include="Properties\Resources.Designer.cs">
    8481      <AutoGen>True</AutoGen>
     
    9895      <DependentUpon>NumericRangeControl.cs</DependentUpon>
    9996    </Compile>
     97    <Compile Include="ViewModels\ArrayValueVM.cs" />
    10098    <Compile Include="ViewModels\JsonItemVMBase.cs" />
    10199    <Compile Include="ViewModels\RangeVM.cs" />
     
    109107    </Compile>
    110108    <Compile Include="FileManager.cs" />
     109    <Compile Include="Views\JsonItemArrayValueControl.cs">
     110      <SubType>UserControl</SubType>
     111    </Compile>
     112    <Compile Include="Views\JsonItemArrayValueControl.Designer.cs">
     113      <DependentUpon>JsonItemArrayValueControl.cs</DependentUpon>
     114    </Compile>
    111115    <Compile Include="Views\JsonItemBoolControl.cs">
    112116      <SubType>UserControl</SubType>
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/JsonItemBaseControl.cs

    r17410 r17417  
    1111namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    1212  public partial class JsonItemBaseControl : UserControl {
    13     private JsonItemVMBase VM { get; set; }
     13    protected JsonItemVMBase VM { get; set; }
    1414
    1515    private JsonItemBaseControl() {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/StringValueVM.cs

    r17412 r17417  
    1212
    1313    public string Value {
    14       get => Item.Value.ToString();
     14      get => Item.Value?.ToString();
    1515      set {
    1616        Item.Value = value;
     
    1818      }
    1919    }
     20
     21    public IEnumerable<string> Range {
     22      get => Item.Range.Cast<string>();
     23      set {
     24        Item.Range = value;
     25        //check if value is still in range
     26        if (!Range.Any(x => x == Value)) {
     27          Value = Range.FirstOrDefault();
     28          if (Range.Count() == 0)
     29            //if no elements exists -> deselect item
     30            base.Selected = false;
     31          OnPropertyChange(this, nameof(Value));
     32        }
     33       
     34        OnPropertyChange(this, nameof(Range));
     35      }
     36    }
    2037  }
    2138}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs

    r17412 r17417  
    4242
    4343    private IDictionary<Type, Type> JI2VM { get; set; }
    44 
    4544
    4645    private void InitCache() {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.Designer.cs

    r17410 r17417  
    4444      this.tableOptions.RowCount = 1;
    4545      this.tableOptions.RowStyles.Add(new System.Windows.Forms.RowStyle());
    46       this.tableOptions.Size = new System.Drawing.Size(478, 151);
     46      this.tableOptions.Size = new System.Drawing.Size(478, 137);
    4747      this.tableOptions.TabIndex = 12;
    4848      //
     
    5656      this.groupBoxRange.Location = new System.Drawing.Point(6, 108);
    5757      this.groupBoxRange.Name = "groupBoxRange";
    58       this.groupBoxRange.Size = new System.Drawing.Size(490, 176);
     58      this.groupBoxRange.Size = new System.Drawing.Size(490, 162);
    5959      this.groupBoxRange.TabIndex = 14;
    6060      this.groupBoxRange.TabStop = false;
     
    9191      this.ForeColor = System.Drawing.Color.Black;
    9292      this.Name = "JsonItemValidValuesControl";
    93       this.Size = new System.Drawing.Size(500, 290);
     93      this.Size = new System.Drawing.Size(500, 276);
    9494      this.Controls.SetChildIndex(this.groupBoxRange, 0);
    9595      this.Controls.SetChildIndex(this.comboBoxValues, 0);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.cs

    r17410 r17417  
    1414    public JsonItemValidValuesControl(StringValueVM vm) : base(vm) {
    1515      InitializeComponent();
    16       /*
    17       foreach (var i in VM.Item.Range) {
    18         AddOption((string)i);
    19         if(i == VM.Item.Value) {
    20           comboBoxValues.SelectedItem = (string)i;
    21         }
    22       }*/
     16      foreach (var i in VM.Item.Range)
     17        SetupOption((string)i);
     18
     19      comboBoxValues.DataBindings.Add("SelectedItem", VM, nameof(StringValueVM.Value));
    2320    }
    24     /*
    25     private void AddOption(string opt) {
     21   
     22    private void SetupOption(string opt) {
    2623      AddComboOption(opt);
    2724      TextBox tb = new TextBox();
     
    5047        items.Add((string)i);
    5148      }
    52       VM.Item.Range = items;
     49      ((StringValueVM)VM).Range = items;
     50      comboBoxValues.Enabled = true;
    5351      tableOptions.Refresh();
    5452    }
     
    6058        items.Add((string)i);
    6159      }
    62       VM.Item.Range = items;
     60      ((StringValueVM)VM).Range = items;
     61      if (((StringValueVM)VM).Range.Count() <= 0) {
     62        comboBoxValues.Enabled = false;
     63        comboBoxValues.SelectedIndex = -1;
     64      }
    6365      tableOptions.Refresh();
    6466    }
    65    
    66     private void comboBoxValues_SelectedValueChanged(object sender, EventArgs e) {
    67       VM.Item.Value = (string)comboBoxValues.SelectedItem;
    68     }
    69 
    70     private void JsonItemValidValuesControl_Load(object sender, EventArgs e) {
    71 
    72     }
    73     */
    7467  }
    7568}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValueControl.cs

    r17411 r17417  
    1313
    1414  public class JsonItemIntValueControl : JsonItemValueControl {
    15     private readonly IntValueVM vm;
    1615
    1716    #region Overriden Properties
    18     protected override object VM => vm;
    1917    protected override string ValuePropertyId => nameof(IntValueVM.Value);
    2018    protected override string MinRangePropertyId => nameof(IntValueVM.MinRange);
     
    2523
    2624    public JsonItemIntValueControl(IntValueVM vm) : base(vm) {
    27       this.vm = vm;
    2825      Init();
    2926    }
     
    3229
    3330  public class JsonItemDoubleValueControl : JsonItemValueControl {
    34     private readonly DoubleValueVM vm;
    3531
    3632    #region Overriden Properties
    37     protected override object VM => vm;
    3833    protected override string ValuePropertyId => nameof(DoubleValueVM.Value);
    3934    protected override string MinRangePropertyId => nameof(DoubleValueVM.MinRange);
     
    4439
    4540    public JsonItemDoubleValueControl(DoubleValueVM vm) : base(vm) {
    46       this.vm = vm;
    4741      Init();
    4842    }
     
    5751
    5852    #region Abstract Properties
    59     protected abstract object VM { get; }
    6053    protected abstract string ValuePropertyId { get; }
    6154    protected abstract string MinRangePropertyId { get; }
     
    7265
    7366    protected void Init() {
    74       TBValue.DataBindings.Add("Text", VM, ValuePropertyId);
     67      TBValue.DataBindings.Add("Text", base.VM, ValuePropertyId);
    7568      NumericRangeControl.TBMinRange.DataBindings.Add("Text", VM, MinRangePropertyId);
    7669      NumericRangeControl.TBMaxRange.DataBindings.Add("Text", VM, MaxRangePropertyId);
Note: See TracChangeset for help on using the changeset viewer.