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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.ComponentModel;
|
---|
25 | using System.Data;
|
---|
26 | using System.Drawing;
|
---|
27 | using System.Text;
|
---|
28 | using System.Windows.Forms;
|
---|
29 | using HeuristicLab.Core;
|
---|
30 |
|
---|
31 | namespace 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 | agentsListView.Enabled = false;
|
---|
59 | } else {
|
---|
60 | agentsListView.Enabled = true;
|
---|
61 | agentsListView.Items.Clear();
|
---|
62 | foreach(IAgent agent in AgentList) {
|
---|
63 | ListViewItem item = new ListViewItem();
|
---|
64 | item.Text = agent.Name;
|
---|
65 | item.Tag = agent;
|
---|
66 | agentsListView.Items.Add(item);
|
---|
67 | }
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | private void variablesListView_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
72 | if(detailsGroupBox.Controls.Count > 0)
|
---|
73 | detailsGroupBox.Controls[0].Dispose();
|
---|
74 | detailsGroupBox.Controls.Clear();
|
---|
75 | detailsGroupBox.Enabled = false;
|
---|
76 | if(agentsListView.SelectedItems.Count == 1) {
|
---|
77 | IAgent agent = (IAgent)agentsListView.SelectedItems[0].Tag;
|
---|
78 | Control control = (Control)new AgentView(agent);
|
---|
79 | detailsGroupBox.Controls.Add(control);
|
---|
80 | control.Dock = DockStyle.Fill;
|
---|
81 | detailsGroupBox.Enabled = true;
|
---|
82 | }
|
---|
83 | }
|
---|
84 |
|
---|
85 | #region Size Changed Events
|
---|
86 | private void variablesListView_SizeChanged(object sender, EventArgs e) {
|
---|
87 | if(agentsListView.Columns.Count > 0)
|
---|
88 | agentsListView.Columns[0].Width = Math.Max(0, agentsListView.Width - 25);
|
---|
89 | }
|
---|
90 | #endregion
|
---|
91 |
|
---|
92 | #region Button Events
|
---|
93 | private void addButton_Click(object sender, EventArgs e) {
|
---|
94 | AgentList.CreateAgent();
|
---|
95 | UpdateControls();
|
---|
96 | }
|
---|
97 | #endregion
|
---|
98 | }
|
---|
99 | }
|
---|
100 |
|
---|