Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/17/08 14:24:16 (15 years ago)
Author:
whackl
Message:

added new features (#397)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Client.Console/HiveClientConsole.cs

    r973 r1002  
    4141  public partial class HiveClientConsole : Form {
    4242
    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
    4648
    4749    public HiveClientConsole() {
    4850      InitializeComponent();
     51      lvwColumnSorter = new ListViewColumnSorterDate();
     52      lvLog.ListViewItemSorter = lvwColumnSorter;
     53      lvwColumnSorter.SortColumn = 3;
     54      lvwColumnSorter.Order = SortOrder.Descending;
    4955      InitTimer();
    5056      ConnectToClient();
     
    6571   
    6672    private void RefreshGui() {
    67       StatusCommons sc = new StatusCommons();
    68      
    6973      try {
    70         sc = cccc.GetStatusInfos();
     74        cccc.GetStatusInfosAsync();
    7175      }
    7276      catch (Exception ex) {
     
    7680          this.Close();
    7781      }
    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       }
    11882    }
    11983
     
    12185      try {
    12286        cccc = new ClientConsoleCommunicatorClient();
     87        cccc.GetStatusInfosCompleted += new EventHandler<GetStatusInfosCompletedEventArgs>(cccc_GetStatusInfosCompleted);
     88        cccc.GetCurrentConnectionCompleted += new EventHandler<GetCurrentConnectionCompletedEventArgs>(cccc_GetCurrentConnectionCompleted);
    12389      }
    12490      catch (Exception) {
     
    12793        if (res == DialogResult.OK)
    12894          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        }
    129149      }
    130150    }
     
    143163        curEventLogEntry.SubItems.Add(eve.InstanceId.ToString());
    144164        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());
    147166        lvLog.Items.Add(curEventLogEntry);
    148167      }
     168      lvJobDetail.Sort();
    149169    }
    150170
     
    162182        if (ev.EntryType == EventLogEntryType.Error)
    163183          curEventLogEntry = new ListViewItem("", 1);
    164         curEventLogEntry.SubItems.Add(ev.EventID.ToString());
     184        curEventLogEntry.SubItems.Add(ev.InstanceId.ToString());
    165185        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());
    168187        lvLog.Items.Add(curEventLogEntry);
     188        lvJobDetail.Sort();
    169189      }
    170190    }
     
    175195
    176196    private void UpdateGraph(ZedGraphControl zgc, int jobsDone, int jobsAborted) {
    177       zgc.GraphPane.GraphObjList.Clear();
    178197      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;
    183209      myPane.Fill.Type = FillType.None;
    184210
    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
    190222      myPane.AddPieSlice(perDone, Color.Green, 0.1, "Jobs done");
     223      myPane.AddPieSlice(perAborted, Color.Red, 0.1, "Jobs aborted");
     224     
    191225      myPane.AxisChange();
    192226    }
     
    198232    private void lvLog_DoubleClick(object sender, EventArgs e) {
    199233      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);
    201235     
    202236      Form EventlogDetails = new EventLogEntryForm(hee);
     
    222256      cccc.Disconnect();
    223257    }
     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    }
    224277  }
    225278}
Note: See TracChangeset for help on using the changeset viewer.