1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2013 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 |
|
---|
22 | using System;
|
---|
23 | using System.Linq;
|
---|
24 | using System.Windows.Forms;
|
---|
25 | using HeuristicLab.DataImporter.Data.CommandBase;
|
---|
26 | using HeuristicLab.DataImporter.Data;
|
---|
27 | using HeuristicLab.PluginInfrastructure;
|
---|
28 |
|
---|
29 |
|
---|
30 | namespace HeuristicLab.DataImporter.DataProcessor {
|
---|
31 | public partial class ImportDialog : Form {
|
---|
32 | private CommandChain commandChain;
|
---|
33 | private Data.Model.DataSet dataSet;
|
---|
34 | public ImportDialog(Data.Model.DataSet dataSet, CommandChain commandChain) {
|
---|
35 | InitializeComponent();
|
---|
36 | this.dataSet = dataSet;
|
---|
37 | this.commandChain = commandChain;
|
---|
38 | IImporter[] importers = ApplicationManager.Manager.GetInstances<IImporter>().ToArray();
|
---|
39 | this.importerListBox.DataSource = importers;
|
---|
40 | }
|
---|
41 |
|
---|
42 | private void btnOK_Click(object sender, EventArgs e) {
|
---|
43 | this.Cursor = Cursors.WaitCursor;
|
---|
44 | try {
|
---|
45 | ICommand cmd = ((IImporter)importerListBox.SelectedItem).CreateImportCommand(this.dataSet);
|
---|
46 | this.commandChain.Add(cmd);
|
---|
47 | }
|
---|
48 | catch (CommandExecutionException cee) {
|
---|
49 | MessageBox.Show(cee.Message, cee.Command.Description);
|
---|
50 | }
|
---|
51 | finally {
|
---|
52 | this.Cursor = Cursors.Default;
|
---|
53 | }
|
---|
54 | }
|
---|
55 |
|
---|
56 | private void importerListBox_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
57 | this.settingsPanel.Controls.Clear();
|
---|
58 | UserControl ctrl = ((IImporter)importerListBox.SelectedItem).SettingsControl;
|
---|
59 | this.Height = 180 + ctrl.Height;
|
---|
60 | this.settingsPanel.Controls.Add(ctrl);
|
---|
61 | }
|
---|
62 | }
|
---|
63 | }
|
---|