Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/01/21 13:40:55 (2 years ago)
Author:
chaider
Message:

#3140

  • some more refactoring
  • added possibility to set value of num nodes in infix parser
  • changed displaying style of number
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.cs

    r17180 r18100  
    2828
    2929namespace 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 NumberTreeNode numberTreeNode;
     32    public NumberTreeNode NewNode {
     33      get { return numberTreeNode; }
    3434      set {
    3535        if (InvokeRequired)
    36           Invoke(new Action<SymbolicExpressionTreeNode>(x => constantTreeNode = (ConstantTreeNode)x), value);
     36          Invoke(new Action<SymbolicExpressionTreeNode>(x => numberTreeNode = (NumberTreeNode)x), value);
    3737        else
    38           constantTreeNode = value;
     38          numberTreeNode = value;
    3939      }
    4040    }
    4141
    42     public ConstantNodeEditDialog(ISymbolicExpressionTreeNode node) {
     42    public NumberNodeEditDialog(ISymbolicExpressionTreeNode node) {
    4343      InitializeComponent();
    4444      oldValueTextBox.TabStop = false; // cannot receive focus using tab key
    45       NewNode = (ConstantTreeNode)node;
     45      NewNode = (NumberTreeNode)node;
    4646      InitializeFields();
    4747    }
     
    4949    private void InitializeFields() {
    5050      if (NewNode == null)
    51         throw new ArgumentException("Node is not a constant.");
     51        throw new ArgumentException("Node is not a number.");
    5252      else {
    5353        this.Text = "Edit constant";
    54         newValueTextBox.Text = oldValueTextBox.Text = Math.Round(constantTreeNode.Value, 4).ToString();
     54        newValueTextBox.Text = oldValueTextBox.Text = Math.Round(numberTreeNode.Value, 4).ToString();
    5555      }
    5656    }
     
    8787    // proxy handler passing key strokes to the parent control
    8888    private void childControl_KeyDown(object sender, KeyEventArgs e) {
    89       ConstantNodeEditDialog_KeyDown(sender, e);
     89      NumberNodeEditDialog_KeyDown(sender, e);
    9090    }
    9191
    92     private void ConstantNodeEditDialog_KeyDown(object sender, KeyEventArgs e) {
     92    private void NumberNodeEditDialog_KeyDown(object sender, KeyEventArgs e) {
    9393      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
    9494        if (!ValidateChildren()) return;
     
    100100    public event EventHandler DialogValidated;
    101101    private void OnDialogValidated(object sender, EventArgs e) {
    102       if (constantTreeNode == null) return;
     102      if (numberTreeNode == null) return;
    103103      var value = double.Parse(newValueTextBox.Text);
    104104      // we impose an extra validation condition: that the new value is different from the original value
    105       if (constantTreeNode.Value.Equals(value)) return;
     105      if (numberTreeNode.Value.Equals(value)) return;
    106106
    107       constantTreeNode.Value = value;
     107      numberTreeNode.Value = value;
    108108      DialogResult = DialogResult.OK;
    109109      var dialogValidated = DialogValidated;
Note: See TracChangeset for help on using the changeset viewer.