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

Last change on this file since 10367 was 10367, checked in by rstoll, 6 years ago
  • modified PreprocessingData, uses columnIndex now instead of variableName (is faster and more convenient), set variabelName based methods to Obsolete
  • Already changed SearchLogic, DataGridLogic, StatisticLogic as well as PreprocessingDataManipulation

*

File size: 4.8 KB
Line 
1using System;
2using System.Windows.Forms;
3using HeuristicLab.Common;
4using HeuristicLab.Core;
5using HeuristicLab.Core.Views;
6using HeuristicLab.MainForm;
7
8namespace HeuristicLab.DataPreprocessing {
9  [View("DataPreprocessing View")]
10  [Content(typeof(PreprocessingContext), true)]
11  public partial class DataPreprocessingView : ItemView {
12
13    private DataGridContent dataGridContent;
14    private StatisticsContent statisticsContent;
15    private FilterContent filterContent;
16    private TransformationContent tranformationContent;
17    private LineChartContent lineChartContent;
18    private HistogramContent histogramContent;
19
20    public DataPreprocessingView() {
21      InitializeComponent();
22    }
23
24    protected override void OnContentChanged() {
25      base.OnContentChanged();
26      InitializeContents();
27    }
28
29    //Create list view item for content list view
30    private ListViewItem CreateListViewItem(IItem item) {
31      ListViewItem listViewItem = new ListViewItem();
32
33      listViewItem.Text = item.ToString();
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;
38
39      return listViewItem;
40    }
41
42    private void InitializeContents() {
43
44      //create content items
45      IPreprocessingData data = Content.Data;
46      ISearchLogic searchLogic = new SearchLogic(data);
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);
50      filterContent = new FilterContent(new FilterLogic());
51      tranformationContent = new TransformationContent(new TransformationLogic());
52      lineChartContent = new LineChartContent(new LineChartLogic());
53      histogramContent = new HistogramContent(new HistogramLogic());
54
55      //create view items
56      contentListView.SmallImageList = new ImageList();
57      ListViewItem contentListViewItem = CreateListViewItem(dataGridContent);
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
64      //add view items to content list view
65      contentListView.Items.Add(statisticsListViewItem);
66      contentListView.Items.Add(contentListViewItem);
67      contentListView.Items.Add(filterListViewItem);
68      contentListView.Items.Add(transformationListViewItem);
69      contentListView.Items.Add(lineChartListViewItem);
70      contentListView.Items.Add(histogramListViewItem);
71
72      //default view -> statistic view
73      contentListView.SelectedIndices.Add(0);
74    }
75
76    public new PreprocessingContext Content {
77      get { return (PreprocessingContext)base.Content; }
78      set {
79        base.Content = value;
80      }
81    }
82
83    private void listView1_SelectedIndexChanged(object sender, EventArgs e) {
84
85      if (contentListView.SelectedItems.Count > 0) {
86        ListViewItem listViewItem = (ListViewItem)contentListView.SelectedItems[0];
87        this.viewHost.Content = (IItem)listViewItem.Tag;
88      }
89    }
90
91    private void listView1_DoubleClick(object sender, EventArgs e) {
92      if (contentListView.SelectedItems.Count > 0) {
93        ListViewItem listViewItem = (ListViewItem)contentListView.SelectedItems[0];
94        MainFormManager.MainForm.ShowContent((IItem)listViewItem.Tag);
95      }
96    }
97
98    private void exportProblemButton_Click(object sender, EventArgs e) {
99      var cloner = new PreprocessingCloner(Content);
100      var alteredClone = cloner.GenerateAlteredClone(Content.Problem);
101
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
109      var content = alteredClone as IStorableContent;
110      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
111        bool compressed = saveFileDialog.FilterIndex != 1;
112        ContentManager.Save(content, saveFileDialog.FileName, compressed);
113      }
114    }
115
116    private void applyInNewTabButton_Click(object sender, EventArgs e) {
117      var cloner = new PreprocessingCloner(Content);
118      var item = cloner.GenerateAlteredClone(Content.ParentItem);
119
120      MainFormManager.MainForm.ShowContent(item);
121    }
122  }
123}
Note: See TracBrowser for help on using the repository browser.