Changeset 14432 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs
- Timestamp:
- 11/30/16 16:33:05 (8 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs
r14185 r14432 57 57 this.okButton = new System.Windows.Forms.Button(); 58 58 this.cancelButton = new System.Windows.Forms.Button(); 59 this.variableNameTextBox = new System.Windows.Forms.TextBox(); 59 60 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 60 61 this.SuspendLayout(); … … 168 169 this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); 169 170 // 171 // variableNameTextBox 172 // 173 this.variableNameTextBox.Location = new System.Drawing.Point(101, 63); 174 this.variableNameTextBox.Name = "variableNameTextBox"; 175 this.variableNameTextBox.Size = new System.Drawing.Size(127, 20); 176 this.variableNameTextBox.TabIndex = 11; 177 this.variableNameTextBox.Visible = false; 178 // 170 179 // InsertNodeDialog 171 180 // … … 175 184 this.ClientSize = new System.Drawing.Size(241, 133); 176 185 this.ControlBox = false; 186 this.Controls.Add(this.variableNameTextBox); 177 187 this.Controls.Add(this.cancelButton); 178 188 this.Controls.Add(this.okButton); … … 208 218 private System.Windows.Forms.Button cancelButton; 209 219 private System.Windows.Forms.Button okButton; 220 private System.Windows.Forms.TextBox variableNameTextBox; 210 221 } 211 222 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs
r14185 r14432 23 23 using System.Collections.Generic; 24 24 using System.ComponentModel; 25 using System.Linq; 25 26 using System.Text; 26 27 using System.Windows.Forms; … … 30 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 31 32 public partial class InsertNodeDialog : Form { 33 public string SelectedVariableName { 34 get { 35 var variable = SelectedSymbol as Variable; 36 if (variable == null) 37 return string.Empty; 38 return variable.VariableNames.Any() ? variableNamesCombo.Text : variableNameTextBox.Text; 39 } 40 } 41 32 42 public InsertNodeDialog() { 33 43 InitializeComponent(); … … 40 50 } 41 51 42 public ISymbol SelectedSymbol (){43 return (ISymbol)allowedSymbolsCombo.SelectedItem;52 public ISymbol SelectedSymbol { 53 get { return (ISymbol)allowedSymbolsCombo.SelectedItem; } 44 54 } 45 55 … … 56 66 constantValueTextBox.Visible = true; 57 67 } else if (symbol is Variable) { 58 var variable = (Variable)symbol; 59 foreach (var name in variable.VariableNames) variableNamesCombo.Items.Add(name); 60 variableNamesCombo.SelectedIndex = 0; 68 var variableSymbol = (Variable)symbol; 69 if (variableSymbol.VariableNames.Any()) { 70 foreach (var name in variableSymbol.VariableNames) 71 variableNamesCombo.Items.Add(name); 72 variableNamesCombo.SelectedIndex = 0; 73 variableNamesCombo.Visible = true; 74 variableNameTextBox.Visible = false; 75 } else { 76 variableNamesCombo.Visible = false; 77 variableNameTextBox.Visible = true; 78 } 61 79 variableNameLabel.Visible = true; 62 variableNamesCombo.Visible = true;63 80 variableWeightLabel.Visible = true; 64 81 variableWeightTextBox.Visible = true; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeVariableNodeEditDialog.Designer.cs
r14185 r14432 55 55 this.okButton = new System.Windows.Forms.Button(); 56 56 this.cancelButton = new System.Windows.Forms.Button(); 57 this.variableNameTextBox = new System.Windows.Forms.TextBox(); 57 58 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 58 59 this.SuspendLayout(); … … 146 147 this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); 147 148 // 149 // variableNameTextBox 150 // 151 this.variableNameTextBox.Location = new System.Drawing.Point(101, 12); 152 this.variableNameTextBox.Name = "variableNameTextBox"; 153 this.variableNameTextBox.Size = new System.Drawing.Size(131, 20); 154 this.variableNameTextBox.TabIndex = 12; 155 this.variableNameTextBox.Visible = false; 156 // 148 157 // VariableNodeEditDialog 149 158 // … … 154 163 this.ClientSize = new System.Drawing.Size(244, 134); 155 164 this.ControlBox = false; 165 this.Controls.Add(this.variableNameTextBox); 156 166 this.Controls.Add(this.cancelButton); 157 167 this.Controls.Add(this.okButton); … … 188 198 public System.Windows.Forms.TextBox newValueTextBox; 189 199 public System.Windows.Forms.ComboBox variableNamesCombo; 200 private System.Windows.Forms.TextBox variableNameTextBox; 190 201 } 191 202 } -
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.