Changeset 3346


Ignore:
Timestamp:
04/14/10 14:19:46 (11 years ago)
Author:
mkommend
Message:

implemented comments from swa (ticket #968)

Location:
trunk/sources/HeuristicLab.Data.Views/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data.Views/3.3/ColumnsVisibilityDialog.Designer.cs

    r3316 r3346  
    4949      this.MinimizeBox = false;
    5050      this.Name = "ColumnsVisibilityDialog";
     51      this.ShowIcon = false;
    5152      this.ShowInTaskbar = false;
    5253      this.Text = "Show / Hide Columns";
  • trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.Designer.cs

    r3333 r3346  
    8484      this.dataGridView.AllowUserToAddRows = false;
    8585      this.dataGridView.AllowUserToDeleteRows = false;
     86      this.dataGridView.AllowUserToOrderColumns = true;
    8687      this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    8788                  | System.Windows.Forms.AnchorStyles.Left)
    8889                  | System.Windows.Forms.AnchorStyles.Right)));
    89       this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.DisplayedCells;
    9090      this.dataGridView.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
    9191      this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  • trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs

    r3337 r3346  
    113113      else
    114114        dataGridView.ColumnCount = Content.Columns;
     115
    115116      UpdateRowHeaders();
    116117      UpdateColumnHeaders();
     118      dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.ColumnHeader);
     119      dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders);
    117120      dataGridView.Enabled = true;
    118121    }
     
    123126          dataGridView.Columns[i].HeaderText = Content.ColumnNames.ElementAt(i);
    124127        else
    125           dataGridView.Columns[i].HeaderText = "Column " + i;
     128          dataGridView.Columns[i].HeaderText = "Column " + (i + 1);
    126129      }
    127130      dataGridView.Invalidate();
     
    133136          dataGridView.Rows[i].HeaderCell.Value = Content.RowNames.ElementAt(i);
    134137        else
    135           dataGridView.Rows[i].HeaderCell.Value = i.ToString();
     138          dataGridView.Rows[i].HeaderCell.Value = "Row " + (i + 1);
    136139      }
    137140      dataGridView.Invalidate();
     
    291294      int[] newSortedIndex = Enumerable.Range(0, Content.Rows).ToArray();
    292295      if (sortedColumnIndizes.Count != 0) {
    293         rowComparer.sortedIndizes = sortedColumnIndizes;
    294         rowComparer.matrix = Content;
     296        rowComparer.SortedIndizes = sortedColumnIndizes;
     297        rowComparer.Matrix = Content;
    295298        Array.Sort(newSortedIndex, rowComparer);
    296299      }
     
    308311    #endregion
    309312
    310     private class RowComparer : IComparer<int> {
    311       public List<KeyValuePair<int, SortOrder>> sortedIndizes;
    312       public IStringConvertibleMatrix matrix;
     313    public class RowComparer : IComparer<int> {
    313314      public RowComparer() {
     315      }
     316
     317      private List<KeyValuePair<int, SortOrder>> sortedIndizes;
     318      public IEnumerable<KeyValuePair<int, SortOrder>> SortedIndizes {
     319        get { return this.sortedIndizes; }
     320        set { sortedIndizes = new List<KeyValuePair<int, SortOrder>>(value); }
     321      }
     322      private IStringConvertibleMatrix matrix;
     323      public IStringConvertibleMatrix Matrix {
     324        get { return this.matrix; }
     325        set { this.matrix = value; }
    314326      }
    315327
     
    320332        string string1, string2;
    321333
    322         foreach (KeyValuePair<int, SortOrder> pair in sortedIndizes) {
    323           string1 = matrix.GetValue(x, pair.Key);
    324           string2 = matrix.GetValue(y, pair.Key);
    325           if (double.TryParse(string1, out double1) && double.TryParse(string2, out double2))
    326             result = double1.CompareTo(double2);
    327           else if (DateTime.TryParse(string1, out dateTime1) && DateTime.TryParse(string2, out dateTime2))
    328             result = dateTime1.CompareTo(dateTime2);
    329           else {
    330             if (string1 != null)
    331               result = string1.CompareTo(string2);
    332             else if (string2 != null)
    333               result = string2.CompareTo(string1) * -1;
    334           }
    335           if (pair.Value == SortOrder.Descending)
    336             result *= -1;
    337           if (result != 0)
    338             return result;
     334        if (matrix == null)
     335          throw new InvalidOperationException("Could not sort IStringConvertibleMatrix if the matrix member is null.");
     336        if (sortedIndizes == null)
     337          return 0;
     338
     339        foreach (KeyValuePair<int, SortOrder> pair in sortedIndizes.Where(p => p.Value != SortOrder.None)) {
     340            string1 = matrix.GetValue(x, pair.Key);
     341            string2 = matrix.GetValue(y, pair.Key);
     342            if (double.TryParse(string1, out double1) && double.TryParse(string2, out double2))
     343              result = double1.CompareTo(double2);
     344            else if (DateTime.TryParse(string1, out dateTime1) && DateTime.TryParse(string2, out dateTime2))
     345              result = dateTime1.CompareTo(dateTime2);
     346            else {
     347              if (string1 != null)
     348                result = string1.CompareTo(string2);
     349              else if (string2 != null)
     350                result = string2.CompareTo(string1) * -1;
     351            }
     352            if (pair.Value == SortOrder.Descending)
     353              result *= -1;
     354            if (result != 0)
     355              return result;
    339356        }
    340357        return result;
Note: See TracChangeset for help on using the changeset viewer.