Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10947 for branches


Ignore:
Timestamp:
06/04/14 14:57:45 (10 years ago)
Author:
rstoll
Message:
  • Changed ComparisonFilter, using DoubleValue and DateTime rather than just StringValue
  • Included better input validation for ComparisonFilterView
  • Bug "Search and Sorted DataGridContentView" fixed
Location:
branches/DataPreprocessing
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/ComparisonFilterView.Designer.cs

    r10693 r10947  
    9191      this.cbAttr.Location = new System.Drawing.Point(92, 12);
    9292      this.cbAttr.Name = "cbAttr";
    93       this.cbAttr.Size = new System.Drawing.Size(247, 21);
     93      this.cbAttr.Size = new System.Drawing.Size(235, 21);
    9494      this.cbAttr.TabIndex = 3;
    9595      this.cbAttr.SelectedIndexChanged += new System.EventHandler(this.cbAttr_SelectedIndexChanged);
     
    103103      this.cbFilterOperation.Location = new System.Drawing.Point(92, 39);
    104104      this.cbFilterOperation.Name = "cbFilterOperation";
    105       this.cbFilterOperation.Size = new System.Drawing.Size(247, 21);
     105      this.cbFilterOperation.Size = new System.Drawing.Size(235, 21);
    106106      this.cbFilterOperation.TabIndex = 4;
    107107      this.cbFilterOperation.SelectedIndexChanged += new System.EventHandler(this.cbFilterOperation_SelectedIndexChanged);
     
    113113      this.tbFilterData.Location = new System.Drawing.Point(92, 67);
    114114      this.tbFilterData.Name = "tbFilterData";
    115       this.tbFilterData.Size = new System.Drawing.Size(247, 20);
     115      this.tbFilterData.Size = new System.Drawing.Size(235, 20);
    116116      this.tbFilterData.TabIndex = 5;
    117117      this.tbFilterData.Validating += new System.ComponentModel.CancelEventHandler(this.tbFilterData_Validating);
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/ComparisonFilterView.cs

    r10735 r10947  
    2020#endregion
    2121
     22using System;
    2223using System.Linq;
     24using HeuristicLab.Core;
    2325using HeuristicLab.Core.Views;
    24 using HeuristicLab.Core;
    2526using HeuristicLab.Data;
    2627using HeuristicLab.DataPreprocessing.Filter;
    2728using HeuristicLab.MainForm;
    28 using System.Collections;
    29 using System;
    30 using System.Collections.Generic;
    3129
    3230namespace HeuristicLab.DataPreprocessing.Views {
     
    4442
    4543
    46     protected override void OnContentChanged()
    47     {
     44    protected override void OnContentChanged() {
    4845      base.OnContentChanged();
    4946      cbAttr.Items.Clear(); //cmbConstraintColumn.Items.Clear();
    5047      cbFilterOperation.Items.Clear(); //cmbConstraintOperation.Items.Clear();
    5148      tbFilterData.Text = string.Empty;
    52       if (Content != null)
    53       {
     49      if (Content != null) {
    5450        cbFilterOperation.Items.AddRange(Content.AllowedConstraintOperations.ToArray());
    5551        if (Content.ConstraintOperation != null)
     
    5955        UpdateColumnComboBox();
    6056        ReadOnly = Content.Active;
    61         if (Content.ConstraintData != null)
    62         {
     57        if (Content.ConstraintData != null) {
    6358          tbFilterData.Text = Content.ConstraintData.GetValue();
    64         }
    65         else
    66         {
     59        } else {
    6760          this.Content_ConstraintColumnChanged(cbAttr, EventArgs.Empty); // TODO
    6861        }
    6962      }
    70       if (Content == null || Content.ConstraintData == null)
    71       {
     63      if (Content == null || Content.ConstraintData == null) {
    7264        tbFilterData.Text = string.Empty;
    73       }
    74       else
    75       {
     65      } else {
    7666        tbFilterData.Text = Content.ConstraintData.GetValue();
    7767      }
    7868    }
    7969
    80     protected virtual void UpdateColumnComboBox()
    81     {
     70    protected virtual void UpdateColumnComboBox() {
    8271      this.cbAttr.Items.Clear();
    83       if (Content.ConstrainedValue != null)
    84       {
     72      if (Content.ConstrainedValue != null) {
    8573        this.cbAttr.Items.AddRange(Content.ConstrainedValue.VariableNames.ToArray<string>());
    8674        //if (!string.IsNullOrEmpty(Content.ConstraintColumn))
     
    8977        //if (Content.ConstraintColumn != null)
    9078        //{
    91           cbAttr.SelectedItem = Content.ConstraintColumn;
    92           if (Content.ConstraintData != null)
    93             tbFilterData.Text = Content.ConstraintData.GetValue();
    94           else
    95             this.Content_ConstraintColumnChanged(cbAttr, EventArgs.Empty);
     79        cbAttr.SelectedItem = Content.ConstraintColumn;
     80        if (Content.ConstraintData != null)
     81          tbFilterData.Text = Content.ConstraintData.GetValue();
     82        else
     83          this.Content_ConstraintColumnChanged(cbAttr, EventArgs.Empty);
    9684        //}
    9785      }
    9886    }
    9987
    100     protected override void RegisterContentEvents()
    101     {
     88    protected override void RegisterContentEvents() {
    10289      base.RegisterContentEvents();
    10390      this.Content.ActiveChanged += new EventHandler(Content_ActiveChanged);
     
    10895    }
    10996
    110     protected override void DeregisterContentEvents()
    111     {
     97    protected override void DeregisterContentEvents() {
    11298      base.DeregisterContentEvents();
    11399      this.Content.ActiveChanged -= new EventHandler(Content_ActiveChanged);
     
    118104    }
    119105
    120     protected virtual void Content_ConstrainedValueChanged(object sender, EventArgs e)
    121     {
     106    protected virtual void Content_ConstrainedValueChanged(object sender, EventArgs e) {
    122107      this.UpdateColumnComboBox();
    123108    }
    124109
    125     private void Content_ConstrainedDataChanged(object sender, EventArgs e)
    126     {
     110    private void Content_ConstrainedDataChanged(object sender, EventArgs e) {
    127111      if (Content.ConstraintData != null)
    128112        tbFilterData.Text = Content.ConstraintData.GetValue();
     
    131115    }
    132116
    133     protected virtual void Content_ConstraintColumnChanged(object sender, EventArgs e)
    134     {
    135       if (Content.ConstrainedValue != null)
    136       {
    137         if (cbAttr.Items.IndexOf(cbAttr.SelectedItem) != Content.ConstraintColumn)
    138         {
     117    protected virtual void Content_ConstraintColumnChanged(object sender, EventArgs e) {
     118      if (Content.ConstrainedValue != null) {
     119        if (cbAttr.Items.IndexOf(cbAttr.SelectedItem) != Content.ConstraintColumn) {
    139120          cbAttr.SelectedItem = this.cbAttr.Items[Content.ConstraintColumn];
    140121        }
    141122      }
    142       if (Content.ConstraintData == null)
    143         this.Content.ConstraintData = new StringValue();
     123      if (Content.ConstraintData == null) {
     124        this.Content.ConstraintData = CreateStringConvertibleValue(cbAttr.SelectedIndex);
     125      }
    144126    }
    145127
    146128
    147     protected virtual void Content_ComparisonOperationChanged(object sender, EventArgs e)
    148     {
     129    protected virtual void Content_ComparisonOperationChanged(object sender, EventArgs e) {
    149130      if (Content.ConstraintOperation != (ConstraintOperation)this.cbFilterOperation.SelectedItem)
    150131        this.cbFilterOperation.SelectedItem = Content.ConstraintOperation;
    151132    }
    152133
    153     protected override void SetEnabledStateOfControls()
    154     {
     134    protected override void SetEnabledStateOfControls() {
    155135      base.SetEnabledStateOfControls();
    156136      /*
     
    165145    }
    166146
    167     private void cbAttr_SelectedIndexChanged(object sender, EventArgs e)
    168     {
    169       if (Content.ConstrainedValue != null)
    170       {
     147    private void cbAttr_SelectedIndexChanged(object sender, EventArgs e) {
     148      if (Content.ConstrainedValue != null) {
    171149        Content.ConstraintColumn = Content.ConstrainedValue.GetColumnIndex(cbAttr.SelectedItem.ToString());
    172150      }
    173151    }
    174152
    175     private void cbFilterOperation_SelectedIndexChanged(object sender, EventArgs e)
    176     {
     153    private void cbFilterOperation_SelectedIndexChanged(object sender, EventArgs e) {
    177154      Content.ConstraintOperation = (ConstraintOperation)this.cbFilterOperation.SelectedItem;
    178155    }
    179156
    180     protected virtual void Content_ActiveChanged(object sender, EventArgs e)
    181     {
     157    protected virtual void Content_ActiveChanged(object sender, EventArgs e) {
    182158      this.ReadOnly = !Content.Active;
    183159      SetEnabledStateOfControls();
     
    185161    }
    186162
    187     private void tbFilterData_Validated(object sender, EventArgs e)
    188     {
    189       IStringConvertibleValue value = new StringValue();
    190         value.SetValue(tbFilterData.Text);
    191         Content.ConstraintData = value;
     163    private void tbFilterData_Validated(object sender, EventArgs e) {
     164      IStringConvertibleValue value = CreateStringConvertibleValue(cbAttr.SelectedIndex);
     165      value.SetValue(tbFilterData.Text);
     166      Content.ConstraintData = value;
    192167    }
    193168
    194     private void tbFilterData_Validating(object sender, System.ComponentModel.CancelEventArgs e)
    195     {
    196         string errorMessage = string.Empty;
    197         if (!Content.ConstraintData.Validate(tbFilterData.Text, out errorMessage))
    198         {
    199           errorProvider.SetError(tbFilterData, errorMessage);
    200           e.Cancel = true;
    201         }
    202         else
    203           errorProvider.Clear();
     169    private IStringConvertibleValue CreateStringConvertibleValue(int columnIndex) {
     170      IStringConvertibleValue value;
     171      if (Content.ConstrainedValue.IsType<double>(columnIndex)) {
     172        value = new DoubleValue();
     173      } else if (Content.ConstrainedValue.IsType<String>(columnIndex)) {
     174        value = new StringValue();
     175      } else if (Content.ConstrainedValue.IsType<DateTime>(columnIndex)) {
     176        value = new DateTimeValue();
     177      } else {
     178        throw new ArgumentException("unsupported type");
     179      }
     180      return value;
     181    }
     182
     183    private void tbFilterData_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
     184      string errorMessage = string.Empty;
     185      if (!Content.ConstraintData.Validate(tbFilterData.Text, out errorMessage)) {
     186        errorProvider.SetError(tbFilterData, errorMessage);
     187        e.Cancel = true;
     188      } else
     189        errorProvider.Clear();
    204190    }
    205191
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/CopyOfStringConvertibleMatrixView.cs

    r10916 r10947  
    104104    }
    105105
     106    // Was private before
     107    protected void Sort() {
     108      virtualRowIndices = Sort(sortedColumnIndices);
     109      UpdateSortGlyph();
     110      UpdateRowHeaders();
     111      dataGridView.Invalidate();
     112    }
     113
     114    // Was private before
     115    protected List<KeyValuePair<int, SortOrder>> sortedColumnIndices;
     116
    106117    #region unchanged copied from original - see  HeuristicLab.Data.Views.StringConvertibleMatrix
    107118
    108119    protected int[] virtualRowIndices;
    109     private List<KeyValuePair<int, SortOrder>> sortedColumnIndices;
    110120    private RowComparer rowComparer;
    111121
     
    293303    private Point[] GetSelectedCellsAsPoints() {
    294304      Point[] points = new Point[dataGridView.SelectedCells.Count];
    295       for (int i = 0; i < dataGridView.SelectedCells.Count; i++)
    296       {
     305      for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
    297306        points[i].X = dataGridView.SelectedCells[i].ColumnIndex;
    298307        points[i].Y = dataGridView.SelectedCells[i].RowIndex;
     
    487496    }
    488497
    489     private void Sort() {
    490       virtualRowIndices = Sort(sortedColumnIndices);
    491       UpdateSortGlyph();
    492       UpdateRowHeaders();
    493       dataGridView.Invalidate();
    494     }
    495498    protected virtual int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {
    496499      int[] newSortedIndex = Enumerable.Range(0, Content.Rows).ToArray();
     
    597600    }
    598601
    599    
     602
    600603  }
    601604    #endregion
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs

    r10946 r10947  
    7373      dataGridView.KeyDown += dataGridView_KeyDown;
    7474      dataGridView.MouseUp += dataGridView_MouseUp;
     75      dataGridView.ColumnHeaderMouseClick += dataGridView_ColumnHeaderMouseClick;
    7576      contextMenuCell.Items.Add(ShowHideColumns);
    7677      _highlightedRowIndices = new List<int>();
     
    7980    }
    8081
     82    private void dataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
     83      searchIterator = null;
     84    }
     85
    8186    protected override void dataGridView_SelectionChanged(object sender, EventArgs e) {
    8287      if (Content != null) {
     
    8792            return;
    8893          }
    89            
     94
    9095          base.dataGridView_SelectionChanged(sender, e);
    91        
     96
    9297          Content.DataGridLogic.SetSelection(GetSelectedCells());
    9398        }
     
    96101
    97102    private void dataGridView_MouseUp(object sender, MouseEventArgs e) {
    98       if (!updateOnMouseUp) 
     103      if (!updateOnMouseUp)
    99104        return;
    100105
    101106      updateOnMouseUp = false;
    102107      dataGridView_SelectionChanged(sender, e);
    103     }                                     
     108    }
    104109
    105110    protected override void OnContentChanged() {
     
    250255
    251256    void findAndReplaceDialog_FindNextEvent(object sender, EventArgs e) {
    252       if (searchIterator == null ||
    253         currentSearchText != findAndReplaceDialog.GetSearchText() ||
    254         currentComparisonOperation != findAndReplaceDialog.GetComparisonOperation()) {
     257      if (searchIterator == null
     258        || currentSearchText != findAndReplaceDialog.GetSearchText()
     259        || currentComparisonOperation != findAndReplaceDialog.GetComparisonOperation()) {
     260
    255261        searchIterator = new FindPreprocessingItemsIterator(FindAll(findAndReplaceDialog.GetSearchText()));
    256262        currentSearchText = findAndReplaceDialog.GetSearchText();
     
    349355      bool searchInSelection = HightlightedCellsBackground.Values.Sum(list => list.Count) > 1;
    350356      ComparisonOperation comparisonOperation = findAndReplaceDialog.GetComparisonOperation();
    351       var comparisonFilter = new ComparisonFilter(Content.FilterLogic.PreprocessingData, GetConstraintOperation(comparisonOperation), new StringValue(match), true);
    352       var filters = new List<Filter.IFilter>() { comparisonFilter };
    353357      var foundCells = new Dictionary<int, IList<int>>();
    354358      for (int i = 0; i < Content.FilterLogic.PreprocessingData.Columns; i++) {
    355         comparisonFilter.ConstraintColumn = i;
     359        var filters = CreateFilters(match, comparisonOperation, i);
     360
    356361        bool[] filteredRows = Content.FilterLogic.GetFilterResult(filters, true);
    357362        var foundIndices = new List<int>();
     
    370375        }
    371376      }
    372       return foundCells;
     377      return MapToSorting(foundCells);
     378    }
     379
     380    private List<IFilter> CreateFilters(string match, ComparisonOperation comparisonOperation, int columnIndex) {
     381      IPreprocessingData preprocessingData = Content.FilterLogic.PreprocessingData;
     382      IStringConvertibleValue value;
     383      if (preprocessingData.IsType<double>(columnIndex)) {
     384        value = new DoubleValue();
     385      } else if (preprocessingData.IsType<String>(columnIndex)) {
     386        value = new StringValue();
     387      } else if (preprocessingData.IsType<DateTime>(columnIndex)) {
     388        value = new DateTimeValue();
     389      } else {
     390        throw new ArgumentException("unsupported type");
     391      }
     392      value.SetValue(match);
     393      var comparisonFilter = new ComparisonFilter(preprocessingData, GetConstraintOperation(comparisonOperation), value, true);
     394      comparisonFilter.ConstraintColumn = columnIndex;
     395      return new List<Filter.IFilter>() { comparisonFilter };
     396    }
     397
     398    private IDictionary<int, IList<int>> MapToSorting(Dictionary<int, IList<int>> foundCells) {
     399      if (sortedColumnIndices.Count == 0) {
     400        return foundCells;
     401      } else {
     402        var sortedFoundCells = new Dictionary<int, IList<int>>();
     403
     404        var indicesToVirtual = new Dictionary<int, int>();
     405        for (int i = 0; i < virtualRowIndices.Length; ++i) {
     406          indicesToVirtual.Add(virtualRowIndices[i], i);
     407        }
     408
     409        foreach (var entry in foundCells) {
     410          var cells = new List<int>();
     411          foreach (var cell in entry.Value) {
     412            cells.Add(indicesToVirtual[cell]);
     413          }
     414          cells.Sort();
     415          sortedFoundCells.Add(entry.Key, cells);
     416        }
     417        return sortedFoundCells;
     418      }
    373419    }
    374420
     
    533579    private void StopReplacing() {
    534580      isReplacing = false;
    535       ResumeRepaint(true); 
     581      ResumeRepaint(true);
    536582    }
    537583
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/Filter/ComparisonFilter.cs

    r10785 r10947  
    2020#endregion
    2121
     22using System;
    2223using System.Drawing;
     24using HeuristicLab.Common;
    2325using HeuristicLab.Common.Resources;
    2426using HeuristicLab.Core;
    25 using System;
    26 using System.Collections;
    27 using HeuristicLab.Common;
    2827using HeuristicLab.Data;
    29 using System.Collections.Generic;
    3028
    31 namespace HeuristicLab.DataPreprocessing.Filter
    32 {
    33     [Item("ComparisonFilter", "A filter which compares the member of the preprocessing data with the constraint data.")]
    34     public class ComparisonFilter : ComparisonConstraint, IFilter
    35     {
    36         protected ComparisonFilter(bool deserializing) : base(deserializing) { }
     29namespace HeuristicLab.DataPreprocessing.Filter {
     30  [Item("ComparisonFilter", "A filter which compares the member of the preprocessing data with the constraint data.")]
     31  public class ComparisonFilter : ComparisonConstraint, IFilter {
    3732
    38         protected ComparisonFilter(ComparisonFilter original, Cloner cloner)
    39             : base(original, cloner)
    40         {
    41             constraintColumn = original.constraintColumn;
     33   
     34
     35    protected ComparisonFilter(bool deserializing) : base(deserializing) {
     36   
     37    }
     38
     39    protected ComparisonFilter(ComparisonFilter original, Cloner cloner)
     40      : base(original, cloner) {
     41      constraintColumn = original.constraintColumn;
     42    }
     43    public override IDeepCloneable Clone(Cloner cloner) {
     44      return new ComparisonFilter(this, cloner);
     45    }
     46
     47    public ComparisonFilter() : base() { }
     48    public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData)
     49      : base(constrainedValue, constraintOperation, constraintData) {
     50    }
     51
     52    public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData, bool active)
     53      : base(constrainedValue, constraintOperation, constraintData, active) {
     54    }
     55
     56
     57    public override string ItemName {
     58      get { return "ComparisonFilter"; }
     59    }
     60
     61    public override Image ItemImage {
     62      get { return VSImageLibrary.Filter; }
     63    }
     64
     65    public new IPreprocessingData ConstrainedValue {
     66      get { return (IPreprocessingData)base.ConstrainedValue; }
     67      set { base.ConstrainedValue = value; }
     68    }
     69
     70    public new IStringConvertibleValue ConstraintData {
     71      get { return (IStringConvertibleValue)base.ConstraintData; }
     72      set {
     73        if (!(value is IComparable))
     74          throw new ArgumentException("Only IComparables allowed for ConstraintData");
     75        base.ConstraintData = value;
     76      }
     77    }
     78
     79
     80    private int constraintColumn;
     81    public int ConstraintColumn {
     82      get { return constraintColumn; }
     83      set {
     84        if (ConstrainedValue.Columns < value)
     85          throw new ArgumentException("Could not set ConstraintData to not existing column index.");
     86
     87        if (constraintColumn != value) {
     88          constraintColumn = value;
     89          this.OnConstraintColumnChanged();
     90          this.OnToStringChanged();
    4291        }
    43         public override IDeepCloneable Clone(Cloner cloner)
    44         {
    45             return new ComparisonFilter(this, cloner);
     92      }
     93    }
     94
     95
     96    public new bool[] Check() {
     97      bool[] result = new bool[ConstrainedValue.Rows];
     98
     99      if (!Active)
     100        return result;
     101
     102      for (int row = 0; row < ConstrainedValue.Rows; ++row) {
     103        object item = null;
     104        if (ConstrainedValue.IsType<double>(constraintColumn)) {
     105          item = new HeuristicLab.Data.DoubleValue(ConstrainedValue.GetCell<double>(ConstraintColumn, row));
     106        } else if (ConstrainedValue.IsType<DateTime>(constraintColumn)) {
     107          item = new HeuristicLab.Data.DateTimeValue(ConstrainedValue.GetCell<DateTime>(ConstraintColumn, row));
     108        } else {
     109          item = new StringValue(ConstrainedValue.GetCell<string>(ConstraintColumn, row));
    46110        }
    47111
    48         public ComparisonFilter() : base() { }
    49         public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData)
    50             : base(constrainedValue, constraintOperation, constraintData)
    51         {
    52         }
     112        result[row] = !base.Check(item);
     113      }
    53114
    54         public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData, bool active)
    55             : base(constrainedValue, constraintOperation, constraintData, active)
    56         {
    57         }
     115      return result;
     116    }
    58117
     118    public new bool[] Check(out string errorMessage) {
     119      errorMessage = string.Empty;
     120      return this.Check();
     121    }
    59122
    60         public override string ItemName
    61         {
    62             get { return "ComparisonFilter"; }
    63         }
     123    public event EventHandler ConstraintColumnChanged;
     124    protected virtual void OnConstraintColumnChanged() {
     125      EventHandler handler = ConstraintColumnChanged;
     126      if (handler != null)
     127        handler(this, EventArgs.Empty);
     128    }
    64129
    65         public override Image ItemImage
    66         {
    67             get { return VSImageLibrary.Filter; }
    68         }
     130    public override string ToString() {
     131      string s = string.Empty;
     132      if (ConstrainedValue != null)
     133        s += ConstrainedValue.GetVariableName(ConstraintColumn) + " ";
    69134
    70         public new IPreprocessingData ConstrainedValue
    71         {
    72             get { return (IPreprocessingData)base.ConstrainedValue; }
    73             set { base.ConstrainedValue = value; }
    74         }
     135      if (ConstraintOperation != null)
     136        s += ConstraintOperation.ToString() + " ";
    75137
    76         public new IStringConvertibleValue ConstraintData
    77         {
    78             get { return (IStringConvertibleValue)base.ConstraintData; }
    79             set
    80             {
    81                 if (!(value is IComparable))
    82                     throw new ArgumentException("Only IComparables allowed for ConstraintData");
    83                 base.ConstraintData = value;
    84             }
    85         }
     138      if (ConstraintData != null)
     139        s += ConstraintData.ToString();
     140      else
     141        s += "null";
    86142
    87 
    88         private int constraintColumn;
    89         public int ConstraintColumn
    90         {
    91             get { return constraintColumn; }
    92             set
    93             {
    94                 if (ConstrainedValue.Columns < value)
    95                     throw new ArgumentException("Could not set ConstraintData to not existing column index.");
    96 
    97                 if (constraintColumn != value)
    98                 {
    99                     constraintColumn = value;
    100                     this.OnConstraintColumnChanged();
    101                     this.OnToStringChanged();
    102                 }
    103             }
    104         }
    105 
    106 
    107         public new bool[] Check()
    108         {
    109             bool[] result = new bool[ConstrainedValue.Rows];
    110 
    111             if (!Active)
    112                 return result;
    113 
    114             for (int row = 0; row < ConstrainedValue.Rows; ++row)
    115             {
    116                 object item = null;
    117                 if (ConstrainedValue.IsType<double>(constraintColumn))
    118                 {
    119                   item = new StringValue(ConstrainedValue.GetCell<double>(ConstraintColumn, row).ToString());
    120                 }
    121                 else if (ConstrainedValue.IsType<DateTime>(constraintColumn))
    122                 {
    123                   item = new StringValue(ConstrainedValue.GetCell<DateTime>(ConstraintColumn, row).ToString());
    124                 }
    125                 else
    126                 {
    127                   item = new StringValue(ConstrainedValue.GetCell<string>(ConstraintColumn, row));
    128                 }
    129 
    130                 result[row] = !base.Check(item);
    131             }
    132 
    133             return result;
    134         }
    135 
    136         public new bool[] Check(out string errorMessage)
    137         {
    138             errorMessage = string.Empty;
    139             return this.Check();
    140         }
    141 
    142         public event EventHandler ConstraintColumnChanged;
    143         protected virtual void OnConstraintColumnChanged()
    144         {
    145             EventHandler handler = ConstraintColumnChanged;
    146             if (handler != null)
    147                 handler(this, EventArgs.Empty);
    148         }
    149 
    150         public override string ToString()
    151         {
    152           string s = string.Empty;
    153           if (ConstrainedValue != null)
    154             s += ConstrainedValue.GetVariableName(ConstraintColumn) + " ";
    155 
    156           if (ConstraintOperation != null)
    157             s += ConstraintOperation.ToString() + " ";
    158 
    159           if (ConstraintData != null)
    160             s += ConstraintData.ToString();
    161           else
    162             s += "null";
    163 
    164           s += ".";
    165           return s;
    166         }
     143      s += ".";
     144      return s;
    167145    }
     146  }
    168147}
Note: See TracChangeset for help on using the changeset viewer.