[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 |
|
---|
| 48 | //cache old viewTypes;
|
---|
[6612] | 49 | var viewTypes = new List<Tuple<Type, Image>>();
|
---|
[5829] | 50 | foreach (ListViewItem item in ItemsListView.Items) {
|
---|
| 51 | var viewType = item.Tag as Type;
|
---|
[6612] | 52 | if (viewType != null) viewTypes.Add(Tuple.Create(viewType, imageList.Images[item.ImageIndex]));
|
---|
[5829] | 53 | }
|
---|
| 54 |
|
---|
[3884] | 55 | base.OnContentChanged();
|
---|
[5829] | 56 |
|
---|
| 57 | //readd viewTypes
|
---|
[6612] | 58 | foreach (var tuple in viewTypes)
|
---|
| 59 | AddViewListViewItem(tuple.Item1, tuple.Item2);
|
---|
[5829] | 60 |
|
---|
| 61 | //recover selection
|
---|
| 62 | if (selectedName != null) {
|
---|
| 63 | foreach (ListViewItem item in itemsListView.Items) {
|
---|
| 64 | if (item.Tag != null && item.Tag is Type && item.Text == selectedName)
|
---|
| 65 | item.Selected = true;
|
---|
| 66 | }
|
---|
[3884] | 67 | }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
[5829] | 70 | protected override void itemsListView_DoubleClick(object sender, EventArgs e) {
|
---|
| 71 | if (itemsListView.SelectedItems.Count == 1 && itemsListView.SelectedItems[0].Tag is Type) {
|
---|
| 72 | Type viewType = (Type)itemsListView.SelectedItems[0].Tag;
|
---|
| 73 | MainFormManager.MainForm.ShowContent(Content, viewType);
|
---|
| 74 | } else
|
---|
| 75 | base.itemsListView_DoubleClick(sender, e);
|
---|
[3884] | 76 | }
|
---|
[3915] | 77 |
|
---|
[5829] | 78 | protected override void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
| 79 | if (itemsListView.SelectedItems.Count == 1 && itemsListView.SelectedItems[0].Tag is Type) {
|
---|
| 80 | detailsGroupBox.Enabled = true;
|
---|
| 81 | Type viewType = (Type)itemsListView.SelectedItems[0].Tag;
|
---|
| 82 | viewHost.ViewType = viewType;
|
---|
| 83 | viewHost.Content = Content;
|
---|
| 84 | } else
|
---|
| 85 | base.itemsListView_SelectedIndexChanged(sender, e);
|
---|
[3884] | 86 | }
|
---|
[3915] | 87 |
|
---|
[6612] | 88 | protected void AddViewListViewItem(Type viewType, Image image) {
|
---|
[5829] | 89 | ListViewItem listViewItem = new ListViewItem();
|
---|
| 90 | listViewItem.Text = ViewAttribute.GetViewName(viewType);
|
---|
[6612] | 91 | itemsListView.SmallImageList.Images.Add(image);
|
---|
[5829] | 92 | listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
|
---|
| 93 | listViewItem.Tag = viewType;
|
---|
| 94 | itemsListView.Items.Add(listViewItem);
|
---|
| 95 |
|
---|
| 96 | AdjustListViewColumnSizes();
|
---|
[3915] | 97 | }
|
---|
[5829] | 98 |
|
---|
| 99 | protected void RemoveViewListViewItem(Type viewType) {
|
---|
[6612] | 100 | List<ListViewItem> itemsToRemove = itemsListView.Items.Cast<ListViewItem>().Where(item => item.Tag as Type == viewType).ToList();
|
---|
[5829] | 101 |
|
---|
| 102 | foreach (ListViewItem item in itemsToRemove)
|
---|
| 103 | itemsListView.Items.Remove(item);
|
---|
[3884] | 104 | }
|
---|
| 105 | }
|
---|
| 106 | }
|
---|