Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/22/12 15:03:32 (12 years ago)
Author:
bburlacu
Message:

#1763: Bugfixes and refactoring as suggested in the comments above.

Location:
branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs

    r8409 r8935  
    5353      this.variableNameLabel = new System.Windows.Forms.Label();
    5454      this.variableNamesCombo = new System.Windows.Forms.ComboBox();
     55      this.okButton = new System.Windows.Forms.Button();
     56      this.cancelButton = new System.Windows.Forms.Button();
    5557      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5658      this.SuspendLayout();
     
    5961      //
    6062      this.originalValueLabel.AutoSize = true;
    61       this.originalValueLabel.Location = new System.Drawing.Point(14, 15);
     63      this.originalValueLabel.Location = new System.Drawing.Point(12, 45);
    6264      this.originalValueLabel.Name = "originalValueLabel";
    6365      this.originalValueLabel.Size = new System.Drawing.Size(72, 13);
     
    6769      // oldValueTextBox
    6870      //
    69       this.oldValueTextBox.Location = new System.Drawing.Point(123, 12);
     71      this.oldValueTextBox.Location = new System.Drawing.Point(123, 42);
    7072      this.oldValueTextBox.Name = "oldValueTextBox";
    7173      this.oldValueTextBox.ReadOnly = true;
     
    7577      // newValueTextBox
    7678      //
    77       this.newValueTextBox.Location = new System.Drawing.Point(123, 38);
     79      this.newValueTextBox.Location = new System.Drawing.Point(123, 82);
    7880      this.newValueTextBox.Name = "newValueTextBox";
    7981      this.newValueTextBox.Size = new System.Drawing.Size(131, 20);
     
    8688      //
    8789      this.newValueLabel.AutoSize = true;
    88       this.newValueLabel.Location = new System.Drawing.Point(14, 41);
     90      this.newValueLabel.Location = new System.Drawing.Point(12, 85);
    8991      this.newValueLabel.Name = "newValueLabel";
    9092      this.newValueLabel.Size = new System.Drawing.Size(59, 13);
     
    101103      //
    102104      this.variableNameLabel.AutoSize = true;
    103       this.variableNameLabel.Location = new System.Drawing.Point(14, 74);
     105      this.variableNameLabel.Location = new System.Drawing.Point(12, 7);
    104106      this.variableNameLabel.Name = "variableNameLabel";
    105107      this.variableNameLabel.Size = new System.Drawing.Size(76, 13);
     
    112114      this.variableNamesCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    113115      this.variableNamesCombo.FormattingEnabled = true;
    114       this.variableNamesCombo.Location = new System.Drawing.Point(123, 71);
     116      this.variableNamesCombo.Location = new System.Drawing.Point(123, 4);
    115117      this.variableNamesCombo.Name = "variableNamesCombo";
    116118      this.variableNamesCombo.Size = new System.Drawing.Size(131, 21);
     
    121123      this.variableNamesCombo.Validated += new System.EventHandler(this.variableNamesCombo_Validated);
    122124      //
     125      // okButton
     126      //
     127      this.okButton.Location = new System.Drawing.Point(15, 119);
     128      this.okButton.Name = "okButton";
     129      this.okButton.Size = new System.Drawing.Size(75, 23);
     130      this.okButton.TabIndex = 8;
     131      this.okButton.Text = "OK";
     132      this.okButton.UseVisualStyleBackColor = true;
     133      this.okButton.Click += new System.EventHandler(this.okButton_Click);
     134      //
     135      // cancelButton
     136      //
     137      this.cancelButton.CausesValidation = false;
     138      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     139      this.cancelButton.Location = new System.Drawing.Point(179, 119);
     140      this.cancelButton.Name = "cancelButton";
     141      this.cancelButton.Size = new System.Drawing.Size(75, 23);
     142      this.cancelButton.TabIndex = 9;
     143      this.cancelButton.Text = "Cancel";
     144      this.cancelButton.UseVisualStyleBackColor = true;
     145      this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
     146      //
    123147      // ValueChangeDialog
    124148      //
     
    126150      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    127151      this.AutoSize = true;
    128       this.ClientSize = new System.Drawing.Size(269, 103);
     152      this.CancelButton = this.cancelButton;
     153      this.ClientSize = new System.Drawing.Size(269, 154);
     154      this.ControlBox = false;
     155      this.Controls.Add(this.cancelButton);
     156      this.Controls.Add(this.okButton);
    129157      this.Controls.Add(this.variableNamesCombo);
    130158      this.Controls.Add(this.variableNameLabel);
     
    133161      this.Controls.Add(this.oldValueTextBox);
    134162      this.Controls.Add(this.originalValueLabel);
     163      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
    135164      this.MaximizeBox = false;
    136165      this.MinimizeBox = false;
     
    151180    private System.Windows.Forms.Label originalValueLabel;
    152181    private System.Windows.Forms.TextBox oldValueTextBox;
    153     private System.Windows.Forms.TextBox newValueTextBox;
    154182    private System.Windows.Forms.Label newValueLabel;
    155183    private System.Windows.Forms.ErrorProvider errorProvider;
    156     private System.Windows.Forms.ComboBox variableNamesCombo;
    157184    private System.Windows.Forms.Label variableNameLabel;
     185    private System.Windows.Forms.Button cancelButton;
     186    private System.Windows.Forms.Button okButton;
     187    public System.Windows.Forms.TextBox newValueTextBox;
     188    public System.Windows.Forms.ComboBox variableNamesCombo;
    158189  }
    159190}
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.cs

    r8916 r8935  
    2929namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    3030  public partial class ValueChangeDialog : Form {
    31     private ISymbolicExpressionTreeNode _content;
     31    private ISymbolicExpressionTreeNode content;
    3232    public ISymbolicExpressionTreeNode Content {
    33       get { return _content; }
     33      get { return content; }
    3434      set {
    3535        if (InvokeRequired)
    36           Invoke(new Action<SymbolicExpressionTreeNode>(x => _content = x), value);
     36          Invoke(new Action<SymbolicExpressionTreeNode>(x => content = x), value);
    3737        else
    38           _content = value;
     38          content = value;
    3939      }
    40     }
    41 
    42     public string Caption {
    43       get { return this.Text; }
    44       set {
    45         if (InvokeRequired)
    46           Invoke(new Action<string>(x => this.Caption = x), value);
    47         else
    48           this.Text = value;
    49       }
    50     }
    51 
    52     public string OldValue {
    53       get { return oldValueTextBox.Text; }
    54       set {
    55         if (InvokeRequired)
    56           Invoke(new Action<string>(x => this.NewValue = x), value);
    57         else
    58           oldValueTextBox.Text = value;
    59       }
    60     }
    61 
    62     public string NewValue {
    63       get { return newValueTextBox.Text; }
    64       set {
    65         if (InvokeRequired)
    66           Invoke(new Action<string>(x => this.NewValue = x), value);
    67         else
    68           newValueTextBox.Text = value;
    69       }
    70     }
    71 
    72     public TextBox NewValueTextBox {
    73       get { return newValueTextBox; }
    74     }
    75 
    76     public ComboBox VariableNameComboBox {
    77       get { return variableNamesCombo; }
    7840    }
    7941
     
    8648      Content = content;
    8749      if (Content is VariableTreeNode) {
    88         Caption = "Change variable name or weight";
     50        this.Text = "Change variable name or weight";
    8951        var variable = Content as VariableTreeNode;
    90         OldValue = Math.Round(variable.Weight, 4).ToString();
    91         NewValue = OldValue;
     52        newValueTextBox.Text = oldValueTextBox.Text = Math.Round(variable.Weight, 4).ToString();
    9253        // add a dropbox containing all the available variable names
    9354        variableNameLabel.Visible = true;
     
    9556        foreach (var name in variable.Symbol.VariableNames) variableNamesCombo.Items.Add(name);
    9657        variableNamesCombo.SelectedIndex = variableNamesCombo.Items.IndexOf(variable.VariableName);
    97         //        variableNamesCombo.SelectedText = variable.VariableName;
    98         //        variableNamesCombo.SelectedIndex = 0;
    9958      } else if (Content is ConstantTreeNode) {
    100         Caption = "Change constant value";
     59        this.Text = "Change constant value";
    10160        var constant = Content as ConstantTreeNode;
    102         OldValue = Math.Round(constant.Value, 4).ToString();
    103         NewValue = OldValue;
     61        newValueTextBox.Text = oldValueTextBox.Text = Math.Round(constant.Value, 4).ToString();
    10462      }
    10563    }
     
    155113      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
    156114        if (!ValidateChildren()) return;
    157         DialogValidated(this, e);
     115        OnDialogValidated(this, e); // emit validated effect
    158116        Close();
    159117      }
     
    161119
    162120    public event EventHandler DialogValidated;
     121    private void OnDialogValidated(object sender, EventArgs e) {
     122      var dialogValidated = DialogValidated;
     123      if (dialogValidated != null)
     124        dialogValidated(sender, e);
     125    }
     126
     127    private void cancelButton_Click(object sender, EventArgs e) {
     128      Close();
     129    }
     130
     131    private void okButton_Click(object sender, EventArgs e) {
     132      if (ValidateChildren()) {
     133        OnDialogValidated(this, e);
     134        Close();
     135      }
     136    }
     137
    163138  }
    164139}
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs

    r8409 r8935  
    1 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    223  partial class InsertNodeDialog {
    324    /// <summary>
     
    3455      this.constantValueLabel = new System.Windows.Forms.Label();
    3556      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
     57      this.okButton = new System.Windows.Forms.Button();
     58      this.cancelButton = new System.Windows.Forms.Button();
    3659      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    3760      this.SuspendLayout();
     
    7093      //
    7194      this.variableNameLabel.AutoSize = true;
    72       this.variableNameLabel.Location = new System.Drawing.Point(13, 77);
     95      this.variableNameLabel.Location = new System.Drawing.Point(13, 74);
    7396      this.variableNameLabel.Name = "variableNameLabel";
    7497      this.variableNameLabel.Size = new System.Drawing.Size(35, 13);
     
    81104      this.variableNamesCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    82105      this.variableNamesCombo.FormattingEnabled = true;
    83       this.variableNamesCombo.Location = new System.Drawing.Point(120, 74);
     106      this.variableNamesCombo.Location = new System.Drawing.Point(120, 71);
    84107      this.variableNamesCombo.Name = "variableNamesCombo";
    85108      this.variableNamesCombo.Size = new System.Drawing.Size(108, 21);
     
    123146      this.errorProvider.RightToLeft = true;
    124147      //
     148      // okButton
     149      //
     150      this.okButton.Location = new System.Drawing.Point(12, 112);
     151      this.okButton.Name = "okButton";
     152      this.okButton.Size = new System.Drawing.Size(75, 23);
     153      this.okButton.TabIndex = 9;
     154      this.okButton.Text = "OK";
     155      this.okButton.UseVisualStyleBackColor = true;
     156      this.okButton.Click += new System.EventHandler(this.okButton_Click);
     157      //
     158      // cancelButton
     159      //
     160      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     161      this.cancelButton.Location = new System.Drawing.Point(153, 112);
     162      this.cancelButton.Name = "cancelButton";
     163      this.cancelButton.Size = new System.Drawing.Size(75, 23);
     164      this.cancelButton.TabIndex = 10;
     165      this.cancelButton.Text = "Cancel";
     166      this.cancelButton.UseVisualStyleBackColor = true;
     167      this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
     168      //
    125169      // InsertNodeDialog
    126170      //
    127171      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    128172      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    129       this.ClientSize = new System.Drawing.Size(240, 107);
     173      this.CancelButton = this.cancelButton;
     174      this.ClientSize = new System.Drawing.Size(240, 147);
     175      this.ControlBox = false;
     176      this.Controls.Add(this.cancelButton);
     177      this.Controls.Add(this.okButton);
    130178      this.Controls.Add(this.constantValueLabel);
    131179      this.Controls.Add(this.constantValueTextBox);
     
    136184      this.Controls.Add(this.allowedSymbolsCombo);
    137185      this.Controls.Add(this.nodeSymbolLabel);
     186      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
    138187      this.Name = "InsertNodeDialog";
    139188      this.Text = "SymbolicExpressionTreeNodeInsertDialog";
     
    156205    internal System.Windows.Forms.TextBox variableWeightTextBox;
    157206    internal System.Windows.Forms.ComboBox variableNamesCombo;
     207    private System.Windows.Forms.Button cancelButton;
     208    private System.Windows.Forms.Button okButton;
    158209  }
    159210}
  • branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs

    r8409 r8935  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Collections.Generic;
    324using System.ComponentModel;
     
    930namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    1031  public partial class InsertNodeDialog : Form {
    11     public string Caption {
    12       get { return this.Text; }
    13       set {
    14         if (InvokeRequired)
    15           Invoke(new Action<string>(x => this.Caption = x), value);
    16         else
    17           this.Text = value;
    18       }
    19     }
    20 
    2132    public InsertNodeDialog() {
    2233      InitializeComponent();
     
    5566        constantValueTextBox.Visible = false;
    5667        // add controls to the dialog for changing the variable name or weight
     68      } else {
     69        variableNameLabel.Visible = false;
     70        variableNamesCombo.Visible = false;
     71        variableWeightLabel.Visible = false;
     72        variableWeightTextBox.Visible = false;
     73        constantValueLabel.Visible = false;
     74        constantValueTextBox.Visible = false;
    5775      }
    5876    }
     
    90108
    91109    public event EventHandler DialogValidated;
     110    private void OnDialogValidated(object sender, EventArgs e) {
     111      var dialogValidated = DialogValidated;
     112      if (dialogValidated != null)
     113        dialogValidated(sender, e);
     114    }
    92115
    93116    private void childControl_KeyDown(object sender, KeyEventArgs e) {
     
    98121      if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return) {
    99122        if (ValidateChildren()) {
    100           DialogValidated(this, e);
     123          OnDialogValidated(this, e);
    101124          Close();
    102125        }
    103126      }
    104127    }
     128
     129    private void okButton_Click(object sender, EventArgs e) {
     130      if (ValidateChildren()) {
     131        OnDialogValidated(this, e);
     132        Close();
     133      }
     134    }
     135
     136    private void cancelButton_Click(object sender, EventArgs e) {
     137      Close();
     138    }
    105139  }
    106140}
Note: See TracChangeset for help on using the changeset viewer.