Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/04/10 04:52:28 (15 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • implemented reviewers' comments on version r2917.
Location:
trunk/sources/HeuristicLab.Parameters.Views/3.3
Files:
2 added
6 edited

Legend:

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

    r2917 r2924  
    8585      this.valueGroupBox.TabIndex = 6;
    8686      this.valueGroupBox.TabStop = false;
    87       this.valueGroupBox.Text = "&Value:";
     87      this.valueGroupBox.Text = "Value";
    8888      //
    8989      // viewHost
     
    135135    #endregion
    136136
    137     private System.Windows.Forms.GroupBox valueGroupBox;
    138     private HeuristicLab.Core.Views.ViewHost viewHost;
    139     private System.Windows.Forms.ComboBox valueComboBox;
     137    protected System.Windows.Forms.GroupBox valueGroupBox;
     138    protected HeuristicLab.Core.Views.ViewHost viewHost;
     139    protected System.Windows.Forms.ComboBox valueComboBox;
    140140  }
    141141}
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/ConstrainedValueParameterView.cs

    r2917 r2924  
    2121
    2222using System;
    23 using System.Collections.Generic;
     23using System.Linq;
    2424using HeuristicLab.Collections;
    2525using HeuristicLab.Core;
     
    3333  [View("ConstrainedValueParameter View")]
    3434  [Content(typeof(ConstrainedValueParameter<>), true)]
    35   public sealed partial class ConstrainedValueParameterView<T> : ParameterView where T : class, IItem {
    36     private List<T> valueComboBoxItems;
    37 
     35  public partial class ConstrainedValueParameterView<T> : ParameterView where T : class, IItem {
    3836    /// <summary>
    3937    /// Gets or sets the variable to represent visually.
     
    5250      InitializeComponent();
    5351      Caption = "ConstrainedValueParameter";
    54       valueComboBoxItems = new List<T>();
    5552    }
    5653    /// <summary>
     
    104101
    105102    private void FillValueComboBox() {
    106       valueComboBoxItems.Clear();
    107       valueComboBoxItems.Add(null);
     103      valueComboBox.SelectedIndexChanged -= new EventHandler(valueComboBox_SelectedIndexChanged);
     104      valueComboBox.DataSource = null;
    108105      if (Content != null) {
    109         foreach (T item in Content.ValidValues)
    110           valueComboBoxItems.Add(item);
     106        valueComboBox.DataSource = Content.ValidValues.ToList();
     107        valueComboBox.Enabled = valueComboBox.Items.Count > 0;
     108        valueComboBox.SelectedItem = Content.Value;
    111109      }
    112       valueComboBox.Items.Clear();
    113       foreach (T item in valueComboBoxItems)
    114         valueComboBox.Items.Add(item == null ? "-" : item.ToString());
    115       if (Content != null) valueComboBox.SelectedIndex = valueComboBoxItems.IndexOf(Content.Value);
     110      valueComboBox.SelectedIndexChanged += new EventHandler(valueComboBox_SelectedIndexChanged);
    116111    }
    117112
     
    121116        Invoke(new EventHandler(Content_ValueChanged), sender, e);
    122117      else {
    123         valueComboBox.SelectedIndex = valueComboBoxItems.IndexOf(Content.Value);
     118        valueComboBox.SelectedItem = Content.Value;
    124119        viewHost.Content = Content.Value;
    125120      }
     
    128123      if (InvokeRequired)
    129124        Invoke(new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsAdded), sender, e);
    130       else {
    131         foreach (T item in e.Items) {
    132           valueComboBoxItems.Add(item);
    133           valueComboBox.Items.Add(item == null ? "-" : item.ToString());
    134         }
    135       }
     125      else
     126        FillValueComboBox();
    136127    }
    137128    private void ValidValues_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<T> e) {
    138129      if (InvokeRequired)
    139130        Invoke(new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved), sender, e);
    140       else {
    141         foreach (T item in e.Items) {
    142           int index = valueComboBoxItems.IndexOf(item);
    143           valueComboBoxItems.RemoveAt(index);
    144           valueComboBox.Items.RemoveAt(index);
    145         }
    146       }
     131      else
     132        FillValueComboBox();
    147133    }
    148134    private void ValidValues_CollectionReset(object sender, CollectionItemsChangedEventArgs<T> e) {
     
    155141
    156142    private void valueComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    157       Content.Value = valueComboBoxItems[valueComboBox.SelectedIndex];
     143      Content.Value = (T)valueComboBox.SelectedItem;
    158144    }
    159145  }
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/HeuristicLab.Parameters.Views-3.3.csproj

    r2900 r2924  
    9191    <Compile Include="ConstrainedValueParameterView.Designer.cs">
    9292      <DependentUpon>ConstrainedValueParameterView.cs</DependentUpon>
     93    </Compile>
     94    <Compile Include="OptionalConstrainedValueParameterView.cs">
     95      <SubType>UserControl</SubType>
     96    </Compile>
     97    <Compile Include="OptionalConstrainedValueParameterView.Designer.cs">
     98      <DependentUpon>OptionalConstrainedValueParameterView.cs</DependentUpon>
    9399    </Compile>
    94100    <Compile Include="OptionalValueParameterView.cs">
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/OptionalValueParameterView.Designer.cs

    r2917 r2924  
    9090      this.valueGroupBox.TabIndex = 6;
    9191      this.valueGroupBox.TabStop = false;
    92       this.valueGroupBox.Text = "&Value:";
     92      this.valueGroupBox.Text = "Value";
    9393      //
    9494      // valuePanel
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueLookupParameterView.Designer.cs

    r2917 r2924  
    100100      this.valueGroupBox.TabIndex = 8;
    101101      this.valueGroupBox.TabStop = false;
    102       this.valueGroupBox.Text = "&Value:";
     102      this.valueGroupBox.Text = "Value";
    103103      //
    104104      // valuePanel
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueParameterView.Designer.cs

    r2917 r2924  
    8585      this.valueGroupBox.TabIndex = 6;
    8686      this.valueGroupBox.TabStop = false;
    87       this.valueGroupBox.Text = "&Value:";
     87      this.valueGroupBox.Text = "Value";
    8888      //
    8989      // valuePanel
Note: See TracChangeset for help on using the changeset viewer.