Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 13777 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
Line 
1using System;
2using System.ComponentModel;
3using System.Windows.Forms;
4using HeuristicLab.Problems.DataAnalysis;
5using HeuristicLab.Problems.Instances.DataAnalysis;
6
7namespace HeuristicLab.ExperimentGeneration.DataAnalysis.ExperimentWizard {
8  public partial class ProblemDataPage : HeuristicLab.ExperimentGeneration.DataAnalysis.Wizard.WizardPage {
9    private RegressionProblem problem;
10    private RegressionCSVInstanceProvider instanceProvider;
11
12    private DataAnalysisWizardContext context;
13    public DataAnalysisWizardContext Context {
14      get { return context; }
15    }
16
17    public ProblemDataPage(DataAnalysisWizardContext context) {
18      InitializeComponent();
19      this.context = context;
20      stringConvertibleMatrixView.ReadOnly = true;
21      problem = new RegressionProblem();
22      instanceProvider = new RegressionCSVInstanceProvider();
23    }
24
25    private void ProblemDataPage_SetActive(object sender, CancelEventArgs e) {
26      SetWizardButton(Wizard.WizardButtons.Next);
27    }
28
29    private void ProblemDataPage_WizardNext(object sender, Wizard.WizardPageEventArgs e) {
30      context.Problem = problem;
31    }
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    }
48  }
49}
Note: See TracBrowser for help on using the repository browser.