[10239] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Windows.Forms;
|
---|
| 4 | using HeuristicLab.Common;
|
---|
| 5 | using HeuristicLab.Core;
|
---|
[10254] | 6 | using HeuristicLab.Core.Views;
|
---|
| 7 | using HeuristicLab.MainForm;
|
---|
[10239] | 8 |
|
---|
[10254] | 9 | namespace HeuristicLab.DataPreprocessing {
|
---|
[10239] | 10 | [View("DataPreprocessing View")]
|
---|
| 11 | [Content(typeof(PreprocessingContext), true)]
|
---|
| 12 | public partial class DataPreprocessingView : ItemView {
|
---|
| 13 |
|
---|
| 14 | private DataGridContent dataGridContent;
|
---|
[10303] | 15 | private StatisticsContent statisticsContent;
|
---|
| 16 | private FilterContent filterContent;
|
---|
| 17 | private TransformationContent tranformationContent;
|
---|
| 18 | private LineChartContent lineChartContent;
|
---|
| 19 | private HistogramContent histogramContent;
|
---|
| 20 |
|
---|
[10239] | 21 | private Dictionary<ListViewItem, IItem> listViewItemItemMapping;
|
---|
| 22 |
|
---|
| 23 | public DataPreprocessingView() {
|
---|
| 24 | InitializeComponent();
|
---|
[10258] | 25 | }
|
---|
[10239] | 26 |
|
---|
[10258] | 27 | protected override void OnContentChanged() {
|
---|
| 28 | base.OnContentChanged();
|
---|
[10239] | 29 | InitializeContents();
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | private ListViewItem CreateListViewItem(IItem item) {
|
---|
| 33 | ListViewItem listViewItem = new ListViewItem();
|
---|
| 34 |
|
---|
[10254] | 35 | listViewItem.Text = item.ToString();
|
---|
| 36 | //listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription;
|
---|
| 37 | //itemsListView.SmallImageList.Images.Add(content.);
|
---|
| 38 | //listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
|
---|
| 39 | //listViewItem.Tag = item;
|
---|
[10239] | 40 | return listViewItem;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | private void InitializeContents() {
|
---|
[10258] | 44 | IPreprocessingData data = Content.Data;
|
---|
[10256] | 45 | ISearchLogic searchLogic = new SearchLogic(data);
|
---|
| 46 | dataGridContent = new DataGridContent(new DataGridLogic(data), new PreprocessingDataManipulation(data, searchLogic, new StatisticsLogic(data, searchLogic)));
|
---|
[10303] | 47 | statisticsContent = new StatisticsContent(new StatisticsLogic(data, searchLogic));
|
---|
| 48 | filterContent = new FilterContent(new FilterLogic());
|
---|
| 49 | tranformationContent = new TransformationContent(new TransformationLogic());
|
---|
| 50 | lineChartContent = new LineChartContent(new LineChartLogic());
|
---|
| 51 | histogramContent = new HistogramContent(new HistogramLogic());
|
---|
[10239] | 52 |
|
---|
[10254] | 53 | listViewItemItemMapping = new Dictionary<ListViewItem, IItem>();
|
---|
[10239] | 54 | ListViewItem contentListViewItem = CreateListViewItem(dataGridContent);
|
---|
| 55 | listViewItemItemMapping[contentListViewItem] = dataGridContent;
|
---|
| 56 |
|
---|
[10303] | 57 | ListViewItem statisticsListViewItem = CreateListViewItem(statisticsContent);
|
---|
| 58 | listViewItemItemMapping[statisticsListViewItem] = statisticsContent;
|
---|
| 59 |
|
---|
| 60 | ListViewItem filterListViewItem = CreateListViewItem(filterContent);
|
---|
| 61 | listViewItemItemMapping[filterListViewItem] = filterContent;
|
---|
| 62 |
|
---|
| 63 | ListViewItem transformationListViewItem = CreateListViewItem(tranformationContent);
|
---|
| 64 | listViewItemItemMapping[transformationListViewItem] = tranformationContent;
|
---|
| 65 |
|
---|
| 66 | ListViewItem lineChartListViewItem = CreateListViewItem(lineChartContent);
|
---|
| 67 | listViewItemItemMapping[lineChartListViewItem] = lineChartContent;
|
---|
| 68 |
|
---|
| 69 | ListViewItem histogramListViewItem = CreateListViewItem(histogramContent);
|
---|
| 70 | listViewItemItemMapping[histogramListViewItem] = histogramContent;
|
---|
| 71 |
|
---|
| 72 | contentListView.Items.Add(statisticsListViewItem);
|
---|
[10247] | 73 | contentListView.Items.Add(contentListViewItem);
|
---|
[10303] | 74 | contentListView.Items.Add(filterListViewItem);
|
---|
| 75 | contentListView.Items.Add(transformationListViewItem);
|
---|
| 76 | contentListView.Items.Add(lineChartListViewItem);
|
---|
| 77 | contentListView.Items.Add(histogramListViewItem);
|
---|
[10239] | 78 | }
|
---|
| 79 |
|
---|
[10254] | 80 | public new PreprocessingContext Content {
|
---|
| 81 | get { return (PreprocessingContext)base.Content; }
|
---|
[10304] | 82 | set {
|
---|
[10258] | 83 | base.Content = value;
|
---|
| 84 | }
|
---|
[10239] | 85 | }
|
---|
| 86 |
|
---|
| 87 | private void listView1_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
| 88 |
|
---|
[10254] | 89 | if (contentListView.SelectedItems.Count > 0) {
|
---|
| 90 | ListViewItem listViewItem = (ListViewItem)contentListView.SelectedItems[0];
|
---|
| 91 | this.viewHost.Content = listViewItemItemMapping[listViewItem];
|
---|
| 92 | }
|
---|
[10239] | 93 | }
|
---|
| 94 |
|
---|
| 95 | private void listView1_DoubleClick(object sender, EventArgs e) {
|
---|
[10247] | 96 | ListViewItem listViewItem = (ListViewItem)contentListView.SelectedItems[0];
|
---|
[10239] | 97 | MainFormManager.MainForm.ShowContent(listViewItemItemMapping[listViewItem]);
|
---|
| 98 | }
|
---|
| 99 |
|
---|
[10304] | 100 | private void exportProblemButton_Click(object sender, EventArgs e) {
|
---|
[10310] | 101 | var cloner = new PreprocessingCloner(Content);
|
---|
| 102 | var alteredClone = cloner.GenerateAlteredClone(Content.Problem);
|
---|
| 103 |
|
---|
[10307] | 104 | var saveFileDialog = new SaveFileDialog {
|
---|
| 105 | Title = "Save Item",
|
---|
| 106 | DefaultExt = "hl",
|
---|
| 107 | Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*",
|
---|
| 108 | FilterIndex = 2
|
---|
| 109 | };
|
---|
| 110 |
|
---|
[10310] | 111 | var content = alteredClone as IStorableContent;
|
---|
[10307] | 112 | if (saveFileDialog.ShowDialog() == DialogResult.OK) {
|
---|
| 113 | bool compressed = saveFileDialog.FilterIndex != 1;
|
---|
| 114 | ContentManager.Save(content, saveFileDialog.FileName, compressed);
|
---|
| 115 | }
|
---|
[10304] | 116 | }
|
---|
| 117 |
|
---|
| 118 | private void applyInNewTabButton_Click(object sender, EventArgs e) {
|
---|
[10310] | 119 | IPreprocessingData data = Content.Data;
|
---|
[10247] | 120 |
|
---|
[10310] | 121 | foreach (string variable in data.VariableNames) {
|
---|
| 122 | for (int j = 0; j < data.Rows; j++) {
|
---|
[10254] | 123 | // assume: all double
|
---|
[10310] | 124 | data.SetCell(variable, j, 1.0);
|
---|
[10254] | 125 | }
|
---|
| 126 | }
|
---|
| 127 | MessageBox.Show("Success, now cloning... ");
|
---|
[10239] | 128 |
|
---|
[10310] | 129 | var cloner = new PreprocessingCloner(Content);
|
---|
| 130 | var item = cloner.GenerateAlteredClone(Content.ParentItem);
|
---|
[10239] | 131 |
|
---|
[10254] | 132 | MainFormManager.MainForm.ShowContent(item);
|
---|
| 133 | }
|
---|
[10239] | 134 | }
|
---|
[10310] | 135 | } |
---|