Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/DataPreprocessingView.cs @ 10247

Last change on this file since 10247 was 10247, checked in by psteiner, 11 years ago

Added Try Out Algorithmn button and renamed items

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