Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/08/12 12:10:38 (11 years ago)
Author:
sforsten
Message:

#1292: implemented changes suggested by mkommend in comment:49:ticket:1292

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs

    r8874 r8880  
    3434
    3535    private FeatureCorrelationTimeframeCache correlationTimeframCache;
     36    private string lastFramesValue;
    3637
    3738    public TimeframeFeatureCorrelationView() {
    3839      InitializeComponent();
    3940      correlationTimeframCache = new FeatureCorrelationTimeframeCache();
     41      errorProvider.SetIconAlignment(timeframeTextbox, ErrorIconAlignment.MiddleRight);
     42      errorProvider.SetIconPadding(timeframeTextbox, 2);
     43      lastFramesValue = timeframeTextbox.Text;
    4044    }
    4145
     
    4448      if (Content != null) {
    4549        dataView.RowVisibility = SetInitialVariableVisibility();
    46         VariableSelectionComboBox.DataSource = Content.Dataset.DoubleVariables.ToList();
     50        SetVariableSelectionComboBox();
    4751      }
    4852      base.OnContentChanged();
     53    }
     54
     55    protected virtual void SetVariableSelectionComboBox() {
     56      variableSelectionComboBox.DataSource = Content.Dataset.DoubleVariables.ToList();
    4957    }
    5058
     
    5260      CalculateCorrelation();
    5361    }
     62    private void TimeframeTextbox_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) {
     63      if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return) {
     64        timeFrameLabel.Select();  // select label to validate data
     65      }
    5466
    55     private void TimeframeTextbox_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) {
    56       if (e.KeyCode == Keys.Enter) {
    57         CalculateCorrelation();
     67      if (e.KeyCode == Keys.Escape) {
     68        timeframeTextbox.Text = lastFramesValue;
     69        timeFrameLabel.Select();  // select label to validate data
     70      }
     71    }
     72    private void TimeframeTextbox_Validated(object sender, System.EventArgs e) {
     73      lastFramesValue = timeframeTextbox.Text;
     74      errorProvider.SetError(timeframeTextbox, string.Empty);
     75      CalculateCorrelation();
     76    }
     77    private void TimeframeTextbox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
     78      int help;
     79      if (!int.TryParse(timeframeTextbox.Text, out help)) {
     80        errorProvider.SetError(timeframeTextbox, "Timeframe couldn't be parsed. Enter a valid integer value.");
     81        e.Cancel = true;
     82      } else {
     83        if (help > 50) {
     84          DialogResult dr = MessageBox.Show("The entered value is bigger than 50. Are you sure you want to calculate? " +
     85                                            "The calculation could take some time.", "Huge Value Warning", MessageBoxButtons.YesNo);
     86          e.Cancel = !dr.Equals(DialogResult.Yes);
     87        } else if (help < 0) {
     88          errorProvider.SetError(timeframeTextbox, "The entered value can't be negative!");
     89          e.Cancel = true;
     90        }
    5891      }
    5992    }
    6093
    6194    protected override void CalculateCorrelation() {
    62       if (CorrelationCalcComboBox.SelectedItem != null && PartitionComboBox.SelectedItem != null
    63         && VariableSelectionComboBox.SelectedItem != null && ValidateTimeframeTextbox()) {
    64         string variable = (string)VariableSelectionComboBox.SelectedItem;
    65         IDependencyCalculator calc = (IDependencyCalculator)CorrelationCalcComboBox.SelectedValue;
    66         string partition = (string)PartitionComboBox.SelectedValue;
     95      if (correlationCalcComboBox.SelectedItem != null && partitionComboBox.SelectedItem != null
     96        && variableSelectionComboBox.SelectedItem != null) {
     97        string variable = (string)variableSelectionComboBox.SelectedItem;
     98        IDependencyCalculator calc = (IDependencyCalculator)correlationCalcComboBox.SelectedValue;
     99        string partition = (string)partitionComboBox.SelectedValue;
    67100        int frames;
    68         int.TryParse(TimeframeTextbox.Text, out frames);
     101        int.TryParse(timeframeTextbox.Text, out frames);
    69102        dataView.Enabled = false;
    70103        double[,] corr = correlationTimeframCache.GetTimeframeCorrelation(calc, partition, variable);
     
    82115      }
    83116    }
    84 
    85     private bool ValidateTimeframeTextbox() {
    86       int help;
    87       if (!int.TryParse(TimeframeTextbox.Text, out help)) {
    88         MessageBox.Show("Timeframe couldn't be parsed. Enter a valid integer value.", "Parse Error", MessageBoxButtons.OK);
    89         return false;
    90       } else {
    91         if (help > 50) {
    92           DialogResult dr = MessageBox.Show("The entered value is bigger than 50. Are you sure you want to calculate? " +
    93                                             "The calculation could take some time.", "Huge Value Warning", MessageBoxButtons.YesNo);
    94           return dr.Equals(DialogResult.Yes);
    95         }
    96       }
    97       return true;
    98     }
    99 
    100117
    101118    protected override void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e) {
Note: See TracChangeset for help on using the changeset viewer.