Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/19/16 08:38:56 (8 years ago)
Author:
abeham
Message:

#2560: changed characteristic calculator to output IItem instead of double

Location:
trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.Designer.cs

    r13540 r13550  
    216216      this.calculatorListView.UseCompatibleStateImageBehavior = false;
    217217      this.calculatorListView.View = System.Windows.Forms.View.Details;
     218      this.calculatorListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.calculatorListView_ItemChecked);
    218219      //
    219220      // characteristicColumnHeader
  • trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.cs

    r13540 r13550  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Globalization;
    2524using System.Linq;
    2625using System.Windows.Forms;
     
    9291      uploadCharacteristicsButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly
    9392        && characteristicsMatrixView.Content != null && characteristicsMatrixView.Content.Rows > 0;
     93      calculateButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly && calculatorListView.CheckedItems.Count > 0;
    9494    }
    9595
     
    114114            var item = calculatorListView.Items.Add(c, c);
    115115            item.Group = group;
     116            item.Checked = true;
    116117          }
    117118        }
     
    186187      try {
    187188        RunCreationClient.SetCharacteristicValues(Content.ProblemId, values);
    188       } catch (Exception ex) { PluginInfrastructure.ErrorHandling.ShowErrorDialog(ex); }
     189      } catch (Exception ex) { ErrorHandling.ShowErrorDialog(ex); }
    189190    }
    190191    private void calculateButton_Click(object sender, EventArgs e) {
     192      var characteristics = calculatorListView.CheckedItems.OfType<ListViewItem>().GroupBy(x => x.Group).ToList();
     193      if (characteristics.Count == 0) return;
    191194      var problem = Content.CloneProblem();
    192       var characteristics = calculatorListView.CheckedItems.OfType<ListViewItem>().GroupBy(x => x.Group);
    193       var results = new Dictionary<string, double>();
     195      var results = new Dictionary<string, Value>();
    194196      foreach (var c in characteristics) {
    195197        var calc = (ICharacteristicCalculator)c.Key.Tag;
    196198        foreach (var result in calc.Calculate(problem, c.Select(x => x.Text).ToArray()))
    197           results[result.Key] = result.Value;
    198       }
    199       var matrix = characteristicsMatrixView.Content as StringMatrix;
    200       if (matrix == null) matrix = new StringMatrix(results.Count, 3);
     199          results[result.Key] = RunCreationClient.Instance.ConvertToValue(result.Value, result.Key);
     200      }
     201      var matrix = (characteristicsMatrixView.Content as StringMatrix) ?? (new StringMatrix(results.Count, 3));
    201202      for (var i = 0; i < matrix.Rows; i++) {
    202         double r;
     203        Value r;
    203204        if (results.TryGetValue(matrix[i, 0], out r)) {
    204           matrix[i, 1] = r.ToString(CultureInfo.CurrentCulture.NumberFormat);
    205           matrix[i, 2] = "DoubleValue";
     205          matrix[i, 1] = r.GetValue();
     206          matrix[i, 2] = r.GetType().Name;
    206207          results.Remove(matrix[i, 0]);
    207208        }
     
    213214        if (string.IsNullOrEmpty(matrix[i, 0])) {
    214215          matrix[i, 0] = resultsList[counter].Key;
    215           matrix[i, 1] = resultsList[counter].Value.ToString(CultureInfo.CurrentCulture.NumberFormat);
    216           matrix[i, 2] = "DoubleValue";
     216          matrix[i, 1] = resultsList[counter].Value.GetValue();
     217          matrix[i, 2] = resultsList[counter].Value.GetType().Name;
    217218          resultsList.RemoveAt(counter);
    218219          counter--;
     
    224225        for (var i = matrix.Rows - 1; counter >= 0; i--) {
    225226          matrix[i, 0] = resultsList[0].Key;
    226           matrix[i, 1] = resultsList[0].Value.ToString(CultureInfo.CurrentCulture.NumberFormat);
    227           matrix[i, 2] = "DoubleValue";
     227          matrix[i, 1] = resultsList[0].Value.GetValue();
     228          matrix[i, 2] = resultsList[0].Value.GetType().Name;
     229          resultsList.RemoveAt(0);
    228230          counter--;
    229231        }
    230232      }
     233      SetEnabledStateOfControls();
     234    }
     235    private void calculatorListView_ItemChecked(object sender, ItemCheckedEventArgs e) {
     236      SetEnabledStateOfControls();
    231237    }
    232238    #endregion
     
    239245    }
    240246    #endregion
     247
    241248  }
    242249}
Note: See TracChangeset for help on using the changeset viewer.