Changeset 2756 for trunk/sources/HeuristicLab.Core.Views
- Timestamp:
- 02/05/10 05:23:56 (15 years ago)
- File:
-
- 1 edited
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
Note: See TracChangeset
for help on using the changeset viewer.