Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/03/12 16:46:35 (12 years ago)
Author:
gkronber
Message:

#1847: merged r8084:8205 from trunk into GP move operators branch

Location:
branches/GP-MoveOperators
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GP-MoveOperators

  • branches/GP-MoveOperators/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs

    r8085 r8206  
    3535  [Content(typeof(IStringConvertibleMatrix), true)]
    3636  public partial class StringConvertibleMatrixView : AsynchronousContentView {
    37     private int[] virtualRowIndizes;
    38     private List<KeyValuePair<int, SortOrder>> sortedColumnIndizes;
     37    private int[] virtualRowIndices;
     38    private List<KeyValuePair<int, SortOrder>> sortedColumnIndices;
    3939    private RowComparer rowComparer;
    4040
     
    8282      errorProvider.SetIconAlignment(columnsTextBox, ErrorIconAlignment.MiddleLeft);
    8383      errorProvider.SetIconPadding(columnsTextBox, 2);
    84       sortedColumnIndizes = new List<KeyValuePair<int, SortOrder>>();
     84      sortedColumnIndices = new List<KeyValuePair<int, SortOrder>>();
    8585      rowComparer = new RowComparer();
    8686    }
     
    108108        dataGridView.Rows.Clear();
    109109        dataGridView.Columns.Clear();
    110         virtualRowIndizes = new int[0];
     110        virtualRowIndices = new int[0];
    111111      } else
    112112        UpdateData();
     
    128128      columnsTextBox.Text = Content.Columns.ToString();
    129129      columnsTextBox.Enabled = true;
    130       virtualRowIndizes = Enumerable.Range(0, Content.Rows).ToArray();
     130      virtualRowIndices = Enumerable.Range(0, Content.Rows).ToArray();
    131131
    132132      if (Content.Columns == 0 && dataGridView.ColumnCount != Content.Columns && !Content.ReadOnly)
     
    178178
    179179      while (updatedRows < count) {
    180         if (virtualRowIndizes[index] < Content.RowNames.Count())
    181           dataGridView.Rows[index].HeaderCell.Value = Content.RowNames.ElementAt(virtualRowIndizes[index]);
     180        if (virtualRowIndices[index] < Content.RowNames.Count())
     181          dataGridView.Rows[index].HeaderCell.Value = Content.RowNames.ElementAt(virtualRowIndices[index]);
    182182        else
    183183          dataGridView.Rows[index].HeaderCell.Value = "Row " + (index + 1);
     
    273273      if (!dataGridView.ReadOnly) {
    274274        string value = e.Value.ToString();
    275         int rowIndex = virtualRowIndizes[e.RowIndex];
     275        int rowIndex = virtualRowIndices[e.RowIndex];
    276276        e.ParsingApplied = Content.SetValue(value, rowIndex, e.ColumnIndex);
    277277        if (e.ParsingApplied) e.Value = Content.GetValue(rowIndex, e.ColumnIndex);
     
    283283    private void dataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) {
    284284      if (Content != null && e.RowIndex < Content.Rows && e.ColumnIndex < Content.Columns) {
    285         int rowIndex = virtualRowIndizes[e.RowIndex];
     285        int rowIndex = virtualRowIndices[e.RowIndex];
    286286        e.Value = Content.GetValue(rowIndex, e.ColumnIndex);
    287287      }
     
    340340
    341341      for (int i = minRowIndex; i <= maxRowIndex; i++) {
    342         int rowIndex = this.virtualRowIndizes[i];
     342        int rowIndex = this.virtualRowIndices[i];
    343343        if (addRowNames) {
    344344          s.Append(Content.RowNames.ElementAt(rowIndex));
     
    399399      if (Content != null) {
    400400        if (e.Button == MouseButtons.Left && Content.SortableView) {
    401           bool addToSortedIndizes = (Control.ModifierKeys & Keys.Control) == Keys.Control;
     401          bool addToSortedIndices = (Control.ModifierKeys & Keys.Control) == Keys.Control;
    402402          SortOrder newSortOrder = SortOrder.Ascending;
    403           if (sortedColumnIndizes.Any(x => x.Key == e.ColumnIndex)) {
    404             SortOrder oldSortOrder = sortedColumnIndizes.Where(x => x.Key == e.ColumnIndex).First().Value;
     403          if (sortedColumnIndices.Any(x => x.Key == e.ColumnIndex)) {
     404            SortOrder oldSortOrder = sortedColumnIndices.Where(x => x.Key == e.ColumnIndex).First().Value;
    405405            int enumLength = Enum.GetValues(typeof(SortOrder)).Length;
    406406            newSortOrder = oldSortOrder = (SortOrder)Enum.Parse(typeof(SortOrder), ((((int)oldSortOrder) + 1) % enumLength).ToString());
    407407          }
    408408
    409           if (!addToSortedIndizes)
    410             sortedColumnIndizes.Clear();
    411 
    412           if (sortedColumnIndizes.Any(x => x.Key == e.ColumnIndex)) {
    413             int sortedIndex = sortedColumnIndizes.FindIndex(x => x.Key == e.ColumnIndex);
     409          if (!addToSortedIndices)
     410            sortedColumnIndices.Clear();
     411
     412          if (sortedColumnIndices.Any(x => x.Key == e.ColumnIndex)) {
     413            int sortedIndex = sortedColumnIndices.FindIndex(x => x.Key == e.ColumnIndex);
    414414            if (newSortOrder != SortOrder.None)
    415               sortedColumnIndizes[sortedIndex] = new KeyValuePair<int, SortOrder>(e.ColumnIndex, newSortOrder);
     415              sortedColumnIndices[sortedIndex] = new KeyValuePair<int, SortOrder>(e.ColumnIndex, newSortOrder);
    416416            else
    417               sortedColumnIndizes.RemoveAt(sortedIndex);
     417              sortedColumnIndices.RemoveAt(sortedIndex);
    418418          } else
    419419            if (newSortOrder != SortOrder.None)
    420               sortedColumnIndizes.Add(new KeyValuePair<int, SortOrder>(e.ColumnIndex, newSortOrder));
     420              sortedColumnIndices.Add(new KeyValuePair<int, SortOrder>(e.ColumnIndex, newSortOrder));
    421421          Sort();
    422422        }
     
    425425
    426426    protected virtual void ClearSorting() {
    427       virtualRowIndizes = Enumerable.Range(0, Content.Rows).ToArray();
    428       sortedColumnIndizes.Clear();
     427      virtualRowIndices = Enumerable.Range(0, Content.Rows).ToArray();
     428      sortedColumnIndices.Clear();
    429429      UpdateSortGlyph();
    430430    }
    431431
    432432    private void Sort() {
    433       virtualRowIndizes = Sort(sortedColumnIndizes);
     433      virtualRowIndices = Sort(sortedColumnIndices);
    434434      UpdateSortGlyph();
    435435      UpdateRowHeaders();
     
    439439      int[] newSortedIndex = Enumerable.Range(0, Content.Rows).ToArray();
    440440      if (sortedColumns.Count() != 0) {
    441         rowComparer.SortedIndizes = sortedColumns;
     441        rowComparer.SortedIndices = sortedColumns;
    442442        rowComparer.Matrix = Content;
    443443        Array.Sort(newSortedIndex, rowComparer);
     
    448448      foreach (DataGridViewColumn col in this.dataGridView.Columns)
    449449        col.HeaderCell.SortGlyphDirection = SortOrder.None;
    450       foreach (KeyValuePair<int, SortOrder> p in sortedColumnIndizes)
     450      foreach (KeyValuePair<int, SortOrder> p in sortedColumnIndices)
    451451        this.dataGridView.Columns[p.Key].HeaderCell.SortGlyphDirection = p.Value;
    452452    }
     
    457457      }
    458458
    459       private List<KeyValuePair<int, SortOrder>> sortedIndizes;
    460       public IEnumerable<KeyValuePair<int, SortOrder>> SortedIndizes {
    461         get { return this.sortedIndizes; }
    462         set { sortedIndizes = new List<KeyValuePair<int, SortOrder>>(value); }
     459      private List<KeyValuePair<int, SortOrder>> sortedIndices;
     460      public IEnumerable<KeyValuePair<int, SortOrder>> SortedIndices {
     461        get { return this.sortedIndices; }
     462        set { sortedIndices = new List<KeyValuePair<int, SortOrder>>(value); }
    463463      }
    464464      private IStringConvertibleMatrix matrix;
     
    477477        if (matrix == null)
    478478          throw new InvalidOperationException("Could not sort IStringConvertibleMatrix if the matrix member is null.");
    479         if (sortedIndizes == null)
     479        if (sortedIndices == null)
    480480          return 0;
    481481
    482         foreach (KeyValuePair<int, SortOrder> pair in sortedIndizes.Where(p => p.Value != SortOrder.None)) {
     482        foreach (KeyValuePair<int, SortOrder> pair in sortedIndices.Where(p => p.Value != SortOrder.None)) {
    483483          string1 = matrix.GetValue(x, pair.Key);
    484484          string2 = matrix.GetValue(y, pair.Key);
Note: See TracChangeset for help on using the changeset viewer.