Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 947 was 933, checked in by whackl, 16 years ago

added wcf service to HiveClient (#397)

File size: 4.5 KB
RevLine 
[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
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;
[752]30using System.Diagnostics;
31using System.Threading;
[906]32using ZedGraph;
[933]33using HeuristicLab.Hive.Client.Console.ClientWCFService;
[717]34
35namespace HeuristicLab.Hive.Client.Console {
[752]36
[911]37  delegate void UpdateTextDelegate(EventLogEntry ev);
[752]38
[717]39  public partial class HiveClientConsole : Form {
[752]40
[906]41    EventLog HiveClientEventLog;
42    int selectedEventLogId;
[752]43
[717]44    public HiveClientConsole() {
45      InitializeComponent();
[906]46      GetEventLog();
[911]47
[933]48      ClientConsoleCommunicatorClient cccc = new ClientConsoleCommunicatorClient();
49      cccc.GetStatusInfos();
[906]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);
[911]63        curEventLogEntry.SubItems.Add(eve.InstanceId.ToString());
[906]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);
[752]68      }
[717]69    }
70
[906]71    private void HiveClientConsole_Load(object sender, EventArgs e) {
72      CreateGraph(zGJobs);
73      //SetSize();
74    }
75
[911]76    private void UpdateText(EventLogEntry ev) {
[906]77      if (this.lvLog.InvokeRequired) {
78        this.lvLog.Invoke(new
[752]79          UpdateTextDelegate(UpdateText), new object[] { ev });
80      } else {
[911]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());
[752]89
[911]90
[752]91      }
92    }
93
[906]94    public void OnEntryWritten(object source, EntryWrittenEventArgs e) {
[911]95      UpdateText(e.Entry);
[717]96    }
97
[906]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);
[717]104    }
105
[906]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;
[933]113      myPane.Fill.Type = FillType.None;
[906]114
115      myPane.AddPieSlice(40, Color.Red, 0, "Jobs aborted");
116      myPane.AddPieSlice(60, Color.Green, 0.1, "Jobs done");
117
118      myPane.AxisChange();
[717]119    }
[752]120
[906]121    private void HiveClientConsole_Resize(object sender, EventArgs e) {
122      //SetSize();
[752]123    }
[906]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    }
[717]132  }
[752]133}
Note: See TracBrowser for help on using the repository browser.