Free cookie consent management tool by TermsFeed Policy Generator

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

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

added a results-tab in the cedma console which contains a data chart that can be used to display histograms and scatter plots for any result value.

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