Changeset 8880 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs
- Timestamp:
- 11/08/12 12:10:38 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs
r8874 r8880 34 34 35 35 private FeatureCorrelationTimeframeCache correlationTimeframCache; 36 private string lastFramesValue; 36 37 37 38 public TimeframeFeatureCorrelationView() { 38 39 InitializeComponent(); 39 40 correlationTimeframCache = new FeatureCorrelationTimeframeCache(); 41 errorProvider.SetIconAlignment(timeframeTextbox, ErrorIconAlignment.MiddleRight); 42 errorProvider.SetIconPadding(timeframeTextbox, 2); 43 lastFramesValue = timeframeTextbox.Text; 40 44 } 41 45 … … 44 48 if (Content != null) { 45 49 dataView.RowVisibility = SetInitialVariableVisibility(); 46 VariableSelectionComboBox.DataSource = Content.Dataset.DoubleVariables.ToList();50 SetVariableSelectionComboBox(); 47 51 } 48 52 base.OnContentChanged(); 53 } 54 55 protected virtual void SetVariableSelectionComboBox() { 56 variableSelectionComboBox.DataSource = Content.Dataset.DoubleVariables.ToList(); 49 57 } 50 58 … … 52 60 CalculateCorrelation(); 53 61 } 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 } 54 66 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 } 58 91 } 59 92 } 60 93 61 94 protected override void CalculateCorrelation() { 62 if ( CorrelationCalcComboBox.SelectedItem != null && PartitionComboBox.SelectedItem != null63 && 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; 67 100 int frames; 68 int.TryParse( TimeframeTextbox.Text, out frames);101 int.TryParse(timeframeTextbox.Text, out frames); 69 102 dataView.Enabled = false; 70 103 double[,] corr = correlationTimeframCache.GetTimeframeCorrelation(calc, partition, variable); … … 82 115 } 83 116 } 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 100 117 101 118 protected override void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e) {
Note: See TracChangeset
for help on using the changeset viewer.