Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/09/10 01:15:16 (14 years ago)
Author:
swagner
Message:

Implemented logs of engines (#963).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/EngineView.cs

    r3262 r3289  
    2121
    2222using System;
    23 using HeuristicLab.Common;
    2423using HeuristicLab.MainForm;
    2524
     
    5756    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    5857    protected override void DeregisterContentEvents() {
    59       Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
    6058      Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
    61       Content.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    6259      base.DeregisterContentEvents();
    6360    }
     
    6966    protected override void RegisterContentEvents() {
    7067      base.RegisterContentEvents();
    71       Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
    7268      Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
    73       Content.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    7469    }
    7570
     
    8075    protected override void OnContentChanged() {
    8176      base.OnContentChanged();
    82       logTextBox.Clear();
    8377      if (Content == null) {
    84         logTextBox.Enabled = false;
     78        logView.Content = null;
     79        logView.Enabled = false;
    8580        executionTimeTextBox.Text = "-";
    8681        executionTimeTextBox.Enabled = false;
    8782      } else {
    88         logTextBox.Enabled = true;
     83        logView.Content = Content.Log;
     84        logView.Enabled = true;
    8985        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    9086        executionTimeTextBox.Enabled = true;
     
    9288    }
    9389
    94     #region Content Events
    95     protected virtual void Content_ExecutionStateChanged(object sender, EventArgs e) {
    96       if (InvokeRequired)
    97         Invoke(new EventHandler(Content_ExecutionStateChanged), sender, e);
    98       else {
    99         if (Content.ExecutionState == ExecutionState.Prepared) Log("Engine prepared");
    100         else if (Content.ExecutionState == ExecutionState.Started) Log("Engine started");
    101         else if (Content.ExecutionState == ExecutionState.Paused) Log("Engine paused");
    102         else if (Content.ExecutionState == ExecutionState.Stopped) Log("Engine stopped");
    103       }
    104     }
    10590    protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) {
    10691      if (InvokeRequired)
     
    10994        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    11095    }
    111     protected virtual void Content_ExceptionOccurred(object sender, EventArgs<Exception> e) {
    112       if (InvokeRequired)
    113         Invoke(new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred), sender, e);
    114       else
    115         Log(Auxiliary.BuildErrorMessage(e.Value));
    116     }
    117     #endregion
    118 
    119     #region Helpers
    120     protected virtual void Log(string message) {
    121       if (InvokeRequired)
    122         Invoke(new Action<string>(Log), message);
    123       else {
    124         message = DateTime.Now.ToString() + "\t" + message;
    125         string[] newLines = message.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
    126         string[] lines = new string[logTextBox.Lines.Length + newLines.Length];
    127         logTextBox.Lines.CopyTo(lines, 0);
    128         newLines.CopyTo(lines, logTextBox.Lines.Length);
    129         logTextBox.Lines = lines;
    130       }
    131     }
    132     #endregion
    13396  }
    13497}
Note: See TracChangeset for help on using the changeset viewer.