Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/29/10 17:15:24 (14 years ago)
Author:
epitzer
Message:

Create own class for OperatorTrace, remove unnecessary event handlers, prevent flickering while stepping, permanently highlight execution context's scope (#47)

Location:
branches/HeuristicLab.DebugEngine
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DebugEngine/DebugEngine.cs

    r4947 r4993  
    6060      Log = new Log();
    6161      ExecutionStack = new ExecutionStack();
    62       OperatorTrace = new ItemList<IOperator>();
     62      OperatorTrace = new OperatorTrace();
    6363      operatorParents = new Dictionary<IAtomicOperation, IAtomicOperation>();
    6464      pausePending = stopPending = false;
     
    8585    [Storable]
    8686    public ExecutionStack ExecutionStack { get; protected set; }
     87
     88    [Storable]
     89    public OperatorTrace OperatorTrace { get; private set; }
    8790
    8891    private bool pausePending, stopPending;
     
    113116    }
    114117
    115     [Storable]
    116     public ItemList<IOperator> OperatorTrace { get; private set; }
    117118
    118119    [Storable]
     
    293294        }
    294295        trace.Reverse();
    295         OperatorTrace.Clear();
    296         OperatorTrace.AddRange(trace);
     296        OperatorTrace.ReplaceAll(trace);
    297297      }
    298298    }
  • branches/HeuristicLab.DebugEngine/DebugEngineView.cs

    r4947 r4993  
    5757    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    5858    protected override void DeregisterContentEvents() {
    59       Content.CurrentOperationChanged -= new EventHandler<OperationChangedEventArgs>(Content_CurrentOperationChanged);
    6059      Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
    6160      base.DeregisterContentEvents();
     
    6968      base.RegisterContentEvents();
    7069      Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
    71       Content.CurrentOperationChanged += new EventHandler<OperationChangedEventArgs>(Content_CurrentOperationChanged);
    7270    }
    7371
     
    106104        Invoke(new EventHandler(Content_ExecutionStateChanged), sender, e);
    107105      } else {
     106        SetEnabledStateOfControls();
    108107        switch (Content.ExecutionState) {
    109108          case ExecutionState.Started:
    110             executionStackView.SuspendUpdate();
    111             operatorTraceView.SuspendUpdate();
     109            if (!stepping) {
     110              executionStackView.Content = null;
     111              operatorTraceView.Content = null;
     112              operationContentView.Content = null;
     113            }
    112114            break;
    113115          default:
    114             executionStackView.ResumeUpdate();
     116            executionStackView.Content = Content.ExecutionStack;
     117            operatorTraceView.Content = Content.OperatorTrace;
    115118            operationContentView.Content = new OperationContent(Content.CurrentOperation);
    116             operatorTraceView.ResumeUpdate();
    117119            break;
    118120        }
    119         SetEnabledStateOfControls();
    120121      }
    121122    }
    122123
    123     void Content_CurrentOperationChanged(object sender, OperationChangedEventArgs e) {
    124       if (InvokeRequired) {
    125         Invoke(new EventHandler<OperationChangedEventArgs>(Content_CurrentOperationChanged), sender, e);
    126       } else {
    127 
    128       }
    129     }
    130 
     124    private bool stepping = false;
    131125    private void stepButton_Click(object sender, EventArgs e) {
     126      stepping = true;
    132127      Content.Step(skipStackOpsCheckBox.Checked);
     128      stepping = false;
    133129    }
    134130
  • branches/HeuristicLab.DebugEngine/ExecutionStack.cs

    r4871 r4993  
    1 using System;
    2 using System.Collections.Generic;
     1using System.Collections.Generic;
    32using System.Linq;
    4 using System.Text;
    53using HeuristicLab.Collections;
    64using HeuristicLab.Common;
     
    108namespace HeuristicLab.DebugEngine {
    119
     10  [StorableClass]
    1211  public class ExecutionStack : ObservableList<IOperation>, IContent, IDeepCloneable {
    1312
  • branches/HeuristicLab.DebugEngine/HeuristicLab.DebugEngine.csproj

    r4909 r4993  
    121121  </ItemGroup>
    122122  <ItemGroup>
     123    <Compile Include="OperatorTrace.cs" />
    123124    <Compile Include="DebugEngine.cs" />
    124125    <Compile Include="DebugEngineView.cs">
  • branches/HeuristicLab.DebugEngine/OperationContentView.Designer.cs

    r4909 r4993  
    3030      this.executionContextGroupBox = new System.Windows.Forms.GroupBox();
    3131      this.executionContextTreeView = new System.Windows.Forms.TreeView();
     32      this.executionContextImageList = new System.Windows.Forms.ImageList(this.components);
    3233      this.parametersGroupBox = new System.Windows.Forms.GroupBox();
    3334      this.parameterListView = new System.Windows.Forms.ListView();
     35      this.parameterColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
     36      this.parametersImageList = new System.Windows.Forms.ImageList(this.components);
    3437      this.scopeGroupBox = new System.Windows.Forms.GroupBox();
    3538      this.scopeTreeView = new System.Windows.Forms.TreeView();
     39      this.scopeImageList = new System.Windows.Forms.ImageList(this.components);
    3640      this.nameTextBox = new System.Windows.Forms.TextBox();
    3741      this.contextLabel = new System.Windows.Forms.Label();
    3842      this.atomicLabel = new System.Windows.Forms.Label();
    3943      this.collectionLabel = new System.Windows.Forms.Label();
    40       this.timer = new System.Windows.Forms.Timer(this.components);
    41       this.executionContextImageList = new System.Windows.Forms.ImageList(this.components);
    42       this.parametersImageList = new System.Windows.Forms.ImageList(this.components);
    43       this.scopeImageList = new System.Windows.Forms.ImageList(this.components);
    44       this.parameterColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
    4544      this.groupBox.SuspendLayout();
    4645      this.splitContainer1.Panel1.SuspendLayout();
     
    131130      this.executionContextTreeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.executionContextTreeView_NodeMouseClick);
    132131      this.executionContextTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.executionContextTreeView_NodeMouseDoubleClick);
     132      //
     133      // executionContextImageList
     134      //
     135      this.executionContextImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
     136      this.executionContextImageList.ImageSize = new System.Drawing.Size(16, 16);
     137      this.executionContextImageList.TransparentColor = System.Drawing.Color.Transparent;
    133138      //
    134139      // parametersGroupBox
     
    160165      this.parameterListView.ItemActivate += new System.EventHandler(this.parameterListView_ItemActivate);
    161166      //
     167      // parametersImageList
     168      //
     169      this.parametersImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
     170      this.parametersImageList.ImageSize = new System.Drawing.Size(16, 16);
     171      this.parametersImageList.TransparentColor = System.Drawing.Color.Transparent;
     172      //
    162173      // scopeGroupBox
    163174      //
     
    184195      this.scopeTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.scopeTreeView_NodeMouseDoubleClick);
    185196      //
     197      // scopeImageList
     198      //
     199      this.scopeImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
     200      this.scopeImageList.ImageSize = new System.Drawing.Size(16, 16);
     201      this.scopeImageList.TransparentColor = System.Drawing.Color.Transparent;
     202      //
    186203      // nameTextBox
    187204      //
     
    228245      this.collectionLabel.TabIndex = 0;
    229246      this.collectionLabel.Text = "Collection";
    230       //
    231       // timer
    232       //
    233       this.timer.Interval = 500;
    234       this.timer.Tick += new System.EventHandler(this.timer_Tick);
    235       //
    236       // executionContextImageList
    237       //
    238       this.executionContextImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
    239       this.executionContextImageList.ImageSize = new System.Drawing.Size(16, 16);
    240       this.executionContextImageList.TransparentColor = System.Drawing.Color.Transparent;
    241       //
    242       // parametersImageList
    243       //
    244       this.parametersImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
    245       this.parametersImageList.ImageSize = new System.Drawing.Size(16, 16);
    246       this.parametersImageList.TransparentColor = System.Drawing.Color.Transparent;
    247       //
    248       // scopeImageList
    249       //
    250       this.scopeImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
    251       this.scopeImageList.ImageSize = new System.Drawing.Size(16, 16);
    252       this.scopeImageList.TransparentColor = System.Drawing.Color.Transparent;
    253247      //
    254248      // OperationContentView
     
    289283    private System.Windows.Forms.GroupBox parametersGroupBox;
    290284    private System.Windows.Forms.GroupBox scopeGroupBox;
    291     private System.Windows.Forms.Timer timer;
    292285    private System.Windows.Forms.ImageList executionContextImageList;
    293286    private System.Windows.Forms.ImageList parametersImageList;
  • branches/HeuristicLab.DebugEngine/OperationContentView.cs

    r4931 r4993  
    11using System;
    2 using System.Collections.Generic;
    32using System.Drawing;
    43using System.Text;
     
    9089        while (scope != null && scope.Parent != null)
    9190          scope = scope.Parent;
    92         if (scope != null) {
     91        if (scope != null)
    9392          AddScope(scopeTreeView.Nodes, scope);
    94 
    95         }
    9693      }
    9794      scopeTreeView.EndUpdate();
     
    194191    }
    195192
     193    private TreeNode selectedScopeNode = null;
    196194    private void executionContextTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) {
     195      if (selectedScopeNode != null) {
     196        if (Content.IsAtomic && Content.AtomicOperation.Scope == selectedScopeNode.Tag) {
     197          selectedScopeNode.BackColor = Color.Crimson;
     198          selectedScopeNode.ForeColor = Color.White;
     199          selectedScopeNode.NodeFont = new Font(DefaultFont, FontStyle.Bold);
     200        } else {
     201          selectedScopeNode.BackColor = Color.White;
     202          selectedScopeNode.ForeColor = Color.Black;
     203          selectedScopeNode.NodeFont = DefaultFont;
     204        }
     205      }
    197206      if (e.Node != null) {
    198207        IExecutionContext context = e.Node.Tag as IExecutionContext;
     
    200209          TreeNode scopeNode = FindScopeNode(context.Scope, scopeTreeView.Nodes);
    201210          if (scopeNode != null) {
    202             if (timer.Enabled) {
    203               timer_Tick(this, EventArgs.Empty);
     211            if (Content.IsAtomic && Content.AtomicOperation.Scope == scopeNode.Tag) {
     212              scopeNode.BackColor = Color.DarkViolet;
     213              scopeNode.ForeColor = Color.White;
     214              scopeNode.NodeFont = new Font(DefaultFont, FontStyle.Bold);
     215            } else {
     216              scopeNode.BackColor = Color.Blue;
     217              scopeNode.ForeColor = Color.White;
     218              scopeNode.NodeFont = new Font(DefaultFont, FontStyle.Bold);
    204219            }
    205             timer.Tag = new KeyValuePair<TreeNode, TreeNode>(scopeNode, new TreeNode() {
    206               BackColor = scopeNode.BackColor,
    207               ForeColor = scopeNode.ForeColor,
    208               NodeFont = scopeNode.NodeFont,
    209             });
    210             scopeNode.BackColor = Color.Blue;
    211             scopeNode.ForeColor = Color.White;
    212             scopeNode.NodeFont = new Font(DefaultFont, FontStyle.Bold);
     220            selectedScopeNode = scopeNode;
    213221            scopeTreeView.TopNode = scopeNode;
    214             timer.Start();
    215222          }
    216223        }
    217       }
    218     }
    219 
    220     private void ResetNode(TreeNode node, TreeNode template) {
    221       if (InvokeRequired)
    222         Invoke(new Action<TreeNode, TreeNode>(ResetNode), node, template);
    223       else {
    224         node.ForeColor = template.ForeColor;
    225         node.BackColor = template.BackColor;
    226         node.NodeFont = template.NodeFont;
    227224      }
    228225    }
     
    241238    }
    242239
    243     private void timer_Tick(object sender, EventArgs e) {
    244       KeyValuePair<TreeNode, TreeNode> kvp = (KeyValuePair<TreeNode, TreeNode>)timer.Tag;
    245       ResetNode(kvp.Key, kvp.Value);
    246       timer.Stop();
    247     }
    248 
    249240    private void nameTextBox_DoubleClick(object sender, EventArgs e) {
    250241      if (Content != null && Content.IsAtomic && Content.AtomicOperation.Operator != null)
  • branches/HeuristicLab.DebugEngine/OperationContentView.resx

    r4909 r4993  
    127127    <value>461, 17</value>
    128128  </metadata>
    129   <metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    130     <value>17, 17</value>
    131   </metadata>
    132129</root>
  • branches/HeuristicLab.DebugEngine/OperatorTrace.cs

    r4986 r4993  
    1 using System;
    2 using System.Collections.Generic;
     1using System.Collections.Generic;
    32using System.Linq;
    4 using System.Text;
    53using HeuristicLab.Collections;
    64using HeuristicLab.Common;
     
    108namespace HeuristicLab.DebugEngine {
    119
    12   public class ExecutionStack : ObservableList<IOperation>, IContent, IDeepCloneable {
     10  [StorableClass]
     11  public class OperatorTrace : ObservableList<IOperator>, IContent, IDeepCloneable {
    1312
    14     public ExecutionStack() : base() { }
    15     public ExecutionStack(int capacity) : base(capacity) { }
    16     public ExecutionStack(IEnumerable<IOperation> collection) : base(collection) { }
     13    public OperatorTrace()
     14      : base() {
     15    }
     16    public OperatorTrace(int capacity)
     17      : base(capacity) {
     18    }
     19    public OperatorTrace(IEnumerable<IOperator> collection)
     20      : base(collection) {
     21    }
    1722
    1823    [StorableConstructor]
    19     protected ExecutionStack(bool deserializing) : base(deserializing) { }
    20     protected ExecutionStack(ExecutionStack original, Cloner cloner) {
     24    protected OperatorTrace(bool deserializing) : base(deserializing) { }
     25    protected OperatorTrace(OperatorTrace original, Cloner cloner) {
    2126      cloner.RegisterClonedObject(original, this);
    2227      AddRange(original.Select(op => cloner.Clone(op)));
     
    2631    }
    2732    public virtual IDeepCloneable Clone(Cloner cloner) {
    28       return new ExecutionStack(this, cloner);
     33      return new OperatorTrace(this, cloner);
    2934    }
     35    public virtual void ReplaceAll(IEnumerable<IOperator> operators) {
     36      var oldList = list;
     37      list = new List<IOperator>(operators);
     38      if (oldList.Count != list.Count)
     39        OnPropertyChanged("Count");
     40      OnPropertyChanged("Item[]");
     41      OnCollectionReset(
     42        list.Select((op, i) => new IndexedItem<IOperator>(i, op)),
     43        oldList.Select((op, i) => new IndexedItem<IOperator>(i, op)));
     44    }
     45
    3046  }
    3147}
  • branches/HeuristicLab.DebugEngine/OperatorTraceView.cs

    r4909 r4993  
    44using HeuristicLab.Common.Resources;
    55using HeuristicLab.Core;
    6 using HeuristicLab.Core.Views;
    76using HeuristicLab.MainForm;
     7using HeuristicLab.MainForm.WindowsForms;
    88using HeuristicLab.Operators;
    99
     
    1111
    1212  [View("Operator Trace View")]
    13   [Content(typeof(ItemList<IOperator>), IsDefaultView = true)]
    14   public sealed partial class OperatorTraceView : ItemView {
     13  [Content(typeof(OperatorTrace), IsDefaultView = true)]
     14  public sealed partial class OperatorTraceView : AsynchronousContentView {
    1515
    16     public new ItemList<IOperator> Content {
    17       get { return (ItemList<IOperator>)base.Content; }
     16    public new OperatorTrace Content {
     17      get { return (OperatorTrace)base.Content; }
    1818      set { base.Content = value; }
    1919    }
Note: See TracChangeset for help on using the changeset viewer.