Changeset 15846 for branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/CheckedTransformationListView.cs
- Timestamp:
- 03/19/18 10:25:45 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/CheckedTransformationListView.cs
r15583 r15846 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Reflection; 22 using System.Linq; 25 23 using System.Windows.Forms; 26 24 using HeuristicLab.Core; 27 25 using HeuristicLab.Core.Views; 26 using HeuristicLab.Data; 28 27 using HeuristicLab.MainForm; 29 using HeuristicLab.PluginInfrastructure;30 28 using HeuristicLab.Problems.DataAnalysis; 31 29 32 30 namespace HeuristicLab.DataPreprocessing.Views { 33 31 [View("CheckedTransformationList View")] 34 [Content(typeof(ICheckedItemList<ITransformation>), false)] 35 public partial class CheckedTransformationListView : CheckedItemListView<ITransformation> { 32 [Content(typeof(ICheckedItemList<IDataAnalysisTransformation>), false)] 33 public partial class CheckedTransformationListView : CheckedItemListView<IDataAnalysisTransformation> { 34 35 internal IFilteredPreprocessingData PreprocessingData { get; set; } 36 36 37 public CheckedTransformationListView() { 37 38 InitializeComponent(); … … 39 40 } 40 41 41 protected override ITransformation CreateItem() { 42 if (typeSelectorDialog == null) { 43 typeSelectorDialog = new TypeSelectorDialog(); 44 typeSelectorDialog.Caption = "Select Transformation"; 45 typeSelectorDialog.TypeSelector.Caption = "Available Transformations"; 46 typeSelectorDialog.TypeSelector.Configure(typeof(ITransformation), showNotInstantiableTypes: true, showGenericTypes: false, typeCondition: CanInstanciateTransformation); 47 } 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 //} 48 52 49 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {50 try {51 // TODO: Avoid accessing parent view52 var transformationView = (TransformationView)Parent;53 var columnNames = transformationView.Content.PreprocessingData.VariableNames;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; 54 58 55 return (ITransformation)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(new[] { columnNames });56 } catch (Exception ex) {57 ErrorHandling.ShowErrorDialog(this, ex);58 }59 }60 return null;59 // return (IDataAnalysisTransformation)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(new[] { columnNames }); 60 // } catch (Exception ex) { 61 // ErrorHandling.ShowErrorDialog(this, ex); 62 // } 63 //} 64 //return null; 61 65 } 62 66 63 private bool CanInstanciateTransformation(Type type) {64 foreach (ConstructorInfo ctor in type.GetConstructors(BindingFlags.Public | BindingFlags.Instance)) {65 ParameterInfo[] parameters = ctor.GetParameters();66 if (parameters.Length == 1 && parameters[0].ParameterType == typeof(IEnumerable<string>)) return true;67 }68 return false;69 }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 //} 70 74 } 71 75 }
Note: See TracChangeset
for help on using the changeset viewer.