- Timestamp:
- 01/21/11 10:41:14 (14 years ago)
- 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 21 21 22 22 namespace HeuristicLab.Parameters.Views { 23 partial class ConstrainedValueParameter View<T> {23 partial class ConstrainedValueParameterConfigurationView<T> { 24 24 /// <summary> 25 25 /// Required designer variable. … … 46 46 private void InitializeComponent() { 47 47 this.valueGroupBox = new System.Windows.Forms.GroupBox(); 48 this.configureButton = new System.Windows.Forms.CheckBox(); 48 49 this.showInRunCheckBox = new System.Windows.Forms.CheckBox(); 49 50 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); … … 72 73 // valueGroupBox 73 74 // 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); 77 79 this.valueGroupBox.Controls.Add(this.showInRunCheckBox); 78 80 this.valueGroupBox.Controls.Add(this.viewHost); … … 84 86 this.valueGroupBox.TabStop = false; 85 87 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); 86 104 // 87 105 // showInRunCheckBox … … 103 121 // viewHost 104 122 // 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 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))); 108 126 this.viewHost.Caption = "View"; 109 127 this.viewHost.Content = null; 128 this.viewHost.Enabled = false; 110 129 this.viewHost.Location = new System.Drawing.Point(6, 46); 111 130 this.viewHost.Name = "viewHost"; … … 113 132 this.viewHost.Size = new System.Drawing.Size(374, 185); 114 133 this.viewHost.TabIndex = 2; 134 this.viewHost.ViewsLabelVisible = true; 115 135 this.viewHost.ViewType = null; 116 136 // 117 137 // valueComboBox 118 138 // 119 this.valueComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 120 139 this.valueComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 140 | System.Windows.Forms.AnchorStyles.Right))); 121 141 this.valueComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 122 142 this.valueComboBox.FormattingEnabled = true; 123 143 this.valueComboBox.Location = new System.Drawing.Point(6, 19); 124 144 this.valueComboBox.Name = "valueComboBox"; 125 this.valueComboBox.Size = new System.Drawing.Size(2 78, 21);145 this.valueComboBox.Size = new System.Drawing.Size(248, 21); 126 146 this.valueComboBox.TabIndex = 0; 127 147 this.toolTip.SetToolTip(this.valueComboBox, "Selected Value"); 128 148 this.valueComboBox.SelectedIndexChanged += new System.EventHandler(this.valueComboBox_SelectedIndexChanged); 129 149 // 130 // ConstrainedValueParameter View150 // ConstrainedValueParameterConfigurationView 131 151 // 132 152 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 133 153 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 134 154 this.Controls.Add(this.valueGroupBox); 135 this.Name = "ConstrainedValueParameter View";155 this.Name = "ConstrainedValueParameterConfigurationView"; 136 156 this.Size = new System.Drawing.Size(386, 315); 137 157 this.Controls.SetChildIndex(this.descriptionTextBox, 0); … … 152 172 #endregion 153 173 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; 158 175 } 159 176 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ConstrainedValueParameterConfigurationView.cs
r5337 r5345 21 21 22 22 using System; 23 using System.Collections.Generic;24 using HeuristicLab.Collections;25 23 using HeuristicLab.Common; 26 24 using HeuristicLab.Core; … … 32 30 /// The visual representation of a <see cref="Parameter"/>. 33 31 /// </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 { 49 36 50 37 /// <summary> 51 38 /// Initializes a new instance of <see cref="VariableView"/> with caption "Variable". 52 39 /// </summary> 53 public ConstrainedValueParameter View() {40 public ConstrainedValueParameterConfigurationView() { 54 41 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);82 42 } 83 43 84 44 protected override void OnContentChanged() { 85 45 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; 97 47 } 98 48 99 49 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; 123 51 } 124 52 125 53 #region Content Events 126 protected virtualvoid Content_ValueChanged(object sender, EventArgs e) {54 protected override void Content_ValueChanged(object sender, EventArgs e) { 127 55 if (InvokeRequired) 128 56 Invoke(new EventHandler(Content_ValueChanged), sender, e); 129 57 else { 130 58 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 } 134 64 } 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 else140 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 else146 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 else152 FillValueComboBox();153 }154 protected virtual void Content_GetsCollectedChanged(object sender, EventArgs e) {155 if (InvokeRequired)156 Invoke(new EventHandler(Content_GetsCollectedChanged), sender, e);157 else158 showInRunCheckBox.Checked = Content != null && Content.GetsCollected;159 65 } 160 66 #endregion 161 67 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; 179 74 } 180 75 } 181 #endregion182 76 } 183 77 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ConstrainedValueParameterView.cs
r4332 r5345 129 129 else { 130 130 SetDataTypeTextBoxText(); 131 valueComboBox.SelectedIndex = valueComboBoxItems.IndexOf(Content != null ? Content.Value : null);131 SetComboBoxSelectedIndex(); 132 132 viewHost.ViewType = null; 133 133 viewHost.Content = Content != null ? Content.Value : null; 134 134 } 135 135 } 136 136 137 protected virtual void ValidValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) { 137 138 if (InvokeRequired) … … 179 180 } 180 181 } 182 protected void SetComboBoxSelectedIndex() { 183 valueComboBox.SelectedIndex = valueComboBoxItems.IndexOf(Content != null ? Content.Value : null); 184 } 181 185 #endregion 182 186 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/HeuristicLab.Parameters.Views-3.3.csproj
r5163 r5345 119 119 <DependentUpon>ConstrainedValueParameterView.cs</DependentUpon> 120 120 </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> 121 127 <Compile Include="ScopeTreeLookupParameterView.cs"> 122 128 <SubType>UserControl</SubType>
Note: See TracChangeset
for help on using the changeset viewer.