Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/13/08 17:06:15 (15 years ago)
Author:
aleitner
Message:

added reading logs into a ListBox in the Hive Client Console (#352)

Location:
trunk/sources/HeuristicLab.Hive.Client.Console
Files:
4 edited

Legend:

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

    r717 r752  
    5555      this.tbUuid = new System.Windows.Forms.TextBox();
    5656      this.lblUuid = new System.Windows.Forms.Label();
    57       this.rtbInfoClient = new System.Windows.Forms.RichTextBox();
    5857      this.gbManager = new System.Windows.Forms.GroupBox();
    5958      this.lblPort = new System.Windows.Forms.Label();
    6059      this.lblIp = new System.Windows.Forms.Label();
    6160      this.tbPort = new System.Windows.Forms.TextBox();
    62       this.tbIp = new IPAddressTextBox();
    6361      this.tabPage2 = new System.Windows.Forms.TabPage();
     62      this.lbEventLog = new System.Windows.Forms.ListBox();
     63      this.tbIp = new HeuristicLab.Hive.Client.Console.IPAddressTextBox();
    6464      this.msClientConsole.SuspendLayout();
    6565      this.tcClientConsole.SuspendLayout();
     
    107107      // tpConnection
    108108      //
     109      this.tpConnection.Controls.Add(this.lbEventLog);
    109110      this.tpConnection.Controls.Add(this.btnDisconnect);
    110111      this.tpConnection.Controls.Add(this.btnConnect);
    111112      this.tpConnection.Controls.Add(this.gbUser);
    112       this.tpConnection.Controls.Add(this.rtbInfoClient);
    113113      this.tpConnection.Controls.Add(this.gbManager);
    114114      this.tpConnection.Location = new System.Drawing.Point(4, 22);
     
    168168      this.lblUuid.TabIndex = 0;
    169169      this.lblUuid.Text = "UUID";
    170       //
    171       // rtbInfoClient
    172       //
    173       this.rtbInfoClient.Location = new System.Drawing.Point(18, 218);
    174       this.rtbInfoClient.Name = "rtbInfoClient";
    175       this.rtbInfoClient.Size = new System.Drawing.Size(387, 229);
    176       this.rtbInfoClient.TabIndex = 1;
    177       this.rtbInfoClient.Text = "";
    178170      //
    179171      // gbManager
     
    215207      this.tbPort.TabIndex = 1;
    216208      //
    217       // tbIp
    218       //
    219       this.tbIp.Location = new System.Drawing.Point(57, 19);
    220       this.tbIp.Name = "tbIp";
    221       this.tbIp.Size = new System.Drawing.Size(211, 20);
    222       this.tbIp.TabIndex = 0;
    223       //
    224209      // tabPage2
    225210      //
     
    231216      this.tabPage2.Text = "tabPage2";
    232217      this.tabPage2.UseVisualStyleBackColor = true;
     218      //
     219      // listBox1
     220      //
     221      this.lbEventLog.FormattingEnabled = true;
     222      this.lbEventLog.Location = new System.Drawing.Point(23, 226);
     223      this.lbEventLog.Name = "listBox1";
     224      this.lbEventLog.Size = new System.Drawing.Size(382, 212);
     225      this.lbEventLog.TabIndex = 5;
     226      //
     227      // tbIp
     228      //
     229      this.tbIp.Location = new System.Drawing.Point(57, 19);
     230      this.tbIp.Name = "tbIp";
     231      this.tbIp.Size = new System.Drawing.Size(211, 20);
     232      this.tbIp.TabIndex = 0;
    233233      //
    234234      // HiveClientConsole
     
    250250      this.gbManager.ResumeLayout(false);
    251251      this.gbManager.PerformLayout();
     252      //((System.ComponentModel.ISupportInitialize)(this.performanceCounter1)).EndInit();
    252253      this.ResumeLayout(false);
    253254      this.PerformLayout();
     
    262263    private System.Windows.Forms.TabPage tpConnection;
    263264    private System.Windows.Forms.TabPage tabPage2;
    264     private System.Windows.Forms.RichTextBox rtbInfoClient;
    265265    private System.Windows.Forms.GroupBox gbManager;
    266266    private System.Windows.Forms.TextBox tbPort;
    267     private IPAddressTextBox tbIp;
     267    private HeuristicLab.Hive.Client.Console.IPAddressTextBox tbIp;
    268268    private System.Windows.Forms.Label lblIp;
    269269    private System.Windows.Forms.GroupBox gbUser;
     
    274274    private System.Windows.Forms.TextBox tbUuid;
    275275    private System.Windows.Forms.ToolStripMenuItem tsmiExit;
     276    private System.Windows.Forms.ListBox lbEventLog;
    276277  }
    277278}
  • trunk/sources/HeuristicLab.Hive.Client.Console/HiveClientConsole.cs

    r717 r752  
    2828using System.Text;
    2929using System.Windows.Forms;
     30using System.Diagnostics;
     31using System.Threading;
    3032
    3133namespace HeuristicLab.Hive.Client.Console {
     34
     35  delegate void UpdateTextDelegate(EventLog ev);
     36
    3237  public partial class HiveClientConsole : Form {
     38
     39    int numEntries = 0;
     40
    3341    public HiveClientConsole() {
    3442      InitializeComponent();
     43      tbIp.Text = "010.020.053.006";
     44      EventLog ev = new EventLog("Hive Client");
     45      ev.Source = "Hive Client";
     46      string str = ev.Entries[ev.Entries.Count - 1].Message;
     47      foreach (System.Diagnostics.EventLogEntry entry in ev.Entries) {
     48        lbEventLog.Items.Add(entry.TimeWritten + " -> " + entry.Message);
     49      }
     50      lbEventLog.SelectedIndex = lbEventLog.Items.Count - 1;
     51      numEntries = ev.Entries.Count;
     52      ev.EntryWritten += new EntryWrittenEventHandler(OnEntryWritten);
     53      ev.EnableRaisingEvents = true;
     54    }
     55
     56    private void UpdateText(EventLog ev) {
     57      if (this.lbEventLog.InvokeRequired) {
     58        this.lbEventLog.Invoke(new
     59          UpdateTextDelegate(UpdateText), new object[] { ev });
     60      } else {
     61        string str = ev.Entries[numEntries].TimeWritten + " -> " + ev.Entries[numEntries].Message;
     62        numEntries++;
     63        lbEventLog.Items.Add(str);
     64        lbEventLog.SelectedIndex = lbEventLog.Items.Count - 1;
     65
     66      }
    3567    }
    3668
     
    4577      tbPort.Enabled = false;
    4678      tbUuid.Enabled = false;
    47       rtbInfoClient.Text += tbIp.Text;
     79      lbEventLog.Items.Add(tbIp.Text);
    4880    }
    4981
     
    5587      tbUuid.Enabled = true;
    5688    }
     89
     90    public void OnEntryWritten(object source, EntryWrittenEventArgs e) {
     91      UpdateText((EventLog)source);
     92    }
    5793  }
    5894}
  • trunk/sources/HeuristicLab.Hive.Client.Console/HiveClientConsole.resx

    r717 r752  
    121121    <value>17, 17</value>
    122122  </metadata>
     123  <metadata name="performanceCounter1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     124    <value>150, 17</value>
     125  </metadata>
    123126</root>
  • trunk/sources/HeuristicLab.Hive.Client.Console/IPAdressTextBox.cs

    r717 r752  
    4646    private System.ComponentModel.Container components = null;
    4747
    48     private IPNotation ipNotation = IPNotation.IPv4Decimal;
    49     private IPNotation newIPNotation = IPNotation.IPv4Decimal;
    50     private bool bOverwrite = true;
    51     private bool bPreventLeave = true;
     48    private IPNotation m_ipNotation = IPNotation.IPv4Decimal;
     49    private IPNotation m_newIPNotation = IPNotation.IPv4Decimal;
     50    private bool m_bOverwrite = true;
     51    private bool m_bPreventLeave = true;
    5252    private System.Windows.Forms.ErrorProvider error;
    53     private Regex regexValidNumbers = new Regex("[0-9]");
    54     private ArrayList arlDelimeter = new ArrayList(new char[] { '.' });
     53    private Regex m_regexValidNumbers = new Regex("[0-9]");
     54    private ArrayList m_arlDelimeter = new ArrayList(new char[] { '.' });
    5555
    5656
     
    218218      set {
    219219        try {
    220           if (IPAddressTextBox.ValidateIP(value, this.newIPNotation, this.arlDelimeter))
    221             base.Text = IPAddressTextBox.MakeValidSpaces(value, this.newIPNotation, this.arlDelimeter);
     220          if (IPAddressTextBox.ValidateIP(value, this.m_newIPNotation, this.m_arlDelimeter))
     221            base.Text = IPAddressTextBox.MakeValidSpaces(value, this.m_newIPNotation, this.m_arlDelimeter);
    222222        }
    223223        catch {
     
    237237    public bool OverWriteMode {
    238238      get {
    239         return this.bOverwrite;
     239        return this.m_bOverwrite;
    240240      }
    241241      set {
    242         if (value != this.bOverwrite) {
    243           this.bOverwrite = value;
     242        if (value != this.m_bOverwrite) {
     243          this.m_bOverwrite = value;
    244244          this.OnOverWriteChanged(value);
    245245        }
     
    257257    public bool PreventLeaveAtError {
    258258      get {
    259         return this.bPreventLeave;
     259        return this.m_bPreventLeave;
    260260      }
    261261      set {
    262         if (value != this.bPreventLeave) {
    263           this.bPreventLeave = value;
     262        if (value != this.m_bPreventLeave) {
     263          this.m_bPreventLeave = value;
    264264          this.OnPreventLeaveChanged(value);
    265265        }
     
    277277    public IPNotation Notation {
    278278      get {
    279         return this.ipNotation;
     279        return this.m_ipNotation;
    280280      }
    281281      set {
    282         if (value != this.ipNotation) {
     282        if (value != this.m_ipNotation) {
    283283          try {
    284             this.newIPNotation = value;
    285             this.ChangeNotation(this.ipNotation, this.newIPNotation);
    286             this.ipNotation = this.newIPNotation;
    287             this.OnNotationChanged(this.newIPNotation);
     284            this.m_newIPNotation = value;
     285            this.ChangeNotation(this.m_ipNotation, this.m_newIPNotation);
     286            this.m_ipNotation = this.m_newIPNotation;
     287            this.OnNotationChanged(this.m_newIPNotation);
    288288          }
    289289          catch (Exception LastError) {
     
    346346    private void ChangeNotation(IPNotation arg_oldValue, IPNotation arg_newValue) {
    347347      string sTo = "";
    348       ArrayList arlFrom = new ArrayList(this.Text.Replace(" ", "").Split((char[])this.arlDelimeter.ToArray(typeof(char))));
     348      ArrayList arlFrom = new ArrayList(this.Text.Replace(" ", "").Split((char[])this.m_arlDelimeter.ToArray(typeof(char))));
    349349
    350350      switch (arg_newValue) {
    351351        case IPNotation.IPv4Decimal:
    352           this.regexValidNumbers = new Regex("[0-9]");
    353           this.arlDelimeter = new ArrayList(new char[] { '.' });
     352          this.m_regexValidNumbers = new Regex("[0-9]");
     353          this.m_arlDelimeter = new ArrayList(new char[] { '.' });
    354354          break;
    355355        case IPNotation.IPv4DecimalCIDR:
    356           this.regexValidNumbers = new Regex("[0-9]");
    357           this.arlDelimeter = new ArrayList(new char[] { '.', '/' });
     356          this.m_regexValidNumbers = new Regex("[0-9]");
     357          this.m_arlDelimeter = new ArrayList(new char[] { '.', '/' });
    358358          break;
    359359        case IPNotation.IPv4Binary:
    360           this.regexValidNumbers = new Regex("[01]");
    361           this.arlDelimeter = new ArrayList(new char[] { '.' });
     360          this.m_regexValidNumbers = new Regex("[01]");
     361          this.m_arlDelimeter = new ArrayList(new char[] { '.' });
    362362          break;
    363363        case IPNotation.IPv4BinaryCIDR:
    364           this.regexValidNumbers = new Regex("[01]");
    365           this.arlDelimeter = new ArrayList(new char[] { '.', '/' });
     364          this.m_regexValidNumbers = new Regex("[01]");
     365          this.m_arlDelimeter = new ArrayList(new char[] { '.', '/' });
    366366          break;
    367367        default:
     
    502502          }
    503503          break;
    504 
     504        default:
     505          break;
    505506      }
    506507
     
    544545        if ((char.IsLetterOrDigit(Convert.ToChar(e.KeyValue)) || e.KeyCode == Keys.NumPad0)//Numpad0=96 --> `
    545546          && iPos < this.TextLength) {
    546           if (this.arlDelimeter.Contains(cText[iPos]))
     547          if (this.m_arlDelimeter.Contains(cText[iPos]))
    547548            iPos += 1;
    548549          this.SelectionStart = iPos;
     
    573574      if ((char.IsLetterOrDigit(Convert.ToChar(e.KeyValue)) || e.KeyCode == Keys.NumPad0)//Numpad0=96 --> `
    574575        && iPos < this.TextLength) {
    575         if (this.arlDelimeter.Contains(cText[iPos]))
     576        if (this.m_arlDelimeter.Contains(cText[iPos]))
    576577          iPos += 1;
    577578
     
    590591      //valid input charachters
    591592      if (char.IsControl(e.KeyChar) ||
    592         regexValidNumbers.IsMatch(e.KeyChar.ToString())) {
     593        m_regexValidNumbers.IsMatch(e.KeyChar.ToString())) {
    593594        e.Handled = false;
    594595      } else {
     
    637638    protected override void OnValidating(CancelEventArgs e) {
    638639      //e.Cancel = true;//suppress cancel-signal = not validated
    639       e.Cancel = (!this.ValidateIP() && this.bPreventLeave);
     640      e.Cancel = (!this.ValidateIP() && this.m_bPreventLeave);
    640641      base.OnValidating(e);
    641642    }
     
    729730    public string GetPureIPAddress() {
    730731      string s = "";
    731       ArrayList arlIP = new ArrayList(this.Text.Replace(" ", "").Split((char[])this.arlDelimeter.ToArray(typeof(char))));
     732      ArrayList arlIP = new ArrayList(this.Text.Replace(" ", "").Split((char[])this.m_arlDelimeter.ToArray(typeof(char))));
    732733      for (int i = 0; i < arlIP.Count; i++) {
    733734        while (arlIP[i].ToString().StartsWith("0"))
    734735          arlIP[i] = arlIP[i].ToString().Substring(1);
    735736      }
    736       s = IPAddressTextBox.MakeIP((string[])arlIP.ToArray(typeof(string)), this.ipNotation);
     737      s = IPAddressTextBox.MakeIP((string[])arlIP.ToArray(typeof(string)), this.m_ipNotation);
    737738      return s;
    738739    }
     
    923924    /// <returns>true/false valid/not</returns>
    924925    private bool ValidateIP() {
    925       if (IPAddressTextBox.ValidateIP(this.Text, this.newIPNotation, this.arlDelimeter))
     926      if (IPAddressTextBox.ValidateIP(this.Text, this.m_newIPNotation, this.m_arlDelimeter))
    926927        return true;
    927928      else
Note: See TracChangeset for help on using the changeset viewer.