#region License Information /* HeuristicLab * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using HeuristicLab.Core; namespace HeuristicLab.CEDMA.Core { public partial class DataSetListView : ViewBase { public DataSetList DataSetList{ get { return (DataSetList)Item; } set { base.Item = value; } } public DataSetListView() { InitializeComponent(); Caption = "DataSet View"; } public DataSetListView(DataSetList dataSetList) : this() { DataSetList = dataSetList; dataSetList.Changed += new EventHandler(dataSetList_Changed); } void dataSetList_Changed(object sender, EventArgs e) { UpdateControls(); } protected override void UpdateControls() { base.UpdateControls(); detailsGroupBox.Controls.Clear(); detailsGroupBox.Enabled = false; if(DataSetList == null) { Caption = "Data Sets View"; dataSetsTreeView.Enabled = false; } else { dataSetsTreeView.Enabled = true; dataSetsTreeView.Nodes.Clear(); foreach(DataSet dataSet in DataSetList) { TreeNode node = new TreeNode(); node.Text = dataSet.Name; node.Tag = dataSet; node.Nodes.Add("dummy"); dataSetsTreeView.Nodes.Add(node); } } } #region Button Events private void addButton_Click(object sender, EventArgs e) { DataSet dataSet = new DataSet(); DataSetList.Add(dataSet); UpdateControls(); } #endregion private void dataSetsTreeView_AfterSelect(object sender, TreeViewEventArgs e) { if(detailsGroupBox.Controls.Count > 0) detailsGroupBox.Controls[0].Dispose(); detailsGroupBox.Controls.Clear(); detailsGroupBox.Enabled = false; if(dataSetsTreeView.SelectedNode != null) { IViewable viewable = (IViewable)dataSetsTreeView.SelectedNode.Tag; Control control = (Control)viewable.CreateView(); detailsGroupBox.Controls.Add(control); control.Dock = DockStyle.Fill; detailsGroupBox.Enabled = true; } } private void refreshButton_Click(object sender, EventArgs e) { UpdateControls(); } } }