Changeset 18132 for trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.cs
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/3140_NumberSymbol (added) merged: 18091,18093,18100,18112-18121,18123-18131
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
/branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views (added) merged: 18100,18114-18115,18125
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.cs
r17180 r18132 28 28 29 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 30 public partial class ConstantNodeEditDialog : Form {31 private ConstantTreeNode constantTreeNode;32 public ConstantTreeNode NewNode {33 get { return constantTreeNode; }30 public partial class NumberNodeEditDialog : Form { 31 private INumericTreeNode numberTreeNode; 32 public INumericTreeNode NewNode { 33 get { return numberTreeNode; } 34 34 set { 35 35 if (InvokeRequired) 36 Invoke(new Action<SymbolicExpressionTreeNode>(x => constantTreeNode = (ConstantTreeNode)x), value);36 Invoke(new Action<SymbolicExpressionTreeNode>(x => numberTreeNode = (INumericTreeNode)x), value); 37 37 else 38 constantTreeNode = value;38 numberTreeNode = value; 39 39 } 40 40 } 41 41 42 public ConstantNodeEditDialog(ISymbolicExpressionTreeNode node) {42 public NumberNodeEditDialog(ISymbolicExpressionTreeNode node) { 43 43 InitializeComponent(); 44 44 oldValueTextBox.TabStop = false; // cannot receive focus using tab key 45 NewNode = ( ConstantTreeNode)node;45 NewNode = (INumericTreeNode)node; 46 46 InitializeFields(); 47 47 } … … 49 49 private void InitializeFields() { 50 50 if (NewNode == null) 51 throw new ArgumentException("Node is not a constant.");51 throw new ArgumentException("Node is not a number."); 52 52 else { 53 this.Text = "Edit constant";54 newValueTextBox.Text = oldValueTextBox.Text = Math.Round( constantTreeNode.Value, 4).ToString();53 this.Text = "Edit number"; 54 newValueTextBox.Text = oldValueTextBox.Text = Math.Round(numberTreeNode.Value, 4).ToString(); 55 55 } 56 56 } … … 71 71 72 72 private static bool ValidateNewValue(string value, out string errorMessage) { 73 double val; 74 bool valid = double.TryParse(value, out val); 73 bool valid = double.TryParse(value, out _); 75 74 errorMessage = string.Empty; 76 75 if (!valid) { … … 87 86 // proxy handler passing key strokes to the parent control 88 87 private void childControl_KeyDown(object sender, KeyEventArgs e) { 89 ConstantNodeEditDialog_KeyDown(sender, e);88 NumberNodeEditDialog_KeyDown(sender, e); 90 89 } 91 90 92 private void ConstantNodeEditDialog_KeyDown(object sender, KeyEventArgs e) {91 private void NumberNodeEditDialog_KeyDown(object sender, KeyEventArgs e) { 93 92 if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) { 94 93 if (!ValidateChildren()) return; … … 100 99 public event EventHandler DialogValidated; 101 100 private void OnDialogValidated(object sender, EventArgs e) { 102 if ( constantTreeNode == null) return;101 if (numberTreeNode == null) return; 103 102 var value = double.Parse(newValueTextBox.Text); 104 103 // we impose an extra validation condition: that the new value is different from the original value 105 if ( constantTreeNode.Value.Equals(value)) return;104 if (numberTreeNode.Value.Equals(value)) return; 106 105 107 constantTreeNode.Value = value;106 numberTreeNode.Value = value; 108 107 DialogResult = DialogResult.OK; 109 108 var dialogValidated = DialogValidated;
Note: See TracChangeset
for help on using the changeset viewer.