Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5345 for trunk


Ignore:
Timestamp:
01/21/11 10:41:14 (14 years ago)
Author:
epitzer
Message:

Add new alternate view ConstrainedValueParameterConfigurationView for configuring the ValidValues ItemSet (#1390)

Location:
trunk/sources/HeuristicLab.Parameters.Views/3.3
Files:
2 edited
2 copied

Legend:

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

    r5337 r5345  
    2121
    2222namespace HeuristicLab.Parameters.Views {
    23   partial class ConstrainedValueParameterView<T> {
     23  partial class ConstrainedValueParameterConfigurationView<T> {
    2424    /// <summary>
    2525    /// Required designer variable.
     
    4646    private void InitializeComponent() {
    4747      this.valueGroupBox = new System.Windows.Forms.GroupBox();
     48      this.configureButton = new System.Windows.Forms.CheckBox();
    4849      this.showInRunCheckBox = new System.Windows.Forms.CheckBox();
    4950      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     
    7273      // valueGroupBox
    7374      //
    74       this.valueGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    75                   | System.Windows.Forms.AnchorStyles.Left)
    76                   | System.Windows.Forms.AnchorStyles.Right)));
     75      this.valueGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     76            | System.Windows.Forms.AnchorStyles.Left)
     77            | System.Windows.Forms.AnchorStyles.Right)));
     78      this.valueGroupBox.Controls.Add(this.configureButton);
    7779      this.valueGroupBox.Controls.Add(this.showInRunCheckBox);
    7880      this.valueGroupBox.Controls.Add(this.viewHost);
     
    8486      this.valueGroupBox.TabStop = false;
    8587      this.valueGroupBox.Text = "Value";
     88      //
     89      // configureButton
     90      //
     91      this.configureButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     92      this.configureButton.Appearance = System.Windows.Forms.Appearance.Button;
     93      this.configureButton.AutoSize = true;
     94      this.configureButton.Location = new System.Drawing.Point(260, 17);
     95      this.configureButton.MinimumSize = new System.Drawing.Size(24, 24);
     96      this.configureButton.Name = "configureButton";
     97      this.configureButton.Size = new System.Drawing.Size(24, 24);
     98      this.configureButton.TabIndex = 3;
     99      this.configureButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Edit;
     100      this.configureButton.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
     101      this.toolTip.SetToolTip(this.configureButton, "Edit ValidValues");
     102      this.configureButton.UseVisualStyleBackColor = true;
     103      this.configureButton.CheckedChanged += new System.EventHandler(this.configureButton_CheckedChanged);
    86104      //
    87105      // showInRunCheckBox
     
    103121      // viewHost
    104122      //
    105       this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    106                   | System.Windows.Forms.AnchorStyles.Left)
    107                   | System.Windows.Forms.AnchorStyles.Right)));
     123      this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     124            | System.Windows.Forms.AnchorStyles.Left)
     125            | System.Windows.Forms.AnchorStyles.Right)));
    108126      this.viewHost.Caption = "View";
    109127      this.viewHost.Content = null;
     128      this.viewHost.Enabled = false;
    110129      this.viewHost.Location = new System.Drawing.Point(6, 46);
    111130      this.viewHost.Name = "viewHost";
     
    113132      this.viewHost.Size = new System.Drawing.Size(374, 185);
    114133      this.viewHost.TabIndex = 2;
     134      this.viewHost.ViewsLabelVisible = true;
    115135      this.viewHost.ViewType = null;
    116136      //
    117137      // valueComboBox
    118138      //
    119       this.valueComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    120                   | System.Windows.Forms.AnchorStyles.Right)));
     139      this.valueComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     140            | System.Windows.Forms.AnchorStyles.Right)));
    121141      this.valueComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    122142      this.valueComboBox.FormattingEnabled = true;
    123143      this.valueComboBox.Location = new System.Drawing.Point(6, 19);
    124144      this.valueComboBox.Name = "valueComboBox";
    125       this.valueComboBox.Size = new System.Drawing.Size(278, 21);
     145      this.valueComboBox.Size = new System.Drawing.Size(248, 21);
    126146      this.valueComboBox.TabIndex = 0;
    127147      this.toolTip.SetToolTip(this.valueComboBox, "Selected Value");
    128148      this.valueComboBox.SelectedIndexChanged += new System.EventHandler(this.valueComboBox_SelectedIndexChanged);
    129149      //
    130       // ConstrainedValueParameterView
     150      // ConstrainedValueParameterConfigurationView
    131151      //
    132152      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    133153      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    134154      this.Controls.Add(this.valueGroupBox);
    135       this.Name = "ConstrainedValueParameterView";
     155      this.Name = "ConstrainedValueParameterConfigurationView";
    136156      this.Size = new System.Drawing.Size(386, 315);
    137157      this.Controls.SetChildIndex(this.descriptionTextBox, 0);
     
    152172    #endregion
    153173
    154     protected System.Windows.Forms.GroupBox valueGroupBox;
    155     protected HeuristicLab.MainForm.WindowsForms.ViewHost viewHost;
    156     protected System.Windows.Forms.ComboBox valueComboBox;
    157     protected System.Windows.Forms.CheckBox showInRunCheckBox;
     174    protected System.Windows.Forms.CheckBox configureButton;
    158175  }
    159176}
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/ConstrainedValueParameterConfigurationView.cs

    r5337 r5345  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using HeuristicLab.Collections;
    2523using HeuristicLab.Common;
    2624using HeuristicLab.Core;
     
    3230  /// The visual representation of a <see cref="Parameter"/>.
    3331  /// </summary>
    34   [View("ConstrainedValueParameter View")]
    35   [Content(typeof(OptionalConstrainedValueParameter<>), true)]
    36   [Content(typeof(ConstrainedValueParameter<>), true)]
    37   public partial class ConstrainedValueParameterView<T> : ParameterView where T : class, IItem {
    38     private List<T> valueComboBoxItems;
    39 
    40     /// <summary>
    41     /// Gets or sets the variable to represent visually.
    42     /// </summary>
    43     /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
    44     /// No own data storage present.</remarks>
    45     public new OptionalConstrainedValueParameter<T> Content {
    46       get { return (OptionalConstrainedValueParameter<T>)base.Content; }
    47       set { base.Content = value; }
    48     }
     32  [View("ConstrainedValueParameter ConfigurationView")]
     33  [Content(typeof(OptionalConstrainedValueParameter<>), false)]
     34  [Content(typeof(ConstrainedValueParameter<>), false)]
     35  public partial class ConstrainedValueParameterConfigurationView<T> : ConstrainedValueParameterView<T> where T : class, IItem {
    4936
    5037    /// <summary>
    5138    /// Initializes a new instance of <see cref="VariableView"/> with caption "Variable".
    5239    /// </summary>
    53     public ConstrainedValueParameterView() {
     40    public ConstrainedValueParameterConfigurationView() {
    5441      InitializeComponent();
    55       valueComboBoxItems = new List<T>();
    56     }
    57 
    58     /// <summary>
    59     /// Removes the eventhandlers from the underlying <see cref="IVariable"/>.
    60     /// </summary>
    61     /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    62     protected override void DeregisterContentEvents() {
    63       Content.GetsCollectedChanged -= new EventHandler(Content_GetsCollectedChanged);
    64       Content.ValidValues.ItemsAdded -= new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsAdded);
    65       Content.ValidValues.ItemsRemoved -= new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved);
    66       Content.ValidValues.CollectionReset -= new CollectionItemsChangedEventHandler<T>(ValidValues_CollectionReset);
    67       Content.ValueChanged -= new EventHandler(Content_ValueChanged);
    68       base.DeregisterContentEvents();
    69     }
    70 
    71     /// <summary>
    72     /// Adds eventhandlers to the underlying <see cref="IVariable"/>.
    73     /// </summary>
    74     /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    75     protected override void RegisterContentEvents() {
    76       base.RegisterContentEvents();
    77       Content.GetsCollectedChanged += new EventHandler(Content_GetsCollectedChanged);
    78       Content.ValidValues.ItemsAdded += new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsAdded);
    79       Content.ValidValues.ItemsRemoved += new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved);
    80       Content.ValidValues.CollectionReset += new CollectionItemsChangedEventHandler<T>(ValidValues_CollectionReset);
    81       Content.ValueChanged += new EventHandler(Content_ValueChanged);
    8242    }
    8343
    8444    protected override void OnContentChanged() {
    8545      base.OnContentChanged();
    86       if (Content == null) {
    87         showInRunCheckBox.Checked = false;
    88         viewHost.Content = null;
    89         FillValueComboBox();
    90       } else {
    91         SetDataTypeTextBoxText();
    92         FillValueComboBox();
    93         showInRunCheckBox.Checked = Content.GetsCollected;
    94         viewHost.ViewType = null;
    95         viewHost.Content = Content.Value;
    96       }
     46      configureButton.Checked = false;
    9747    }
    9848
    9949    protected override void SetEnabledStateOfControls() {
    100       base.SetEnabledStateOfControls();
    101       valueGroupBox.Enabled = Content != null;
    102       valueComboBox.Enabled = (valueComboBox.Items.Count > 0) && !ReadOnly;
    103       showInRunCheckBox.Enabled = Content != null && !ReadOnly;
    104     }
    105 
    106     protected virtual void FillValueComboBox() {
    107       valueComboBox.SelectedIndexChanged -= new EventHandler(valueComboBox_SelectedIndexChanged);
    108       valueComboBoxItems.Clear();
    109       valueComboBox.Items.Clear();
    110       if (!(Content is ConstrainedValueParameter<T>)) {
    111         valueComboBoxItems.Add(null);
    112         valueComboBox.Items.Add("-");
    113       }
    114       if (Content != null) {
    115         foreach (T item in Content.ValidValues) {
    116           valueComboBoxItems.Add(item);
    117           valueComboBox.Items.Add(item.ToString());
    118         }
    119         valueComboBox.Enabled = (valueComboBox.Items.Count > 0) && !ReadOnly;
    120         valueComboBox.SelectedIndex = valueComboBoxItems.IndexOf(Content.Value);
    121       }
    122       valueComboBox.SelectedIndexChanged += new EventHandler(valueComboBox_SelectedIndexChanged);
     50      configureButton.Enabled = Content != null && !ReadOnly;
    12351    }
    12452
    12553    #region Content Events
    126     protected virtual void Content_ValueChanged(object sender, EventArgs e) {
     54    protected override void Content_ValueChanged(object sender, EventArgs e) {
    12755      if (InvokeRequired)
    12856        Invoke(new EventHandler(Content_ValueChanged), sender, e);
    12957      else {
    13058        SetDataTypeTextBoxText();
    131         valueComboBox.SelectedIndex = valueComboBoxItems.IndexOf(Content != null ? Content.Value : null);
    132         viewHost.ViewType = null;
    133         viewHost.Content = Content != null ? Content.Value : null;
     59        SetComboBoxSelectedIndex();
     60        if (!configureButton.Checked) {
     61          viewHost.ViewType = null;
     62          viewHost.Content = Content != null ? Content.Value : null;
     63        }
    13464      }
    135     }
    136     protected virtual void ValidValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) {
    137       if (InvokeRequired)
    138         Invoke(new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsAdded), sender, e);
    139       else
    140         FillValueComboBox();
    141     }
    142     protected virtual void ValidValues_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<T> e) {
    143       if (InvokeRequired)
    144         Invoke(new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved), sender, e);
    145       else
    146         FillValueComboBox();
    147     }
    148     protected virtual void ValidValues_CollectionReset(object sender, CollectionItemsChangedEventArgs<T> e) {
    149       if (InvokeRequired)
    150         Invoke(new CollectionItemsChangedEventHandler<T>(ValidValues_CollectionReset), sender, e);
    151       else
    152         FillValueComboBox();
    153     }
    154     protected virtual void Content_GetsCollectedChanged(object sender, EventArgs e) {
    155       if (InvokeRequired)
    156         Invoke(new EventHandler(Content_GetsCollectedChanged), sender, e);
    157       else
    158         showInRunCheckBox.Checked = Content != null && Content.GetsCollected;
    15965    }
    16066    #endregion
    16167
    162     protected virtual void valueComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    163       if (valueComboBox.SelectedIndex >= 0)
    164         Content.Value = valueComboBoxItems[valueComboBox.SelectedIndex];
    165     }
    166     protected virtual void showInRunCheckBox_CheckedChanged(object sender, EventArgs e) {
    167       if (Content != null) Content.GetsCollected = showInRunCheckBox.Checked;
    168     }
    169 
    170     #region Helpers
    171     protected void SetDataTypeTextBoxText() {
    172       if (Content == null) {
    173         dataTypeTextBox.Text = "-";
    174       } else {
    175         if ((Content.Value != null) && (Content.Value.GetType() != Content.DataType))
    176           dataTypeTextBox.Text = Content.DataType.GetPrettyName() + " (" + Content.Value.GetType().GetPrettyName() + ")";
    177         else
    178           dataTypeTextBox.Text = Content.DataType.GetPrettyName();
     68    protected virtual void configureButton_CheckedChanged(object sender, EventArgs e) {
     69      if (Content == null) return;
     70      var newContent = configureButton.Checked ? (IContent)Content.ValidValues : (IContent)Content.Value;
     71      if (viewHost.Content != newContent) {
     72        viewHost.ViewType = null;
     73        viewHost.Content = newContent;
    17974      }
    18075    }
    181     #endregion
    18276  }
    18377}
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/ConstrainedValueParameterView.cs

    r4332 r5345  
    129129      else {
    130130        SetDataTypeTextBoxText();
    131         valueComboBox.SelectedIndex = valueComboBoxItems.IndexOf(Content != null ? Content.Value : null);
     131        SetComboBoxSelectedIndex();
    132132        viewHost.ViewType = null;
    133133        viewHost.Content = Content != null ? Content.Value : null;
    134134      }
    135135    }
     136
    136137    protected virtual void ValidValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) {
    137138      if (InvokeRequired)
     
    179180      }
    180181    }
     182    protected void SetComboBoxSelectedIndex() {
     183      valueComboBox.SelectedIndex = valueComboBoxItems.IndexOf(Content != null ? Content.Value : null);
     184    }
    181185    #endregion
    182186  }
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/HeuristicLab.Parameters.Views-3.3.csproj

    r5163 r5345  
    119119      <DependentUpon>ConstrainedValueParameterView.cs</DependentUpon>
    120120    </Compile>
     121    <Compile Include="ConstrainedValueParameterConfigurationView.cs">
     122      <SubType>UserControl</SubType>
     123    </Compile>
     124    <Compile Include="ConstrainedValueParameterConfigurationView.Designer.cs">
     125      <DependentUpon>ConstrainedValueParameterConfigurationView.cs</DependentUpon>
     126    </Compile>
    121127    <Compile Include="ScopeTreeLookupParameterView.cs">
    122128      <SubType>UserControl</SubType>
Note: See TracChangeset for help on using the changeset viewer.