Changeset 15281 for branches/Async/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeVariableNodeEditDialog.cs
- Timestamp:
- 07/23/17 11:17:18 (8 years ago)
- Location:
- branches/Async
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Async
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/Async/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
-
branches/Async/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeVariableNodeEditDialog.cs
r12012 r15281 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.ComponentModel; 24 using System.Linq; 24 25 using System.Text; 25 26 using System.Windows.Forms; … … 33 34 get { return variableTreeNode; } 34 35 set { 35 if (InvokeRequired) 36 Invoke(new Action<SymbolicExpressionTreeNode>(x => variableTreeNode = (VariableTreeNode)x), value); 37 else 36 if (InvokeRequired) { 37 Invoke(new Action<SymbolicExpressionTreeNode>(x => 38 { 39 variableTreeNode = (VariableTreeNode) x; 40 variableNameTextBox.Text = variableTreeNode.VariableName; 41 }), value); 42 } else { 38 43 variableTreeNode = value; 44 variableNameTextBox.Text = variableTreeNode.VariableName; 45 } 39 46 } 47 } 48 49 public string SelectedVariableName { 50 get { return variableNamesCombo.Visible ? variableNamesCombo.Text : variableNameTextBox.Text; } 40 51 } 41 52 … … 43 54 InitializeComponent(); 44 55 oldValueTextBox.TabStop = false; // cannot receive focus using tab key 45 46 56 NewNode = (VariableTreeNode)node; // will throw an invalid cast exception if node is not of the correct type 47 57 InitializeFields(); … … 57 67 variableNameLabel.Visible = true; 58 68 variableNamesCombo.Visible = true; 59 foreach (var name in variableTreeNode.Symbol.VariableNames) variableNamesCombo.Items.Add(name); 60 variableNamesCombo.SelectedIndex = variableNamesCombo.Items.IndexOf(variableTreeNode.VariableName); 69 if (variableTreeNode.Symbol.VariableNames.Any()) { 70 foreach (var name in variableTreeNode.Symbol.VariableNames) 71 variableNamesCombo.Items.Add(name); 72 variableNamesCombo.SelectedIndex = variableNamesCombo.Items.IndexOf(variableTreeNode.VariableName); 73 variableNamesCombo.Visible = true; 74 variableNameTextBox.Visible = false; 75 } else { 76 variableNamesCombo.Visible = false; 77 variableNameTextBox.Visible = true; 78 } 61 79 } 62 80 } … … 93 111 #region combo box validation and events 94 112 private void variableNamesCombo_Validating(object sender, CancelEventArgs e) { 113 if (variableNamesCombo.Items.Count == 0) return; 95 114 if (variableNamesCombo.Items.Contains(variableNamesCombo.SelectedItem)) return; 96 115 e.Cancel = true; … … 119 138 private void OnDialogValidated(object sender, EventArgs e) { 120 139 double weight = double.Parse(newValueTextBox.Text); 121 var variableName = (string)variableNamesCombo.SelectedItem;122 140 // we impose an extra validation condition: that the weight/value be different than the original ones 141 var variableName = SelectedVariableName; 123 142 if (variableTreeNode.Weight.Equals(weight) && variableTreeNode.VariableName.Equals(variableName)) return; 124 143 variableTreeNode.Weight = weight;
Note: See TracChangeset
for help on using the changeset viewer.