Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Client.Console/HiveClientConsole.cs @ 906

Last change on this file since 906 was 906, checked in by whackl, 15 years ago

Hive Client Console Forms w/o services (#397)

File size: 4.7 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.ComponentModel;
25using System.Data;
26using System.Drawing;
27using System.Linq;
28using System.Text;
29using System.Windows.Forms;
30using System.Diagnostics;
31using System.Threading;
32using ZedGraph;
33
34namespace HeuristicLab.Hive.Client.Console {
35
36  delegate void UpdateTextDelegate(EventLog ev);
37
38  public partial class HiveClientConsole : Form {
39
40    EventLog HiveClientEventLog;
41    int selectedEventLogId;
42
43    public HiveClientConsole() {
44      InitializeComponent();
45      GetEventLog();
46    }
47
48    private void GetEventLog() {
49      HiveClientEventLog = new EventLog("Hive Client");
50      HiveClientEventLog.Source = "Hive Client";
51      HiveClientEventLog.EntryWritten += new EntryWrittenEventHandler(OnEntryWritten);
52      HiveClientEventLog.EnableRaisingEvents = true;
53
54      ListViewItem curEventLogEntry;
55      foreach (EventLogEntry eve in HiveClientEventLog.Entries) {
56        curEventLogEntry = new ListViewItem("", 0);
57        if(eve.EntryType == EventLogEntryType.Error)
58          curEventLogEntry = new ListViewItem("", 1);
59        curEventLogEntry.SubItems.Add(eve.EventID.ToString());
60        curEventLogEntry.SubItems.Add(eve.Message);
61        curEventLogEntry.SubItems.Add(eve.TimeGenerated.Date.ToString());
62        curEventLogEntry.SubItems.Add(eve.TimeGenerated.TimeOfDay.ToString());
63        lvLog.Items.Add(curEventLogEntry);
64      }
65    }
66
67    private void HiveClientConsole_Load(object sender, EventArgs e) {
68      CreateGraph(zGJobs);
69      //SetSize();
70    }
71
72    private void UpdateText(EventLog ev) {
73      if (this.lvLog.InvokeRequired) {
74        this.lvLog.Invoke(new
75          UpdateTextDelegate(UpdateText), new object[] { ev });
76      } else {
77        //string str = ev.Entries[numEntries].TimeWritten + " -> " + ev.Entries[numEntries].Message;
78        //numEntries++;
79        //lbEventLog.Items.Add(str);
80        //lbEventLog.SelectedIndex = lbEventLog.Items.Count - 1;
81
82      }
83    }
84
85    //private void tsmiExit_Click(object sender, EventArgs e) {
86    //  this.Close();
87    //}
88
89    //private void btnConnect_Click(object sender, EventArgs e) {
90    //  btnConnect.Enabled = false;
91    //  btnDisconnect.Enabled = true;
92    //  tbIp.Enabled = false;
93    //  tbPort.Enabled = false;
94    //  tbUuid.Enabled = false;
95    //  lbEventLog.Items.Add(tbIp.Text);
96    //}
97
98    //private void btnDisconnect_Click(object sender, EventArgs e) {
99    //  btnDisconnect.Enabled = false;
100    //  btnConnect.Enabled = true;
101    //  tbIp.Enabled = true;
102    //  tbPort.Enabled = true;
103    //  tbUuid.Enabled = true;
104    //}
105
106    public void OnEntryWritten(object source, EntryWrittenEventArgs e) {
107      UpdateText((EventLog)source);
108    }
109
110    private void SetSize() {
111      zGJobs.Location = new Point(10, 10);
112      // Leave a small margin around the outside of the control
113
114      zGJobs.Size = new Size(ClientRectangle.Width - 20,
115                              ClientRectangle.Height - 20);
116    }
117
118
119    private void CreateGraph(ZedGraphControl zgc) {
120      GraphPane myPane = zgc.GraphPane;
121
122      // Set the titles and axis labels
123      myPane.Legend.IsVisible = false;
124      myPane.Title.IsVisible = false;
125
126      myPane.AddPieSlice(40, Color.Red, 0, "Jobs aborted");
127      myPane.AddPieSlice(60, Color.Green, 0.1, "Jobs done");
128
129      myPane.AxisChange();
130    }
131
132    private void HiveClientConsole_Resize(object sender, EventArgs e) {
133      //SetSize();
134    }
135
136    private void lvLog_DoubleClick(object sender, EventArgs e) {
137      ListViewItem lvi = lvLog.SelectedItems[0];
138
139      HiveEventEntry hee = new HiveEventEntry(lvi.SubItems[2].Text, lvi.SubItems[3].Text, lvi.SubItems[4].Text, lvi.SubItems[1].Text);
140     
141      Form EventlogDetails = new EventLogEntryForm(hee);
142      EventlogDetails.Show();
143    }
144  }
145}
Note: See TracBrowser for help on using the repository browser.