source: branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/CheckedTransformationListView.cs @ 15846

Last change on this file since 15846 was 15846, checked in by pfleck, 3 years ago

#2906 First concept of simple transformation (single target transformation)

File size: 3.2 KB
Line 
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
22using System.Linq;
23using System.Windows.Forms;
24using HeuristicLab.Core;
25using HeuristicLab.Core.Views;
26using HeuristicLab.Data;
27using HeuristicLab.MainForm;
28using HeuristicLab.Problems.DataAnalysis;
29
30namespace 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}
Note: See TracBrowser for help on using the repository browser.