Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/15/21 11:50:57 (2 years ago)
Author:
gkronber
Message:

#3140: merged r18091:18131 from branch to trunk

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views

  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.cs

    r17180 r18132  
    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 INumericTreeNode numberTreeNode;
     32    public INumericTreeNode 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 = (INumericTreeNode)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 = (INumericTreeNode)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 {
    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();
    5555      }
    5656    }
     
    7171
    7272    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 _);
    7574      errorMessage = string.Empty;
    7675      if (!valid) {
     
    8786    // proxy handler passing key strokes to the parent control
    8887    private void childControl_KeyDown(object sender, KeyEventArgs e) {
    89       ConstantNodeEditDialog_KeyDown(sender, e);
     88      NumberNodeEditDialog_KeyDown(sender, e);
    9089    }
    9190
    92     private void ConstantNodeEditDialog_KeyDown(object sender, KeyEventArgs e) {
     91    private void NumberNodeEditDialog_KeyDown(object sender, KeyEventArgs e) {
    9392      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
    9493        if (!ValidateChildren()) return;
     
    10099    public event EventHandler DialogValidated;
    101100    private void OnDialogValidated(object sender, EventArgs e) {
    102       if (constantTreeNode == null) return;
     101      if (numberTreeNode == null) return;
    103102      var value = double.Parse(newValueTextBox.Text);
    104103      // 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;
    106105
    107       constantTreeNode.Value = value;
     106      numberTreeNode.Value = value;
    108107      DialogResult = DialogResult.OK;
    109108      var dialogValidated = DialogValidated;
Note: See TracChangeset for help on using the changeset viewer.