[3884] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[5445] | 3 | * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[3884] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
[5829] | 21 |
|
---|
[3884] | 22 | using System;
|
---|
[5829] | 23 | using System.Collections.Generic;
|
---|
[6612] | 24 | using System.Drawing;
|
---|
| 25 | using System.Linq;
|
---|
[3884] | 26 | using System.Windows.Forms;
|
---|
| 27 | using HeuristicLab.MainForm;
|
---|
[5829] | 28 | using HeuristicLab.Optimization.Views;
|
---|
[3884] | 29 |
|
---|
| 30 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
[5834] | 31 | [View("DataAnalysisSolution View")]
|
---|
[5829] | 32 | [Content(typeof(DataAnalysisSolution), true)]
|
---|
| 33 | public partial class DataAnalysisSolutionView : ResultCollectionView {
|
---|
[3884] | 34 | public DataAnalysisSolutionView() {
|
---|
| 35 | InitializeComponent();
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[5829] | 38 | public new DataAnalysisSolution Content {
|
---|
| 39 | get { return (DataAnalysisSolution)base.Content; }
|
---|
[3884] | 40 | set { base.Content = value; }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | protected override void OnContentChanged() {
|
---|
[5829] | 44 | string selectedName = null;
|
---|
| 45 | if ((itemsListView.SelectedItems.Count == 1) && (itemsListView.SelectedItems[0].Tag != null && itemsListView.SelectedItems[0].Tag is Type))
|
---|
| 46 | selectedName = itemsListView.SelectedItems[0].Text;
|
---|
| 47 |
|
---|
[3884] | 48 | base.OnContentChanged();
|
---|
[6642] | 49 | AddEvaluationViewTypes();
|
---|
[5829] | 50 |
|
---|
| 51 | //recover selection
|
---|
| 52 | if (selectedName != null) {
|
---|
| 53 | foreach (ListViewItem item in itemsListView.Items) {
|
---|
| 54 | if (item.Tag != null && item.Tag is Type && item.Text == selectedName)
|
---|
| 55 | item.Selected = true;
|
---|
| 56 | }
|
---|
[3884] | 57 | }
|
---|
| 58 | }
|
---|
| 59 |
|
---|
[6642] | 60 | protected virtual void AddEvaluationViewTypes() {
|
---|
| 61 | if (Content != null) {
|
---|
| 62 | var viewTypes = MainFormManager.GetViewTypes(Content.GetType(), true)
|
---|
| 63 | .Where(t => typeof(IDataAnalysisSolutionEvaluationView).IsAssignableFrom(t));
|
---|
| 64 | foreach (var viewType in viewTypes)
|
---|
| 65 | AddViewListViewItem(viewType, ((IDataAnalysisSolutionEvaluationView)Activator.CreateInstance(viewType)).ViewImage);
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[5829] | 69 | protected override void itemsListView_DoubleClick(object sender, EventArgs e) {
|
---|
| 70 | if (itemsListView.SelectedItems.Count == 1 && itemsListView.SelectedItems[0].Tag is Type) {
|
---|
| 71 | Type viewType = (Type)itemsListView.SelectedItems[0].Tag;
|
---|
| 72 | MainFormManager.MainForm.ShowContent(Content, viewType);
|
---|
| 73 | } else
|
---|
| 74 | base.itemsListView_DoubleClick(sender, e);
|
---|
[3884] | 75 | }
|
---|
[3915] | 76 |
|
---|
[5829] | 77 | protected override void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
| 78 | if (itemsListView.SelectedItems.Count == 1 && itemsListView.SelectedItems[0].Tag is Type) {
|
---|
| 79 | detailsGroupBox.Enabled = true;
|
---|
| 80 | Type viewType = (Type)itemsListView.SelectedItems[0].Tag;
|
---|
| 81 | viewHost.ViewType = viewType;
|
---|
| 82 | viewHost.Content = Content;
|
---|
| 83 | } else
|
---|
| 84 | base.itemsListView_SelectedIndexChanged(sender, e);
|
---|
[3884] | 85 | }
|
---|
[3915] | 86 |
|
---|
[6612] | 87 | protected void AddViewListViewItem(Type viewType, Image image) {
|
---|
[5829] | 88 | ListViewItem listViewItem = new ListViewItem();
|
---|
| 89 | listViewItem.Text = ViewAttribute.GetViewName(viewType);
|
---|
[6612] | 90 | itemsListView.SmallImageList.Images.Add(image);
|
---|
[5829] | 91 | listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
|
---|
| 92 | listViewItem.Tag = viewType;
|
---|
| 93 | itemsListView.Items.Add(listViewItem);
|
---|
| 94 |
|
---|
| 95 | AdjustListViewColumnSizes();
|
---|
[3915] | 96 | }
|
---|
[5829] | 97 |
|
---|
| 98 | protected void RemoveViewListViewItem(Type viewType) {
|
---|
[6612] | 99 | List<ListViewItem> itemsToRemove = itemsListView.Items.Cast<ListViewItem>().Where(item => item.Tag as Type == viewType).ToList();
|
---|
[5829] | 100 |
|
---|
| 101 | foreach (ListViewItem item in itemsToRemove)
|
---|
| 102 | itemsListView.Items.Remove(item);
|
---|
[3884] | 103 | }
|
---|
| 104 | }
|
---|
| 105 | }
|
---|