1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2018 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.Linq;
|
---|
23 | using System.Windows.Forms;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Core.Views;
|
---|
26 | using HeuristicLab.Data;
|
---|
27 | using HeuristicLab.MainForm;
|
---|
28 | using HeuristicLab.Problems.DataAnalysis;
|
---|
29 |
|
---|
30 | namespace HeuristicLab.DataPreprocessing.Views {
|
---|
31 | [View("CheckedTransformationList View")]
|
---|
32 | [Content(typeof(ICheckedItemList<IDataAnalysisTransformation>), false)]
|
---|
33 | public partial class CheckedTransformationListView : CheckedItemListView<IDataAnalysisTransformation> {
|
---|
34 |
|
---|
35 | internal IFilteredPreprocessingData PreprocessingData { get; set; }
|
---|
36 |
|
---|
37 | public CheckedTransformationListView() {
|
---|
38 | InitializeComponent();
|
---|
39 | itemsGroupBox.Text = "Transformations";
|
---|
40 | }
|
---|
41 |
|
---|
42 | protected override IDataAnalysisTransformation CreateItem() {
|
---|
43 | var newTransformation = new DataAnalysisTransformation(PreprocessingData.VariableNames.Select(x => new StringValue(x)));
|
---|
44 | newTransformation.TransformedVariableParameter.ValidValues.Add(new StringValue("<New Variable>"));
|
---|
45 | return newTransformation;
|
---|
46 | //if (typeSelectorDialog == null) {
|
---|
47 | // typeSelectorDialog = new TypeSelectorDialog();
|
---|
48 | // typeSelectorDialog.Caption = "Select Transformation";
|
---|
49 | // typeSelectorDialog.TypeSelector.Caption = "Available Transformations";
|
---|
50 | // typeSelectorDialog.TypeSelector.Configure(typeof(IDataAnalysisTransformation), showNotInstantiableTypes: true, showGenericTypes: false, typeCondition: CanInstanciateTransformation);
|
---|
51 | //}
|
---|
52 |
|
---|
53 | //if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
|
---|
54 | // try {
|
---|
55 | // // TODO: Avoid accessing parent view
|
---|
56 | // var transformationView = (TransformationView)Parent;
|
---|
57 | // var columnNames = transformationView.Content.PreprocessingData.VariableNames;
|
---|
58 |
|
---|
59 | // return (IDataAnalysisTransformation)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(new[] { columnNames });
|
---|
60 | // } catch (Exception ex) {
|
---|
61 | // ErrorHandling.ShowErrorDialog(this, ex);
|
---|
62 | // }
|
---|
63 | //}
|
---|
64 | //return null;
|
---|
65 | }
|
---|
66 |
|
---|
67 | //private bool CanInstanciateTransformation(Type type) {
|
---|
68 | // foreach (ConstructorInfo ctor in type.GetConstructors(BindingFlags.Public | BindingFlags.Instance)) {
|
---|
69 | // ParameterInfo[] parameters = ctor.GetParameters();
|
---|
70 | // if (parameters.Length == 1 && parameters[0].ParameterType == typeof(IEnumerable<string>)) return true;
|
---|
71 | // }
|
---|
72 | // return false;
|
---|
73 | //}
|
---|
74 | }
|
---|
75 | }
|
---|