Free cookie consent management tool by TermsFeed Policy Generator

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

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

worked on #211 (Full operator-graphs are stored multiple times in the database even though most of it is static anyway)

  • created a new type of operator library that is connected to the CEDMA db and a view for it
File size: 8.5 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 Timer refreshTimer;
42    private System.ComponentModel.IContainer components;
43    private Button opLibButton;
44    private Label label1;
45    private Console console;
46
47    public ConsoleEditor(Console console) {
48      InitializeComponent();
49      this.console = console;
50    }
51
52    private void InitializeComponent() {
53      this.components = new System.ComponentModel.Container();
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.connectButton = new System.Windows.Forms.Button();
59      this.comboBox1 = new System.Windows.Forms.ComboBox();
60      this.projectLabel = new System.Windows.Forms.Label();
61      this.newButton = new System.Windows.Forms.Button();
62      this.refreshTimer = new System.Windows.Forms.Timer(this.components);
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.Enabled = false;
91      this.tabControl.Location = new System.Drawing.Point(6, 85);
92      this.tabControl.Name = "tabControl";
93      this.tabControl.SelectedIndex = 0;
94      this.tabControl.Size = new System.Drawing.Size(506, 378);
95      this.tabControl.TabIndex = 2;
96      //
97      // agentsPage
98      //
99      this.agentsPage.Location = new System.Drawing.Point(4, 22);
100      this.agentsPage.Name = "agentsPage";
101      this.agentsPage.Padding = new System.Windows.Forms.Padding(3);
102      this.agentsPage.Size = new System.Drawing.Size(498, 352);
103      this.agentsPage.TabIndex = 1;
104      this.agentsPage.Text = "Agents";
105      this.agentsPage.UseVisualStyleBackColor = true;
106      //
107      // connectButton
108      //
109      this.connectButton.Location = new System.Drawing.Point(305, 1);
110      this.connectButton.Name = "connectButton";
111      this.connectButton.Size = new System.Drawing.Size(75, 23);
112      this.connectButton.TabIndex = 3;
113      this.connectButton.Text = "&Connect";
114      this.connectButton.UseVisualStyleBackColor = true;
115      this.connectButton.Click += new System.EventHandler(this.connectButton_Click);
116      //
117      // comboBox1
118      //
119      this.comboBox1.Enabled = false;
120      this.comboBox1.FormattingEnabled = true;
121      this.comboBox1.Location = new System.Drawing.Point(94, 29);
122      this.comboBox1.Name = "comboBox1";
123      this.comboBox1.Size = new System.Drawing.Size(121, 21);
124      this.comboBox1.TabIndex = 4;
125      //
126      // projectLabel
127      //
128      this.projectLabel.AutoSize = true;
129      this.projectLabel.Enabled = false;
130      this.projectLabel.Location = new System.Drawing.Point(42, 32);
131      this.projectLabel.Name = "projectLabel";
132      this.projectLabel.Size = new System.Drawing.Size(43, 13);
133      this.projectLabel.TabIndex = 5;
134      this.projectLabel.Text = "Project:";
135      //
136      // newButton
137      //
138      this.newButton.Enabled = false;
139      this.newButton.Location = new System.Drawing.Point(221, 27);
140      this.newButton.Name = "newButton";
141      this.newButton.Size = new System.Drawing.Size(75, 23);
142      this.newButton.TabIndex = 6;
143      this.newButton.Text = "New...";
144      this.newButton.UseVisualStyleBackColor = true;
145      //
146      // refreshTimer
147      //
148      this.refreshTimer.Interval = 3000;
149      this.refreshTimer.Tick += new System.EventHandler(this.refreshTimer_Tick);
150      //
151      // opLibButton
152      //
153      this.opLibButton.Enabled = false;
154      this.opLibButton.Location = new System.Drawing.Point(94, 56);
155      this.opLibButton.Name = "opLibButton";
156      this.opLibButton.Size = new System.Drawing.Size(75, 23);
157      this.opLibButton.TabIndex = 7;
158      this.opLibButton.Text = "&Open";
159      this.opLibButton.UseVisualStyleBackColor = true;
160      this.opLibButton.Click += new System.EventHandler(this.opLibButton_Click);
161      //
162      // label1
163      //
164      this.label1.AutoSize = true;
165      this.label1.Location = new System.Drawing.Point(3, 61);
166      this.label1.Name = "label1";
167      this.label1.Size = new System.Drawing.Size(85, 13);
168      this.label1.TabIndex = 8;
169      this.label1.Text = "Operator Library:";
170      //
171      // ConsoleEditor
172      //
173      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
174      this.Controls.Add(this.label1);
175      this.Controls.Add(this.opLibButton);
176      this.Controls.Add(this.newButton);
177      this.Controls.Add(this.projectLabel);
178      this.Controls.Add(this.comboBox1);
179      this.Controls.Add(this.connectButton);
180      this.Controls.Add(this.tabControl);
181      this.Controls.Add(this.uriLabel);
182      this.Controls.Add(this.uriTextBox);
183      this.Name = "ConsoleEditor";
184      this.Size = new System.Drawing.Size(515, 466);
185      this.tabControl.ResumeLayout(false);
186      this.ResumeLayout(false);
187      this.PerformLayout();
188
189    }
190
191    private void connectButton_Click(object sender, EventArgs e) {
192      try {
193        console.Connect(uriTextBox.Text);
194        connectButton.Enabled = false;
195        tabControl.Enabled = true;
196        agentsPage.Controls.Clear();
197        agentsPage.Controls.Add((Control)console.AgentList.CreateView());
198        agentsPage.Controls[0].Dock = DockStyle.Fill;
199        refreshTimer.Enabled = true;
200        opLibButton.Enabled = true;
201        opLibButton.Enabled = true;
202      } catch(CommunicationException ex) {
203        // TASK create helper class for error reporting
204        MessageBox.Show("Exception while trying to connect to " + uriTextBox.Text + "\n" + ex.Message);
205      }
206    }
207
208    private void refreshTimer_Tick(object sender, EventArgs e) {
209      refreshTimer.Stop();
210      UpdateControls();
211      refreshTimer.Enabled = true;
212    }
213
214    private void opLibButton_Click(object sender, EventArgs e) {
215      IOperatorLibrary opLib = console.OperatorLibrary;
216      if(opLib != null) {
217        IView view = opLib.CreateView();
218        if(view != null)
219          PluginManager.ControlManager.ShowControl(view);
220      }
221    }
222  }
223}
Note: See TracBrowser for help on using the repository browser.