Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysisService/HeuristicLab.ExperimentGeneration.DataAnalysis.ExperimentWizard/3.3/ProblemDataPage.cs @ 11808

Last change on this file since 11808 was 7953, checked in by spimming, 13 years ago

#1807:

  • added file dialog to select csv problem file
  • wizard page to select target variable
  • plugin dependencies updated
File size: 1.9 KB
RevLine 
[7953]1using System;
2using System.ComponentModel;
3using System.Windows.Forms;
[7816]4using HeuristicLab.Problems.DataAnalysis;
[7953]5using HeuristicLab.Problems.Instances.DataAnalysis;
[7808]6
7namespace HeuristicLab.ExperimentGeneration.DataAnalysis.ExperimentWizard {
8  public partial class ProblemDataPage : HeuristicLab.ExperimentGeneration.DataAnalysis.Wizard.WizardPage {
[7953]9    private RegressionProblem problem;
10    private RegressionCSVInstanceProvider instanceProvider;
11
[7824]12    private DataAnalysisWizardContext context;
13    public DataAnalysisWizardContext Context {
14      get { return context; }
15    }
16
17    public ProblemDataPage(DataAnalysisWizardContext context) {
[7808]18      InitializeComponent();
[7824]19      this.context = context;
[7953]20      stringConvertibleMatrixView.ReadOnly = true;
21      problem = new RegressionProblem();
22      instanceProvider = new RegressionCSVInstanceProvider();
[7808]23    }
24
25    private void ProblemDataPage_SetActive(object sender, CancelEventArgs e) {
26      SetWizardButton(Wizard.WizardButtons.Next);
27    }
[7824]28
29    private void ProblemDataPage_WizardNext(object sender, Wizard.WizardPageEventArgs e) {
[7953]30      context.Problem = problem;
[7824]31    }
[7953]32
33    private void btnChooseFile_Click(object sender, System.EventArgs e) {
34      OpenFileDialog fileDialog = new OpenFileDialog();
35      fileDialog.Filter = "csv files (*.csv)|*.csv|All files (*.*)|*.*";
36      if (fileDialog.ShowDialog() == DialogResult.OK) {
37        try {
38          txtFilePath.Text = fileDialog.FileName;
39          IRegressionProblemData problemData = instanceProvider.LoadData(fileDialog.FileName);
40          problem.Load(problemData);
41          stringConvertibleMatrixView.Content = problem.ProblemData.Dataset;
42        }
43        catch (Exception ex) {
44          MessageBox.Show(String.Format("There was an error parsing the file: {0}", Environment.NewLine + ex.Message), "Error while parsing", MessageBoxButtons.OK, MessageBoxIcon.Error);
45        }
46      }
47    }
[7808]48  }
49}
Note: See TracBrowser for help on using the repository browser.