- Timestamp:
- 03/06/10 03:30:37 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.cs
r2917 r2948 94 94 dataTypeTextBox.Text = Content.Value == null ? "-" : Content.Value.GetType().GetPrettyName(); 95 95 dataTypeTextBox.Enabled = Content.Value != null; 96 setValueButton.Enabled = Content.Value == null;96 setValueButton.Enabled = true; 97 97 clearValueButton.Enabled = Content.Value != null; 98 98 valueGroupBox.Enabled = true; … … 107 107 dataTypeTextBox.Text = Content.Value == null ? "-" : Content.Value.GetType().GetPrettyName(); 108 108 dataTypeTextBox.Enabled = Content.Value != null; 109 setValueButton.Enabled = Content.Value == null;110 109 clearValueButton.Enabled = Content.Value != null; 111 110 viewHost.Content = Content.Value; -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ConstrainedValueParameterView.cs
r2924 r2948 21 21 22 22 using System; 23 using System. Linq;23 using System.Collections.Generic; 24 24 using HeuristicLab.Collections; 25 25 using HeuristicLab.Core; … … 32 32 /// </summary> 33 33 [View("ConstrainedValueParameter View")] 34 [Content(typeof(OptionalConstrainedValueParameter<>), true)] 34 35 [Content(typeof(ConstrainedValueParameter<>), true)] 35 36 public partial class ConstrainedValueParameterView<T> : ParameterView where T : class, IItem { 37 private List<T> valueComboBoxItems; 38 36 39 /// <summary> 37 40 /// Gets or sets the variable to represent visually. … … 39 42 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>. 40 43 /// No own data storage present.</remarks> 41 public new ConstrainedValueParameter<T> Content {42 get { return ( ConstrainedValueParameter<T>)base.Content; }44 public new OptionalConstrainedValueParameter<T> Content { 45 get { return (OptionalConstrainedValueParameter<T>)base.Content; } 43 46 set { base.Content = value; } 44 47 } … … 50 53 InitializeComponent(); 51 54 Caption = "ConstrainedValueParameter"; 55 valueComboBoxItems = new List<T>(); 52 56 } 53 57 /// <summary> … … 56 60 /// <remarks>Calls <see cref="VariableView()"/>.</remarks> 57 61 /// <param name="variable">The variable to represent visually.</param> 58 public ConstrainedValueParameterView( ConstrainedValueParameter<T> content)62 public ConstrainedValueParameterView(OptionalConstrainedValueParameter<T> content) 59 63 : this() { 60 64 Content = content; … … 102 106 private void FillValueComboBox() { 103 107 valueComboBox.SelectedIndexChanged -= new EventHandler(valueComboBox_SelectedIndexChanged); 104 valueComboBox.DataSource = null; 108 valueComboBoxItems.Clear(); 109 valueComboBox.Items.Clear(); 110 if (!(Content is ConstrainedValueParameter<T>)) { 111 valueComboBoxItems.Add(null); 112 valueComboBox.Items.Add("-"); 113 } 105 114 if (Content != null) { 106 valueComboBox.DataSource = Content.ValidValues.ToList(); 115 foreach (T item in Content.ValidValues) { 116 valueComboBoxItems.Add(item); 117 valueComboBox.Items.Add(item.ToString()); 118 } 107 119 valueComboBox.Enabled = valueComboBox.Items.Count > 0; 108 valueComboBox.SelectedI tem = Content.Value;120 valueComboBox.SelectedIndex = valueComboBoxItems.IndexOf(Content.Value); 109 121 } 110 122 valueComboBox.SelectedIndexChanged += new EventHandler(valueComboBox_SelectedIndexChanged); … … 116 128 Invoke(new EventHandler(Content_ValueChanged), sender, e); 117 129 else { 118 valueComboBox.SelectedI tem = Content.Value;130 valueComboBox.SelectedIndex = valueComboBoxItems.IndexOf(Content.Value); 119 131 viewHost.Content = Content.Value; 120 132 } … … 141 153 142 154 private void valueComboBox_SelectedIndexChanged(object sender, EventArgs e) { 143 Content.Value = (T)valueComboBox.SelectedItem;155 Content.Value = valueComboBoxItems[valueComboBox.SelectedIndex]; 144 156 } 145 157 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/HeuristicLab.Parameters.Views-3.3.csproj
r2924 r2948 92 92 <DependentUpon>ConstrainedValueParameterView.cs</DependentUpon> 93 93 </Compile> 94 <Compile Include="OptionalConstrainedValueParameterView.cs">95 <SubType>UserControl</SubType>96 </Compile>97 <Compile Include="OptionalConstrainedValueParameterView.Designer.cs">98 <DependentUpon>OptionalConstrainedValueParameterView.cs</DependentUpon>99 </Compile>100 <Compile Include="OptionalValueParameterView.cs">101 <SubType>UserControl</SubType>102 </Compile>103 <Compile Include="OptionalValueParameterView.Designer.cs">104 <DependentUpon>OptionalValueParameterView.cs</DependentUpon>105 </Compile>106 94 <Compile Include="ValueLookupParameterView.cs"> 107 95 <SubType>UserControl</SubType> -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueLookupParameterView.cs
r2917 r2948 97 97 actualNameTextBox.Text = Content.ActualName; 98 98 actualNameTextBox.Enabled = true; 99 setValueButton.Enabled = Content.Value == null;99 setValueButton.Enabled = true; 100 100 clearValueButton.Enabled = Content.Value != null; 101 101 valueGroupBox.Enabled = true; … … 114 114 Invoke(new EventHandler(Content_ValueChanged), sender, e); 115 115 else { 116 setValueButton.Enabled = Content.Value == null;117 116 clearValueButton.Enabled = Content.Value != null; 118 117 viewHost.Content = Content.Value; -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueParameterView.Designer.cs
r2924 r2948 33 33 protected override void Dispose(bool disposing) { 34 34 if (disposing) { 35 if (typeSelectorDialog != null) typeSelectorDialog.Dispose(); 35 36 if (components != null) components.Dispose(); 36 37 } … … 48 49 this.valuePanel = new System.Windows.Forms.Panel(); 49 50 this.viewHost = new HeuristicLab.Core.Views.ViewHost(); 51 this.clearValueButton = new System.Windows.Forms.Button(); 52 this.setValueButton = new System.Windows.Forms.Button(); 50 53 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 51 54 this.valueGroupBox.SuspendLayout(); 52 55 this.valuePanel.SuspendLayout(); 53 56 this.SuspendLayout(); 54 //55 // dataTypeLabel56 //57 this.dataTypeLabel.Location = new System.Drawing.Point(3, 55);58 57 // 59 58 // dataTypeTextBox … … 80 79 | System.Windows.Forms.AnchorStyles.Right))); 81 80 this.valueGroupBox.Controls.Add(this.valuePanel); 81 this.valueGroupBox.Controls.Add(this.clearValueButton); 82 this.valueGroupBox.Controls.Add(this.setValueButton); 82 83 this.valueGroupBox.Location = new System.Drawing.Point(0, 78); 83 84 this.valueGroupBox.Name = "valueGroupBox"; … … 94 95 | System.Windows.Forms.AnchorStyles.Right))); 95 96 this.valuePanel.Controls.Add(this.viewHost); 96 this.valuePanel.Location = new System.Drawing.Point(6, 19);97 this.valuePanel.Location = new System.Drawing.Point(6, 49); 97 98 this.valuePanel.Name = "valuePanel"; 98 this.valuePanel.Size = new System.Drawing.Size(374, 212);99 this.valuePanel.Size = new System.Drawing.Size(374, 182); 99 100 this.valuePanel.TabIndex = 0; 100 101 this.valuePanel.DragOver += new System.Windows.Forms.DragEventHandler(this.valuePanel_DragEnterOver); … … 108 109 this.viewHost.Location = new System.Drawing.Point(0, 0); 109 110 this.viewHost.Name = "viewHost"; 110 this.viewHost.Size = new System.Drawing.Size(374, 212);111 this.viewHost.Size = new System.Drawing.Size(374, 182); 111 112 this.viewHost.TabIndex = 0; 112 113 this.viewHost.ViewType = null; 114 // 115 // clearValueButton 116 // 117 this.clearValueButton.Enabled = false; 118 this.clearValueButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Remove; 119 this.clearValueButton.Location = new System.Drawing.Point(36, 19); 120 this.clearValueButton.Name = "clearValueButton"; 121 this.clearValueButton.Size = new System.Drawing.Size(24, 24); 122 this.clearValueButton.TabIndex = 1; 123 this.toolTip.SetToolTip(this.clearValueButton, "Clear Value"); 124 this.clearValueButton.UseVisualStyleBackColor = true; 125 this.clearValueButton.Click += new System.EventHandler(this.setValueButton_Click); 126 // 127 // setValueButton 128 // 129 this.setValueButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Add; 130 this.setValueButton.Location = new System.Drawing.Point(6, 19); 131 this.setValueButton.Name = "setValueButton"; 132 this.setValueButton.Size = new System.Drawing.Size(24, 24); 133 this.setValueButton.TabIndex = 0; 134 this.toolTip.SetToolTip(this.setValueButton, "Set Value"); 135 this.setValueButton.UseVisualStyleBackColor = true; 136 this.setValueButton.Click += new System.EventHandler(this.changeValueButton_Click); 113 137 // 114 138 // ValueParameterView … … 139 163 protected System.Windows.Forms.Panel valuePanel; 140 164 protected HeuristicLab.Core.Views.ViewHost viewHost; 165 protected System.Windows.Forms.Button setValueButton; 166 protected System.Windows.Forms.Button clearValueButton; 141 167 } 142 168 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueParameterView.cs
r2917 r2948 31 31 /// </summary> 32 32 [View("ValueParameter View")] 33 [Content(typeof(OptionalValueParameter<>), true)] 33 34 [Content(typeof(ValueParameter<>), true)] 35 [Content(typeof(IValueParameter<>), false)] 34 36 public partial class ValueParameterView<T> : ParameterView where T : class, IItem { 37 protected TypeSelectorDialog typeSelectorDialog; 38 35 39 /// <summary> 36 40 /// Gets or sets the variable to represent visually. … … 38 42 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>. 39 43 /// No own data storage present.</remarks> 40 public new ValueParameter<T> Content {41 get { return ( ValueParameter<T>)base.Content; }44 public new IValueParameter<T> Content { 45 get { return (IValueParameter<T>)base.Content; } 42 46 set { base.Content = value; } 43 47 } … … 55 59 /// <remarks>Calls <see cref="VariableView()"/>.</remarks> 56 60 /// <param name="variable">The variable to represent visually.</param> 57 public ValueParameterView( ValueParameter<T> content)61 public ValueParameterView(IValueParameter<T> content) 58 62 : this() { 59 63 Content = content; … … 82 86 if (Content == null) { 83 87 Caption = "ValueParameter"; 88 setValueButton.Enabled = false; 89 clearValueButton.Visible = true; 90 clearValueButton.Enabled = false; 84 91 viewHost.Content = null; 85 92 valueGroupBox.Enabled = false; 86 93 } else { 87 94 Caption = Content.Name + " (" + Content.GetType().Name + ")"; 95 setValueButton.Enabled = true; 96 clearValueButton.Visible = !(Content is ValueParameter<T>); 97 clearValueButton.Enabled = Content.Value != null; 88 98 valueGroupBox.Enabled = true; 89 99 viewHost.Content = Content.Value; … … 95 105 Invoke(new EventHandler(Content_ValueChanged), sender, e); 96 106 else { 107 clearValueButton.Enabled = Content.Value != null; 97 108 viewHost.Content = Content.Value; 98 109 } 99 110 } 100 111 112 protected virtual void changeValueButton_Click(object sender, EventArgs e) { 113 if (typeSelectorDialog == null) { 114 typeSelectorDialog = new TypeSelectorDialog(); 115 typeSelectorDialog.Caption = "Select Value"; 116 typeSelectorDialog.TypeSelector.Configure(Content.DataType, false, false); 117 } 118 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) 119 Content.Value = (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 120 } 121 protected virtual void setValueButton_Click(object sender, EventArgs e) { 122 Content.Value = null; 123 } 101 124 protected virtual void valuePanel_DragEnterOver(object sender, DragEventArgs e) { 102 125 e.Effect = DragDropEffects.None; -
trunk/sources/HeuristicLab.Parameters/3.3/ValueParameter.cs
r2947 r2948 35 35 get { return base.Value; } 36 36 set { 37 if ( value == null) throw new ArgumentNullException();37 if ((value == null) && (Value != null)) throw new ArgumentNullException(); 38 38 base.Value = value; 39 39 } 40 40 } 41 41 42 private ValueParameter() : base() { } 42 public ValueParameter() : base() { } 43 public ValueParameter(string name) : base(name) { } 43 44 public ValueParameter(string name, T value) : base(name, value) { } 45 public ValueParameter(string name, string description) : base(name, description) { } 44 46 public ValueParameter(string name, string description, T value) : base(name, description, value) { } 45 46 public override IDeepCloneable Clone(Cloner cloner) {47 ValueParameter<T> clone = new ValueParameter<T>(Name, Description, Value);48 cloner.RegisterClonedObject(this, clone);49 clone.Value = (T)cloner.Clone(Value);50 return clone;51 }52 47 } 53 48 }
Note: See TracChangeset
for help on using the changeset viewer.