Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 560 was 560, checked in by gkronber, 16 years ago
  • added strong name key to CEDMA.Charting.
  • moved classes related to charting from CEDMA.Core to CEDMA.Charting

#268

File size: 8.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;
29using HeuristicLab.PluginInfrastructure;
30using System.Drawing;
31using HeuristicLab.CEDMA.DB.Interfaces;
32
33namespace HeuristicLab.CEDMA.Core {
34  class ConsoleEditor : EditorBase {
35    private System.Windows.Forms.TextBox uriTextBox;
36    private System.Windows.Forms.Label uriLabel;
37    private System.Windows.Forms.TabControl tabControl;
38    private System.Windows.Forms.TabPage agentsPage;
39    private Button connectButton;
40    private ComboBox comboBox1;
41    private Label projectLabel;
42    private Button newButton;
43    private Button opLibButton;
44    private Label label1;
45    private TabPage resultsTabPage;
46    private Console console;
47
48    public ConsoleEditor(Console console) {
49      InitializeComponent();
50      this.console = console;
51    }
52
53    private void InitializeComponent() {
54      this.uriTextBox = new System.Windows.Forms.TextBox();
55      this.uriLabel = new System.Windows.Forms.Label();
56      this.tabControl = new System.Windows.Forms.TabControl();
57      this.agentsPage = new System.Windows.Forms.TabPage();
58      this.resultsTabPage = new System.Windows.Forms.TabPage();
59      this.connectButton = new System.Windows.Forms.Button();
60      this.comboBox1 = new System.Windows.Forms.ComboBox();
61      this.projectLabel = new System.Windows.Forms.Label();
62      this.newButton = new System.Windows.Forms.Button();
63      this.opLibButton = new System.Windows.Forms.Button();
64      this.label1 = new System.Windows.Forms.Label();
65      this.tabControl.SuspendLayout();
66      this.SuspendLayout();
67      //
68      // uriTextBox
69      //
70      this.uriTextBox.Location = new System.Drawing.Point(94, 3);
71      this.uriTextBox.Name = "uriTextBox";
72      this.uriTextBox.Size = new System.Drawing.Size(205, 20);
73      this.uriTextBox.TabIndex = 0;
74      //
75      // uriLabel
76      //
77      this.uriLabel.AutoSize = true;
78      this.uriLabel.Location = new System.Drawing.Point(3, 6);
79      this.uriLabel.Name = "uriLabel";
80      this.uriLabel.Size = new System.Drawing.Size(82, 13);
81      this.uriLabel.TabIndex = 1;
82      this.uriLabel.Text = "CEDMA Server:";
83      //
84      // tabControl
85      //
86      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
87                  | System.Windows.Forms.AnchorStyles.Left)
88                  | System.Windows.Forms.AnchorStyles.Right)));
89      this.tabControl.Controls.Add(this.agentsPage);
90      this.tabControl.Controls.Add(this.resultsTabPage);
91      this.tabControl.Enabled = false;
92      this.tabControl.Location = new System.Drawing.Point(6, 85);
93      this.tabControl.Name = "tabControl";
94      this.tabControl.SelectedIndex = 0;
95      this.tabControl.Size = new System.Drawing.Size(506, 378);
96      this.tabControl.TabIndex = 2;
97      //
98      // agentsPage
99      //
100      this.agentsPage.Location = new System.Drawing.Point(4, 22);
101      this.agentsPage.Name = "agentsPage";
102      this.agentsPage.Padding = new System.Windows.Forms.Padding(3);
103      this.agentsPage.Size = new System.Drawing.Size(498, 352);
104      this.agentsPage.TabIndex = 1;
105      this.agentsPage.Text = "Agents";
106      this.agentsPage.UseVisualStyleBackColor = true;
107      //
108      // resultsTabPage
109      //
110      this.resultsTabPage.Location = new System.Drawing.Point(4, 22);
111      this.resultsTabPage.Name = "resultsTabPage";
112      this.resultsTabPage.Padding = new System.Windows.Forms.Padding(3);
113      this.resultsTabPage.Size = new System.Drawing.Size(498, 352);
114      this.resultsTabPage.TabIndex = 2;
115      this.resultsTabPage.Text = "Results";
116      this.resultsTabPage.UseVisualStyleBackColor = true;
117      //
118      // connectButton
119      //
120      this.connectButton.Location = new System.Drawing.Point(305, 1);
121      this.connectButton.Name = "connectButton";
122      this.connectButton.Size = new System.Drawing.Size(75, 23);
123      this.connectButton.TabIndex = 3;
124      this.connectButton.Text = "&Connect";
125      this.connectButton.UseVisualStyleBackColor = true;
126      this.connectButton.Click += new System.EventHandler(this.connectButton_Click);
127      //
128      // comboBox1
129      //
130      this.comboBox1.Enabled = false;
131      this.comboBox1.FormattingEnabled = true;
132      this.comboBox1.Location = new System.Drawing.Point(94, 29);
133      this.comboBox1.Name = "comboBox1";
134      this.comboBox1.Size = new System.Drawing.Size(121, 21);
135      this.comboBox1.TabIndex = 4;
136      //
137      // projectLabel
138      //
139      this.projectLabel.AutoSize = true;
140      this.projectLabel.Enabled = false;
141      this.projectLabel.Location = new System.Drawing.Point(42, 32);
142      this.projectLabel.Name = "projectLabel";
143      this.projectLabel.Size = new System.Drawing.Size(43, 13);
144      this.projectLabel.TabIndex = 5;
145      this.projectLabel.Text = "Project:";
146      //
147      // newButton
148      //
149      this.newButton.Enabled = false;
150      this.newButton.Location = new System.Drawing.Point(221, 27);
151      this.newButton.Name = "newButton";
152      this.newButton.Size = new System.Drawing.Size(75, 23);
153      this.newButton.TabIndex = 6;
154      this.newButton.Text = "New...";
155      this.newButton.UseVisualStyleBackColor = true;
156      //
157      // opLibButton
158      //
159      this.opLibButton.Enabled = false;
160      this.opLibButton.Location = new System.Drawing.Point(94, 56);
161      this.opLibButton.Name = "opLibButton";
162      this.opLibButton.Size = new System.Drawing.Size(75, 23);
163      this.opLibButton.TabIndex = 7;
164      this.opLibButton.Text = "&Open";
165      this.opLibButton.UseVisualStyleBackColor = true;
166      this.opLibButton.Click += new System.EventHandler(this.opLibButton_Click);
167      //
168      // label1
169      //
170      this.label1.AutoSize = true;
171      this.label1.Location = new System.Drawing.Point(3, 61);
172      this.label1.Name = "label1";
173      this.label1.Size = new System.Drawing.Size(85, 13);
174      this.label1.TabIndex = 8;
175      this.label1.Text = "Operator Library:";
176      //
177      // ConsoleEditor
178      //
179      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
180      this.Controls.Add(this.label1);
181      this.Controls.Add(this.opLibButton);
182      this.Controls.Add(this.newButton);
183      this.Controls.Add(this.projectLabel);
184      this.Controls.Add(this.comboBox1);
185      this.Controls.Add(this.connectButton);
186      this.Controls.Add(this.tabControl);
187      this.Controls.Add(this.uriLabel);
188      this.Controls.Add(this.uriTextBox);
189      this.Name = "ConsoleEditor";
190      this.Size = new System.Drawing.Size(515, 466);
191      this.tabControl.ResumeLayout(false);
192      this.ResumeLayout(false);
193      this.PerformLayout();
194
195    }
196
197    private void connectButton_Click(object sender, EventArgs e) {
198      try {
199        console.Connect(uriTextBox.Text);
200        connectButton.Enabled = false;
201        tabControl.Enabled = true;
202        agentsPage.Controls.Clear();
203        agentsPage.Controls.Add((Control)console.AgentList.CreateView());
204        agentsPage.Controls[0].Dock = DockStyle.Fill;
205        resultsTabPage.Controls.Clear();
206        resultsTabPage.Controls.Add((Control)console.ResultsList.CreateView());
207        resultsTabPage.Controls[0].Dock = DockStyle.Fill;
208        opLibButton.Enabled = true;
209        opLibButton.Enabled = true;
210      } catch(CommunicationException ex) {
211        MessageBox.Show("Exception while trying to connect to " + uriTextBox.Text + "\n" + ex.Message);
212      }
213    }
214
215    private void opLibButton_Click(object sender, EventArgs e) {
216      IOperatorLibrary opLib = console.OperatorLibrary;
217      if(opLib != null) {
218        IView view = opLib.CreateView();
219        if(view != null)
220          PluginManager.ControlManager.ShowControl(view);
221      }
222    }
223  }
224}
Note: See TracBrowser for help on using the repository browser.