Changeset 14432 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeVariableNodeEditDialog.cs
- Timestamp:
- 11/30/16 16:33:05 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeVariableNodeEditDialog.cs
r14185 r14432 22 22 using System; 23 23 using System.ComponentModel; 24 using System.Linq; 24 25 using System.Text; 25 26 using System.Windows.Forms; … … 40 41 } 41 42 43 public string SelectedVariableName { 44 get { return variableNamesCombo.Visible ? variableNamesCombo.Text : variableNameTextBox.Text; } 45 } 46 42 47 public VariableNodeEditDialog(ISymbolicExpressionTreeNode node) { 43 48 InitializeComponent(); 44 49 oldValueTextBox.TabStop = false; // cannot receive focus using tab key 45 46 50 NewNode = (VariableTreeNode)node; // will throw an invalid cast exception if node is not of the correct type 47 51 InitializeFields(); … … 57 61 variableNameLabel.Visible = true; 58 62 variableNamesCombo.Visible = true; 59 foreach (var name in variableTreeNode.Symbol.VariableNames) variableNamesCombo.Items.Add(name); 60 variableNamesCombo.SelectedIndex = variableNamesCombo.Items.IndexOf(variableTreeNode.VariableName); 63 if (variableTreeNode.Symbol.VariableNames.Any()) { 64 foreach (var name in variableTreeNode.Symbol.VariableNames) 65 variableNamesCombo.Items.Add(name); 66 variableNamesCombo.SelectedIndex = variableNamesCombo.Items.IndexOf(variableTreeNode.VariableName); 67 variableNamesCombo.Visible = true; 68 variableNameTextBox.Visible = false; 69 } else { 70 variableNamesCombo.Visible = false; 71 variableNameTextBox.Visible = true; 72 } 61 73 } 62 74 } … … 93 105 #region combo box validation and events 94 106 private void variableNamesCombo_Validating(object sender, CancelEventArgs e) { 107 if (variableNamesCombo.Items.Count == 0) return; 95 108 if (variableNamesCombo.Items.Contains(variableNamesCombo.SelectedItem)) return; 96 109 e.Cancel = true; … … 119 132 private void OnDialogValidated(object sender, EventArgs e) { 120 133 double weight = double.Parse(newValueTextBox.Text); 121 var variableName = (string)variableNamesCombo.SelectedItem;122 134 // we impose an extra validation condition: that the weight/value be different than the original ones 135 var variableName = SelectedVariableName; 123 136 if (variableTreeNode.Weight.Equals(weight) && variableTreeNode.VariableName.Equals(variableName)) return; 124 137 variableTreeNode.Weight = weight;
Note: See TracChangeset
for help on using the changeset viewer.