Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/08/13 15:36:13 (12 years ago)
Author:
mkommend
Message:

#1837: Updated sliding window GP branch with trunk changes.

Location:
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views

  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4

    • Property svn:ignore
      •  

        old new  
        22obj
        33*.user
        4 HeuristicLabProblemsDataAnalysisSymbolicViewsPlugin.cs
        54*.vs10x
        65Plugin.cs
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableConditionView.cs

    r5809 r9126  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
     23using System.Linq;
    2324using System.Windows.Forms;
     25using HeuristicLab.Collections;
     26using HeuristicLab.Core;
     27using HeuristicLab.Core.Views;
     28using HeuristicLab.Data;
    2429using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
    2530using HeuristicLab.MainForm;
     
    3035  [Content(typeof(VariableCondition), true)]
    3136  public partial class VariableConditionView : SymbolView {
     37    private readonly CheckedItemCollectionView<StringValue> variableNamesView;
     38
    3239    public new VariableCondition Content {
    3340      get { return (VariableCondition)base.Content; }
     
    3744    public VariableConditionView() {
    3845      InitializeComponent();
     46      variableNamesView = new CheckedItemCollectionView<StringValue>();
     47      variableNamesView.Dock = DockStyle.Fill;
     48      variableNamesTabPage.Controls.Add(variableNamesView);
     49      variableNamesView.Content = new CheckedItemCollection<StringValue>();
     50
     51      RegisterVariableNamesViewContentEvents();
     52    }
     53
     54    private void RegisterVariableNamesViewContentEvents() {
     55      variableNamesView.Content.ItemsAdded += new CollectionItemsChangedEventHandler<StringValue>(VariableNames_Changed);
     56      variableNamesView.Content.ItemsRemoved += new CollectionItemsChangedEventHandler<StringValue>(VariableNames_Changed);
     57      variableNamesView.Content.CheckedItemsChanged += new CollectionItemsChangedEventHandler<StringValue>(VariableNames_Changed);
     58      variableNamesView.Content.CollectionReset += new CollectionItemsChangedEventHandler<StringValue>(VariableNames_Changed);
     59      foreach (var variable in variableNamesView.Content) {
     60        variable.ValueChanged += new EventHandler(Variable_ValueChanged);
     61      }
     62    }
     63
     64    private void DeregisterVariableNamesViewContentEvents() {
     65      variableNamesView.Content.ItemsAdded -= new CollectionItemsChangedEventHandler<StringValue>(VariableNames_Changed);
     66      variableNamesView.Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<StringValue>(VariableNames_Changed);
     67      variableNamesView.Content.CheckedItemsChanged -= new CollectionItemsChangedEventHandler<StringValue>(VariableNames_Changed);
     68      variableNamesView.Content.CollectionReset -= new CollectionItemsChangedEventHandler<StringValue>(VariableNames_Changed);
     69      foreach (var variable in variableNamesView.Content) {
     70        variable.ValueChanged -= new EventHandler(Variable_ValueChanged);
     71      }
    3972    }
    4073
     
    76109    }
    77110
    78 
    79 
    80111    private void UpdateControl() {
    81112      if (Content == null) {
     
    88119        slopeChangeMuTextBox.Text = string.Empty;
    89120        slopeChangeSigmaTextBox.Text = string.Empty;
     121        // temporarily deregister to prevent circular calling of events
     122        DeregisterVariableNamesViewContentEvents();
     123        variableNamesView.Content.Clear();
     124        RegisterVariableNamesViewContentEvents();
    90125      } else {
     126        // temporarily deregister to prevent circular calling of events
     127        DeregisterVariableNamesViewContentEvents();
     128        variableNamesView.Content.Clear();
     129        foreach (var variableName in Content.AllVariableNames) {
     130          variableNamesView.Content.Add(new StringValue(variableName), Content.VariableNames.Contains(variableName));
     131        }
     132        RegisterVariableNamesViewContentEvents();
     133
    91134        thresholdInitializationMuTextBox.Text = Content.ThresholdInitializerMu.ToString();
    92135        thresholdInitializationSigmaTextBox.Text = Content.ThresholdInitializerSigma.ToString();
     
    102145
    103146    #region control events
    104     private void thresholdMuTextBox_TextChanged(object sender, EventArgs e) {
     147    private void VariableNames_Changed(object sender, CollectionItemsChangedEventArgs<StringValue> e) {
     148      foreach (var newVar in e.Items)
     149        newVar.ValueChanged += new EventHandler(Variable_ValueChanged);
     150      foreach (var oldVar in e.OldItems)
     151        oldVar.ValueChanged -= new EventHandler(Variable_ValueChanged);
     152      UpdateContent();
     153    }
     154
     155    private void Variable_ValueChanged(object sender, EventArgs e) {
     156      UpdateContent();
     157    }
     158
     159    private void UpdateContent() {
     160      if (Content != null) {
     161        DeregisterContentEvents();
     162        Content.VariableNames = variableNamesView.Content.CheckedItems.Select(x => x.Value).ToList();
     163        RegisterContentEvents();
     164      }
     165    }
     166
     167    private void ThresholdInitializationMuTextBox_TextChanged(object sender, EventArgs e) {
    105168      double value;
    106169      if (double.TryParse(thresholdInitializationMuTextBox.Text, out value)) {
     
    109172      } else errorProvider.SetError(thresholdInitializationMuTextBox, "Invalid value");
    110173    }
    111     private void thresholdInitializationSigmaTextBox_TextChanged(object sender, EventArgs e) {
     174    private void ThresholdInitializationSigmaTextBox_TextChanged(object sender, EventArgs e) {
    112175      double value;
    113176      if (double.TryParse(thresholdInitializationSigmaTextBox.Text, out value)) {
     
    116179      } else errorProvider.SetError(thresholdInitializationSigmaTextBox, "Invalid value");
    117180    }
    118     private void slopeInitializationMuTextBox_TextChanged(object sender, EventArgs e) {
     181    private void SlopeInitializationMuTextBox_TextChanged(object sender, EventArgs e) {
    119182      double value;
    120183      if (double.TryParse(slopeInitializationMuTextBox.Text, out value)) {
     
    123186      } else errorProvider.SetError(slopeInitializationMuTextBox, "Invalid value");
    124187    }
    125     private void slopeInitializationSigmaTextBox_TextChanged(object sender, EventArgs e) {
     188    private void SlopeInitializationSigmaTextBox_TextChanged(object sender, EventArgs e) {
    126189      double value;
    127190      if (double.TryParse(slopeInitializationSigmaTextBox.Text, out value)) {
     
    131194    }
    132195
    133     private void thresholdChangeMuTextBox_TextChanged(object sender, EventArgs e) {
     196    private void ThresholdChangeMuTextBox_TextChanged(object sender, EventArgs e) {
    134197      double value;
    135198      if (double.TryParse(thresholdChangeMuTextBox.Text, out value)) {
     
    139202    }
    140203
    141     private void thresholdChangeSigmaTextBox_TextChanged(object sender, EventArgs e) {
     204    private void ThresholdChangeSigmaTextBox_TextChanged(object sender, EventArgs e) {
    142205      double value;
    143206      if (double.TryParse(thresholdChangeSigmaTextBox.Text, out value)) {
     
    146209      } else errorProvider.SetError(thresholdChangeSigmaTextBox, "Invalid value");
    147210    }
    148     private void slopeChangeMuTextBox_TextChanged(object sender, EventArgs e) {
     211    private void SlopeChangeMuTextBox_TextChanged(object sender, EventArgs e) {
    149212      double value;
    150213      if (double.TryParse(slopeChangeMuTextBox.Text, out value)) {
     
    154217    }
    155218
    156     private void slopeChangeSigmaTextBox_TextChanged(object sender, EventArgs e) {
     219    private void SlopeChangeSigmaTextBox_TextChanged(object sender, EventArgs e) {
    157220      double value;
    158221      if (double.TryParse(slopeChangeSigmaTextBox.Text, out value)) {
     
    162225    }
    163226    #endregion
    164 
    165227  }
    166228}
Note: See TracChangeset for help on using the changeset viewer.