Changeset 4871 for branches/HeuristicLab.DebugEngine/DebugEngineView.cs
- Timestamp:
- 11/20/10 14:13:32 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DebugEngine/DebugEngineView.cs
r4765 r4871 30 30 using HeuristicLab.Persistence.Auxiliary; 31 31 namespace HeuristicLab.DebugEngine { 32 32 33 /// <summary> 33 /// Base class for editors of engines.34 /// Engine espcially for debugging 34 35 /// </summary> 35 36 [View("DebugEngine View")] 36 37 [Content(typeof(DebugEngine), true)] 37 38 public partial class DebugEngineView : ItemView { 39 40 #region Basics 41 38 42 /// <summary> 39 43 /// Gets or sets the current engine. … … 46 50 47 51 /// <summary> 48 /// Initializes a new instance of <see cref=" EngineBaseEditor"/>.52 /// Initializes a new instance of <see cref="DebugEngineView"/>. 49 53 /// </summary> 50 54 public DebugEngineView() { … … 60 64 /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks> 61 65 protected override void DeregisterContentEvents() { 66 Content.CurrentOperationChanged -= new EventHandler<OperationChangedEventArgs>(Content_CurrentOperationChanged); 62 67 Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged); 63 68 Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged); … … 73 78 Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged); 74 79 Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged); 80 Content.CurrentOperationChanged += new EventHandler<OperationChangedEventArgs>(Content_CurrentOperationChanged); 75 81 } 76 82 … … 84 90 logView.Content = null; 85 91 executionTimeTextBox.Text = "-"; 92 executionStackView.Content = null; 86 93 } else { 87 94 logView.Content = Content.Log; 88 95 executionTimeTextBox.Text = Content.ExecutionTime.ToString(); 96 executionStackView.Content = Content.ExecutionStack; 89 97 } 90 98 } … … 101 109 } 102 110 111 #endregion 112 103 113 protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) { 104 114 if (InvokeRequired) … … 109 119 110 120 void Content_ExecutionStateChanged(object sender, EventArgs e) { 111 switch (Content.ExecutionState) { 112 case ExecutionState.Paused: 113 case ExecutionState.Stopped: 114 case ExecutionState.Prepared: 115 UpdateView(); break; 116 } 117 } 118 119 protected virtual void UpdateView() { 120 if (InvokeRequired) { 121 Invoke(new Action(UpdateView)); 122 } else { 123 UpdateExecutionStack(); 121 if (InvokeRequired) 122 Invoke(new EventHandler(Content_ExecutionStateChanged), sender, e); 123 else { 124 switch (Content.ExecutionState) { 125 case ExecutionState.Started: executionStackView.SuspendUpdate(); break; 126 default: executionStackView.ResumeUpdate(); break; 127 } 128 } 129 } 130 131 #region Current Operation 132 133 void Content_CurrentOperationChanged(object sender, OperationChangedEventArgs e) { 134 if (InvokeRequired) 135 Invoke(new EventHandler<OperationChangedEventArgs>(Content_CurrentOperationChanged), sender, e); 136 else 124 137 SetOperation(Content.CurrentOperation); 125 }126 138 } 127 139 … … 133 145 if (atomicOperation != null && atomicOperation.Operator != null) { 134 146 operationTextBox.Text = string.Format("Atomic {0}", atomicOperation.Operator.Name); 135 toolTip.SetToolTip(operationTextBox, TypeName(atomicOperation.Operator));147 toolTip.SetToolTip(operationTextBox, Utils.TypeName(atomicOperation.Operator)); 136 148 } 137 149 OperationCollection operationCollection = operation as OperationCollection; … … 152 164 } 153 165 154 private void UpdateExecutionStack() {155 executionStackTreeView.BeginUpdate();156 executionStackTreeView.Nodes.Clear();157 AddOperations(executionStackTreeView.Nodes, Content.ExecutionStack.ToArray());158 executionStackTreeView.ExpandAll();159 if (executionStackTreeView.Nodes.Count > 0)160 executionStackTreeView.TopNode = executionStackTreeView.Nodes[0];161 executionStackTreeView.EndUpdate();162 }163 164 166 private void UpdateScope(IScope scope) { 165 167 scopeTreeView.BeginUpdate(); … … 174 176 } 175 177 176 private string TypeName(object obj) { 177 if (obj == null) 178 return "null"; 179 return TypeNameParser.Parse(obj.GetType().ToString()).GetTypeNameInCode(true); 180 } 181 182 private void AddOperations(TreeNodeCollection nodes, IEnumerable<IOperation> operations) { 183 foreach (IOperation op in operations) { 184 if (op is IAtomicOperation) { 185 IAtomicOperation atom = op as IAtomicOperation; 186 TreeNode node = nodes.Add(atom.Operator.Name); 187 node.Tag = atom; 188 node.ToolTipText = TypeName(atom); 189 node.ImageKey = "AtomicOperation"; 190 if (atom.Operator.Breakpoint) 191 node.ForeColor = Color.Red; 192 foreach (var param in atom.Operator.Parameters) { 193 string typeName = "null"; 194 TreeNode paramNode = node.Nodes.Add(string.Format("Param {0} = {1}", param.Name, GetApproximateValue(param, ref typeName))); 195 paramNode.Tag = param; 196 paramNode.ToolTipText = string.Format("{0} = {1}", TypeName(param), typeName); 197 paramNode.ImageKey = "Parameter"; 198 } 199 } else if (op is OperationCollection) { 200 OperationCollection ops = op as OperationCollection; 201 TreeNode node = executionStackTreeView.Nodes.Add(string.Format("{0} Operations", ops.Count)); 202 node.Tag = op; 203 node.ToolTipText = TypeName(ops); 204 node.ImageKey = "OperationCollection"; 205 AddOperations(node.Nodes, ops); 206 } 207 } 208 } 209 178 179 180 /* 210 181 private string GetApproximateValue(IParameter param, ref string typeName) { 211 182 string valueString = "<none>"; … … 229 200 return valueString; 230 201 } 202 */ 231 203 232 204 private void AddScope(TreeNodeCollection nodes, IScope scope) { 233 205 TreeNode node = nodes.Add(scope.Name); 234 if (Content.Current Operation != null && Content.CurrentOperation.Scope == scope) {206 if (Content.CurrentAtomicOperation != null && Content.CurrentAtomicOperation.Scope == scope) { 235 207 node.ForeColor = Color.Red; 236 208 node.BackColor = Color.LightGray; … … 239 211 TreeNode varNode = node.Nodes.Add(string.Format("{0}={1}", var.Name, var.Value.ToString())); 240 212 varNode.Tag = var.Value; 241 varNode.ToolTipText = TypeName(var.Value);213 varNode.ToolTipText = Utils.TypeName(var.Value); 242 214 } 243 215 foreach (var subScope in scope.SubScopes) { 244 216 AddScope(node.Nodes, subScope); 217 } 218 } 219 220 #endregion 221 222 protected virtual void UpdateView() { 223 if (InvokeRequired) { 224 Invoke(new Action(UpdateView)); 225 } else { 226 SetOperation(Content.CurrentOperation); 245 227 } 246 228 } … … 249 231 Content.Step(); 250 232 UpdateView(); 251 }252 253 private void executionStackTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) {254 if (e.Node != null) {255 IAtomicOperation op = e.Node.Tag as IAtomicOperation;256 if (op != null) {257 op.Operator.Breakpoint = !op.Operator.Breakpoint;258 if (op.Operator.Breakpoint) {259 e.Node.ForeColor = Color.Red;260 } else {261 e.Node.ForeColor = Color.Black;262 }263 executionStackTreeView.SelectedNode = null;264 }265 IParameter param = e.Node.Tag as IParameter;266 if (param != null)267 MainFormManager.MainForm.ShowContent(param);268 }269 233 } 270 234
Note: See TracChangeset
for help on using the changeset viewer.