Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/10 03:40:45 (14 years ago)
Author:
swagner
Message:

Adapted views of HeuristicLab.Parameters.Views according the new read-only property (#973).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueParameterView.cs

    r2949 r3365  
    8686      if (Content == null) {
    8787        Caption = "ValueParameter";
    88         setValueButton.Enabled = false;
    8988        clearValueButton.Visible = true;
    90         clearValueButton.Enabled = false;
    9189        viewHost.Content = null;
    92         valueGroupBox.Enabled = false;
    9390      } else {
    9491        Caption = Content.Name + " (" + Content.GetType().Name + ")";
    95         setValueButton.Enabled = true;
    9692        clearValueButton.Visible = !(Content is ValueParameter<T>);
    97         clearValueButton.Enabled = Content.Value != null;
    98         valueGroupBox.Enabled = true;
    9993        viewHost.ViewType = null;
    10094        viewHost.Content = Content.Value;
    10195      }
     96      SetEnabledStateOfControls();
     97    }
     98
     99    protected override void OnReadOnlyChanged() {
     100      base.OnReadOnlyChanged();
     101      SetEnabledStateOfControls();
     102    }
     103
     104    private void SetEnabledStateOfControls() {
     105      setValueButton.Enabled = Content != null && !ReadOnly;
     106      clearValueButton.Enabled = Content != null && Content.Value != null && !ReadOnly;
     107      valueGroupBox.Enabled = Content != null;
     108      viewHost.ReadOnly = ReadOnly;
    102109    }
    103110
     
    106113        Invoke(new EventHandler(Content_ValueChanged), sender, e);
    107114      else {
    108         clearValueButton.Enabled = Content.Value != null;
     115        clearValueButton.Enabled = Content.Value != null && !ReadOnly;
    109116        viewHost.ViewType = null;
    110117        viewHost.Content = Content.Value;
     
    127134      e.Effect = DragDropEffects.None;
    128135      Type type = e.Data.GetData("Type") as Type;
    129       if ((type != null) && (Content.DataType.IsAssignableFrom(type))) {
     136      if (!ReadOnly && (type != null) && (Content.DataType.IsAssignableFrom(type))) {
    130137        if ((e.KeyState & 8) == 8) e.Effect = DragDropEffects.Copy;  // CTRL key
    131138        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
Note: See TracChangeset for help on using the changeset viewer.