Changeset 2756
- Timestamp:
- 02/05/10 05:23:56 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 7 added
- 1 deleted
- 12 edited
- 8 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorTreeView.cs
r2727 r2756 38 38 [Content(typeof(IOperator), false)] 39 39 public sealed partial class OperatorTreeView : ItemView { 40 private Dictionary<I OperatorParameter, List<TreeNode>> operatorParameterNodeTable;40 private Dictionary<IValueParameter<IOperator>, List<TreeNode>> opParamNodeTable; 41 41 private Dictionary<IOperator, List<TreeNode>> operatorNodeTable; 42 42 private Dictionary<IObservableKeyedCollection<string, IParameter>, IOperator> parametersOperatorTable; … … 58 58 InitializeComponent(); 59 59 graphTreeView.Sorted = true; 60 op eratorParameterNodeTable = new Dictionary<IOperatorParameter, List<TreeNode>>();60 opParamNodeTable = new Dictionary<IValueParameter<IOperator>, List<TreeNode>>(); 61 61 operatorNodeTable = new Dictionary<IOperator, List<TreeNode>>(); 62 62 parametersOperatorTable = new Dictionary<IObservableKeyedCollection<string, IParameter>, IOperator>(); … … 94 94 95 95 #region TreeNode Management 96 private TreeNode CreateTreeNode(I OperatorParameter operatorParameter) {96 private TreeNode CreateTreeNode(IValueParameter<IOperator> opParam) { 97 97 TreeNode node = new TreeNode(); 98 node.Text = op eratorParameter.Name + ": ";99 SetOperatorParameterTag(node, op eratorParameter);100 101 if (!op eratorParameterNodeTable.ContainsKey(operatorParameter)) {102 op eratorParameterNodeTable.Add(operatorParameter, new List<TreeNode>());103 op eratorParameter.ValueChanged += new EventHandler(operatorParameter_ValueChanged);104 } 105 op eratorParameterNodeTable[operatorParameter].Add(node);106 107 IOperator op = op eratorParameter.Value;98 node.Text = opParam.Name + ": "; 99 SetOperatorParameterTag(node, opParam); 100 101 if (!opParamNodeTable.ContainsKey(opParam)) { 102 opParamNodeTable.Add(opParam, new List<TreeNode>()); 103 opParam.ValueChanged += new EventHandler(opParam_ValueChanged); 104 } 105 opParamNodeTable[opParam].Add(node); 106 107 IOperator op = opParam.Value; 108 108 if (op == null) 109 109 node.Text += "-"; … … 139 139 140 140 foreach (IParameter param in op.Parameters) { 141 if (param is I OperatorParameter)141 if (param is IValueParameter<IOperator>) 142 142 node.Nodes.Add(new TreeNode()); 143 143 } … … 167 167 ClearTreeNode(node); 168 168 169 I OperatorParameteropParam = GetOperatorParameterTag(node);169 IValueParameter<IOperator> opParam = GetOperatorParameterTag(node); 170 170 if (opParam != null) { 171 op eratorParameterNodeTable[opParam].Remove(node);172 if (op eratorParameterNodeTable[opParam].Count == 0) {173 opParam.ValueChanged -= new EventHandler(op eratorParameter_ValueChanged);174 op eratorParameterNodeTable.Remove(opParam);171 opParamNodeTable[opParam].Remove(node); 172 if (opParamNodeTable[opParam].Count == 0) { 173 opParam.ValueChanged -= new EventHandler(opParam_ValueChanged); 174 opParamNodeTable.Remove(opParam); 175 175 } 176 176 } … … 180 180 private void AddParameterNodes(IOperator op, IEnumerable<IParameter> parameters) { 181 181 foreach (IParameter param in parameters) { 182 I OperatorParameter opParam = param as IOperatorParameter;182 IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>; 183 183 if (opParam != null) { 184 184 foreach (TreeNode node in operatorNodeTable[op]) … … 189 189 private void RemoveParameterNodes(IEnumerable<IParameter> parameters) { 190 190 foreach (IParameter param in parameters) { 191 I OperatorParameter opParam = param as IOperatorParameter;191 IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>; 192 192 if (opParam != null) { 193 while (op eratorParameterNodeTable.ContainsKey(opParam))194 RemoveTreeNode(op eratorParameterNodeTable[opParam][0]);193 while (opParamNodeTable.ContainsKey(opParam)) 194 RemoveTreeNode(opParamNodeTable[opParam][0]); 195 195 } 196 196 } … … 199 199 200 200 #region Parameter and Operator Events 201 private void op eratorParameter_ValueChanged(object sender, EventArgs e) {202 if (InvokeRequired) 203 Invoke(new EventHandler(op eratorParameter_ValueChanged), sender, e);204 else { 205 I OperatorParameter opParam = (IOperatorParameter)sender;206 foreach (TreeNode node in op eratorParameterNodeTable[opParam].ToArray())201 private void opParam_ValueChanged(object sender, EventArgs e) { 202 if (InvokeRequired) 203 Invoke(new EventHandler(opParam_ValueChanged), sender, e); 204 else { 205 IValueParameter<IOperator> opParam = (IValueParameter<IOperator>)sender; 206 foreach (TreeNode node in opParamNodeTable[opParam].ToArray()) 207 207 ClearTreeNode(node); 208 foreach (TreeNode node in op eratorParameterNodeTable[opParam]) {208 foreach (TreeNode node in opParamNodeTable[opParam]) { 209 209 node.Text = opParam.Name + ": "; 210 210 if (opParam.Value == null) … … 221 221 IOperator op = (IOperator)sender; 222 222 foreach (TreeNode node in operatorNodeTable[op]) { 223 I OperatorParameteropParam = GetOperatorParameterTag(node);223 IValueParameter<IOperator> opParam = GetOperatorParameterTag(node); 224 224 if (opParam == null) 225 225 node.Text = op.Name + " (" + op.ItemName + ")"; … … 287 287 IOperator op = GetOperatorTag(node); 288 288 foreach (IParameter param in op.Parameters) { 289 I OperatorParameter opParam = param as IOperatorParameter;289 IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>; 290 290 if (opParam != null) node.Nodes.Add(CreateTreeNode(opParam)); 291 291 } … … 299 299 private void graphTreeView_KeyDown(object sender, KeyEventArgs e) { 300 300 if ((e.KeyCode == Keys.Delete) && (graphTreeView.SelectedNode != null)) { 301 I OperatorParameteropParam = GetOperatorParameterTag(graphTreeView.SelectedNode);301 IValueParameter<IOperator> opParam = GetOperatorParameterTag(graphTreeView.SelectedNode); 302 302 if (opParam != null) opParam.Value = null; 303 303 } … … 324 324 private void graphTreeView_ItemDrag(object sender, ItemDragEventArgs e) { 325 325 TreeNode node = (TreeNode)e.Item; 326 I OperatorParameteropParam = GetOperatorParameterTag(node);326 IValueParameter<IOperator> opParam = GetOperatorParameterTag(node); 327 327 IOperator op = GetOperatorTag(node); 328 328 DataObject data = new DataObject(); … … 357 357 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) op = (IOperator)op.Clone(); 358 358 TreeNode node = graphTreeView.GetNodeAt(graphTreeView.PointToClient(new Point(e.X, e.Y))); 359 I OperatorParameteropParam = GetOperatorParameterTag(node);359 IValueParameter<IOperator> opParam = GetOperatorParameterTag(node); 360 360 opParam.Value = op; 361 361 } … … 389 389 } 390 390 391 private I OperatorParameterGetOperatorParameterTag(TreeNode node) {391 private IValueParameter<IOperator> GetOperatorParameterTag(TreeNode node) { 392 392 if (node.Tag != null) 393 return ((Tuple<I OperatorParameter, IOperator>)node.Tag).Item1;393 return ((Tuple<IValueParameter<IOperator>, IOperator>)node.Tag).Item1; 394 394 else 395 395 return null; 396 396 } 397 private void SetOperatorParameterTag(TreeNode node, I OperatorParameter operatorParameter) {397 private void SetOperatorParameterTag(TreeNode node, IValueParameter<IOperator> opParam) { 398 398 if (node.Tag == null) 399 node.Tag = new Tuple<I OperatorParameter, IOperator>(operatorParameter, null);400 else 401 ((Tuple<I OperatorParameter, IOperator>)node.Tag).Item1 = operatorParameter;399 node.Tag = new Tuple<IValueParameter<IOperator>, IOperator>(opParam, null); 400 else 401 ((Tuple<IValueParameter<IOperator>, IOperator>)node.Tag).Item1 = opParam; 402 402 } 403 403 private IOperator GetOperatorTag(TreeNode node) { 404 404 if (node.Tag != null) 405 return ((Tuple<I OperatorParameter, IOperator>)node.Tag).Item2;405 return ((Tuple<IValueParameter<IOperator>, IOperator>)node.Tag).Item2; 406 406 else 407 407 return null; … … 409 409 private void SetOperatorTag(TreeNode node, IOperator op) { 410 410 if (node.Tag == null) 411 node.Tag = new Tuple<I OperatorParameter, IOperator>(null, op);412 else 413 ((Tuple<I OperatorParameter, IOperator>)node.Tag).Item2 = op;411 node.Tag = new Tuple<IValueParameter<IOperator>, IOperator>(null, op); 412 else 413 ((Tuple<IValueParameter<IOperator>, IOperator>)node.Tag).Item2 = op; 414 414 } 415 415 #endregion -
trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj
r2754 r2756 104 104 <Compile Include="ChangedEventArgs.cs" /> 105 105 <None Include="HeuristicLabCorePlugin.cs.frame" /> 106 <Compile Include="Interfaces\IValueLookupParameter.cs" /> 107 <Compile Include="Interfaces\IValueParameter.cs" /> 108 <Compile Include="Interfaces\ILookupParameter.cs" /> 106 109 <Compile Include="ItemArray.cs" /> 107 110 <Compile Include="DeepCloneable.cs" /> 108 111 <Compile Include="Engine.cs" /> 109 <Compile Include="Interfaces\IOperatorParameter.cs" />110 112 <Compile Include="Interfaces\IScope.cs" /> 111 113 <Compile Include="Interfaces\IVariable.cs" /> -
trunk/sources/HeuristicLab.Core/3.3/OperatorGraph.cs
r2664 r2756 115 115 var opParams = from o in Operators 116 116 from p in o.Parameters 117 where p is I OperatorParameter118 where (((I OperatorParameter)p).Value != null) && (((IOperatorParameter)p).Value == op)119 select (I OperatorParameter)p;120 foreach (I OperatorParameteropParam in opParams)117 where p is IValueParameter<IOperator> 118 where (((IValueParameter<IOperator>)p).Value != null) && (((IValueParameter<IOperator>)p).Value == op) 119 select (IValueParameter<IOperator>)p; 120 foreach (IValueParameter<IOperator> opParam in opParams) 121 121 opParam.Value = null; 122 122 } 123 123 private void AddParameter(IParameter param) { 124 I OperatorParameter opParam = param as IOperatorParameter;124 IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>; 125 125 if (opParam != null) { 126 126 RegisterOperatorParameterEvents(opParam); … … 129 129 } 130 130 private void RemoveParameter(IParameter param) { 131 I OperatorParameter opParam = param as IOperatorParameter;131 IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>; 132 132 if (opParam != null) { 133 133 DeregisterOperatorParameterEvents(opParam); … … 163 163 op.Parameters.CollectionReset -= new CollectionItemsChangedEventHandler<IParameter>(Parameters_CollectionReset); 164 164 } 165 private void RegisterOperatorParameterEvents(I OperatorParameteropParam) {165 private void RegisterOperatorParameterEvents(IValueParameter<IOperator> opParam) { 166 166 opParam.ValueChanged += new EventHandler(opParam_ValueChanged); 167 167 } 168 private void DeregisterOperatorParameterEvents(I OperatorParameteropParam) {168 private void DeregisterOperatorParameterEvents(IValueParameter<IOperator> opParam) { 169 169 opParam.ValueChanged -= new EventHandler(opParam_ValueChanged); 170 170 } … … 207 207 } 208 208 private void opParam_ValueChanged(object sender, EventArgs e) { 209 I OperatorParameter opParam = (IOperatorParameter)sender;209 IValueParameter<IOperator> opParam = (IValueParameter<IOperator>)sender; 210 210 if (opParam.Value != null) Operators.Add(opParam.Value); 211 211 } -
trunk/sources/HeuristicLab.Operators.Views/3.3/HeuristicLab.Operators.Views-3.3.csproj
r2754 r2756 58 58 </Compile> 59 59 <None Include="HeuristicLabOperatorsViewsPlugin.cs.frame" /> 60 <Compile Include="MultipleSuccessorsOperatorView.cs"> 61 <SubType>UserControl</SubType> 62 </Compile> 63 <Compile Include="MultipleSuccessorsOperatorView.Designer.cs"> 64 <DependentUpon>MultipleSuccessorsOperatorView.cs</DependentUpon> 65 </Compile> 60 66 <Compile Include="HeuristicLabOperatorsViewsPlugin.cs" /> 61 67 <Compile Include="OperatorView.cs"> -
trunk/sources/HeuristicLab.Operators/3.3/Counter.cs
r2740 r2756 36 36 [Creatable("Test")] 37 37 public sealed class Counter : SingleSuccessorOperator { 38 public ItemParameter<IntData> Value{39 get { return ( ItemParameter<IntData>)Parameters["Value"]; }38 public LookupParameter<IntData> ValueParameter { 39 get { return (LookupParameter<IntData>)Parameters["Value"]; } 40 40 } 41 public ItemParameter<IntData> Increment { 42 get { return (ItemParameter<IntData>)Parameters["Increment"]; } 41 public ValueLookupParameter<IntData> IncrementParaneter { 42 get { return (ValueLookupParameter<IntData>)Parameters["Increment"]; } 43 } 44 public IntData Increment { 45 get { return IncrementParaneter.Value; } 46 set { IncrementParaneter.Value = value; } 43 47 } 44 48 45 49 public Counter() 46 50 : base() { 47 Parameters.Add(new ItemParameter<IntData>("Value", "The value which should be incremented."));48 Parameters.Add(new ItemParameter<IntData>("Increment", "The increment which is added to the value.", new IntData(1)));51 Parameters.Add(new LookupParameter<IntData>("Value", "The value which should be incremented.")); 52 Parameters.Add(new ValueLookupParameter<IntData>("Increment", "The increment which is added to the value.", new IntData(1))); 49 53 } 50 54 51 55 public override ExecutionContextCollection Apply() { 52 IntData value = (IntData)Value.Value; 53 IntData increment = (IntData)Increment.Value; 54 value.Value += increment.Value; 56 if (ValueParameter.ActualValue == null) ValueParameter.ActualValue = new IntData(); 57 ValueParameter.ActualValue.Value += IncrementParaneter.ActualValue.Value; 55 58 return base.Apply(); 56 59 } -
trunk/sources/HeuristicLab.Operators/3.3/MultipleSuccessorsOperator.cs
r2740 r2756 38 38 [EmptyStorableClass] 39 39 public abstract class MultipleSuccessorsOperator : Operator { 40 protected I OperatorParameter[] SuccessorParameters {40 protected IValueParameter<IOperator>[] SuccessorParameters { 41 41 get { 42 42 return (from p in Parameters 43 where p is I OperatorParameter43 where p is IValueParameter<IOperator> 44 44 orderby p.Name ascending 45 select (I OperatorParameter)p).ToArray();45 select (IValueParameter<IOperator>)p).ToArray(); 46 46 } 47 47 } … … 53 53 successors = new OperatorList(); 54 54 var opParams = SuccessorParameters; 55 foreach (I OperatorParameteropParam in opParams) {55 foreach (IValueParameter<IOperator> opParam in opParams) { 56 56 opParam.ValueChanged += new EventHandler(opParam_ValueChanged); 57 57 successors.Add(opParam.Value); … … 73 73 private void UpdateOperatorParameters() { 74 74 var opParams = SuccessorParameters; 75 foreach (I OperatorParameteropParam in opParams) {75 foreach (IValueParameter<IOperator> opParam in opParams) { 76 76 opParam.ValueChanged -= new EventHandler(opParam_ValueChanged); 77 77 Parameters.Remove(opParam.Name); 78 78 } 79 79 for (int i = 0; i < Successors.Count; i++) { 80 I OperatorParameteropParam = new OperatorParameter(i.ToString(), string.Empty, Successors[i]);80 IValueParameter<IOperator> opParam = new OperatorParameter(i.ToString(), string.Empty, Successors[i]); 81 81 opParam.ValueChanged += new EventHandler(opParam_ValueChanged); 82 82 Parameters.Add(opParam); … … 92 92 private void successors_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOperator>> e) { 93 93 foreach (IndexedItem<IOperator> item in e.Items) 94 ((I OperatorParameter)Parameters[item.Index.ToString()]).Value = item.Value;94 ((IValueParameter<IOperator>)Parameters[item.Index.ToString()]).Value = item.Value; 95 95 } 96 96 private void successors_ItemsMoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOperator>> e) { 97 97 foreach (IndexedItem<IOperator> item in e.Items) 98 ((I OperatorParameter)Parameters[item.Index.ToString()]).Value = item.Value;98 ((IValueParameter<IOperator>)Parameters[item.Index.ToString()]).Value = item.Value; 99 99 } 100 100 private void successors_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOperator>> e) { … … 102 102 } 103 103 private void opParam_ValueChanged(object sender, EventArgs e) { 104 I OperatorParameter opParam = (IOperatorParameter)sender;104 IValueParameter<IOperator> opParam = (IValueParameter<IOperator>)sender; 105 105 int index = int.Parse(opParam.Name); 106 106 successors[index] = opParam.Value; -
trunk/sources/HeuristicLab.Parameters.Views/3.3/HeuristicLab.Parameters.Views-3.3.csproj
r2754 r2756 52 52 <ItemGroup> 53 53 <None Include="HeuristicLabParametersViewsPlugin.cs.frame" /> 54 <Compile Include=" SubScopesItemParameterView.cs">54 <Compile Include="ValueLookupParameterView.cs"> 55 55 <SubType>UserControl</SubType> 56 56 </Compile> 57 <Compile Include=" SubScopesItemParameterView.Designer.cs">58 <DependentUpon> SubScopesItemParameterView.cs</DependentUpon>57 <Compile Include="ValueLookupParameterView.Designer.cs"> 58 <DependentUpon>ValueLookupParameterView.cs</DependentUpon> 59 59 </Compile> 60 <Compile Include=" OperatorParameterView.cs">60 <Compile Include="LookupParameterView.cs"> 61 61 <SubType>UserControl</SubType> 62 62 </Compile> 63 <Compile Include=" OperatorParameterView.Designer.cs">64 <DependentUpon> OperatorParameterView.cs</DependentUpon>63 <Compile Include="LookupParameterView.Designer.cs"> 64 <DependentUpon>LookupParameterView.cs</DependentUpon> 65 65 </Compile> 66 66 <Compile Include="HeuristicLabParametersViewsPlugin.cs" /> 67 <Compile Include="ItemParameterView.cs">68 <SubType>UserControl</SubType>69 </Compile>70 <Compile Include="ItemParameterView.Designer.cs">71 <DependentUpon>ItemParameterView.cs</DependentUpon>72 </Compile>73 67 <Compile Include="ParameterView.cs"> 74 68 <SubType>UserControl</SubType> … … 78 72 </Compile> 79 73 <Compile Include="Properties\AssemblyInfo.cs" /> 74 <Compile Include="ValueParameterView.cs"> 75 <SubType>UserControl</SubType> 76 </Compile> 77 <Compile Include="ValueParameterView.Designer.cs"> 78 <DependentUpon>ValueParameterView.cs</DependentUpon> 79 </Compile> 80 80 </ItemGroup> 81 81 <ItemGroup> -
trunk/sources/HeuristicLab.Parameters.Views/3.3/LookupParameterView.Designer.cs
r2754 r2756 21 21 22 22 namespace HeuristicLab.Parameters.Views { 23 partial class SubScopesItemParameterView<T> {23 partial class LookupParameterView<T> { 24 24 /// <summary> 25 25 /// Required designer variable. … … 33 33 protected override void Dispose(bool disposing) { 34 34 if (disposing) { 35 if (typeSelectorDialog != null) typeSelectorDialog.Dispose();36 35 if (components != null) components.Dispose(); 37 36 } … … 46 45 /// </summary> 47 46 private void InitializeComponent() { 48 this.components = new System.ComponentModel.Container();49 47 this.actualNameTextBox = new System.Windows.Forms.TextBox(); 50 48 this.actualNameLabel = new System.Windows.Forms.Label(); 51 this.toolTip = new System.Windows.Forms.ToolTip(this.components);52 49 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 53 50 this.SuspendLayout(); … … 101 98 this.actualNameLabel.Text = "&Actual Name:"; 102 99 // 103 // SubScopesItemParameterView100 // LookupParameterView 104 101 // 105 102 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); … … 107 104 this.Controls.Add(this.actualNameTextBox); 108 105 this.Controls.Add(this.actualNameLabel); 109 this.Name = " SubScopesItemParameterView";106 this.Name = "LookupParameterView"; 110 107 this.Size = new System.Drawing.Size(386, 143); 111 108 this.Controls.SetChildIndex(this.descriptionTextBox, 0); … … 127 124 protected System.Windows.Forms.TextBox actualNameTextBox; 128 125 protected System.Windows.Forms.Label actualNameLabel; 129 protected System.Windows.Forms.ToolTip toolTip;130 126 } 131 127 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/LookupParameterView.cs
r2754 r2756 35 35 /// The visual representation of a <see cref="Parameter"/>. 36 36 /// </summary> 37 [Content(typeof( SubScopesItemParameter<>), true)]38 public partial class SubScopesItemParameterView<T> : ParameterView where T : class, IItem {39 protected TypeSelectorDialog typeSelectorDialog;40 37 [Content(typeof(LookupParameter<>), true)] 38 [Content(typeof(SubScopesLookupParameter<>), true)] 39 [Content(typeof(ILookupParameter<>), false)] 40 public partial class LookupParameterView<T> : ParameterView where T : class, IItem { 41 41 /// <summary> 42 42 /// Gets or sets the variable to represent visually. … … 44 44 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>. 45 45 /// No own data storage present.</remarks> 46 public new SubScopesItemParameter<T> Content {47 get { return ( SubScopesItemParameter<T>)base.Content; }46 public new ILookupParameter<T> Content { 47 get { return (ILookupParameter<T>)base.Content; } 48 48 set { base.Content = value; } 49 49 } … … 52 52 /// Initializes a new instance of <see cref="VariableView"/> with caption "Variable". 53 53 /// </summary> 54 public SubScopesItemParameterView() {54 public LookupParameterView() { 55 55 InitializeComponent(); 56 Caption = " SubScopesItemParameter";56 Caption = "LookupParameter"; 57 57 } 58 58 /// <summary> … … 61 61 /// <remarks>Calls <see cref="VariableView()"/>.</remarks> 62 62 /// <param name="variable">The variable to represent visually.</param> 63 public SubScopesItemParameterView(SubScopesItemParameter<T> content)63 public LookupParameterView(ILookupParameter<T> content) 64 64 : this() { 65 65 Content = content; … … 87 87 base.OnContentChanged(); 88 88 if (Content == null) { 89 Caption = " SubScopesItemParameter";89 Caption = "LookupParameter"; 90 90 actualNameTextBox.Text = "-"; 91 91 actualNameTextBox.Enabled = false; -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueLookupParameterView.Designer.cs
r2754 r2756 21 21 22 22 namespace HeuristicLab.Parameters.Views { 23 partial class ItemParameterView<T> {23 partial class ValueLookupParameterView<T> { 24 24 /// <summary> 25 25 /// Required designer variable. … … 47 47 private void InitializeComponent() { 48 48 this.components = new System.ComponentModel.Container(); 49 this. localValueGroupBox = new System.Windows.Forms.GroupBox();50 this. localValuePanel = new System.Windows.Forms.Panel();49 this.valueGroupBox = new System.Windows.Forms.GroupBox(); 50 this.valuePanel = new System.Windows.Forms.Panel(); 51 51 this.viewHost = new HeuristicLab.Core.Views.ViewHost(); 52 this.clearLocalValueButton = new System.Windows.Forms.Button(); 53 this.setLocalValueButton = new System.Windows.Forms.Button(); 52 this.clearValueButton = new System.Windows.Forms.Button(); 53 this.setValueButton = new System.Windows.Forms.Button(); 54 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 54 55 this.actualNameTextBox = new System.Windows.Forms.TextBox(); 55 56 this.actualNameLabel = new System.Windows.Forms.Label(); 56 this.toolTip = new System.Windows.Forms.ToolTip(this.components);57 57 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 58 this. localValueGroupBox.SuspendLayout();59 this. localValuePanel.SuspendLayout();58 this.valueGroupBox.SuspendLayout(); 59 this.valuePanel.SuspendLayout(); 60 60 this.SuspendLayout(); 61 61 // … … 89 89 this.descriptionTextBox.TabIndex = 5; 90 90 // 91 // localValueGroupBox92 // 93 this. localValueGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)91 // valueGroupBox 92 // 93 this.valueGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 94 94 | System.Windows.Forms.AnchorStyles.Left) 95 95 | System.Windows.Forms.AnchorStyles.Right))); 96 this. localValueGroupBox.Controls.Add(this.localValuePanel);97 this. localValueGroupBox.Controls.Add(this.clearLocalValueButton);98 this. localValueGroupBox.Controls.Add(this.setLocalValueButton);99 this. localValueGroupBox.Location = new System.Drawing.Point(0, 146);100 this. localValueGroupBox.Name = "localValueGroupBox";101 this. localValueGroupBox.Size = new System.Drawing.Size(386, 169);102 this. localValueGroupBox.TabIndex = 10;103 this. localValueGroupBox.TabStop = false;104 this. localValueGroupBox.Text = "Local&Value:";105 // 106 // localValuePanel107 // 108 this. localValuePanel.AllowDrop = true;109 this. localValuePanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)96 this.valueGroupBox.Controls.Add(this.valuePanel); 97 this.valueGroupBox.Controls.Add(this.clearValueButton); 98 this.valueGroupBox.Controls.Add(this.setValueButton); 99 this.valueGroupBox.Location = new System.Drawing.Point(0, 146); 100 this.valueGroupBox.Name = "valueGroupBox"; 101 this.valueGroupBox.Size = new System.Drawing.Size(386, 169); 102 this.valueGroupBox.TabIndex = 8; 103 this.valueGroupBox.TabStop = false; 104 this.valueGroupBox.Text = "&Value:"; 105 // 106 // valuePanel 107 // 108 this.valuePanel.AllowDrop = true; 109 this.valuePanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 110 110 | System.Windows.Forms.AnchorStyles.Left) 111 111 | System.Windows.Forms.AnchorStyles.Right))); 112 this. localValuePanel.Controls.Add(this.viewHost);113 this. localValuePanel.Location = new System.Drawing.Point(6, 48);114 this. localValuePanel.Name = "localValuePanel";115 this. localValuePanel.Size = new System.Drawing.Size(374, 115);116 this. localValuePanel.TabIndex = 0;117 this. localValuePanel.DragOver += new System.Windows.Forms.DragEventHandler(this.localValuePanel_DragEnterOver);118 this. localValuePanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.localValuePanel_DragDrop);119 this. localValuePanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.localValuePanel_DragEnterOver);112 this.valuePanel.Controls.Add(this.viewHost); 113 this.valuePanel.Location = new System.Drawing.Point(6, 48); 114 this.valuePanel.Name = "valuePanel"; 115 this.valuePanel.Size = new System.Drawing.Size(374, 115); 116 this.valuePanel.TabIndex = 0; 117 this.valuePanel.DragOver += new System.Windows.Forms.DragEventHandler(this.valuePanel_DragEnterOver); 118 this.valuePanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.valuePanel_DragDrop); 119 this.valuePanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.valuePanel_DragEnterOver); 120 120 // 121 121 // viewHost … … 128 128 this.viewHost.TabIndex = 0; 129 129 // 130 // clear LocalValueButton131 // 132 this.clear LocalValueButton.Enabled = false;133 this.clear LocalValueButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Remove;134 this.clear LocalValueButton.Location = new System.Drawing.Point(35, 19);135 this.clear LocalValueButton.Name = "clearLocalValueButton";136 this.clear LocalValueButton.Size = new System.Drawing.Size(23, 23);137 this.clear LocalValueButton.TabIndex = 9;138 this.toolTip.SetToolTip(this.clear LocalValueButton, "Clear Value");139 this.clear LocalValueButton.UseVisualStyleBackColor = true;140 this.clear LocalValueButton.Click += new System.EventHandler(this.clearLocalValueButton_Click);141 // 142 // set LocalValueButton143 // 144 this.set LocalValueButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Add;145 this.set LocalValueButton.Location = new System.Drawing.Point(6, 19);146 this.set LocalValueButton.Name = "setLocalValueButton";147 this.set LocalValueButton.Size = new System.Drawing.Size(23, 23);148 this.set LocalValueButton.TabIndex = 8;149 this.toolTip.SetToolTip(this.set LocalValueButton, "Set Value");150 this.set LocalValueButton.UseVisualStyleBackColor = true;151 this.set LocalValueButton.Click += new System.EventHandler(this.setLocalValueButton_Click);130 // clearValueButton 131 // 132 this.clearValueButton.Enabled = false; 133 this.clearValueButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Remove; 134 this.clearValueButton.Location = new System.Drawing.Point(35, 19); 135 this.clearValueButton.Name = "clearValueButton"; 136 this.clearValueButton.Size = new System.Drawing.Size(23, 23); 137 this.clearValueButton.TabIndex = 1; 138 this.toolTip.SetToolTip(this.clearValueButton, "Clear Value"); 139 this.clearValueButton.UseVisualStyleBackColor = true; 140 this.clearValueButton.Click += new System.EventHandler(this.clearValueButton_Click); 141 // 142 // setValueButton 143 // 144 this.setValueButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Add; 145 this.setValueButton.Location = new System.Drawing.Point(6, 19); 146 this.setValueButton.Name = "setValueButton"; 147 this.setValueButton.Size = new System.Drawing.Size(23, 23); 148 this.setValueButton.TabIndex = 0; 149 this.toolTip.SetToolTip(this.setValueButton, "Set Value"); 150 this.setValueButton.UseVisualStyleBackColor = true; 151 this.setValueButton.Click += new System.EventHandler(this.setValueButton_Click); 152 152 // 153 153 // actualNameTextBox … … 170 170 this.actualNameLabel.Text = "&Actual Name:"; 171 171 // 172 // ItemParameterView172 // ValueLookupParameterView 173 173 // 174 174 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 175 175 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 176 this.Controls.Add(this.localValueGroupBox);177 176 this.Controls.Add(this.actualNameTextBox); 178 177 this.Controls.Add(this.actualNameLabel); 179 this.Name = "ItemParameterView"; 178 this.Controls.Add(this.valueGroupBox); 179 this.Name = "ValueLookupParameterView"; 180 180 this.Size = new System.Drawing.Size(386, 315); 181 181 this.Controls.SetChildIndex(this.descriptionTextBox, 0); 182 182 this.Controls.SetChildIndex(this.descriptionLabel, 0); 183 183 this.Controls.SetChildIndex(this.dataTypeTextBox, 0); 184 this.Controls.SetChildIndex(this.actualNameLabel, 0);185 184 this.Controls.SetChildIndex(this.dataTypeLabel, 0); 186 185 this.Controls.SetChildIndex(this.nameTextBox, 0); 186 this.Controls.SetChildIndex(this.nameLabel, 0); 187 this.Controls.SetChildIndex(this.valueGroupBox, 0); 188 this.Controls.SetChildIndex(this.actualNameLabel, 0); 187 189 this.Controls.SetChildIndex(this.actualNameTextBox, 0); 188 this.Controls.SetChildIndex(this.nameLabel, 0);189 this.Controls.SetChildIndex(this.localValueGroupBox, 0);190 190 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 191 this. localValueGroupBox.ResumeLayout(false);192 this. localValuePanel.ResumeLayout(false);191 this.valueGroupBox.ResumeLayout(false); 192 this.valuePanel.ResumeLayout(false); 193 193 this.ResumeLayout(false); 194 194 this.PerformLayout(); … … 198 198 #endregion 199 199 200 protected System.Windows.Forms.GroupBox localValueGroupBox; 200 protected System.Windows.Forms.GroupBox valueGroupBox; 201 protected System.Windows.Forms.Panel valuePanel; 202 protected HeuristicLab.Core.Views.ViewHost viewHost; 203 protected System.Windows.Forms.Button setValueButton; 204 protected System.Windows.Forms.ToolTip toolTip; 205 protected System.Windows.Forms.Button clearValueButton; 201 206 protected System.Windows.Forms.TextBox actualNameTextBox; 202 207 protected System.Windows.Forms.Label actualNameLabel; 203 protected System.Windows.Forms.Panel localValuePanel;204 protected HeuristicLab.Core.Views.ViewHost viewHost;205 protected System.Windows.Forms.Button setLocalValueButton;206 protected System.Windows.Forms.ToolTip toolTip;207 protected System.Windows.Forms.Button clearLocalValueButton;208 208 } 209 209 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueLookupParameterView.cs
r2754 r2756 35 35 /// The visual representation of a <see cref="Parameter"/>. 36 36 /// </summary> 37 [Content(typeof(ItemParameter<>), true)] 38 public partial class ItemParameterView<T> : ParameterView where T : class, IItem { 37 [Content(typeof(ValueLookupParameter<>), true)] 38 [Content(typeof(IValueLookupParameter<>), false)] 39 public partial class ValueLookupParameterView<T> : ParameterView where T : class, IItem { 39 40 protected TypeSelectorDialog typeSelectorDialog; 40 41 … … 44 45 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>. 45 46 /// No own data storage present.</remarks> 46 public new I temParameter<T> Content {47 get { return (I temParameter<T>)base.Content; }47 public new IValueLookupParameter<T> Content { 48 get { return (IValueLookupParameter<T>)base.Content; } 48 49 set { base.Content = value; } 49 50 } … … 52 53 /// Initializes a new instance of <see cref="VariableView"/> with caption "Variable". 53 54 /// </summary> 54 public ItemParameterView() {55 public ValueLookupParameterView() { 55 56 InitializeComponent(); 56 Caption = " ItemParameter";57 Caption = "ValueLookupParameter"; 57 58 } 58 59 /// <summary> … … 61 62 /// <remarks>Calls <see cref="VariableView()"/>.</remarks> 62 63 /// <param name="variable">The variable to represent visually.</param> 63 public ItemParameterView(ItemParameter<T> content)64 public ValueLookupParameterView(IValueLookupParameter<T> content) 64 65 : this() { 65 66 Content = content; … … 72 73 protected override void DeregisterContentEvents() { 73 74 Content.ActualNameChanged -= new EventHandler(Content_ActualNameChanged); 74 Content. LocalValueChanged -= new EventHandler(Content_LocalValueChanged);75 Content.ValueChanged -= new EventHandler(Content_ValueChanged); 75 76 base.DeregisterContentEvents(); 76 77 } … … 83 84 base.RegisterContentEvents(); 84 85 Content.ActualNameChanged += new EventHandler(Content_ActualNameChanged); 85 Content. LocalValueChanged += new EventHandler(Content_LocalValueChanged);86 Content.ValueChanged += new EventHandler(Content_ValueChanged); 86 87 } 87 88 … … 89 90 base.OnContentChanged(); 90 91 if (Content == null) { 91 Caption = " ItemParameter";92 Caption = "ValueLookupParameter"; 92 93 actualNameTextBox.Text = "-"; 93 94 actualNameTextBox.Enabled = false; 94 set LocalValueButton.Enabled = false;95 clear LocalValueButton.Enabled = false;96 localValueGroupBox.Enabled = false;95 setValueButton.Enabled = false; 96 clearValueButton.Enabled = false; 97 valueGroupBox.Enabled = false; 97 98 viewHost.Content = null; 98 99 } else { 99 100 Caption = Content.Name + " (" + Content.GetType().Name + ")"; 100 101 actualNameTextBox.Text = Content.ActualName; 101 actualNameTextBox.Enabled = Content.LocalValue == null;102 set LocalValueButton.Enabled = Content.LocalValue == null;103 clear LocalValueButton.Enabled = Content.LocalValue != null;104 localValueGroupBox.Enabled = true;105 viewHost.Content = Content. LocalValue;102 actualNameTextBox.Enabled = true; 103 setValueButton.Enabled = Content.Value == null; 104 clearValueButton.Enabled = Content.Value != null; 105 valueGroupBox.Enabled = true; 106 viewHost.Content = Content.Value; 106 107 } 107 108 } … … 113 114 actualNameTextBox.Text = Content.ActualName; 114 115 } 115 protected virtual void Content_ LocalValueChanged(object sender, EventArgs e) {116 protected virtual void Content_ValueChanged(object sender, EventArgs e) { 116 117 if (InvokeRequired) 117 Invoke(new EventHandler(Content_ LocalValueChanged), sender, e);118 Invoke(new EventHandler(Content_ValueChanged), sender, e); 118 119 else { 119 actualNameTextBox.Enabled = Content.LocalValue == null; 120 setLocalValueButton.Enabled = Content.LocalValue == null; 121 clearLocalValueButton.Enabled = Content.LocalValue != null; 122 viewHost.Content = Content.LocalValue; 120 setValueButton.Enabled = Content.Value == null; 121 clearValueButton.Enabled = Content.Value != null; 122 viewHost.Content = Content.Value; 123 123 } 124 124 } … … 127 127 Content.ActualName = actualNameTextBox.Text; 128 128 } 129 protected virtual void set LocalValueButton_Click(object sender, EventArgs e) {129 protected virtual void setValueButton_Click(object sender, EventArgs e) { 130 130 if (typeSelectorDialog == null) { 131 131 typeSelectorDialog = new TypeSelectorDialog(); 132 typeSelectorDialog.Caption = "Select Local Value Type"; 132 typeSelectorDialog.Caption = "Select Value"; 133 typeSelectorDialog.TypeSelector.Configure(Content.DataType, false, false); 133 134 } 134 typeSelectorDialog.TypeSelector.Configure(Content.DataType, false, false);135 135 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) 136 Content. LocalValue = (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();136 Content.Value = (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 137 137 } 138 protected virtual void clear LocalValueButton_Click(object sender, EventArgs e) {139 Content. LocalValue = null;138 protected virtual void clearValueButton_Click(object sender, EventArgs e) { 139 Content.Value = null; 140 140 } 141 protected virtual void localValuePanel_DragEnterOver(object sender, DragEventArgs e) {141 protected virtual void valuePanel_DragEnterOver(object sender, DragEventArgs e) { 142 142 e.Effect = DragDropEffects.None; 143 143 Type type = e.Data.GetData("Type") as Type; … … 150 150 } 151 151 } 152 protected virtual void localValuePanel_DragDrop(object sender, DragEventArgs e) {152 protected virtual void valuePanel_DragDrop(object sender, DragEventArgs e) { 153 153 if (e.Effect != DragDropEffects.None) { 154 T item= e.Data.GetData("Value") as T;155 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (T)item.Clone();156 Content. LocalValue = item;154 T value = e.Data.GetData("Value") as T; 155 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) value = (T)value.Clone(); 156 Content.Value = value; 157 157 } 158 158 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueParameterView.Designer.cs
r2754 r2756 21 21 22 22 namespace HeuristicLab.Parameters.Views { 23 partial class OperatorParameterView{23 partial class ValueParameterView<T> { 24 24 /// <summary> 25 25 /// Required designer variable. … … 58 58 this.SuspendLayout(); 59 59 // 60 // dataTypeLabel61 //62 this.dataTypeLabel.TabIndex = 6;63 //64 60 // dataTypeTextBox 65 61 // 66 62 this.dataTypeTextBox.Location = new System.Drawing.Point(80, 94); 67 63 this.dataTypeTextBox.Size = new System.Drawing.Size(306, 20); 68 this.dataTypeTextBox.TabIndex = 7;69 64 // 70 65 // nameTextBox … … 75 70 this.nameTextBox.Size = new System.Drawing.Size(306, 20); 76 71 // 77 // descriptionLabel78 //79 this.descriptionLabel.TabIndex = 4;80 //81 72 // descriptionTextBox 82 73 // 83 74 this.descriptionTextBox.Location = new System.Drawing.Point(80, 26); 84 75 this.descriptionTextBox.Size = new System.Drawing.Size(306, 62); 85 this.descriptionTextBox.TabIndex = 5;86 76 // 87 77 // valueGroupBox … … 96 86 this.valueGroupBox.Name = "valueGroupBox"; 97 87 this.valueGroupBox.Size = new System.Drawing.Size(386, 195); 98 this.valueGroupBox.TabIndex = 10;88 this.valueGroupBox.TabIndex = 6; 99 89 this.valueGroupBox.TabStop = false; 100 90 this.valueGroupBox.Text = "&Value:"; … … 131 121 this.clearValueButton.Name = "clearValueButton"; 132 122 this.clearValueButton.Size = new System.Drawing.Size(23, 23); 133 this.clearValueButton.TabIndex = 9;123 this.clearValueButton.TabIndex = 1; 134 124 this.toolTip.SetToolTip(this.clearValueButton, "Clear Value"); 135 125 this.clearValueButton.UseVisualStyleBackColor = true; … … 142 132 this.setValueButton.Name = "setValueButton"; 143 133 this.setValueButton.Size = new System.Drawing.Size(23, 23); 144 this.setValueButton.TabIndex = 8;134 this.setValueButton.TabIndex = 0; 145 135 this.toolTip.SetToolTip(this.setValueButton, "Set Value"); 146 136 this.setValueButton.UseVisualStyleBackColor = true; 147 137 this.setValueButton.Click += new System.EventHandler(this.setValueButton_Click); 148 138 // 149 // OperatorParameterView139 // ValueParameterView 150 140 // 151 141 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 152 142 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 153 143 this.Controls.Add(this.valueGroupBox); 154 this.Name = " OperatorParameterView";144 this.Name = "ValueParameterView"; 155 145 this.Size = new System.Drawing.Size(386, 315); 156 146 this.Controls.SetChildIndex(this.descriptionTextBox, 0); -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueParameterView.cs
r2754 r2756 35 35 /// The visual representation of a <see cref="Parameter"/>. 36 36 /// </summary> 37 [Content(typeof( OperatorParameter), true)]38 [Content(typeof(I OperatorParameter), false)]39 public partial class OperatorParameterView : ParameterView{37 [Content(typeof(ValueParameter<>), true)] 38 [Content(typeof(IValueParameter<>), false)] 39 public partial class ValueParameterView<T> : ParameterView where T : class, IItem { 40 40 protected TypeSelectorDialog typeSelectorDialog; 41 41 … … 45 45 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>. 46 46 /// No own data storage present.</remarks> 47 public new I OperatorParameterContent {48 get { return (I OperatorParameter)base.Content; }47 public new IValueParameter<T> Content { 48 get { return (IValueParameter<T>)base.Content; } 49 49 set { base.Content = value; } 50 50 } … … 53 53 /// Initializes a new instance of <see cref="VariableView"/> with caption "Variable". 54 54 /// </summary> 55 public OperatorParameterView() {55 public ValueParameterView() { 56 56 InitializeComponent(); 57 Caption = " OperatorParameter";57 Caption = "ValueParameter"; 58 58 } 59 59 /// <summary> … … 62 62 /// <remarks>Calls <see cref="VariableView()"/>.</remarks> 63 63 /// <param name="variable">The variable to represent visually.</param> 64 public OperatorParameterView(IOperatorParametercontent)64 public ValueParameterView(IValueParameter<T> content) 65 65 : this() { 66 66 Content = content; … … 88 88 base.OnContentChanged(); 89 89 if (Content == null) { 90 Caption = " OperatorParameter";90 Caption = "ValueParameter"; 91 91 setValueButton.Enabled = false; 92 92 clearValueButton.Enabled = false; … … 115 115 if (typeSelectorDialog == null) { 116 116 typeSelectorDialog = new TypeSelectorDialog(); 117 typeSelectorDialog.Caption = "Select Operator";117 typeSelectorDialog.Caption = "Select Value"; 118 118 typeSelectorDialog.TypeSelector.Configure(Content.DataType, false, false); 119 119 } 120 120 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) 121 Content.Value = ( IOperator)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();121 Content.Value = (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 122 122 } 123 123 protected virtual void clearValueButton_Click(object sender, EventArgs e) { … … 137 137 protected virtual void valuePanel_DragDrop(object sender, DragEventArgs e) { 138 138 if (e.Effect != DragDropEffects.None) { 139 IOperator value = e.Data.GetData("Value") as IOperator;140 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) value = ( IOperator)value.Clone();139 T value = e.Data.GetData("Value") as T; 140 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) value = (T)value.Clone(); 141 141 Content.Value = value; 142 142 } -
trunk/sources/HeuristicLab.Parameters/3.3/HeuristicLab.Parameters-3.3.csproj
r2754 r2756 50 50 <ItemGroup> 51 51 <None Include="HeuristicLabParametersPlugin.cs.frame" /> 52 <Compile Include="SubScopesItemParameter.cs" /> 52 <Compile Include="LookupParameter.cs" /> 53 <Compile Include="SubScopesLookupParameter.cs" /> 54 <Compile Include="ValueLookupParameter.cs" /> 55 <Compile Include="ValueParameter.cs" /> 53 56 <Compile Include="ScopeParameter.cs" /> 54 57 <Compile Include="HeuristicLabParametersPlugin.cs" /> 55 <Compile Include="ItemParameter.cs" />56 58 <Compile Include="OperatorParameter.cs" /> 57 59 <Compile Include="Parameter.cs" /> … … 66 68 <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project> 67 69 <Name>HeuristicLab.Collections-3.3</Name> 70 </ProjectReference> 71 <ProjectReference Include="..\..\HeuristicLab.Common\3.2\HeuristicLab.Common-3.2.csproj"> 72 <Project>{1FC004FC-59AF-4249-B1B6-FF25873A20E4}</Project> 73 <Name>HeuristicLab.Common-3.2</Name> 68 74 </ProjectReference> 69 75 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> -
trunk/sources/HeuristicLab.Parameters/3.3/HeuristicLabParametersPlugin.cs.frame
r2754 r2756 32 32 [PluginFile("HeuristicLab.Parameters-3.3.dll", PluginFileType.Assembly)] 33 33 [PluginDependency("HeuristicLab.Collections", "3.3")] 34 [PluginDependency("HeuristicLab.Common", "3.2")] 34 35 [PluginDependency("HeuristicLab.Core", "3.3")] 35 36 [PluginDependency("HeuristicLab.Persistence", "3.3")] -
trunk/sources/HeuristicLab.Parameters/3.3/OperatorParameter.cs
r2740 r2756 32 32 /// </summary> 33 33 [Item("OperatorParameter", "A parameter which represents an operator.")] 34 [EmptyStorableClass] 34 35 [Creatable("Test")] 35 public class OperatorParameter : Parameter, IOperatorParameter { 36 private IOperator value; 37 [Storable] 38 public IOperator Value { 39 get { return this.value; } 40 set { 41 if (value != this.value) { 42 if (this.value != null) this.value.Changed -= new ChangedEventHandler(Value_Changed); 43 this.value = value; 44 if (this.value != null) this.value.Changed += new ChangedEventHandler(Value_Changed); 45 OnValueChanged(); 46 } 47 } 36 public class OperatorParameter : ValueParameter<IOperator> { 37 public OperatorParameter() 38 : base("Anonymous") { 48 39 } 49 50 public OperatorParameter() 51 : base("Anonymous", null, typeof(IOperator)) { 40 public OperatorParameter(string name) 41 : base(name) { 42 } 43 public OperatorParameter(string name, IOperator value) 44 : base(name, value) { 45 Value = value; 52 46 } 53 47 public OperatorParameter(string name, string description) 54 : base(name, description , typeof(IOperator)) {48 : base(name, description) { 55 49 } 56 50 public OperatorParameter(string name, string description, IOperator value) 57 : base(name, description, typeof(IOperator)) {51 : base(name, description, value) { 58 52 Value = value; 59 }60 61 public override IDeepCloneable Clone(Cloner cloner) {62 OperatorParameter clone = (OperatorParameter)base.Clone(cloner);63 clone.Value = (IOperator)cloner.Clone(value);64 return clone;65 }66 67 public override string ToString() {68 return string.Format("{0}: {1} ({2})", Name, Value != null ? Value.ToString() : "null", DataType.Name);69 }70 71 public event EventHandler ValueChanged;72 private void OnValueChanged() {73 if (ValueChanged != null)74 ValueChanged(this, new EventArgs());75 OnChanged();76 }77 private void Value_Changed(object sender, ChangedEventArgs e) {78 OnChanged(e);79 53 } 80 54 } -
trunk/sources/HeuristicLab.Parameters/3.3/Parameter.cs
r2740 r2756 56 56 dataType = typeof(IItem); 57 57 } 58 protected Parameter(string name, Type dataType) 59 : base(name) { 60 if (dataType == null) throw new ArgumentNullException(); 61 this.dataType = dataType; 62 } 58 63 protected Parameter(string name, string description, Type dataType) 59 64 : base(name, description) { -
trunk/sources/HeuristicLab.Parameters/3.3/ScopeParameter.cs
r2740 r2756 40 40 41 41 public ScopeParameter() 42 : base("Anonymous", null, typeof(IScope)) { 42 : base("Anonymous", typeof(IScope)) { 43 } 44 public ScopeParameter(string name) 45 : base(name, typeof(IScope)) { 43 46 } 44 47 public ScopeParameter(string name, string description) -
trunk/sources/HeuristicLab.Parameters/3.3/SubScopesLookupParameter.cs
r2754 r2756 24 24 using System.Text; 25 25 using System.Xml; 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 31 32 /// A generic parameter representing instances of type T which are collected from the sub-scopes of the current scope. 32 33 /// </summary> 33 [Item("SubScopes ItemParameter<T>", "A generic parameter representing instances of type T which are collected from the sub-scopes of the current scope.")]34 public class SubScopes ItemParameter<T> : Parameterwhere T : class, IItem {34 [Item("SubScopesLookupParameter<T>", "A generic parameter representing instances of type T which are collected from the sub-scopes of the current scope.")] 35 public class SubScopesLookupParameter<T> : Parameter, ILookupParameter<T> where T : class, IItem { 35 36 [Storable] 36 37 private string actualName; … … 46 47 } 47 48 48 public T[] Values {49 get { return Get Values(); }50 set { Set Values(value); }49 public T[] ActualValues { 50 get { return GetActualValues(); } 51 set { SetActualValues(value); } 51 52 } 52 53 53 public SubScopes ItemParameter()54 : base("Anonymous", null,typeof(T)) {54 public SubScopesLookupParameter() 55 : base("Anonymous", typeof(T)) { 55 56 actualName = Name; 56 57 } 57 public SubScopesItemParameter(string name, string description) 58 public SubScopesLookupParameter(string name) 59 : base(name, typeof(T)) { 60 actualName = Name; 61 } 62 public SubScopesLookupParameter(string name, string description) 58 63 : base(name, description, typeof(T)) { 59 64 actualName = Name; … … 61 66 62 67 public override IDeepCloneable Clone(Cloner cloner) { 63 SubScopes ItemParameter<T> clone = (SubScopesItemParameter<T>)base.Clone(cloner);68 SubScopesLookupParameter<T> clone = (SubScopesLookupParameter<T>)base.Clone(cloner); 64 69 clone.actualName = actualName; 65 70 return clone; … … 70 75 } 71 76 72 protected string GetActualName() { 73 string name = Name; 74 ExecutionContext current = ExecutionContext; 75 while (current != null) { 76 if (current.Operator.Parameters.ContainsKey(name)) 77 name = ((SubScopesItemParameter<T>)current.Operator.Parameters[name]).ActualName; 78 current = current.Parent; 77 protected virtual T[] GetActualValues() { 78 string name = LookupParameter<T>.TranslateName(Name, ExecutionContext); 79 IScope scope = ExecutionContext.Scope; 80 T[] values = new T[scope.SubScopes.Count]; 81 IVariable var; 82 T value; 83 84 for (int i = 0; i < values.Length; i++) { 85 scope.SubScopes[i].Variables.TryGetValue(name, out var); 86 if (var != null) { 87 value = var.Value as T; 88 if (value == null) 89 throw new InvalidOperationException( 90 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 91 name, 92 typeof(T).GetPrettyName()) 93 ); 94 values[i] = value; 95 } 79 96 } 80 return name;97 return values; 81 98 } 82 protected virtual T[] GetValues() { 83 string name = GetActualName(); 84 IScope scope = ExecutionContext.Scope; 85 T[] value = new T[scope.SubScopes.Count]; 86 IVariable var; 87 88 for (int i = 0; i < value.Length; i++) { 89 scope.SubScopes[i].Variables.TryGetValue(name, out var); 90 if (var != null) value[i] = (T)var.Value; 91 } 92 return value; 93 } 94 protected virtual void SetValues(T[] values) { 95 string name = GetActualName(); 99 protected virtual void SetActualValues(T[] values) { 100 string name = LookupParameter<T>.TranslateName(Name, ExecutionContext); 96 101 IScope scope = ExecutionContext.Scope; 97 102 IVariable var; -
trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs
r2754 r2756 24 24 using System.Text; 25 25 using System.Xml; 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 29 30 namespace HeuristicLab.Parameters { 30 31 /// <summary> 31 /// A generic parameter which represents an instance of type T.32 /// A parameter whose value is either defined it the parameter itself or is retrieved from the scope. 32 33 /// </summary> 33 [Item(" ItemParameter<T>", "A generic parameter which represents an instance of type T.")]34 public class ItemParameter<T> : Parameterwhere T : class, IItem {34 [Item("ValueLookupParameter<T>", "A parameter whose value is either defined it the parameter itself or is retrieved from the scope.")] 35 public class ValueLookupParameter<T> : Parameter, IValueLookupParameter<T> where T : class, IItem { 35 36 [Storable] 36 37 private string actualName; … … 46 47 } 47 48 48 private T localValue;49 private T value; 49 50 [Storable] 50 public T LocalValue {51 get { return this. localValue; }51 public T Value { 52 get { return this.value; } 52 53 set { 53 if (value != this.localValue) { 54 if ((value != null) && (!DataType.IsInstanceOfType(value))) throw new ArgumentException("Static value does not match data type of parameter"); 55 if (this.localValue != null) this.localValue.Changed -= new ChangedEventHandler(LocalValue_Changed); 56 this.localValue = value; 57 if (this.localValue != null) this.localValue.Changed += new ChangedEventHandler(LocalValue_Changed); 58 OnLocalValueChanged(); 54 if (value != this.value) { 55 if (this.value != null) this.value.Changed -= new ChangedEventHandler(Value_Changed); 56 this.value = value; 57 if (this.value != null) this.value.Changed += new ChangedEventHandler(Value_Changed); 58 OnValueChanged(); 59 59 } 60 60 } 61 61 } 62 62 63 public T Value {64 get { return Get Value(); }65 set { Set Value(value); }63 public T ActualValue { 64 get { return GetActualValue(); } 65 set { SetActualValue(value); } 66 66 } 67 67 68 public ItemParameter()69 : base("Anonymous", null,typeof(T)) {68 public ValueLookupParameter() 69 : base("Anonymous", typeof(T)) { 70 70 actualName = Name; 71 LocalValue = null;72 71 } 73 public ItemParameter(string name, string description) 72 public ValueLookupParameter(string name) 73 : base(name, typeof(T)) { 74 actualName = Name; 75 } 76 public ValueLookupParameter(string name, T value) 77 : base(name, typeof(T)) { 78 actualName = Name; 79 Value = value; 80 } 81 public ValueLookupParameter(string name, string description) 74 82 : base(name, description, typeof(T)) { 75 83 actualName = Name; 76 LocalValue = null;77 84 } 78 public ItemParameter(string name, string description, T localValue)85 public ValueLookupParameter(string name, string description, T value) 79 86 : base(name, description, typeof(T)) { 80 87 actualName = Name; 81 LocalValue = localValue;88 Value = value; 82 89 } 83 90 84 91 public override IDeepCloneable Clone(Cloner cloner) { 85 ItemParameter<T> clone = (ItemParameter<T>)base.Clone(cloner);92 ValueLookupParameter<T> clone = (ValueLookupParameter<T>)base.Clone(cloner); 86 93 clone.actualName = actualName; 87 clone. LocalValue = (T)cloner.Clone(localValue);94 clone.Value = (T)cloner.Clone(value); 88 95 return clone; 89 96 } 90 97 91 98 public override string ToString() { 92 return string.Format("{0}: {1} ({2})", Name, LocalValue != null ? LocalValue.ToString() : ActualName, DataType.Name);99 return string.Format("{0}: {1} ({2})", Name, Value != null ? Value.ToString() : ActualName, DataType.Name); 93 100 } 94 101 95 protected ItemParameter<T> GetParameter(out string name) { 96 ItemParameter<T> param = this; 102 private IValueParameter<T> GetParameter(out string name) { 103 IValueParameter<T> valueParam = this; 104 ILookupParameter<T> lookupParam = this; 97 105 ExecutionContext current = ExecutionContext; 98 name = param.Name; 99 while (param != null) { 100 if (param.LocalValue != null) return param; 101 name = param.ActualName; 106 107 name = Name; 108 while ((valueParam != null) && (lookupParam != null)) { 109 if ((valueParam != null) && (valueParam.Value != null)) return valueParam; 110 if (lookupParam != null) name = lookupParam.ActualName; 111 102 112 current = current.Parent; 103 113 while ((current != null) && !current.Operator.Parameters.ContainsKey(name)) 104 114 current = current.Parent; 105 if (current != null) 106 param = (ItemParameter<T>)current.Operator.Parameters[actualName]; 107 else 108 param = null; 115 116 if (current != null) { 117 valueParam = current.Operator.Parameters[name] as IValueParameter<T>; 118 lookupParam = current.Operator.Parameters[name] as ILookupParameter<T>; 119 if ((valueParam == null) && (lookupParam == null)) 120 throw new InvalidOperationException( 121 string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\" or an \"{2}\".", 122 name, 123 typeof(IValueParameter<T>).GetPrettyName(), 124 typeof(ILookupParameter<T>).GetPrettyName()) 125 ); 126 } else { 127 valueParam = null; 128 lookupParam = null; 129 } 109 130 } 110 131 return null; 111 132 } 112 pr otected IVariable GetVariable(string name) {133 private IVariable LookupVariable(string name) { 113 134 IScope scope = ExecutionContext.Scope; 114 135 while ((scope != null) && !scope.Variables.ContainsKey(name)) … … 116 137 return scope != null ? scope.Variables[actualName] : null; 117 138 } 118 protected virtual T Get Value() {139 protected virtual T GetActualValue() { 119 140 string name; 120 141 // try to get local value from context stack 121 I temParameter<T> param = GetParameter(out name);142 IValueParameter<T> param = GetParameter(out name); 122 143 if (param != null) return param.Value; 123 else { 124 // try to get variable from scope 125 IVariable var = GetVariable(name); 126 if (var != null) return (T)var.Value; 144 else { // try to get variable from scope 145 IVariable var = LookupVariable(name); 146 if (var != null) { 147 T value = var.Value as T; 148 if (value == null) 149 throw new InvalidOperationException( 150 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 151 name, 152 typeof(T).GetPrettyName()) 153 ); 154 return value; 155 } 127 156 } 128 157 return null; 129 158 } 130 protected virtual void Set Value(T value) {159 protected virtual void SetActualValue(T value) { 131 160 string name; 132 161 // try to get local value from context stack 133 I temParameter<T> param = GetParameter(out name);162 IValueParameter<T> param = GetParameter(out name); 134 163 if (param != null) param.Value = value; 135 else { 136 // try to get variable from scope 137 IVariable var = GetVariable(name); 164 else { // try to get variable from scope 165 IVariable var = LookupVariable(name); 138 166 if (var != null) var.Value = value; 139 167 else ExecutionContext.Scope.Variables.Add(new Variable(name, value)); … … 147 175 OnChanged(); 148 176 } 149 public event EventHandler LocalValueChanged;150 private void On LocalValueChanged() {151 if ( LocalValueChanged != null)152 LocalValueChanged(this, new EventArgs());177 public event EventHandler ValueChanged; 178 private void OnValueChanged() { 179 if (ValueChanged != null) 180 ValueChanged(this, new EventArgs()); 153 181 OnChanged(); 154 182 } 155 private void LocalValue_Changed(object sender, ChangedEventArgs e) {183 private void Value_Changed(object sender, ChangedEventArgs e) { 156 184 OnChanged(e); 157 185 }
Note: See TracChangeset
for help on using the changeset viewer.