Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentListView.cs @ 6465

Last change on this file since 6465 was 6465, checked in by cneumuel, 13 years ago

#1233

  • show owner of experimens in listview
File size: 3.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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
21
22using System;
23using System.Windows.Forms;
24using HeuristicLab.Core;
25using HeuristicLab.Core.Views;
26using HeuristicLab.MainForm;
27
28namespace HeuristicLab.Clients.Hive.ExperimentManager.Views {
29  [View("HiveExperimentList View")]
30  [Content(typeof(ItemCollection<RefreshableHiveExperiment>), false)]
31  public partial class RefreshableHiveExperimentListView : ItemCollectionView<RefreshableHiveExperiment> {
32
33    public RefreshableHiveExperimentListView() {
34      InitializeComponent();
35      this.itemsListView.View = View.Details;
36      this.itemsListView.Columns.Clear();
37      this.itemsListView.Columns.Add(new ColumnHeader("Date") { Text = "Date" });
38      this.itemsListView.Columns.Add(new ColumnHeader("Name") { Text = "Name" });
39      this.itemsListView.HeaderStyle = ColumnHeaderStyle.Clickable;
40      this.itemsListView.FullRowSelect = true;
41    }
42
43    protected override RefreshableHiveExperiment CreateItem() {
44      return new RefreshableHiveExperiment();
45    }
46
47    protected override void removeButton_Click(object sender, EventArgs e) {
48      DialogResult result = MessageBox.Show("This action will permanently delete this experiment (also on the hive server). Continue?", "Delete Experiment", MessageBoxButtons.OKCancel);
49      if (result == DialogResult.OK) {
50        base.removeButton_Click(sender, e);
51      }
52    }
53
54    protected override ListViewItem CreateListViewItem(RefreshableHiveExperiment item) {
55      ListViewItem listViewItem = base.CreateListViewItem(item);
56      listViewItem.SubItems.Clear();
57      listViewItem.SubItems.Insert(0, new ListViewItem.ListViewSubItem(listViewItem, item.HiveExperiment.DateCreated.ToString("dd.MM.yyyy HH:mm")));
58      listViewItem.SubItems.Insert(1, new ListViewItem.ListViewSubItem(listViewItem, item.HiveExperiment.Name));
59      listViewItem.Group = GetListViewGroup(item.HiveExperiment.OwnerUsername);
60      return listViewItem;
61    }
62
63    private ListViewGroup GetListViewGroup(string groupName) {
64      foreach (ListViewGroup group in itemsListView.Groups) {
65        if (group.Name == groupName)
66          return group;
67      }
68      var newGroup = new ListViewGroup(string.Format("Owner ({0})", groupName), HorizontalAlignment.Left) { Name = groupName };
69      itemsListView.Groups.Add(newGroup);
70      return newGroup;
71    }
72  }
73}
Note: See TracBrowser for help on using the repository browser.