1 | using System;
|
---|
2 | using System.ComponentModel;
|
---|
3 | using System.Windows.Forms;
|
---|
4 | using HeuristicLab.Problems.DataAnalysis;
|
---|
5 | using HeuristicLab.Problems.Instances.DataAnalysis;
|
---|
6 |
|
---|
7 | namespace 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 | }
|
---|