Changeset 1027
- Timestamp:
- 12/18/08 14:55:53 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Client.Console/HiveClientConsole.cs
r1016 r1027 37 37 namespace HeuristicLab.Hive.Client.Console { 38 38 39 #region Delegates 40 39 41 delegate void UpdateTextDelegate(EventLogEntry ev); 40 42 43 #endregion 44 41 45 public partial class HiveClientConsole : Form { 46 47 #region Declarations 48 49 private const string ENDPOINTADRESS = "net.tcp://127.0.0.1:8000/ClientConsole/ClientConsoleCommunicator"; 50 private const string EVENTLOGNAME = "Hive Client"; 42 51 43 52 private EventLog HiveClientEventLog; … … 46 55 private ListViewColumnSorterDate lvwColumnSorter; 47 56 57 #endregion 58 59 #region Constructor 48 60 49 61 public HiveClientConsole() { … … 59 71 } 60 72 73 #endregion 74 75 #region Methods 76 61 77 private void InitTimer() { 62 78 refreshTimer = new System.Windows.Forms.Timer(); … … 66 82 } 67 83 68 void refreshTimer_Tick(object sender, EventArgs e) {69 RefreshGui();70 }71 72 84 private void RefreshGui() { 73 85 try { … … 84 96 private void ConnectToClient() { 85 97 try { 86 cccc = new ClientConsoleCommunicatorClient(new NetTcpBinding(), new EndpointAddress( "net.tcp://127.0.0.1:8000/ClientConsole/ClientConsoleCommunicator"));98 cccc = new ClientConsoleCommunicatorClient(new NetTcpBinding(), new EndpointAddress(ENDPOINTADRESS)); 87 99 cccc.GetStatusInfosCompleted += new EventHandler<GetStatusInfosCompletedEventArgs>(cccc_GetStatusInfosCompleted); 88 100 cccc.GetCurrentConnectionCompleted += new EventHandler<GetCurrentConnectionCompletedEventArgs>(cccc_GetCurrentConnectionCompleted); … … 96 108 } 97 109 98 void cccc_GetCurrentConnectionCompleted(object sender, GetCurrentConnectionCompletedEventArgs e) { 110 private void GetEventLog() { 111 HiveClientEventLog = new EventLog(EVENTLOGNAME); 112 HiveClientEventLog.Source = EVENTLOGNAME; 113 HiveClientEventLog.EntryWritten += new EntryWrittenEventHandler(OnEntryWritten); 114 HiveClientEventLog.EnableRaisingEvents = true; 115 116 ListViewItem curEventLogEntry; 117 118 foreach (EventLogEntry ele in HiveClientEventLog.Entries) { 119 curEventLogEntry = GenerateEventEntry(ele); 120 lvLog.Items.Add(curEventLogEntry); 121 } 122 lvJobDetail.Sort(); 123 } 124 125 private ListViewItem GenerateEventEntry(EventLogEntry ele) { 126 ListViewItem curEventLogEntry; 127 curEventLogEntry = new ListViewItem("", 0); 128 if (ele.EntryType == EventLogEntryType.Error) 129 curEventLogEntry = new ListViewItem("", 1); 130 curEventLogEntry.SubItems.Add(ele.InstanceId.ToString()); 131 curEventLogEntry.SubItems.Add(ele.Message); 132 curEventLogEntry.SubItems.Add(ele.TimeGenerated.ToString()); 133 return curEventLogEntry; 134 } 135 136 private void UpdateGraph(int jobsDone, int jobsAborted) { 137 ZedGraphControl zgc = new ZedGraphControl(); 138 GraphPane myPane = zgc.GraphPane; 139 myPane.GraphObjList.Clear(); 140 141 myPane.Title.IsVisible = false; // no title 142 myPane.Border.IsVisible = false; // no border 143 myPane.Chart.Border.IsVisible = false; // no border around the chart 144 myPane.XAxis.IsVisible = false; // no x-axis 145 myPane.YAxis.IsVisible = false; // no y-axis 146 myPane.Legend.IsVisible = false; // no legend 147 148 myPane.Fill.Color = Color.FromKnownColor(KnownColor.Control); 149 150 myPane.Chart.Fill.Type = FillType.None; 151 myPane.Fill.Type = FillType.Solid; 152 153 double sum = (double)jobsDone + jobsAborted; 154 double perDone = (double)jobsDone / sum * 100; 155 double perAborted = (double)jobsAborted / sum * 100; 156 157 myPane.AddPieSlice(perDone, Color.Green, 0.1, ""); 158 myPane.AddPieSlice(perAborted, Color.Red, 0.1, ""); 159 160 //Hides the slice labels 161 PieItem.Default.LabelType = PieLabelType.None; 162 163 myPane.AxisChange(); 164 165 pbGraph.Image = zgc.GetImage(); 166 } 167 168 #endregion 169 170 #region Events 171 172 private void refreshTimer_Tick(object sender, EventArgs e) { 173 RefreshGui(); 174 } 175 176 private void cccc_GetCurrentConnectionCompleted(object sender, GetCurrentConnectionCompletedEventArgs e) { 99 177 if (e.Error == null) { 100 178 ConnectionContainer curConnection = e.Result; … … 104 182 } 105 183 106 void cccc_GetStatusInfosCompleted(object sender, GetStatusInfosCompletedEventArgs e) {184 private void cccc_GetStatusInfosCompleted(object sender, GetStatusInfosCompletedEventArgs e) { 107 185 108 186 if (e.Error == null) { … … 152 230 } 153 231 154 private void GetEventLog() {155 HiveClientEventLog = new EventLog("Hive Client");156 HiveClientEventLog.Source = "Hive Client";157 HiveClientEventLog.EntryWritten += new EntryWrittenEventHandler(OnEntryWritten);158 HiveClientEventLog.EnableRaisingEvents = true;159 160 ListViewItem curEventLogEntry;161 foreach (EventLogEntry eve in HiveClientEventLog.Entries) {162 curEventLogEntry = new ListViewItem("", 0);163 if(eve.EntryType == EventLogEntryType.Error)164 curEventLogEntry = new ListViewItem("", 1);165 curEventLogEntry.SubItems.Add(eve.InstanceId.ToString());166 curEventLogEntry.SubItems.Add(eve.Message);167 curEventLogEntry.SubItems.Add(eve.TimeGenerated.ToString());168 lvLog.Items.Add(curEventLogEntry);169 }170 lvJobDetail.Sort();171 }172 173 232 private void HiveClientConsole_Load(object sender, EventArgs e) { 174 // SetSize();233 //nothing to do 175 234 } 176 235 … … 180 239 UpdateTextDelegate(UpdateText), new object[] { ev }); 181 240 } else { 182 ListViewItem curEventLogEntry; 183 curEventLogEntry = new ListViewItem("", 0); 184 if (ev.EntryType == EventLogEntryType.Error) 185 curEventLogEntry = new ListViewItem("", 1); 186 curEventLogEntry.SubItems.Add(ev.InstanceId.ToString()); 187 curEventLogEntry.SubItems.Add(ev.Message); 188 curEventLogEntry.SubItems.Add(ev.TimeGenerated.ToString()); 241 ListViewItem curEventLogEntry = GenerateEventEntry(ev); 189 242 lvLog.Items.Add(curEventLogEntry); 190 243 lvJobDetail.Sort(); … … 196 249 } 197 250 198 private void UpdateGraph(int jobsDone, int jobsAborted) {199 ZedGraphControl zgc = new ZedGraphControl();200 GraphPane myPane = zgc.GraphPane;201 myPane.GraphObjList.Clear();202 203 myPane.Title.IsVisible = false; // no title204 myPane.Border.IsVisible = false; // no border205 myPane.Chart.Border.IsVisible = false; // no border around the chart206 myPane.XAxis.IsVisible = false; // no x-axis207 myPane.YAxis.IsVisible = false; // no y-axis208 myPane.Legend.IsVisible = false; // no legend209 210 myPane.Fill.Color = Color.FromKnownColor(KnownColor.Control);211 212 myPane.Chart.Fill.Type = FillType.None;213 myPane.Fill.Type = FillType.Solid;214 215 double sum = (double)jobsDone + jobsAborted;216 double perDone = (double)jobsDone / sum * 100;217 double perAborted = (double)jobsAborted / sum * 100;218 219 myPane.AddPieSlice(perDone, Color.Green, 0.1, "");220 myPane.AddPieSlice(perAborted, Color.Red, 0.1, "");221 222 //Hides the slice labels223 PieItem.Default.LabelType = PieLabelType.None;224 225 myPane.AxisChange();226 227 pbGraph.Image = zgc.GetImage();228 }229 230 251 private void HiveClientConsole_Resize(object sender, EventArgs e) { 231 // SetSize();252 //nothing to do 232 253 } 233 254 … … 235 256 ListViewItem lvi = lvLog.SelectedItems[0]; 236 257 HiveEventEntry hee = new HiveEventEntry(lvi.SubItems[2].Text, lvi.SubItems[3].Text, lvi.SubItems[1].Text); 237 258 238 259 Form EventlogDetails = new EventLogEntryForm(hee); 239 260 EventlogDetails.Show(); … … 244 265 int port; 245 266 ConnectionContainer cc = new ConnectionContainer(); 246 //IPAddress.TryParse(tbIPAdress.Text.ToString(), ipAdress);247 267 if (IPAddress.TryParse(tbIPAdress.Text, out ipAdress) && int.TryParse(tbPort.Text, out port)) { 248 268 cc.IPAdress = tbIPAdress.Text; … … 276 296 lvLog.Sort(); 277 297 } 298 299 #endregion 278 300 } 279 301 }
Note: See TracChangeset
for help on using the changeset viewer.