Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/09/10 11:09:37 (13 years ago)
Author:
epitzer
Message:

Show expected parameter values and include type information in tool tip (#47)

File:
1 edited

Legend:

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

    r4747 r4753  
    2727using HeuristicLab.Core.Views;
    2828using HeuristicLab.MainForm;
     29using HeuristicLab.Persistence.Auxiliary;
    2930namespace HeuristicLab.DebugEngine {
    3031  /// <summary>
     
    116117        Invoke(new Action(UpdateView));
    117118      } else {
     119        executionStackTreeView.BeginUpdate();
    118120        executionStackTreeView.Nodes.Clear();
    119121        AddOperations(executionStackTreeView.Nodes, Content.ExecutionStack.ToArray());
    120122        executionStackTreeView.ExpandAll();
    121 
     123        if (executionStackTreeView.Nodes.Count > 0)
     124          executionStackTreeView.TopNode = executionStackTreeView.Nodes[0];
     125        executionStackTreeView.EndUpdate();
     126
     127
     128        scopeTreeView.BeginUpdate();
    122129        scopeTreeView.Nodes.Clear();
    123130        if (Content.CurrentOperation != null) {
     
    125132        }
    126133        scopeTreeView.ExpandAll();
    127       }
     134        if (scopeTreeView.Nodes.Count > 0)
     135          scopeTreeView.TopNode = scopeTreeView.Nodes[0];
     136        scopeTreeView.EndUpdate();
     137      }
     138    }
     139
     140    private string TypeName(object obj) {
     141      if (obj == null)
     142        return "null";
     143      return TypeNameParser.Parse(obj.GetType().ToString()).GetTypeNameInCode(true);
    128144    }
    129145
     
    134150          TreeNode node = nodes.Add(atom.Operator.Name);
    135151          node.Tag = atom;
     152          node.ToolTipText = TypeName(atom);
    136153          if (atom.Operator.Breakpoint)
    137154            node.ForeColor = Color.Red;
    138155          foreach (var param in atom.Operator.Parameters) {
    139             IItem value = null;
    140             try {
    141               value = param.ActualValue;
    142             } catch (Exception) { }
    143             TreeNode paramNode = node.Nodes.Add(string.Format("Param {0}={1}", param.Name, value));
     156            string typeName = "null";
     157            TreeNode paramNode = node.Nodes.Add(string.Format("Param {0} = {1}", param.Name, GetApproximateValue(param, ref typeName)));
    144158            paramNode.Tag = param;
     159            paramNode.ToolTipText = string.Format("{0} = {1}", TypeName(param), typeName);
    145160          }
    146161        } else if (op is OperationCollection) {
     
    148163          TreeNode node = executionStackTreeView.Nodes.Add(string.Format("{0} Operations", ops.Count));
    149164          node.Tag = op;
     165          node.ToolTipText = TypeName(ops);
    150166          AddOperations(node.Nodes, ops);
    151167        }
    152168      }
     169    }
     170
     171    private string GetApproximateValue(IParameter param, ref string typeName) {
     172      string value = "<none>";
     173      try {
     174        IExecutionContext context = Content.CurrentOperation as IExecutionContext;
     175        IExecutionContext oldContext = param.ExecutionContext;
     176        if (context != null) {
     177          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);
     184        }
     185      } catch (Exception) { }
     186      return value;
    153187    }
    154188
     
    158192        TreeNode varNode = node.Nodes.Add(string.Format("{0}={1}", var.Name, var.Value.ToString()));
    159193        varNode.Tag = var.Value;
     194        varNode.ToolTipText = TypeName(var.Value);
    160195      }
    161196      foreach (var subScope in scope.SubScopes) {
Note: See TracChangeset for help on using the changeset viewer.