Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6598


Ignore:
Timestamp:
07/27/11 13:15:14 (13 years ago)
Author:
epitzer
Message:

register to value change events on all variable strings (#1602)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableView.cs

    r6236 r6598  
    5858      variableNamesView.Content.CheckedItemsChanged += new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed);
    5959      variableNamesView.Content.CollectionReset += new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed);
    60     }
    61 
     60      foreach (var variable in variableNamesView.Content) {
     61        variable.ValueChanged += new EventHandler(variable_ValueChanged);
     62      }
     63    }
     64
     65   
    6266    private void DeregisterVariableNamesViewContentEvents() {
    6367      variableNamesView.Content.ItemsAdded -= new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed);
     
    6569      variableNamesView.Content.CheckedItemsChanged -= new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed);
    6670      variableNamesView.Content.CollectionReset -= new CollectionItemsChangedEventHandler<StringValue>(variableNames_Changed);
     71      foreach (var variable in variableNamesView.Content) {
     72        variable.ValueChanged -= new EventHandler(variable_ValueChanged);
     73      }
    6774    }
    6875
     
    93100      additiveWeightChangeSigmaTextBox.ReadOnly = ReadOnly;
    94101      multiplicativeWeightChangeSigmaTextBox.Enabled = Content != null;
    95       multiplicativeWeightChangeSigmaTextBox.ReadOnly = ReadOnly;
     102      multiplicativeWeightChangeSigmaTextBox.ReadOnly = ReadOnly;     
    96103    }
    97104
     
    104111    #region control event handlers
    105112    private void variableNames_Changed(object sender, CollectionItemsChangedEventArgs<StringValue> args) {
     113      if (args.Items != null)
     114        foreach (var newVar in args.Items)
     115          newVar.ValueChanged += new EventHandler(variable_ValueChanged);
     116      if (args.OldItems != null)
     117        foreach (var oldVar in args.OldItems)
     118          oldVar.ValueChanged -= new EventHandler(variable_ValueChanged);
     119      UpdateContent();
     120    }   
     121
     122    void variable_ValueChanged(object sender, EventArgs e) {
     123      UpdateContent();
     124    }
     125
     126    private void UpdateContent() {
    106127      if (Content != null) {
    107128        Content.Changed -= new EventHandler(Content_Changed);
     
    110131      }
    111132    }
     133
    112134
    113135    private void weightMuTextBox_TextChanged(object sender, EventArgs e) {
Note: See TracChangeset for help on using the changeset viewer.