예제 #1
0
        protected void DrawExpander(ItemInfo info, Graphics g)
        {
            Rectangle rc = this.GetImageExpanderRect(info.Item);

            bool drawn = false;
            if (VisualStyleRenderer.IsSupported)
            {

                VisualStyleElement old, explorer, hover = null;

                // create the default one
                old = info.Expanded ? VisualStyleElement.TreeView.Glyph.Opened : VisualStyleElement.TreeView.Glyph.Closed;

                // create the fancy explorer one
                explorer = VisualStyleElement.CreateElement("Explorer::TreeView", old.Part, old.State);

                // create the explorer one that is highlighted
                if (info.ExpanderHot)
                {
                    hover = VisualStyleElement.CreateElement(explorer.ClassName, 4, explorer.State);
                }

                // try each one (fancy one first)
                foreach (VisualStyleElement e in new VisualStyleElement[] { hover, explorer, old })
                {
                    if (e == null)
                    {
                        continue;
                    }

                    if (VisualStyleRenderer.IsElementDefined(e))
                    {
                        VisualStyleRenderer renderer = new VisualStyleRenderer(e);
                        renderer.DrawBackground(g, rc);
                        drawn = true;
                        break;
                    }
                }
            }

            if (!drawn)
            {
                g.DrawRectangle(Pens.Blue, rc);
            }
        }
예제 #2
0
        private List<ListViewItem> GetCallstackItems(ItemInfo info, ThrownException ex)
        {
            List<ListViewItem> items = new List<ListViewItem>();

            //MethodContainer.CallStack stack = this.MethodContainer.Analysis.GetCallstack(ex.Method);
            CallStack stack = ((MethodItem)info.Data).Method.Analysis.GetCallstack(ex.Method);

            // add the methods in it
            if (stack != null)
            {
                bool first = true;
                ItemInfo previous = null;
                foreach (Method m in stack)
                {
                    if (first)
                    {
                        first = false;
                        continue;
                    }

                    ItemInfo child = MakeItem(null, m);
                    if (previous != null)
                    {
                        ((MethodItem)child.Data).CalledBy = ((MethodItem)previous.Data).Method;
                    }
                    else
                    {
                        ((MethodItem)child.Data).CalledBy = ((MethodItem)info.Data).Method;
                    }

                    child.Item.IndentCount = info.Item.IndentCount + 1;

                    child.Parent = info;
                    child.PreviousChild = previous;

                    previous = child;

                    items.Add(child.Item);
                }

                // add an item for the throw statement
                ItemInfo throwItem = MakeItem(ex);
                throwItem.Item.Text = "throw " + ex.Exception.Name;
                throwItem.Item.IndentCount++;

                throwItem.PreviousChild = previous;
                throwItem.Parent = info;

                items.Add(throwItem.Item);
            }
            return items;
        }
예제 #3
0
        /// <summary>
        /// Makes a new item.
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <param name="method">The method.</param>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        protected ItemInfo MakeItem(ThrownException exception, Method method = null, ListViewGroup group = null)
        {
            bool isMethod = (method != null);
            bool isProperty = isMethod && method.MethodBase.IsProperty();
            bool isThrow = !isMethod && (exception != null);

            if (!isMethod)
            {
                method = exception.Method;
            }

            ListViewItem item;
            PropertyInfo pi = null;
            if (isProperty)
            {
                bool getter = method.MethodBase.Name.StartsWith("get_");
                pi = method.MethodBase.GetMethodProperty();
                item = new ListViewItem(string.Format(CultureInfo.InvariantCulture, "{0} ({1})", pi.Name, getter ? "get" : "set"));
            }
            else
            {
                item = new ListViewItem(method.ToString());
            }

            if (isProperty)
            {
                item.ImageKey = NodeInfo.ImageKeyFromObject(pi);
            }
            else if (isMethod)
            {
                // use the method for the icon
                item.ImageKey = NodeInfo.ImageKeyFromObject(method.MethodBase);
            }
            else
            {
                // use the exception for the icon
                item.ImageKey = NodeInfo.ImageKeyFromObject(exception.Exception);
            }

            ItemInfo info;
            MethodItem me = new MethodItem(method, exception);

            if (exception == null)
            {
                info = new ItemInfo(item, me, NodeType.Method);
                item.SubItems.Add("");
            }
            else
            {
                info = new ItemInfo(item, me, NodeType.Method);
                info.Expandable = !isThrow;
                item.SubItems.Add(exception.Exception.Name);

            }

            item.Tag = info;

            item.SubItems.Add(method.MethodBase.DeclaringType.Name);
            item.SubItems.Add(method.MethodBase.DeclaringType.Module.Name);

            item.IndentCount = 1;

            if (group != null)
            {
                item.Group = group;
            }

            return info;
        }
예제 #4
0
        protected override void ItemExpanded(ItemInfo info, bool expanded)
        {
            if (info.SubItems == null)
            {
                info.SubItems = this.GetChildren(info);
            }

            base.ItemExpanded(info, expanded);
        }
예제 #5
0
        /// <summary>
        /// Gets the child items for the given item.
        /// </summary>
        /// <param name="info">The info.</param>
        /// <returns></returns>
        protected List<ListViewItem> GetChildren(ItemInfo info)
        {
            MethodItem me = info.Data as MethodItem;

            if (me.Exception != null)
            {
                return this.GetCallstackItems(info, me.Exception);
            }

            return null;
        }
예제 #6
0
        protected CallStack GetCallStackForChild(ItemInfo info)
        {
            // child item - get the stack by moving up the list
            CallStack stack = new CallStack();
            ItemInfo previous = info;

            while (previous != null)
            {
                MethodItem te = previous.Data as MethodItem;
                stack.Push(te.Method);
                previous = previous.PreviousChild;
            }

            return stack;
        }
예제 #7
0
 private void SetExpand(ItemInfo info, bool expanded)
 {
     if ((info != null) && info.Expandable && (info.Expanded != expanded))
     {
         this.ItemExpanded(info, expanded);
     }
 }
예제 #8
0
        protected void SetHotItem(ItemInfo info)
        {
            if (this.HotItem != null)
            {
                this.HotItem.ExpanderHot = false;
                this.Invalidate(this.GetImageExpanderRect(this.HotItem.Item));
            }

            this.HotItem = info;

            if (this.HotItem != null)
            {
                this.HotItem.ExpanderHot = true;
                this.HotItem.Item.Text = this.HotItem.Item.Text + " ";
                this.Invalidate(this.GetImageExpanderRect(this.HotItem.Item));
            }
        }
예제 #9
0
 /// <summary>Creates a new listview item, base on the item info class given.</summary>
 /// <param name="itemInfo">The item info.</param>
 /// <returns>The new list view item.</returns>
 protected virtual ListViewItem NewItem(ItemInfo itemInfo)
 {
     return itemInfo.Item;
 }
예제 #10
0
 protected bool MouseOverExpander(ItemInfo info, int x, int y)
 {
     if ((info != null) && (info.Expandable))
     {
         Rectangle rc = this.GetImageExpanderRect(info.Item);
         if (rc.Contains(x, y))
         {
             return true;
         }
     }
     return false;
 }
예제 #11
0
        protected virtual void ItemExpanded(ItemInfo info, bool expanded)
        {
            ListViewItem item = info.Item;
            info.Expanded = expanded;

            if (item.SubItems == null)
            {
                return;
            }

            // show or hide the sub-items
            try
            {
                this.BeginUpdate();

                if (info.Expanded)
                {
                    int index = item.Index;
                    foreach (ListViewItem itm in info.SubItems)
                    {
                        itm.Group = info.Item.Group;
                        this.Items.Insert(++index, itm);
                    }
                }
                else
                {
                    foreach (ListViewItem i in info.SubItems)
                    {
                        this.Items.Remove(i);
                    }
                }

                return;
            }
            finally
            {
                this.EndUpdate();
            }
        }