Changeset 4759 for branches/HeuristicLab.DebugEngine/DebugEngineView.cs
- Timestamp:
- 11/09/10 15:58:12 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DebugEngine/DebugEngineView.cs
r4753 r4759 24 24 using System.Drawing; 25 25 using System.Windows.Forms; 26 using HeuristicLab.Common.Resources; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Core.Views; … … 49 50 public DebugEngineView() { 50 51 InitializeComponent(); 52 updateButton.Image = VS2008ImageLibrary.Refresh; 53 stepButton.Image = VS2008ImageLibrary.MoveNext; 54 parentButton.Image = VS2008ImageLibrary.ArrowUp; 51 55 } 52 56 … … 117 121 Invoke(new Action(UpdateView)); 118 122 } else { 119 executionStackTreeView.BeginUpdate(); 120 executionStackTreeView.Nodes.Clear(); 121 AddOperations(executionStackTreeView.Nodes, Content.ExecutionStack.ToArray()); 122 executionStackTreeView.ExpandAll(); 123 if (executionStackTreeView.Nodes.Count > 0) 124 executionStackTreeView.TopNode = executionStackTreeView.Nodes[0]; 125 executionStackTreeView.EndUpdate(); 126 127 128 scopeTreeView.BeginUpdate(); 129 scopeTreeView.Nodes.Clear(); 130 if (Content.CurrentOperation != null) { 131 AddScope(scopeTreeView.Nodes, Content.CurrentOperation.Scope); 132 } 133 scopeTreeView.ExpandAll(); 134 if (scopeTreeView.Nodes.Count > 0) 135 scopeTreeView.TopNode = scopeTreeView.Nodes[0]; 136 scopeTreeView.EndUpdate(); 137 } 123 UpdateExecutionStack(); 124 SetOperation(Content.CurrentOperation); 125 } 126 } 127 128 private void SetOperation(IOperation operation) { 129 IAtomicOperation atomicOperation = operation as IAtomicOperation; 130 operationTextBox.Text = "<none>"; 131 toolTip.SetToolTip(operationTextBox, null); 132 if (atomicOperation != null && atomicOperation.Operator != null) { 133 operationTextBox.Text = string.Format("Atomic {0}", atomicOperation.Operator.Name); 134 toolTip.SetToolTip(operationTextBox, TypeName(atomicOperation.Operator)); 135 } 136 OperationCollection operationCollection = operation as OperationCollection; 137 if (operationCollection != null) 138 operationTextBox.Text = string.Format("Collection {0}", operationCollection.Count); 139 IExecutionContext context = operation as IExecutionContext; 140 IScope scope = null; 141 if (context != null) { 142 scope = context.Scope; 143 while (scope != null && scope.Parent != null) 144 scope = scope.Parent; 145 } 146 UpdateScope(scope); 147 if (context != null) 148 parentButton.Enabled = context.Parent != null; 149 scopeTreeView.Tag = context; 150 } 151 152 private void UpdateExecutionStack() { 153 executionStackTreeView.BeginUpdate(); 154 executionStackTreeView.Nodes.Clear(); 155 AddOperations(executionStackTreeView.Nodes, Content.ExecutionStack.ToArray()); 156 executionStackTreeView.ExpandAll(); 157 if (executionStackTreeView.Nodes.Count > 0) 158 executionStackTreeView.TopNode = executionStackTreeView.Nodes[0]; 159 executionStackTreeView.EndUpdate(); 160 } 161 162 private void UpdateScope(IScope scope) { 163 scopeTreeView.BeginUpdate(); 164 scopeTreeView.Nodes.Clear(); 165 if (scope != null) { 166 AddScope(scopeTreeView.Nodes, scope); 167 } 168 scopeTreeView.ExpandAll(); 169 if (scopeTreeView.Nodes.Count > 0) 170 scopeTreeView.TopNode = scopeTreeView.Nodes[0]; 171 scopeTreeView.EndUpdate(); 138 172 } 139 173 … … 151 185 node.Tag = atom; 152 186 node.ToolTipText = TypeName(atom); 187 node.ImageKey = "AtomicOperation"; 153 188 if (atom.Operator.Breakpoint) 154 189 node.ForeColor = Color.Red; … … 158 193 paramNode.Tag = param; 159 194 paramNode.ToolTipText = string.Format("{0} = {1}", TypeName(param), typeName); 195 paramNode.ImageKey = "Parameter"; 160 196 } 161 197 } else if (op is OperationCollection) { … … 164 200 node.Tag = op; 165 201 node.ToolTipText = TypeName(ops); 202 node.ImageKey = "OperationCollection"; 166 203 AddOperations(node.Nodes, ops); 167 204 } … … 170 207 171 208 private string GetApproximateValue(IParameter param, ref string typeName) { 172 string value = "<none>"; 209 string valueString = "<none>"; 210 IExecutionContext context = Content.CurrentOperation as IExecutionContext; 211 IExecutionContext originalContext = param.ExecutionContext; 212 object value = null; 173 213 try { 174 IExecutionContext context = Content.CurrentOperation as IExecutionContext; 175 IExecutionContext oldContext = param.ExecutionContext; 176 if (context != null) { 214 try { 177 215 param.ExecutionContext = context; 178 } 179 value = param.ActualValue.ToString(); 180 typeName = TypeName(param.ActualValue); 181 if (context != oldContext) { 182 param.ExecutionContext = oldContext; 183 value = string.Format("~ {0}", value); 216 value = param.ActualValue; 217 } finally { 218 param.ExecutionContext = originalContext; 184 219 } 185 220 } catch (Exception) { } 186 return value; 221 if (value != null) { 222 valueString = value.ToString(); 223 if (context != originalContext) 224 valueString = " ~ " + valueString; 225 typeName = TypeName(value); 226 } 227 return valueString; 187 228 } 188 229 189 230 private void AddScope(TreeNodeCollection nodes, IScope scope) { 190 231 TreeNode node = nodes.Add(scope.Name); 232 if (Content.CurrentOperation != null && Content.CurrentOperation.Scope == scope) { 233 node.ForeColor = Color.Red; 234 node.BackColor = Color.LightGray; 235 } 191 236 foreach (var var in scope.Variables) { 192 237 TreeNode varNode = node.Nodes.Add(string.Format("{0}={1}", var.Name, var.Value.ToString())); … … 230 275 MainFormManager.MainForm.ShowContent((IItem)e.Node.Tag); 231 276 } 277 278 private void parentButton_Click(object sender, EventArgs e) { 279 IExecutionContext context = scopeTreeView.Tag as IExecutionContext; 280 if (context != null) { 281 SetOperation(context.Parent as IOperation); 282 } 283 } 232 284 } 233 285 }
Note: See TracChangeset
for help on using the changeset viewer.