- Timestamp:
- 12/17/08 14:24:16 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Client.Console/HiveClientConsole.cs
r973 r1002 41 41 public partial class HiveClientConsole : Form { 42 42 43 EventLog HiveClientEventLog; 44 ClientConsoleCommunicatorClient cccc; 45 System.Windows.Forms.Timer refreshTimer; 43 private EventLog HiveClientEventLog; 44 private ClientConsoleCommunicatorClient cccc; 45 private System.Windows.Forms.Timer refreshTimer; 46 private ListViewColumnSorterDate lvwColumnSorter; 47 46 48 47 49 public HiveClientConsole() { 48 50 InitializeComponent(); 51 lvwColumnSorter = new ListViewColumnSorterDate(); 52 lvLog.ListViewItemSorter = lvwColumnSorter; 53 lvwColumnSorter.SortColumn = 3; 54 lvwColumnSorter.Order = SortOrder.Descending; 49 55 InitTimer(); 50 56 ConnectToClient(); … … 65 71 66 72 private void RefreshGui() { 67 StatusCommons sc = new StatusCommons();68 69 73 try { 70 sc = cccc.GetStatusInfos();74 cccc.GetStatusInfosAsync(); 71 75 } 72 76 catch (Exception ex) { … … 76 80 this.Close(); 77 81 } 78 79 lbGuid.Text = sc.ClientGuid.ToString();80 lbCs.Text = sc.ConnectedSince.ToString();81 lbConnectionStatus.Text = sc.Status.ToString();82 lbJobdone.Text = sc.JobsDone.ToString();83 lbJobsAborted.Text = sc.JobsAborted.ToString();84 lbJobsFetched.Text = sc.JobsFetched.ToString();85 86 this.Text = "Client Console (" + sc.Status.ToString() + ")";87 lbStatus.Text = sc.Status.ToString();88 89 ListViewItem curJobStatusItem;90 91 if (sc.Jobs != null) {92 lvJobDetail.Items.Clear();93 double progress;94 foreach (JobStatus curJob in sc.Jobs) {95 curJobStatusItem = new ListViewItem(curJob.JobId.ToString());96 curJobStatusItem.SubItems.Add(curJob.Since.ToString());97 progress = curJob.Progress * 100;98 curJobStatusItem.SubItems.Add(progress.ToString());99 lvJobDetail.Items.Add(curJobStatusItem);100 }101 }102 103 UpdateGraph(zGJobs, sc.JobsDone, sc.JobsAborted);104 105 if (sc.Status == NetworkEnumWcfConnState.Connected) {106 btConnect.Enabled = false;107 btnDisconnect.Enabled = true;108 ConnectionContainer curConnection = cccc.GetCurrentConnection();109 tbIPAdress.Text = curConnection.IPAdress;110 tbPort.Text = curConnection.Port.ToString();111 } else if (sc.Status == NetworkEnumWcfConnState.Disconnected) {112 btConnect.Enabled = true;113 btnDisconnect.Enabled = false;114 } else if (sc.Status == NetworkEnumWcfConnState.Failed) {115 btConnect.Enabled = true;116 btnDisconnect.Enabled = false;117 }118 82 } 119 83 … … 121 85 try { 122 86 cccc = new ClientConsoleCommunicatorClient(); 87 cccc.GetStatusInfosCompleted += new EventHandler<GetStatusInfosCompletedEventArgs>(cccc_GetStatusInfosCompleted); 88 cccc.GetCurrentConnectionCompleted += new EventHandler<GetCurrentConnectionCompletedEventArgs>(cccc_GetCurrentConnectionCompleted); 123 89 } 124 90 catch (Exception) { … … 127 93 if (res == DialogResult.OK) 128 94 this.Close(); 95 } 96 } 97 98 void cccc_GetCurrentConnectionCompleted(object sender, GetCurrentConnectionCompletedEventArgs e) { 99 if (e.Error == null) { 100 ConnectionContainer curConnection = e.Result; 101 tbIPAdress.Text = curConnection.IPAdress; 102 tbPort.Text = curConnection.Port.ToString(); 103 } 104 } 105 106 void cccc_GetStatusInfosCompleted(object sender, GetStatusInfosCompletedEventArgs e) { 107 108 if (e.Error == null) { 109 StatusCommons sc = e.Result; 110 111 lbGuid.Text = sc.ClientGuid.ToString(); 112 lbCs.Text = sc.ConnectedSince.ToString(); 113 lbConnectionStatus.Text = sc.Status.ToString(); 114 lbJobdone.Text = sc.JobsDone.ToString(); 115 lbJobsAborted.Text = sc.JobsAborted.ToString(); 116 lbJobsFetched.Text = sc.JobsFetched.ToString(); 117 118 this.Text = "Client Console (" + sc.Status.ToString() + ")"; 119 lbStatus.Text = sc.Status.ToString(); 120 121 ListViewItem curJobStatusItem; 122 123 if (sc.Jobs != null) { 124 lvJobDetail.Items.Clear(); 125 double progress; 126 foreach (JobStatus curJob in sc.Jobs) { 127 curJobStatusItem = new ListViewItem(curJob.JobId.ToString()); 128 curJobStatusItem.SubItems.Add(curJob.Since.ToString()); 129 progress = curJob.Progress * 100; 130 curJobStatusItem.SubItems.Add(progress.ToString()); 131 lvJobDetail.Items.Add(curJobStatusItem); 132 } 133 lvJobDetail.Sort(); 134 } 135 136 UpdateGraph(zGJobs, sc.JobsDone, sc.JobsAborted); 137 138 if (sc.Status == NetworkEnumWcfConnState.Connected) { 139 btConnect.Enabled = false; 140 btnDisconnect.Enabled = true; 141 cccc.GetCurrentConnectionAsync(); 142 } else if (sc.Status == NetworkEnumWcfConnState.Disconnected) { 143 btConnect.Enabled = true; 144 btnDisconnect.Enabled = false; 145 } else if (sc.Status == NetworkEnumWcfConnState.Failed) { 146 btConnect.Enabled = true; 147 btnDisconnect.Enabled = false; 148 } 129 149 } 130 150 } … … 143 163 curEventLogEntry.SubItems.Add(eve.InstanceId.ToString()); 144 164 curEventLogEntry.SubItems.Add(eve.Message); 145 curEventLogEntry.SubItems.Add(eve.TimeGenerated.Date.ToString()); 146 curEventLogEntry.SubItems.Add(eve.TimeGenerated.TimeOfDay.ToString()); 165 curEventLogEntry.SubItems.Add(eve.TimeGenerated.ToString()); 147 166 lvLog.Items.Add(curEventLogEntry); 148 167 } 168 lvJobDetail.Sort(); 149 169 } 150 170 … … 162 182 if (ev.EntryType == EventLogEntryType.Error) 163 183 curEventLogEntry = new ListViewItem("", 1); 164 curEventLogEntry.SubItems.Add(ev. EventID.ToString());184 curEventLogEntry.SubItems.Add(ev.InstanceId.ToString()); 165 185 curEventLogEntry.SubItems.Add(ev.Message); 166 curEventLogEntry.SubItems.Add(ev.TimeGenerated.Date.ToString()); 167 curEventLogEntry.SubItems.Add(ev.TimeGenerated.TimeOfDay.ToString()); 186 curEventLogEntry.SubItems.Add(ev.TimeGenerated.ToString()); 168 187 lvLog.Items.Add(curEventLogEntry); 188 lvJobDetail.Sort(); 169 189 } 170 190 } … … 175 195 176 196 private void UpdateGraph(ZedGraphControl zgc, int jobsDone, int jobsAborted) { 177 zgc.GraphPane.GraphObjList.Clear();178 197 GraphPane myPane = zgc.GraphPane; 179 180 // Set the titles and axis labels 181 myPane.Legend.IsVisible = false; 182 myPane.Title.IsVisible = false; 198 myPane.GraphObjList.Clear(); 199 200 201 myPane.Title.IsVisible = false; // no title 202 myPane.Border.IsVisible = false; // no border 203 myPane.Chart.Border.IsVisible = false; // no border around the chart 204 myPane.XAxis.IsVisible = false; // no x-axis 205 myPane.YAxis.IsVisible = false; // no y-axis 206 myPane.Legend.IsVisible = false; // no legend 207 208 myPane.Chart.Fill.Type = FillType.None; 183 209 myPane.Fill.Type = FillType.None; 184 210 185 double sum = jobsDone + jobsAborted; 186 double perDone = jobsDone / sum * 100; 187 double perAborted = jobsAborted / sum * 100; 188 189 myPane.AddPieSlice(perAborted, Color.Red, 0, "Jobs aborted"); 211 //// Set the titles and axis labels 212 //myPane.Legend.IsVisible = false; 213 //myPane.Title.IsVisible = false; 214 ////myPane.Fill.Type = FillType.None; 215 ////myPane.Fill = new Fill(); 216 ////myPane.Fill.Color = Color.Transparent; 217 218 double sum = (double)jobsDone + jobsAborted; 219 double perDone = (double)jobsDone / sum * 100; 220 double perAborted = (double)jobsAborted / sum * 100; 221 190 222 myPane.AddPieSlice(perDone, Color.Green, 0.1, "Jobs done"); 223 myPane.AddPieSlice(perAborted, Color.Red, 0.1, "Jobs aborted"); 224 191 225 myPane.AxisChange(); 192 226 } … … 198 232 private void lvLog_DoubleClick(object sender, EventArgs e) { 199 233 ListViewItem lvi = lvLog.SelectedItems[0]; 200 HiveEventEntry hee = new HiveEventEntry(lvi.SubItems[2].Text, lvi.SubItems[3].Text, lvi.SubItems[ 4].Text, lvi.SubItems[1].Text);234 HiveEventEntry hee = new HiveEventEntry(lvi.SubItems[2].Text, lvi.SubItems[3].Text, lvi.SubItems[1].Text); 201 235 202 236 Form EventlogDetails = new EventLogEntryForm(hee); … … 222 256 cccc.Disconnect(); 223 257 } 258 259 private void lvLog_ColumnClick(object sender, ColumnClickEventArgs e) { 260 // Determine if clicked column is already the column that is being sorted. 261 if (e.Column == lvwColumnSorter.SortColumn) { 262 // Reverse the current sort direction for this column. 263 if (lvwColumnSorter.Order == SortOrder.Ascending) { 264 lvwColumnSorter.Order = SortOrder.Descending; 265 } else { 266 lvwColumnSorter.Order = SortOrder.Ascending; 267 } 268 } else { 269 // Set the column number that is to be sorted; default to ascending. 270 lvwColumnSorter.SortColumn = e.Column; 271 lvwColumnSorter.Order = SortOrder.Ascending; 272 } 273 274 // Perform the sort with these new sort options. 275 lvLog.Sort(); 276 } 224 277 } 225 278 }
Note: See TracChangeset
for help on using the changeset viewer.