Free cookie consent management tool by TermsFeed Policy Generator

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

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

added client service (#397)

File size: 4.6 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//using HeuristicLab.Hive.Client.Console.ClientWCFService;
34using System.ServiceModel;
35
36namespace HeuristicLab.Hive.Client.Console {
37
38  delegate void UpdateTextDelegate(EventLogEntry ev);
39
40  public partial class HiveClientConsole : Form {
41
42    EventLog HiveClientEventLog;
43    int selectedEventLogId;
44
45    public HiveClientConsole() {
46      InitializeComponent();
47      GetEventLog();
48
49      //ClientConsoleCommunicatorClient cccc = new ClientConsoleCommunicatorClient(new NetTcpBinding(),
50      //    new EndpointAddress("net.tcp://127.0.0.1:8000/ClientConsole/ClientConsoleCommunicator"));
51      //StatusCommons sc = cccc.GetStatusInfos();
52    }
53
54    private void GetEventLog() {
55      HiveClientEventLog = new EventLog("Hive Client");
56      HiveClientEventLog.Source = "Hive Client";
57      HiveClientEventLog.EntryWritten += new EntryWrittenEventHandler(OnEntryWritten);
58      HiveClientEventLog.EnableRaisingEvents = true;
59
60      ListViewItem curEventLogEntry;
61      foreach (EventLogEntry eve in HiveClientEventLog.Entries) {
62        curEventLogEntry = new ListViewItem("", 0);
63        if(eve.EntryType == EventLogEntryType.Error)
64          curEventLogEntry = new ListViewItem("", 1);
65        curEventLogEntry.SubItems.Add(eve.InstanceId.ToString());
66        curEventLogEntry.SubItems.Add(eve.Message);
67        curEventLogEntry.SubItems.Add(eve.TimeGenerated.Date.ToString());
68        curEventLogEntry.SubItems.Add(eve.TimeGenerated.TimeOfDay.ToString());
69        lvLog.Items.Add(curEventLogEntry);
70      }
71    }
72
73    private void HiveClientConsole_Load(object sender, EventArgs e) {
74      CreateGraph(zGJobs);
75      //SetSize();
76    }
77
78    private void UpdateText(EventLogEntry ev) {
79      if (this.lvLog.InvokeRequired) {
80        this.lvLog.Invoke(new
81          UpdateTextDelegate(UpdateText), new object[] { ev });
82      } else {
83        ListViewItem curEventLogEntry;
84        curEventLogEntry = new ListViewItem("", 0);
85        if (ev.EntryType == EventLogEntryType.Error)
86          curEventLogEntry = new ListViewItem("", 1);
87        curEventLogEntry.SubItems.Add(ev.EventID.ToString());
88        curEventLogEntry.SubItems.Add(ev.Message);
89        curEventLogEntry.SubItems.Add(ev.TimeGenerated.Date.ToString());
90        curEventLogEntry.SubItems.Add(ev.TimeGenerated.TimeOfDay.ToString());
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      myPane.Fill.Type = FillType.None;
114
115      myPane.AddPieSlice(40, Color.Red, 0, "Jobs aborted");
116      myPane.AddPieSlice(60, Color.Green, 0.1, "Jobs done");
117
118      myPane.AxisChange();
119    }
120
121    private void HiveClientConsole_Resize(object sender, EventArgs e) {
122      //SetSize();
123    }
124
125    private void lvLog_DoubleClick(object sender, EventArgs e) {
126      ListViewItem lvi = lvLog.SelectedItems[0];
127      HiveEventEntry hee = new HiveEventEntry(lvi.SubItems[2].Text, lvi.SubItems[3].Text, lvi.SubItems[4].Text, lvi.SubItems[1].Text);
128     
129      Form EventlogDetails = new EventLogEntryForm(hee);
130      EventlogDetails.Show();
131    }
132  }
133}
Note: See TracBrowser for help on using the repository browser.