1 #region License Information
3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
5 * This file is part of HeuristicLab.
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
24 using HeuristicLab
.Common
;
25 using HeuristicLab
.MainForm
;
27 namespace HeuristicLab
.Core
.Views
{
29 /// Base class for editors of engines.
32 [Content(typeof(Log
), true)]
33 [Content(typeof(ILog
), false)]
34 public partial class LogView
: ItemView
{
36 /// Gets or sets the current engine.
38 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="EditorBase"/>.</remarks>
39 public new ILog Content
{
40 get { return (ILog)base.Content; }
41 set { base.Content = value; }
45 /// Initializes a new instance of <see cref="EngineBaseEditor"/>.
48 InitializeComponent();
52 /// Removes the event handlers from the underlying <see cref="IEngine"/>.
54 /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
55 protected override void DeregisterContentEvents() {
56 Content
.Cleared
-= new EventHandler(Content_Cleared
);
57 Content
.MessageAdded
-= new EventHandler
<EventArgs
<string>>(Content_MessageAdded
);
58 base.DeregisterContentEvents();
62 /// Adds event handlers to the underlying <see cref="IEngine"/>.
64 /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
65 protected override void RegisterContentEvents() {
66 base.RegisterContentEvents();
67 Content
.Cleared
+= new EventHandler(Content_Cleared
);
68 Content
.MessageAdded
+= new EventHandler
<EventArgs
<string>>(Content_MessageAdded
);
72 /// Updates all controls with the latest data of the model.
74 /// <remarks>Calls <see cref="EditorBase.UpdateControls"/> of base class <see cref="EditorBase"/>.</remarks>
75 protected override void OnContentChanged() {
76 base.OnContentChanged();
78 if (Content
== null) {
79 logTextBox
.Enabled
= false;
81 logTextBox
.Enabled
= true;
82 if (Content
.Messages
.FirstOrDefault() != null)
83 logTextBox
.Text
= string.Join(Environment
.NewLine
, Content
.Messages
.ToArray());
87 protected virtual void Content_MessageAdded(object sender
, EventArgs
<string> e
) {
89 Invoke(new EventHandler
<EventArgs
<string>>(Content_MessageAdded
), sender
, e
);
91 logTextBox
.Text
= string.Join(Environment
.NewLine
, Content
.Messages
.ToArray());
92 logTextBox
.SelectionStart
= logTextBox
.Text
.Length
;
93 logTextBox
.ScrollToCaret();
97 protected virtual void Content_Cleared(object sender
, EventArgs e
) {
99 Invoke(new EventHandler(Content_Cleared
), sender
, e
);
104 protected virtual void clearButton_Click(object sender
, EventArgs e
) {