Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.Core/DataSetListView.cs @ 1287

Last change on this file since 1287 was 1287, checked in by gkronber, 15 years ago

Merged change sets from CEDMA branch to trunk:

File size: 3.2 KB
RevLine 
[357]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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.Collections.Generic;
24using System.ComponentModel;
25using System.Data;
26using System.Drawing;
27using System.Text;
28using System.Windows.Forms;
29using HeuristicLab.Core;
30
[377]31namespace HeuristicLab.CEDMA.Core {
[957]32  public partial class DataSetListView : ViewBase {
[1287]33    public DataSetList DataSetList {
[957]34      get { return (DataSetList)Item; }
[357]35      set { base.Item = value; }
36    }
37
[957]38    public DataSetListView() {
[357]39      InitializeComponent();
[957]40      Caption = "DataSet View";
[357]41    }
[957]42    public DataSetListView(DataSetList dataSetList)
[357]43      : this() {
[957]44      DataSetList = dataSetList;
45      dataSetList.Changed += new EventHandler(dataSetList_Changed);
[357]46    }
47
[957]48    void dataSetList_Changed(object sender, EventArgs e) {
[1287]49      if (InvokeRequired) Invoke((EventHandler)dataSetList_Changed, sender, e);
50      else UpdateControls();
[357]51    }
52
53    protected override void UpdateControls() {
54      base.UpdateControls();
55      detailsGroupBox.Controls.Clear();
56      detailsGroupBox.Enabled = false;
[957]57      if(DataSetList == null) {
58        Caption = "Data Sets View";
[1287]59        dataSetsListView.Enabled = false;
[357]60      } else {
[1287]61        dataSetsListView.Enabled = true;
62        dataSetsListView.Items.Clear();
[957]63        foreach(DataSet dataSet in DataSetList) {
[1287]64          ListViewItem node = new ListViewItem();
[957]65          node.Text = dataSet.Name;
66          node.Tag = dataSet;
[1287]67          dataSetsListView.Items.Add(node);
[357]68        }
69      }
70    }
71
[390]72    #region Button Events
73    private void addButton_Click(object sender, EventArgs e) {
[1287]74      DataSet dataSet = new DataSet();
75      dataSet.Store = DataSetList.Store;
76      DataSetList.Add(dataSet);
77      UpdateControls();
[390]78    }
[1287]79    private void dataSetsListView_SelectedIndexChanged(object sender, EventArgs e) {
80      if(dataSetsListView.SelectedItems.Count > 0) {
81        if(detailsGroupBox.Controls.Count > 0)
82          detailsGroupBox.Controls[0].Dispose();
83        detailsGroupBox.Controls.Clear();
84        detailsGroupBox.Enabled = false;
85        IViewable viewable = (IViewable)dataSetsListView.SelectedItems[0].Tag;
[393]86        Control control = (Control)viewable.CreateView();
[357]87        detailsGroupBox.Controls.Add(control);
88        control.Dock = DockStyle.Fill;
89        detailsGroupBox.Enabled = true;
90      }
91    }
[1287]92    #endregion
[510]93
[1287]94
[510]95    private void refreshButton_Click(object sender, EventArgs e) {
96      UpdateControls();
97    }
[357]98  }
99}
100
Note: See TracBrowser for help on using the repository browser.