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