Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/15/10 01:34:27 (14 years ago)
Author:
mkommend
Message:

implemented first version of View.ReadOnly and adapted some views to the new mechanism (ticket #973)

File:
1 edited

Legend:

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

    r3346 r3350  
    8282        Caption = "StringConvertibleMatrix View";
    8383        rowsTextBox.Text = "";
    84         rowsTextBox.Enabled = false;
    8584        columnsTextBox.Text = "";
    86         columnsTextBox.Enabled = false;
    8785        dataGridView.Rows.Clear();
    8886        dataGridView.Columns.Clear();
    89         dataGridView.Enabled = false;
    9087        virtualRowIndizes = new int[0];
    9188      } else {
    9289        Caption = "StringConvertibleMatrix (" + Content.GetType().Name + ")";
    93         UpdateReadOnlyControls();
    9490        UpdateData();
     91      }
     92      SetEnableStateOfControls();
     93    }
     94    protected override void OnReadOnlyChanged() {
     95      base.OnReadOnlyChanged();
     96      SetEnableStateOfControls();
     97    }
     98    private void SetEnableStateOfControls() {
     99      if (Content == null) {
     100        rowsTextBox.Enabled = false;
     101        columnsTextBox.Enabled = false;
     102        dataGridView.Enabled = false;
     103      } else {
     104        rowsTextBox.Enabled = true;
     105        columnsTextBox.Enabled = true;
     106        dataGridView.Enabled = true;
     107        rowsTextBox.ReadOnly = ReadOnly;
     108        columnsTextBox.ReadOnly = ReadOnly;
     109        dataGridView.ReadOnly = ReadOnly;
    95110      }
    96111    }
     
    338353
    339354        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;
     355          string1 = matrix.GetValue(x, pair.Key);
     356          string2 = matrix.GetValue(y, pair.Key);
     357          if (double.TryParse(string1, out double1) && double.TryParse(string2, out double2))
     358            result = double1.CompareTo(double2);
     359          else if (DateTime.TryParse(string1, out dateTime1) && DateTime.TryParse(string2, out dateTime2))
     360            result = dateTime1.CompareTo(dateTime2);
     361          else {
     362            if (string1 != null)
     363              result = string1.CompareTo(string2);
     364            else if (string2 != null)
     365              result = string2.CompareTo(string1) * -1;
     366          }
     367          if (pair.Value == SortOrder.Descending)
     368            result *= -1;
     369          if (result != 0)
     370            return result;
    356371        }
    357372        return result;
Note: See TracChangeset for help on using the changeset viewer.