Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.Core/AgentListView.cs @ 390

Last change on this file since 390 was 390, checked in by gkronber, 16 years ago

unified runs and agents (are actually the same with the minor difference that agents can create new agents (runs)) (ticket #188)

File size: 3.0 KB
Line 
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
31namespace HeuristicLab.CEDMA.Core {
32  public partial class AgentListView : ViewBase {
33    public IAgentList AgentList {
34      get { return (IAgentList)Item; }
35      set { base.Item = value; }
36    }
37
38    public AgentListView() {
39      InitializeComponent();
40      Caption = "Agent View";
41    }
42    public AgentListView(IAgentList agentList)
43      : this() {
44      AgentList = agentList;
45      agentList.Changed += new EventHandler(agentList_Changed);
46    }
47
48    void agentList_Changed(object sender, EventArgs e) {
49      UpdateControls();
50    }
51
52    protected override void UpdateControls() {
53      base.UpdateControls();
54      detailsGroupBox.Controls.Clear();
55      detailsGroupBox.Enabled = false;
56      if(AgentList == null) {
57        Caption = "Agents View";
58        agentTreeView.Enabled = false;
59      } else {
60        agentTreeView.Enabled = true;
61        agentTreeView.Nodes.Clear();
62        foreach(IAgent agent in AgentList) {
63          TreeNode node = new TreeNode();
64          node.Text = agent.Name;
65          node.Tag = agent;
66          agentTreeView.Nodes.Add(node);
67        }
68      }
69    }
70
71    #region Button Events
72    private void addButton_Click(object sender, EventArgs e) {
73      AgentList.CreateAgent();
74      UpdateControls();
75    }
76    #endregion
77
78    private void agentTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e) {
79    }
80
81    private void agentTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
82      if(detailsGroupBox.Controls.Count > 0)
83        detailsGroupBox.Controls[0].Dispose();
84      detailsGroupBox.Controls.Clear();
85      detailsGroupBox.Enabled = false;
86      if(agentTreeView.SelectedNode != null) {
87        IAgent agent = (IAgent)agentTreeView.SelectedNode.Tag;
88        Control control = (Control)new AgentView(agent);
89        detailsGroupBox.Controls.Add(control);
90        control.Dock = DockStyle.Fill;
91        detailsGroupBox.Enabled = true;
92      }
93    }
94  }
95}
96
Note: See TracBrowser for help on using the repository browser.