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 | private ChooseItemDialog chooseItemDialog;
|
---|
34 |
|
---|
35 | public IAgentList AgentList {
|
---|
36 | get { return (IAgentList)Item; }
|
---|
37 | set { base.Item = value; }
|
---|
38 | }
|
---|
39 |
|
---|
40 | public AgentListView() {
|
---|
41 | InitializeComponent();
|
---|
42 | Caption = "Agent View";
|
---|
43 | }
|
---|
44 | public AgentListView(IAgentList agentList)
|
---|
45 | : this() {
|
---|
46 | AgentList = agentList;
|
---|
47 | agentList.Changed += new EventHandler(agentList_Changed);
|
---|
48 | }
|
---|
49 |
|
---|
50 | void agentList_Changed(object sender, EventArgs e) {
|
---|
51 | UpdateControls();
|
---|
52 | }
|
---|
53 |
|
---|
54 | protected override void UpdateControls() {
|
---|
55 | base.UpdateControls();
|
---|
56 | detailsGroupBox.Controls.Clear();
|
---|
57 | detailsGroupBox.Enabled = false;
|
---|
58 | if(AgentList == null) {
|
---|
59 | Caption = "Agents View";
|
---|
60 | agentsListView.Enabled = false;
|
---|
61 | } else {
|
---|
62 | agentsListView.Enabled = true;
|
---|
63 | agentsListView.Items.Clear();
|
---|
64 | foreach(IAgent agent in AgentList) {
|
---|
65 | ListViewItem item = new ListViewItem();
|
---|
66 | item.Text = agent.Name;
|
---|
67 | item.Tag = agent;
|
---|
68 | agentsListView.Items.Add(item);
|
---|
69 | }
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | private void variablesListView_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
74 | if(detailsGroupBox.Controls.Count > 0)
|
---|
75 | detailsGroupBox.Controls[0].Dispose();
|
---|
76 | detailsGroupBox.Controls.Clear();
|
---|
77 | detailsGroupBox.Enabled = false;
|
---|
78 | if(agentsListView.SelectedItems.Count == 1) {
|
---|
79 | IAgent agent = (IAgent)agentsListView.SelectedItems[0].Tag;
|
---|
80 | Control control = (Control)new AgentView(agent);
|
---|
81 | detailsGroupBox.Controls.Add(control);
|
---|
82 | control.Dock = DockStyle.Fill;
|
---|
83 | detailsGroupBox.Enabled = true;
|
---|
84 | }
|
---|
85 | }
|
---|
86 |
|
---|
87 | #region Size Changed Events
|
---|
88 | private void variablesListView_SizeChanged(object sender, EventArgs e) {
|
---|
89 | if(agentsListView.Columns.Count > 0)
|
---|
90 | agentsListView.Columns[0].Width = Math.Max(0, agentsListView.Width - 25);
|
---|
91 | }
|
---|
92 | #endregion
|
---|
93 |
|
---|
94 | #region Button Events
|
---|
95 | private void addButton_Click(object sender, EventArgs e) {
|
---|
96 | AgentList.CreateAgent();
|
---|
97 | UpdateControls();
|
---|
98 | }
|
---|
99 | #endregion
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|