Free cookie consent management tool by TermsFeed Policy Generator

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

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

worked on #187 - code is still a mess

File size: 7.7 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.Console {
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 overviewPage;
36    private System.Windows.Forms.TabPage agentsPage;
37    private System.Windows.Forms.TabPage resultsPage;
38    private Button connectButton;
39    private ComboBox comboBox1;
40    private Label projectLabel;
41    private Button newButton;
42    private Console console;
43
44    public ConsoleEditor(Console console) {
45      InitializeComponent();
46      this.console = console;
47    }
48
49    private void InitializeComponent() {
50      this.uriTextBox = new System.Windows.Forms.TextBox();
51      this.uriLabel = new System.Windows.Forms.Label();
52      this.tabControl = new System.Windows.Forms.TabControl();
53      this.overviewPage = new System.Windows.Forms.TabPage();
54      this.agentsPage = new System.Windows.Forms.TabPage();
55      this.resultsPage = new System.Windows.Forms.TabPage();
56      this.connectButton = new System.Windows.Forms.Button();
57      this.comboBox1 = new System.Windows.Forms.ComboBox();
58      this.projectLabel = new System.Windows.Forms.Label();
59      this.newButton = new System.Windows.Forms.Button();
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.overviewPage);
85      this.tabControl.Controls.Add(this.agentsPage);
86      this.tabControl.Controls.Add(this.resultsPage);
87      this.tabControl.Enabled = false;
88      this.tabControl.Location = new System.Drawing.Point(6, 56);
89      this.tabControl.Name = "tabControl";
90      this.tabControl.SelectedIndex = 0;
91      this.tabControl.Size = new System.Drawing.Size(506, 407);
92      this.tabControl.TabIndex = 2;
93      //
94      // overviewPage
95      //
96      this.overviewPage.Location = new System.Drawing.Point(4, 22);
97      this.overviewPage.Name = "overviewPage";
98      this.overviewPage.Padding = new System.Windows.Forms.Padding(3);
99      this.overviewPage.Size = new System.Drawing.Size(498, 381);
100      this.overviewPage.TabIndex = 0;
101      this.overviewPage.Text = "Overview";
102      this.overviewPage.UseVisualStyleBackColor = true;
103      //
104      // agentsPage
105      //
106      this.agentsPage.Location = new System.Drawing.Point(4, 22);
107      this.agentsPage.Name = "agentsPage";
108      this.agentsPage.Padding = new System.Windows.Forms.Padding(3);
109      this.agentsPage.Size = new System.Drawing.Size(498, 381);
110      this.agentsPage.TabIndex = 1;
111      this.agentsPage.Text = "Agents";
112      this.agentsPage.UseVisualStyleBackColor = true;
113      //
114      // resultsPage
115      //
116      this.resultsPage.Location = new System.Drawing.Point(4, 22);
117      this.resultsPage.Name = "resultsPage";
118      this.resultsPage.Padding = new System.Windows.Forms.Padding(3);
119      this.resultsPage.Size = new System.Drawing.Size(498, 381);
120      this.resultsPage.TabIndex = 2;
121      this.resultsPage.Text = "Results";
122      this.resultsPage.UseVisualStyleBackColor = true;
123      //
124      // connectButton
125      //
126      this.connectButton.Location = new System.Drawing.Point(302, 1);
127      this.connectButton.Name = "connectButton";
128      this.connectButton.Size = new System.Drawing.Size(75, 23);
129      this.connectButton.TabIndex = 3;
130      this.connectButton.Text = "&Connect";
131      this.connectButton.UseVisualStyleBackColor = true;
132      this.connectButton.Click += new System.EventHandler(this.connectButton_Click);
133      //
134      // comboBox1
135      //
136      this.comboBox1.Enabled = false;
137      this.comboBox1.FormattingEnabled = true;
138      this.comboBox1.Location = new System.Drawing.Point(91, 29);
139      this.comboBox1.Name = "comboBox1";
140      this.comboBox1.Size = new System.Drawing.Size(121, 21);
141      this.comboBox1.TabIndex = 4;
142      //
143      // projectLabel
144      //
145      this.projectLabel.AutoSize = true;
146      this.projectLabel.Enabled = false;
147      this.projectLabel.Location = new System.Drawing.Point(42, 32);
148      this.projectLabel.Name = "projectLabel";
149      this.projectLabel.Size = new System.Drawing.Size(43, 13);
150      this.projectLabel.TabIndex = 5;
151      this.projectLabel.Text = "Project:";
152      //
153      // newButton
154      //
155      this.newButton.Enabled = false;
156      this.newButton.Location = new System.Drawing.Point(218, 27);
157      this.newButton.Name = "newButton";
158      this.newButton.Size = new System.Drawing.Size(75, 23);
159      this.newButton.TabIndex = 6;
160      this.newButton.Text = "New...";
161      this.newButton.UseVisualStyleBackColor = true;
162      //
163      // ConsoleEditor
164      //
165      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
166      this.Controls.Add(this.newButton);
167      this.Controls.Add(this.projectLabel);
168      this.Controls.Add(this.comboBox1);
169      this.Controls.Add(this.connectButton);
170      this.Controls.Add(this.tabControl);
171      this.Controls.Add(this.uriLabel);
172      this.Controls.Add(this.uriTextBox);
173      this.Name = "ConsoleEditor";
174      this.Size = new System.Drawing.Size(515, 466);
175      this.tabControl.ResumeLayout(false);
176      this.ResumeLayout(false);
177      this.PerformLayout();
178
179    }
180
181    private void connectButton_Click(object sender, EventArgs e) {
182      try {
183        console.Connect(uriTextBox.Text);
184        connectButton.Enabled = false;
185        tabControl.Enabled = true;
186        agentsPage.Controls.Clear();
187        agentsPage.Controls.Add((Control)console.AgentList.CreateView());
188        agentsPage.Controls[0].Dock = DockStyle.Fill;
189      } catch(CommunicationException ex) {
190        // TASK create helper class for error reporting
191        MessageBox.Show("Exception while trying to connect to " + uriTextBox.Text + "\n" + ex.Message);
192      }
193    }
194  }
195}
Note: See TracBrowser for help on using the repository browser.