Free cookie consent management tool by TermsFeed Policy Generator

source: branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Views/3.4/BenchmarkGeneratorDialog.cs @ 7396

Last change on this file since 7396 was 7396, checked in by sforsten, 12 years ago

#1669:

  • deleted unnecessary code
File size: 4.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections;
24using System.Collections.Generic;
25using System.Windows.Forms;
26using HeuristicLab.Common;
27using HeuristicLab.PluginInfrastructure;
28
29namespace HeuristicLab.Problems.DataAnalysis.Views {
30  internal partial class BenchmarkGeneratorDialog : Form {
31    private bool initialized;
32
33    private IDataAnalysisProblem Content;
34
35    private IDataAnalysisProblemData problemData;
36    public IDataAnalysisProblemData ProblemData {
37      get {
38        return problemData;
39      }
40    }
41
42    public BenchmarkGeneratorDialog(IDataAnalysisProblem Content) {
43      initialized = false;
44      InitializeComponent();
45      this.Content = Content;
46    }
47
48    private void NewItemDialog_Load(object sender, EventArgs e) {
49      if (!initialized) {
50        IEnumerable<IDataAnalysisBenchmarkProblemDataGenerator> generators = new List<IDataAnalysisBenchmarkProblemDataGenerator>();
51        if (Content is IRegressionProblem)
52          generators = ApplicationManager.Manager.GetInstances<IRegressionBenchmarkProblemDataGenerator>();
53        else if (Content is IClassificationProblem)
54          generators = ApplicationManager.Manager.GetInstances<IClassificationBenchmarkProblemDataGenerator>();
55        else if (Content is IClusteringProblem)
56          generators = ApplicationManager.Manager.GetInstances<IClusteringBenchmarkProblemDataGenerator>();
57
58        foreach (var generator in generators) {
59          ListViewItem item = new ListViewItem(new string[] { generator.Name, generator.Description });
60          item.Tag = generator;
61          BenchmarkGeneratorListView.Items.Add(item);
62        }
63
64        BenchmarkGeneratorListView.ListViewItemSorter = new ListViewItemComparer();
65
66        for (int i = 0; i < BenchmarkGeneratorListView.Columns.Count; i++)
67          BenchmarkGeneratorListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
68
69        initialized = true;
70      }
71    }
72
73    private void NewItemDialog_Shown(object sender, EventArgs e) {
74      problemData = null;
75    }
76
77    private void BenchmarkGeneratorListView_SelectedIndexChanged(object sender, EventArgs e) {
78      okButton.Enabled = BenchmarkGeneratorListView.SelectedItems.Count == 1;
79    }
80
81    private void okButton_Click(object sender, EventArgs e) {
82      if (BenchmarkGeneratorListView.SelectedItems.Count == 1) {
83        problemData = ((IDataAnalysisBenchmarkProblemDataGenerator)BenchmarkGeneratorListView.SelectedItems[0].Tag).GenerateProblemData();
84        DialogResult = DialogResult.OK;
85        Close();
86      }
87    }
88
89    private void BenchmarkGeneratorListView_DoubleClick(object sender, EventArgs e) {
90      if (BenchmarkGeneratorListView.SelectedItems.Count == 1) {
91        problemData = ((IDataAnalysisBenchmarkProblemDataGenerator)BenchmarkGeneratorListView.SelectedItems[0].Tag).GenerateProblemData();
92        DialogResult = DialogResult.OK;
93        Close();
94      }
95    }
96
97    private class ListViewItemComparer : IComparer {
98      private NaturalStringComparer comp = new NaturalStringComparer();
99
100      public int Compare(object x, object y) {
101        return comp.Compare(((ListViewItem)x).SubItems[0].Text, ((ListViewItem)y).SubItems[0].Text);
102      }
103    }
104  }
105}
Note: See TracBrowser for help on using the repository browser.