Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.Core/ConsoleEditor.cs @ 407

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

worked on very basic control to view the tree of agents/runs (ticket #188)

File size: 7.1 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.Linq;
25using System.Text;
26using HeuristicLab.Core;
27using System.Windows.Forms;
28using System.ServiceModel;
29
30namespace HeuristicLab.CEDMA.Core {
31  class ConsoleEditor : EditorBase {
32    private System.Windows.Forms.TextBox uriTextBox;
33    private System.Windows.Forms.Label uriLabel;
34    private System.Windows.Forms.TabControl tabControl;
35    private System.Windows.Forms.TabPage agentsPage;
36    private Button connectButton;
37    private ComboBox comboBox1;
38    private Label projectLabel;
39    private Button newButton;
40    private Timer refreshTimer;
41    private System.ComponentModel.IContainer components;
42    private Console console;
43
44    public ConsoleEditor(Console console) {
45      InitializeComponent();
46      this.console = console;
47    }
48
49    private void InitializeComponent() {
50      this.components = new System.ComponentModel.Container();
51      this.uriTextBox = new System.Windows.Forms.TextBox();
52      this.uriLabel = new System.Windows.Forms.Label();
53      this.tabControl = new System.Windows.Forms.TabControl();
54      this.agentsPage = new System.Windows.Forms.TabPage();
55      this.connectButton = new System.Windows.Forms.Button();
56      this.comboBox1 = new System.Windows.Forms.ComboBox();
57      this.projectLabel = new System.Windows.Forms.Label();
58      this.newButton = new System.Windows.Forms.Button();
59      this.refreshTimer = new System.Windows.Forms.Timer(this.components);
60      this.tabControl.SuspendLayout();
61      this.SuspendLayout();
62      //
63      // uriTextBox
64      //
65      this.uriTextBox.Location = new System.Drawing.Point(91, 3);
66      this.uriTextBox.Name = "uriTextBox";
67      this.uriTextBox.Size = new System.Drawing.Size(205, 20);
68      this.uriTextBox.TabIndex = 0;
69      //
70      // uriLabel
71      //
72      this.uriLabel.AutoSize = true;
73      this.uriLabel.Location = new System.Drawing.Point(3, 6);
74      this.uriLabel.Name = "uriLabel";
75      this.uriLabel.Size = new System.Drawing.Size(82, 13);
76      this.uriLabel.TabIndex = 1;
77      this.uriLabel.Text = "CEDMA Server:";
78      //
79      // tabControl
80      //
81      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
82                  | System.Windows.Forms.AnchorStyles.Left)
83                  | System.Windows.Forms.AnchorStyles.Right)));
84      this.tabControl.Controls.Add(this.agentsPage);
85      this.tabControl.Enabled = false;
86      this.tabControl.Location = new System.Drawing.Point(6, 56);
87      this.tabControl.Name = "tabControl";
88      this.tabControl.SelectedIndex = 0;
89      this.tabControl.Size = new System.Drawing.Size(506, 407);
90      this.tabControl.TabIndex = 2;
91      //
92      // agentsPage
93      //
94      this.agentsPage.Location = new System.Drawing.Point(4, 22);
95      this.agentsPage.Name = "agentsPage";
96      this.agentsPage.Padding = new System.Windows.Forms.Padding(3);
97      this.agentsPage.Size = new System.Drawing.Size(498, 381);
98      this.agentsPage.TabIndex = 1;
99      this.agentsPage.Text = "Agents";
100      this.agentsPage.UseVisualStyleBackColor = true;
101      //
102      // connectButton
103      //
104      this.connectButton.Location = new System.Drawing.Point(302, 1);
105      this.connectButton.Name = "connectButton";
106      this.connectButton.Size = new System.Drawing.Size(75, 23);
107      this.connectButton.TabIndex = 3;
108      this.connectButton.Text = "&Connect";
109      this.connectButton.UseVisualStyleBackColor = true;
110      this.connectButton.Click += new System.EventHandler(this.connectButton_Click);
111      //
112      // comboBox1
113      //
114      this.comboBox1.Enabled = false;
115      this.comboBox1.FormattingEnabled = true;
116      this.comboBox1.Location = new System.Drawing.Point(91, 29);
117      this.comboBox1.Name = "comboBox1";
118      this.comboBox1.Size = new System.Drawing.Size(121, 21);
119      this.comboBox1.TabIndex = 4;
120      //
121      // projectLabel
122      //
123      this.projectLabel.AutoSize = true;
124      this.projectLabel.Enabled = false;
125      this.projectLabel.Location = new System.Drawing.Point(42, 32);
126      this.projectLabel.Name = "projectLabel";
127      this.projectLabel.Size = new System.Drawing.Size(43, 13);
128      this.projectLabel.TabIndex = 5;
129      this.projectLabel.Text = "Project:";
130      //
131      // newButton
132      //
133      this.newButton.Enabled = false;
134      this.newButton.Location = new System.Drawing.Point(218, 27);
135      this.newButton.Name = "newButton";
136      this.newButton.Size = new System.Drawing.Size(75, 23);
137      this.newButton.TabIndex = 6;
138      this.newButton.Text = "New...";
139      this.newButton.UseVisualStyleBackColor = true;
140      //
141      // refreshTimer
142      //
143      this.refreshTimer.Interval = 3000;
144      this.refreshTimer.Tick += new System.EventHandler(this.refreshTimer_Tick);
145      //
146      // ConsoleEditor
147      //
148      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
149      this.Controls.Add(this.newButton);
150      this.Controls.Add(this.projectLabel);
151      this.Controls.Add(this.comboBox1);
152      this.Controls.Add(this.connectButton);
153      this.Controls.Add(this.tabControl);
154      this.Controls.Add(this.uriLabel);
155      this.Controls.Add(this.uriTextBox);
156      this.Name = "ConsoleEditor";
157      this.Size = new System.Drawing.Size(515, 466);
158      this.tabControl.ResumeLayout(false);
159      this.ResumeLayout(false);
160      this.PerformLayout();
161
162    }
163
164    private void connectButton_Click(object sender, EventArgs e) {
165      try {
166        console.Connect(uriTextBox.Text);
167        connectButton.Enabled = false;
168        tabControl.Enabled = true;
169        agentsPage.Controls.Clear();
170        agentsPage.Controls.Add((Control)console.AgentList.CreateView());
171        agentsPage.Controls[0].Dock = DockStyle.Fill;
172        refreshTimer.Enabled = true;
173      } catch(CommunicationException ex) {
174        // TASK create helper class for error reporting
175        MessageBox.Show("Exception while trying to connect to " + uriTextBox.Text + "\n" + ex.Message);
176      }
177    }
178
179    private void refreshTimer_Tick(object sender, EventArgs e) {
180      refreshTimer.Stop();
181      UpdateControls();
182      refreshTimer.Enabled = true;
183    }
184  }
185}
Note: See TracBrowser for help on using the repository browser.