[372] | 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 |
|
---|
| 22 | using System;
|
---|
[357] | 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Linq;
|
---|
| 25 | using System.Text;
|
---|
| 26 | using HeuristicLab.Core;
|
---|
| 27 | using System.Windows.Forms;
|
---|
[359] | 28 | using System.ServiceModel;
|
---|
[417] | 29 | using HeuristicLab.PluginInfrastructure;
|
---|
[553] | 30 | using System.Drawing;
|
---|
| 31 | using HeuristicLab.CEDMA.DB.Interfaces;
|
---|
[357] | 32 |
|
---|
[377] | 33 | namespace HeuristicLab.CEDMA.Core {
|
---|
[357] | 34 | class ConsoleEditor : EditorBase {
|
---|
| 35 | private System.Windows.Forms.TextBox uriTextBox;
|
---|
| 36 | private System.Windows.Forms.Label uriLabel;
|
---|
[359] | 37 | private Button connectButton;
|
---|
[561] | 38 | private Button openOpLibButton;
|
---|
[417] | 39 | private Label label1;
|
---|
[561] | 40 | private Label resultsLabel;
|
---|
| 41 | private Button openResultsButton;
|
---|
| 42 | private Button openAgentsButton;
|
---|
| 43 | private Label agentsLabel;
|
---|
[357] | 44 | private Console console;
|
---|
| 45 |
|
---|
| 46 | public ConsoleEditor(Console console) {
|
---|
[359] | 47 | InitializeComponent();
|
---|
[357] | 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();
|
---|
[359] | 54 | this.connectButton = new System.Windows.Forms.Button();
|
---|
[561] | 55 | this.openOpLibButton = new System.Windows.Forms.Button();
|
---|
[417] | 56 | this.label1 = new System.Windows.Forms.Label();
|
---|
[561] | 57 | this.resultsLabel = new System.Windows.Forms.Label();
|
---|
| 58 | this.openResultsButton = new System.Windows.Forms.Button();
|
---|
| 59 | this.openAgentsButton = new System.Windows.Forms.Button();
|
---|
| 60 | this.agentsLabel = new System.Windows.Forms.Label();
|
---|
[357] | 61 | this.SuspendLayout();
|
---|
| 62 | //
|
---|
| 63 | // uriTextBox
|
---|
| 64 | //
|
---|
[417] | 65 | this.uriTextBox.Location = new System.Drawing.Point(94, 3);
|
---|
[357] | 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;
|
---|
[561] | 73 | this.uriLabel.Location = new System.Drawing.Point(6, 6);
|
---|
[357] | 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 | //
|
---|
[359] | 79 | // connectButton
|
---|
| 80 | //
|
---|
[417] | 81 | this.connectButton.Location = new System.Drawing.Point(305, 1);
|
---|
[359] | 82 | this.connectButton.Name = "connectButton";
|
---|
| 83 | this.connectButton.Size = new System.Drawing.Size(75, 23);
|
---|
| 84 | this.connectButton.TabIndex = 3;
|
---|
| 85 | this.connectButton.Text = "&Connect";
|
---|
| 86 | this.connectButton.UseVisualStyleBackColor = true;
|
---|
| 87 | this.connectButton.Click += new System.EventHandler(this.connectButton_Click);
|
---|
| 88 | //
|
---|
[561] | 89 | // openOpLibButton
|
---|
[372] | 90 | //
|
---|
[561] | 91 | this.openOpLibButton.Enabled = false;
|
---|
| 92 | this.openOpLibButton.Location = new System.Drawing.Point(94, 85);
|
---|
| 93 | this.openOpLibButton.Name = "openOpLibButton";
|
---|
| 94 | this.openOpLibButton.Size = new System.Drawing.Size(75, 23);
|
---|
| 95 | this.openOpLibButton.TabIndex = 7;
|
---|
| 96 | this.openOpLibButton.Text = "&Open";
|
---|
| 97 | this.openOpLibButton.UseVisualStyleBackColor = true;
|
---|
| 98 | this.openOpLibButton.Click += new System.EventHandler(this.opLibButton_Click);
|
---|
[372] | 99 | //
|
---|
[417] | 100 | // label1
|
---|
| 101 | //
|
---|
| 102 | this.label1.AutoSize = true;
|
---|
[561] | 103 | this.label1.Location = new System.Drawing.Point(3, 90);
|
---|
[417] | 104 | this.label1.Name = "label1";
|
---|
| 105 | this.label1.Size = new System.Drawing.Size(85, 13);
|
---|
| 106 | this.label1.TabIndex = 8;
|
---|
| 107 | this.label1.Text = "Operator Library:";
|
---|
| 108 | //
|
---|
[561] | 109 | // resultsLabel
|
---|
| 110 | //
|
---|
| 111 | this.resultsLabel.AutoSize = true;
|
---|
| 112 | this.resultsLabel.Location = new System.Drawing.Point(43, 61);
|
---|
| 113 | this.resultsLabel.Name = "resultsLabel";
|
---|
| 114 | this.resultsLabel.Size = new System.Drawing.Size(45, 13);
|
---|
| 115 | this.resultsLabel.TabIndex = 9;
|
---|
| 116 | this.resultsLabel.Text = "Results:";
|
---|
| 117 | //
|
---|
| 118 | // openResultsButton
|
---|
| 119 | //
|
---|
| 120 | this.openResultsButton.Enabled = false;
|
---|
| 121 | this.openResultsButton.Location = new System.Drawing.Point(94, 56);
|
---|
| 122 | this.openResultsButton.Name = "openResultsButton";
|
---|
| 123 | this.openResultsButton.Size = new System.Drawing.Size(75, 23);
|
---|
| 124 | this.openResultsButton.TabIndex = 10;
|
---|
| 125 | this.openResultsButton.Text = "&Open";
|
---|
| 126 | this.openResultsButton.UseVisualStyleBackColor = true;
|
---|
| 127 | this.openResultsButton.Click += new System.EventHandler(this.openChartButton_Click);
|
---|
| 128 | //
|
---|
| 129 | // openAgentsButton
|
---|
| 130 | //
|
---|
| 131 | this.openAgentsButton.Enabled = false;
|
---|
| 132 | this.openAgentsButton.Location = new System.Drawing.Point(94, 27);
|
---|
| 133 | this.openAgentsButton.Name = "openAgentsButton";
|
---|
| 134 | this.openAgentsButton.Size = new System.Drawing.Size(75, 23);
|
---|
| 135 | this.openAgentsButton.TabIndex = 12;
|
---|
| 136 | this.openAgentsButton.Text = "&Open";
|
---|
| 137 | this.openAgentsButton.UseVisualStyleBackColor = true;
|
---|
| 138 | this.openAgentsButton.Click += new System.EventHandler(this.openAgentsButton_Click);
|
---|
| 139 | //
|
---|
| 140 | // agentsLabel
|
---|
| 141 | //
|
---|
| 142 | this.agentsLabel.AutoSize = true;
|
---|
| 143 | this.agentsLabel.Location = new System.Drawing.Point(45, 32);
|
---|
| 144 | this.agentsLabel.Name = "agentsLabel";
|
---|
| 145 | this.agentsLabel.Size = new System.Drawing.Size(43, 13);
|
---|
| 146 | this.agentsLabel.TabIndex = 11;
|
---|
| 147 | this.agentsLabel.Text = "Agents:";
|
---|
| 148 | //
|
---|
[357] | 149 | // ConsoleEditor
|
---|
| 150 | //
|
---|
| 151 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
---|
[561] | 152 | this.Controls.Add(this.openAgentsButton);
|
---|
| 153 | this.Controls.Add(this.agentsLabel);
|
---|
| 154 | this.Controls.Add(this.openResultsButton);
|
---|
| 155 | this.Controls.Add(this.resultsLabel);
|
---|
[417] | 156 | this.Controls.Add(this.label1);
|
---|
[561] | 157 | this.Controls.Add(this.openOpLibButton);
|
---|
[359] | 158 | this.Controls.Add(this.connectButton);
|
---|
[357] | 159 | this.Controls.Add(this.uriLabel);
|
---|
| 160 | this.Controls.Add(this.uriTextBox);
|
---|
| 161 | this.Name = "ConsoleEditor";
|
---|
[561] | 162 | this.Size = new System.Drawing.Size(445, 189);
|
---|
[357] | 163 | this.ResumeLayout(false);
|
---|
| 164 | this.PerformLayout();
|
---|
| 165 |
|
---|
| 166 | }
|
---|
| 167 |
|
---|
[359] | 168 | private void connectButton_Click(object sender, EventArgs e) {
|
---|
| 169 | try {
|
---|
| 170 | console.Connect(uriTextBox.Text);
|
---|
| 171 | connectButton.Enabled = false;
|
---|
[561] | 172 | openOpLibButton.Enabled = true;
|
---|
| 173 | openAgentsButton.Enabled = true;
|
---|
| 174 | openResultsButton.Enabled = true;
|
---|
[359] | 175 | } catch(CommunicationException ex) {
|
---|
| 176 | MessageBox.Show("Exception while trying to connect to " + uriTextBox.Text + "\n" + ex.Message);
|
---|
| 177 | }
|
---|
[357] | 178 | }
|
---|
[393] | 179 |
|
---|
[417] | 180 | private void opLibButton_Click(object sender, EventArgs e) {
|
---|
| 181 | IOperatorLibrary opLib = console.OperatorLibrary;
|
---|
| 182 | if(opLib != null) {
|
---|
| 183 | IView view = opLib.CreateView();
|
---|
| 184 | if(view != null)
|
---|
| 185 | PluginManager.ControlManager.ShowControl(view);
|
---|
| 186 | }
|
---|
| 187 | }
|
---|
[561] | 188 |
|
---|
| 189 | private void openChartButton_Click(object sender, EventArgs e) {
|
---|
| 190 | PluginManager.ControlManager.ShowControl(console.ResultsList.CreateView());
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | private void openAgentsButton_Click(object sender, EventArgs e) {
|
---|
| 194 | PluginManager.ControlManager.ShowControl(console.AgentList.CreateView());
|
---|
| 195 | }
|
---|
[357] | 196 | }
|
---|
| 197 | }
|
---|