Changeset 16545


Ignore:
Timestamp:
01/22/19 11:59:54 (10 months ago)
Author:
chaider
Message:

#2971

  • Added ReadOnly field to NamedIntervals
  • Changes at cell validation of NamedIntervalsView
  • Added save on value changed
Location:
branches/2971_named_intervals
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/NamedIntervalsView.cs

    r16544 r16545  
    6565      base.SetEnabledStateOfControls();
    6666      dataGridView.Enabled = Content != null;
    67       dataGridView.ReadOnly = ReadOnly;
     67      //dataGridView.ReadOnly = ReadOnly;
    6868    }
    6969
     
    108108
    109109    private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) {
    110      
     110      var key = dataGridView.Rows[e.RowIndex].HeaderCell.Value.ToString();
     111
     112      if (e.ColumnIndex < 0 || e.RowIndex < 0) return;
     113
     114      var lowerBound = e.ColumnIndex == 0 ? double.Parse(dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()) : Content.VariableIntervals[key].LowerBound;
     115      var upperBound = e.ColumnIndex == 1 ? double.Parse(dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()) : Content.VariableIntervals[key].UpperBound;
     116
     117      Content.VariableIntervals[key] = new Interval(lowerBound, upperBound);
    111118    }
    112119
     
    114121      double value;
    115122
     123      if (dataGridView.Rows[e.RowIndex].IsNewRow) {
     124        return;
     125      }
     126
    116127      if (!double.TryParse(e.FormattedValue.ToString(), out value)) {
    117         dataGridView.Rows[e.RowIndex].ErrorText = "Value has to be a double value";
    118128        e.Cancel = true;
    119       } else if (string.IsNullOrEmpty(e.FormattedValue.ToString())) {
    120         dataGridView.Rows[e.RowIndex].ErrorText = "Value has to best";
    121         e.Cancel = true;
    122       } else if (double.Parse(dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString()) >
    123                  double.Parse(dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString())) {
    124         dataGridView.Rows[e.RowIndex].ErrorText = "Lower Bound of Interval has to be smaller than Upper Bound";
    125         e.Cancel = true;
     129        dataGridView.Rows[e.RowIndex].ErrorText = "Value must be a double value.";
     130      } else {
     131        if (e.ColumnIndex == 0 && value > double.Parse(dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString()) ||
     132            e.ColumnIndex == 1 && value < double.Parse(dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString())) {
     133          e.Cancel = true;
     134          dataGridView.Rows[e.RowIndex].ErrorText = "Lower Bound of Interval must be smaller than Upper Bound.";
     135        }
    126136      }
     137     
    127138    }
    128139
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/NamedIntervals.cs

    r16544 r16545  
    2626    public ObservableDictionary<string, Interval> VariableIntervals => variableIntervals;
    2727
     28    public bool ReadOnly { get; }
     29
    2830    public bool InsertMany(IEnumerable<KeyValuePair<string, Interval>> entries) {
    2931      if (entries == null) throw new ArgumentNullException("The given dataset is null.");
Note: See TracChangeset for help on using the changeset viewer.