Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/14 12:05:50 (11 years ago)
Author:
pfleck
Message:
  • replaced main menu list with ItemCollectionList
  • added ViewShortcut interface for menu items
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataPreprocessingView.cs

    r10586 r10614  
    2323using System.Windows.Forms;
    2424using HeuristicLab.Common;
    25 using HeuristicLab.Core;
    2625using HeuristicLab.Core.Views;
    2726using HeuristicLab.MainForm;
     
    2928namespace HeuristicLab.DataPreprocessing.Views {
    3029  [View("DataPreprocessing View")]
    31   [Content(typeof(IPreprocessingContext), true)]
     30  [Content(typeof(PreprocessingContext), true)]
     31  [Content(typeof(IPreprocessingContext), false)]
    3232  public partial class DataPreprocessingView : ItemView {
    33 
    34     private DataGridContent dataGridContent;
    35     private StatisticsContent statisticsContent;
    36     private FilterContent filterContent;
    37     private TransformationContent tranformationContent;
    38     private LineChartContent lineChartContent;
    39     private HistogramContent histogramContent;
    40 
    4133    public DataPreprocessingView() {
    4234      InitializeComponent();
    4335    }
    4436
    45     protected override void OnContentChanged() {
    46       base.OnContentChanged();
    47       InitializeContents();
    48     }
    49 
    50     //Create list view item for content list view
    51     private ListViewItem CreateListViewItem(IItem item) {
    52       ListViewItem listViewItem = new ListViewItem();
    53 
    54       listViewItem.Text = item.ToString();
    55       listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription;
    56       contentListView.SmallImageList.Images.Add(item.ItemImage);
    57       listViewItem.ImageIndex = contentListView.SmallImageList.Images.Count - 1;
    58       listViewItem.Tag = item;
    59 
    60       return listViewItem;
    61     }
    62 
    63     private void InitializeContents() {
    64 
    65       //create content items
    66       ITransactionalPreprocessingData data = Content.Data;
    67       ISearchLogic searchLogic = new SearchLogic(data);
    68       var dataGridLogic = new DataGridLogic(data);
    69       StatisticsLogic statisticsLogic = new StatisticsLogic(data, searchLogic);
    70       dataGridContent = new DataGridContent(dataGridLogic, new ManipulationLogic(data, searchLogic, statisticsLogic));
    71       statisticsContent = new StatisticsContent(statisticsLogic);
    72       filterContent = new FilterContent(new FilterLogic());
    73       tranformationContent = new TransformationContent(new TransformationLogic(data, searchLogic, statisticsLogic));
    74       lineChartContent = new LineChartContent(new LineChartLogic(data));
    75       histogramContent = new HistogramContent(new HistogramLogic(data));
    76 
    77       //create view items
    78       contentListView.SmallImageList = new ImageList();
    79       ListViewItem contentListViewItem = CreateListViewItem(dataGridContent);
    80       ListViewItem statisticsListViewItem = CreateListViewItem(statisticsContent);
    81       ListViewItem filterListViewItem = CreateListViewItem(filterContent);
    82       ListViewItem transformationListViewItem = CreateListViewItem(tranformationContent);
    83       ListViewItem lineChartListViewItem = CreateListViewItem(lineChartContent);
    84       ListViewItem histogramListViewItem = CreateListViewItem(histogramContent);
    85 
    86       //add view items to content list view
    87       contentListView.Items.Add(statisticsListViewItem);
    88       contentListView.Items.Add(contentListViewItem);
    89       contentListView.Items.Add(filterListViewItem);
    90       contentListView.Items.Add(transformationListViewItem);
    91       contentListView.Items.Add(lineChartListViewItem);
    92       contentListView.Items.Add(histogramListViewItem);
    93 
    94       //default view -> statistic view
    95       contentListView.SelectedIndices.Add(0);
    96     }
    97 
    98     public new PreprocessingContext Content {
    99       get { return (PreprocessingContext)base.Content; }
     37    public new IPreprocessingContext Content {
     38      get { return (IPreprocessingContext)base.Content; }
    10039      set {
    10140        base.Content = value;
     
    10342    }
    10443
    105     private void listView1_SelectedIndexChanged(object sender, EventArgs e) {
    106 
    107       if (contentListView.SelectedItems.Count > 0) {
    108         ListViewItem listViewItem = (ListViewItem)contentListView.SelectedItems[0];
    109         this.viewHost.Content = (IItem)listViewItem.Tag;
     44    protected override void OnContentChanged() {
     45      base.OnContentChanged();
     46      if (Content != null) {
     47        viewShortcutCollectionView.Content = Content.ViewShortcuts;
     48      } else {
     49        viewShortcutCollectionView.Content = null;
    11050      }
    11151    }
    11252
    113     private void listView1_DoubleClick(object sender, EventArgs e) {
    114       if (contentListView.SelectedItems.Count > 0) {
    115         ListViewItem listViewItem = (ListViewItem)contentListView.SelectedItems[0];
    116         MainFormManager.MainForm.ShowContent((IItem)listViewItem.Tag);
    117       }
     53    protected override void SetEnabledStateOfControls() {
     54      base.SetEnabledStateOfControls();
     55      viewShortcutCollectionView.Enabled = Content != null;
     56      applyInNewTabButton.Enabled = Content != null;
     57      exportProblemButton.Enabled = Content != null;
     58      undoButton.Enabled = Content != null;
    11859    }
    11960
Note: See TracChangeset for help on using the changeset viewer.