[717] | 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;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.ComponentModel;
|
---|
| 25 | using System.Data;
|
---|
| 26 | using System.Drawing;
|
---|
| 27 | using System.Linq;
|
---|
| 28 | using System.Text;
|
---|
| 29 | using System.Windows.Forms;
|
---|
[752] | 30 | using System.Diagnostics;
|
---|
| 31 | using System.Threading;
|
---|
[717] | 32 |
|
---|
| 33 | namespace HeuristicLab.Hive.Client.Console {
|
---|
[752] | 34 |
|
---|
| 35 | delegate void UpdateTextDelegate(EventLog ev);
|
---|
| 36 |
|
---|
[717] | 37 | public partial class HiveClientConsole : Form {
|
---|
[752] | 38 |
|
---|
| 39 | int numEntries = 0;
|
---|
| 40 |
|
---|
[717] | 41 | public HiveClientConsole() {
|
---|
| 42 | InitializeComponent();
|
---|
[752] | 43 | tbIp.Text = "010.020.053.006";
|
---|
| 44 | EventLog ev = new EventLog("Hive Client");
|
---|
| 45 | ev.Source = "Hive Client";
|
---|
| 46 | string str = ev.Entries[ev.Entries.Count - 1].Message;
|
---|
| 47 | foreach (System.Diagnostics.EventLogEntry entry in ev.Entries) {
|
---|
| 48 | lbEventLog.Items.Add(entry.TimeWritten + " -> " + entry.Message);
|
---|
| 49 | }
|
---|
| 50 | lbEventLog.SelectedIndex = lbEventLog.Items.Count - 1;
|
---|
| 51 | numEntries = ev.Entries.Count;
|
---|
| 52 | ev.EntryWritten += new EntryWrittenEventHandler(OnEntryWritten);
|
---|
| 53 | ev.EnableRaisingEvents = true;
|
---|
[717] | 54 | }
|
---|
| 55 |
|
---|
[752] | 56 | private void UpdateText(EventLog ev) {
|
---|
| 57 | if (this.lbEventLog.InvokeRequired) {
|
---|
| 58 | this.lbEventLog.Invoke(new
|
---|
| 59 | UpdateTextDelegate(UpdateText), new object[] { ev });
|
---|
| 60 | } else {
|
---|
| 61 | string str = ev.Entries[numEntries].TimeWritten + " -> " + ev.Entries[numEntries].Message;
|
---|
| 62 | numEntries++;
|
---|
| 63 | lbEventLog.Items.Add(str);
|
---|
| 64 | lbEventLog.SelectedIndex = lbEventLog.Items.Count - 1;
|
---|
| 65 |
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[717] | 69 | private void tsmiExit_Click(object sender, EventArgs e) {
|
---|
| 70 | this.Close();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | private void btnConnect_Click(object sender, EventArgs e) {
|
---|
| 74 | btnConnect.Enabled = false;
|
---|
| 75 | btnDisconnect.Enabled = true;
|
---|
| 76 | tbIp.Enabled = false;
|
---|
| 77 | tbPort.Enabled = false;
|
---|
| 78 | tbUuid.Enabled = false;
|
---|
[752] | 79 | lbEventLog.Items.Add(tbIp.Text);
|
---|
[717] | 80 | }
|
---|
| 81 |
|
---|
| 82 | private void btnDisconnect_Click(object sender, EventArgs e) {
|
---|
| 83 | btnDisconnect.Enabled = false;
|
---|
| 84 | btnConnect.Enabled = true;
|
---|
| 85 | tbIp.Enabled = true;
|
---|
| 86 | tbPort.Enabled = true;
|
---|
| 87 | tbUuid.Enabled = true;
|
---|
| 88 | }
|
---|
[752] | 89 |
|
---|
| 90 | public void OnEntryWritten(object source, EntryWrittenEventArgs e) {
|
---|
| 91 | UpdateText((EventLog)source);
|
---|
| 92 | }
|
---|
[717] | 93 | }
|
---|
[752] | 94 | } |
---|