Free cookie consent management tool by TermsFeed Policy Generator

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

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

bug fixed (#397)

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