Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1027


Ignore:
Timestamp:
12/18/08 14:55:53 (15 years ago)
Author:
whackl
Message:

refactor client console (#397)

File:
1 edited

Legend:

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

    r1016 r1027  
    3737namespace HeuristicLab.Hive.Client.Console {
    3838
     39  #region Delegates
     40
    3941  delegate void UpdateTextDelegate(EventLogEntry ev);
    4042
     43  #endregion
     44
    4145  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";
    4251
    4352    private EventLog HiveClientEventLog;
     
    4655    private ListViewColumnSorterDate lvwColumnSorter;
    4756
     57    #endregion
     58
     59    #region Constructor
    4860
    4961    public HiveClientConsole() {
     
    5971    }
    6072
     73    #endregion
     74
     75    #region Methods
     76
    6177    private void InitTimer() {
    6278      refreshTimer = new System.Windows.Forms.Timer();
     
    6682    }
    6783
    68     void refreshTimer_Tick(object sender, EventArgs e) {
    69       RefreshGui();
    70     }
    71    
    7284    private void RefreshGui() {
    7385      try {
     
    8496    private void ConnectToClient() {
    8597      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));
    8799        cccc.GetStatusInfosCompleted += new EventHandler<GetStatusInfosCompletedEventArgs>(cccc_GetStatusInfosCompleted);
    88100        cccc.GetCurrentConnectionCompleted += new EventHandler<GetCurrentConnectionCompletedEventArgs>(cccc_GetCurrentConnectionCompleted);
     
    96108    }
    97109
    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) {
    99177      if (e.Error == null) {
    100178        ConnectionContainer curConnection = e.Result;
     
    104182    }
    105183
    106     void cccc_GetStatusInfosCompleted(object sender, GetStatusInfosCompletedEventArgs e) {
     184    private void cccc_GetStatusInfosCompleted(object sender, GetStatusInfosCompletedEventArgs e) {
    107185
    108186      if (e.Error == null) {
     
    152230    }
    153231
    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 
    173232    private void HiveClientConsole_Load(object sender, EventArgs e) {
    174       //SetSize();
     233      //nothing to do
    175234    }
    176235
     
    180239          UpdateTextDelegate(UpdateText), new object[] { ev });
    181240      } 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);
    189242        lvLog.Items.Add(curEventLogEntry);
    190243        lvJobDetail.Sort();
     
    196249    }
    197250
    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 title
    204       myPane.Border.IsVisible = false; // no border
    205       myPane.Chart.Border.IsVisible = false; // no border around the chart
    206       myPane.XAxis.IsVisible = false;  // no x-axis
    207       myPane.YAxis.IsVisible = false;  // no y-axis
    208       myPane.Legend.IsVisible = false; // no legend
    209 
    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 labels
    223       PieItem.Default.LabelType = PieLabelType.None;
    224      
    225       myPane.AxisChange();
    226 
    227       pbGraph.Image = zgc.GetImage();
    228     }
    229 
    230251    private void HiveClientConsole_Resize(object sender, EventArgs e) {
    231       //SetSize();
     252      //nothing to do
    232253    }
    233254
     
    235256      ListViewItem lvi = lvLog.SelectedItems[0];
    236257      HiveEventEntry hee = new HiveEventEntry(lvi.SubItems[2].Text, lvi.SubItems[3].Text, lvi.SubItems[1].Text);
    237      
     258
    238259      Form EventlogDetails = new EventLogEntryForm(hee);
    239260      EventlogDetails.Show();
     
    244265      int port;
    245266      ConnectionContainer cc = new ConnectionContainer();
    246       //IPAddress.TryParse(tbIPAdress.Text.ToString(), ipAdress);
    247267      if (IPAddress.TryParse(tbIPAdress.Text, out ipAdress) && int.TryParse(tbPort.Text, out port)) {
    248268        cc.IPAdress = tbIPAdress.Text;
     
    276296      lvLog.Sort();
    277297    }
     298
     299    #endregion
    278300  }
    279301}
Note: See TracChangeset for help on using the changeset viewer.