[10239] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Windows.Forms;
|
---|
| 5 | using HeuristicLab.Common;
|
---|
| 6 | using HeuristicLab.Core;
|
---|
[10254] | 7 | using HeuristicLab.Core.Views;
|
---|
[10239] | 8 | using HeuristicLab.Data;
|
---|
[10254] | 9 | using HeuristicLab.MainForm;
|
---|
| 10 | using HeuristicLab.Optimization;
|
---|
[10239] | 11 | using HeuristicLab.Problems.DataAnalysis;
|
---|
| 12 |
|
---|
[10254] | 13 | namespace HeuristicLab.DataPreprocessing {
|
---|
[10239] | 14 | [View("DataPreprocessing View")]
|
---|
| 15 | [Content(typeof(PreprocessingContext), true)]
|
---|
| 16 | public partial class DataPreprocessingView : ItemView {
|
---|
| 17 |
|
---|
| 18 | private DataGridContent dataGridContent;
|
---|
| 19 | private Dictionary<ListViewItem, IItem> listViewItemItemMapping;
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | public DataPreprocessingView() {
|
---|
| 23 | InitializeComponent();
|
---|
[10258] | 24 | b
|
---|
| 25 | }
|
---|
[10239] | 26 |
|
---|
[10258] | 27 |
|
---|
| 28 | protected override void OnContentChanged() {
|
---|
| 29 | base.OnContentChanged();
|
---|
[10239] | 30 | InitializeContents();
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | private ListViewItem CreateListViewItem(IItem item) {
|
---|
| 34 | ListViewItem listViewItem = new ListViewItem();
|
---|
| 35 |
|
---|
[10254] | 36 | listViewItem.Text = item.ToString();
|
---|
| 37 | //listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription;
|
---|
| 38 | //itemsListView.SmallImageList.Images.Add(content.);
|
---|
| 39 | //listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
|
---|
| 40 | //listViewItem.Tag = item;
|
---|
[10239] | 41 | return listViewItem;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | private void InitializeContents() {
|
---|
[10258] | 45 | IPreprocessingData data = Content.Data;
|
---|
[10256] | 46 | ISearchLogic searchLogic = new SearchLogic(data);
|
---|
| 47 | dataGridContent = new DataGridContent(new DataGridLogic(data), new PreprocessingDataManipulation(data, searchLogic, new StatisticsLogic(data, searchLogic)));
|
---|
[10239] | 48 |
|
---|
[10254] | 49 | listViewItemItemMapping = new Dictionary<ListViewItem, IItem>();
|
---|
[10239] | 50 | ListViewItem contentListViewItem = CreateListViewItem(dataGridContent);
|
---|
| 51 | listViewItemItemMapping[contentListViewItem] = dataGridContent;
|
---|
| 52 |
|
---|
[10247] | 53 | contentListView.Items.Add(contentListViewItem);
|
---|
[10239] | 54 | }
|
---|
| 55 |
|
---|
[10254] | 56 | public new PreprocessingContext Content {
|
---|
| 57 | get { return (PreprocessingContext)base.Content; }
|
---|
[10258] | 58 | set {
|
---|
| 59 | base.Content = value;
|
---|
| 60 | }
|
---|
[10239] | 61 | }
|
---|
| 62 |
|
---|
| 63 | private void listView1_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
| 64 |
|
---|
[10254] | 65 | if (contentListView.SelectedItems.Count > 0) {
|
---|
| 66 | ListViewItem listViewItem = (ListViewItem)contentListView.SelectedItems[0];
|
---|
| 67 | this.viewHost.Content = listViewItemItemMapping[listViewItem];
|
---|
| 68 | }
|
---|
[10239] | 69 | }
|
---|
| 70 |
|
---|
| 71 | private void listView1_DoubleClick(object sender, EventArgs e) {
|
---|
[10247] | 72 | ListViewItem listViewItem = (ListViewItem)contentListView.SelectedItems[0];
|
---|
[10239] | 73 | MainFormManager.MainForm.ShowContent(listViewItemItemMapping[listViewItem]);
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[10254] | 76 | private void tryOutAlgorithmButton_Click(object sender, EventArgs e) {
|
---|
| 77 | IPreprocessingData Data = Content.Data;
|
---|
[10247] | 78 |
|
---|
[10254] | 79 | foreach (string variable in Data.VariableNames) {
|
---|
| 80 | for (int j = 0; j < Data.Rows; j++) {
|
---|
| 81 | // assume: all double
|
---|
| 82 | Data.SetCell(variable, j, 1.0);
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
[10247] | 85 |
|
---|
[10254] | 86 | MessageBox.Show("Success, now cloning... ");
|
---|
[10239] | 87 |
|
---|
[10254] | 88 | Dataset dataset = Data.ExportToDataset();
|
---|
| 89 | var variables = new CheckedItemList<StringValue>(Data.VariableNames.Select(s => new StringValue(s))).AsReadOnly();
|
---|
[10239] | 90 |
|
---|
[10254] | 91 | var cloner = new Cloner();
|
---|
[10239] | 92 |
|
---|
[10254] | 93 | cloner.RegisterClonedObject(Content.DataAnalysisProblemData.Dataset, dataset);
|
---|
| 94 | cloner.RegisterClonedObject(Content.DataAnalysisProblemData.TrainingPartition, Data.TrainingPartition);
|
---|
| 95 | cloner.RegisterClonedObject(Content.DataAnalysisProblemData.TestPartition, Data.TestPartition);
|
---|
| 96 | cloner.RegisterClonedObject(Content.DataAnalysisProblemData.InputVariables, variables);
|
---|
| 97 | if (Content.Algorithm != null) {
|
---|
| 98 | cloner.RegisterClonedObject(Content.Algorithm.Runs, new RunCollection { OptimizerName = Content.Algorithm.Name });
|
---|
| 99 | }
|
---|
[10239] | 100 |
|
---|
[10254] | 101 | var item = cloner.Clone(Content.ParentItem);
|
---|
[10239] | 102 |
|
---|
[10254] | 103 | MainFormManager.MainForm.ShowContent(item);
|
---|
| 104 | }
|
---|
[10239] | 105 | }
|
---|
| 106 | }
|
---|
| 107 |
|
---|