Free cookie consent management tool by TermsFeed Policy Generator

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

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

implemented #255 (CEDMA console should have a refresh button for the treeview with agents and results). Also deleted the obsolete timer in ConsoleEditor.

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