Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/30/17 16:58:44 (8 years ago)
Author:
mkommend
Message:

#2710: Merged r14432, r14494, r14706 into stable.

Location:
stable
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • stable

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

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs

    r14186 r14802  
    5757      this.okButton = new System.Windows.Forms.Button();
    5858      this.cancelButton = new System.Windows.Forms.Button();
     59      this.variableNameTextBox = new System.Windows.Forms.TextBox();
    5960      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6061      this.SuspendLayout();
     
    168169      this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
    169170      //
     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      //
    170179      // InsertNodeDialog
    171180      //
     
    175184      this.ClientSize = new System.Drawing.Size(241, 133);
    176185      this.ControlBox = false;
     186      this.Controls.Add(this.variableNameTextBox);
    177187      this.Controls.Add(this.cancelButton);
    178188      this.Controls.Add(this.okButton);
     
    208218    private System.Windows.Forms.Button cancelButton;
    209219    private System.Windows.Forms.Button okButton;
     220    private System.Windows.Forms.TextBox variableNameTextBox;
    210221  }
    211222}
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs

    r14186 r14802  
    2323using System.Collections.Generic;
    2424using System.ComponentModel;
     25using System.Linq;
    2526using System.Text;
    2627using System.Windows.Forms;
     
    3031namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    3132  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
    3242    public InsertNodeDialog() {
    3343      InitializeComponent();
     
    4050    }
    4151
    42     public ISymbol SelectedSymbol() {
    43       return (ISymbol)allowedSymbolsCombo.SelectedItem;
     52    public ISymbol SelectedSymbol {
     53      get { return (ISymbol)allowedSymbolsCombo.SelectedItem; }
    4454    }
    4555
     
    5666        constantValueTextBox.Visible = true;
    5767      } 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        }
    6179        variableNameLabel.Visible = true;
    62         variableNamesCombo.Visible = true;
    6380        variableWeightLabel.Visible = true;
    6481        variableWeightTextBox.Visible = true;
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeVariableNodeEditDialog.Designer.cs

    r14186 r14802  
    5555      this.okButton = new System.Windows.Forms.Button();
    5656      this.cancelButton = new System.Windows.Forms.Button();
     57      this.variableNameTextBox = new System.Windows.Forms.TextBox();
    5758      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5859      this.SuspendLayout();
     
    146147      this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
    147148      //
     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      //
    148157      // VariableNodeEditDialog
    149158      //
     
    154163      this.ClientSize = new System.Drawing.Size(244, 134);
    155164      this.ControlBox = false;
     165      this.Controls.Add(this.variableNameTextBox);
    156166      this.Controls.Add(this.cancelButton);
    157167      this.Controls.Add(this.okButton);
     
    188198    public System.Windows.Forms.TextBox newValueTextBox;
    189199    public System.Windows.Forms.ComboBox variableNamesCombo;
     200    private System.Windows.Forms.TextBox variableNameTextBox;
    190201  }
    191202}
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeVariableNodeEditDialog.cs

    r14186 r14802  
    2222using System;
    2323using System.ComponentModel;
     24using System.Linq;
    2425using System.Text;
    2526using System.Windows.Forms;
     
    3334      get { return variableTreeNode; }
    3435      set {
    35         if (InvokeRequired)
    36           Invoke(new Action<SymbolicExpressionTreeNode>(x => variableTreeNode = (VariableTreeNode)x), value);
    37         else
     36        if (InvokeRequired) {
     37          Invoke(new Action<SymbolicExpressionTreeNode>(x =>
     38          {
     39            variableTreeNode = (VariableTreeNode) x;
     40            variableNameTextBox.Text = variableTreeNode.VariableName;
     41          }), value);
     42        } else {
    3843          variableTreeNode = value;
     44          variableNameTextBox.Text = variableTreeNode.VariableName;
     45        }
    3946      }
     47    }
     48
     49    public string SelectedVariableName {
     50      get { return variableNamesCombo.Visible ? variableNamesCombo.Text : variableNameTextBox.Text; }
    4051    }
    4152
     
    4354      InitializeComponent();
    4455      oldValueTextBox.TabStop = false; // cannot receive focus using tab key
    45 
    4656      NewNode = (VariableTreeNode)node; // will throw an invalid cast exception if node is not of the correct type
    4757      InitializeFields();
     
    5767        variableNameLabel.Visible = true;
    5868        variableNamesCombo.Visible = true;
    59         foreach (var name in variableTreeNode.Symbol.VariableNames) variableNamesCombo.Items.Add(name);
    60         variableNamesCombo.SelectedIndex = variableNamesCombo.Items.IndexOf(variableTreeNode.VariableName);
     69        if (variableTreeNode.Symbol.VariableNames.Any()) {
     70          foreach (var name in variableTreeNode.Symbol.VariableNames)
     71            variableNamesCombo.Items.Add(name);
     72          variableNamesCombo.SelectedIndex = variableNamesCombo.Items.IndexOf(variableTreeNode.VariableName);
     73          variableNamesCombo.Visible = true;
     74          variableNameTextBox.Visible = false;
     75        } else {
     76          variableNamesCombo.Visible = false;
     77          variableNameTextBox.Visible = true;
     78        }
    6179      }
    6280    }
     
    93111    #region combo box validation and events
    94112    private void variableNamesCombo_Validating(object sender, CancelEventArgs e) {
     113      if (variableNamesCombo.Items.Count == 0) return;
    95114      if (variableNamesCombo.Items.Contains(variableNamesCombo.SelectedItem)) return;
    96115      e.Cancel = true;
     
    119138    private void OnDialogValidated(object sender, EventArgs e) {
    120139      double weight = double.Parse(newValueTextBox.Text);
    121       var variableName = (string)variableNamesCombo.SelectedItem;
    122140      // we impose an extra validation condition: that the weight/value be different than the original ones
     141      var variableName = SelectedVariableName;
    123142      if (variableTreeNode.Weight.Equals(weight) && variableTreeNode.VariableName.Equals(variableName)) return;
    124143      variableTreeNode.Weight = weight;
Note: See TracChangeset for help on using the changeset viewer.