Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Mole II Black Ops - Multifunction Visual Studio Visualizer For WPF - View Public, Private and Protected Data

, , , 17 Dec 2007 CPOL
A high octane multifunction visualizer that allows detailed inspection of the visual tree and logical trees. New feature of Mole II Black Ops allows viewing and drilling into non-public members of any element or sub-element in the visual or logical trees.
mole.visualizer_2_2_vs2005_release.zip
Mole.Visualizer.dll
mole.visualizer_2_2_vs2005_sourceandtestbench.zip
Mole.Visualizer
Custom Controls
Data Source
Image Processing
Data
Debugger Visualizer
Enums Constants
Event Args
Extended Controls
Images
MoleVisualUnavailable.gif
Mole.Visualizer.csi
Mole.Visualizer.suo
Mole.Visualizer.vbproj.user
My Project
Application.myapp
Settings.settings
Settings
Visualizer UI
XSLT
Mole.TestBench
bach.jpg
Mole.TestBench.csi
Mole.TestBench.suo
Mole.TestBench.vbproj.user
My Project
Settings.settings
mole.visualizer_2_2_vs2008_release.zip
Mole.Visualizer.dll
mole.visualizer_2_2_vs2008_sourceandtestbench.zip
MoleVisualUnavailable.gif
Mole.Visualizer.csi
Mole.Visualizer.suo
Mole.Visualizer.vbproj.user
Application.myapp
Settings.settings
bach.jpg
Mole.TestBench.csi
Mole.TestBench.suo
Mole.TestBench.vbproj.user
Settings.settings
Imports System.Windows.Forms
Imports System.ComponentModel

Public NotInheritable Class MoleCrumbs
    Inherits FlowLayoutPanel

#Region " Declarations "

    Private _bolIsBlackOps As Boolean = False
    Private _fntLabelFont As System.Drawing.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Private _intParentElementTreeDictionaryKeyId As Integer
    Private _intThisElementTreeDictionaryKeyId As Integer
    Private _objMoleTrail As New List(Of MoleCrumb)
    Private _strFullTypeName As String = String.Empty

#End Region

#Region " Properties "

    Public ReadOnly Property Count() As Integer
        Get
            Return _objMoleTrail.Count
        End Get
    End Property

    Public ReadOnly Property FullTypeName() As String
        Get
            Return _strFullTypeName
        End Get
    End Property

    Public ReadOnly Property IsBlackOps() As Boolean
        Get
            Return _bolIsBlackOps
        End Get
    End Property

    Public ReadOnly Property ParentElementTreeDictionaryKeyId() As Integer
        Get
            Return _intParentElementTreeDictionaryKeyId
        End Get
    End Property

    Public ReadOnly Property ThisElementTreeDictionaryKeyId() As Integer
        Get
            Return _intThisElementTreeDictionaryKeyId
        End Get
    End Property

#End Region

#Region " Events "

    Public Event MoleCrumbClick(ByVal sender As Object, ByVal e As MoleCrumbEventArgs)
    Public Event MoleViewDataClick(ByVal sender As Object, ByVal e As MoleCrumbEventArgs)

#End Region

#Region " Methods "

    Public Sub Add(ByVal objNewCrumb As MoleCrumb)
        _objMoleTrail.Add(objNewCrumb)
        _intParentElementTreeDictionaryKeyId = objNewCrumb.ParentElementTreeDictionaryKeyId
        _intThisElementTreeDictionaryKeyId = objNewCrumb.ThisElementTreeDictionaryKeyId
        _strFullTypeName = objNewCrumb.FullTypeName
        _bolIsBlackOps = objNewCrumb.IsBlackOps
        Render()
    End Sub

    ''' <summary>
    ''' Pass in the name of the object type that was clicked on in either the VisualTree or LogicalTree TreeView controls
    ''' </summary>
    Public Sub Clear(ByVal strRootObjectTypeName As String, ByVal strRootObjectFullTypeName As String, ByVal strSearchText As String, ByVal bolIsBlackOps As Boolean)

        Dim strSaveSearchText As String = String.Empty

        If _objMoleTrail IsNot Nothing AndAlso _objMoleTrail.Count > 0 AndAlso _objMoleTrail(0).SearchText.Length > 0 Then
            strSaveSearchText = _objMoleTrail(0).SearchText
        End If

        _objMoleTrail.Clear()
        _intParentElementTreeDictionaryKeyId = 0
        _intThisElementTreeDictionaryKeyId = 0
        _strFullTypeName = strRootObjectFullTypeName
        _bolIsBlackOps = bolIsBlackOps

        '
        'do not set the two Id's, they must be zero's!
        _objMoleTrail.Add(New MoleCrumb(False, 0, 0, strRootObjectTypeName, strRootObjectFullTypeName, strSaveSearchText, bolIsBlackOps))
        Render()
    End Sub

    Public Sub SetSearchTextForActiveMoleCrumb(ByVal strSearchText As String)
        _objMoleTrail(_objMoleTrail.Count - 1).SearchText = strSearchText
    End Sub

    Private Sub MoleCrumb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Dim intIndex As Integer = CType(CType(sender, Label).Tag, Integer)
        Dim objMoleCrumb As MoleCrumb = _objMoleTrail(intIndex)

        For intX As Integer = _objMoleTrail.Count - 1 To intIndex Step -1
            _objMoleTrail.RemoveAt(intX)
        Next

        If _objMoleTrail.Count = 0 Then
            _intParentElementTreeDictionaryKeyId = 0
            _intThisElementTreeDictionaryKeyId = 0
            _strFullTypeName = String.Empty
            _bolIsBlackOps = False

        Else
            _intParentElementTreeDictionaryKeyId = _objMoleTrail(_objMoleTrail.Count - 1).ParentElementTreeDictionaryKeyId
            _intThisElementTreeDictionaryKeyId = _objMoleTrail(_objMoleTrail.Count - 1).ThisElementTreeDictionaryKeyId
            _strFullTypeName = _objMoleTrail(_objMoleTrail.Count - 1).FullTypeName
            _bolIsBlackOps = _objMoleTrail(_objMoleTrail.Count - 1).IsBlackOps
        End If

        Render()
        RaiseEvent MoleCrumbClick(Me, New MoleCrumbEventArgs(objMoleCrumb))
    End Sub

    Private Sub MoleViewData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        RaiseEvent MoleViewDataClick(Me, New MoleCrumbEventArgs(Me.ParentElementTreeDictionaryKeyId, Me.ThisElementTreeDictionaryKeyId, _objMoleTrail(_objMoleTrail.Count - 1).Text, "", Me.IsBlackOps))
    End Sub

    Private Sub Render()
        Me.SuspendLayout()
        Me.Controls.Clear()

        If _objMoleTrail.Count > 0 Then

            'TODO  Developers you can enable the View Data feature here

            'Background:  The view data feature was commented out the night we released Mole II because in some situations the data
            'that is displayed doesn't make sense.
            'If all the items in the collection have the SAME Type there is no problem at all.  This is what the original design was targeting.
            '
            'However, if the items in the collection are not the SAME Type the results could be confusing.  The View Data grid uses the first item to build the columns
            'collection.  Take the list box in the demo program.  It has many diffent Types in the list box.  The results in Integers trying to display their properties
            'using a Strings columns.  You get the point.
            '
            'So we commented the below code out to limit confusion.  Feel free to enable the View Data grid, just be aware that it has this limitation.
            '
            'We have spoke about displaying the data in an HTML page, but wanted to get this product out.  So that HTML or other solution will be in the next
            'release or you can code it and tell us about it.
            '
            '======================================================================
            'uncomment here to enable View Data Grid feature.

            Dim btn As New Button
            btn.Name = "btnViewMoleData"
            btn.Text = "View Data"

            If _objMoleTrail(_objMoleTrail.Count - 1).HasData Then
                btn.ForeColor = Drawing.Color.Blue
                AddHandler btn.Click, AddressOf MoleViewData_Click

            Else
                btn.Enabled = False
            End If

            Me.Controls.Add(btn)

            '======================================================================

            For intX As Integer = 0 To _objMoleTrail.Count - 1

                If intX < _objMoleTrail.Count - 1 Then

                    Dim lbl As New LinkLabel
                    lbl.Name = String.Concat("lblMC", intX.ToString)
                    lbl.AutoSize = True
                    lbl.Padding = New Padding(2, 5, 0, 5)
                    lbl.Tag = intX

                    If intX = 0 Then
                        lbl.Text = _objMoleTrail(intX).Text

                    Else
                        lbl.Text = String.Concat(" > ", _objMoleTrail(intX).Text)
                    End If

                    AddHandler lbl.Click, AddressOf MoleCrumb_Click
                    Me.Controls.Add(lbl)

                Else

                    'this is the last item and can also be the first item with only one MoleCrumb, it is a label
                    Dim lbl As New Label
                    lbl.Name = String.Concat("lblMC", intX.ToString)
                    lbl.AutoSize = True
                    lbl.Padding = New Padding(2, 5, 0, 5)
                    lbl.Tag = intX

                    If intX = 0 Then
                        lbl.Text = _objMoleTrail(intX).Text

                    Else
                        lbl.Text = String.Concat(" > ", _objMoleTrail(intX).Text)
                    End If

                    lbl.Font = _fntLabelFont
                    Me.Controls.Add(lbl)
                End If

            Next

            Me.Margin = New Padding(8)

        Else
            Me.Margin = New Padding(0)
        End If

        Me.ResumeLayout()
    End Sub

#End Region

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Authors

Andrew Smith
Architect Infragistics, Inc.
United States United States
Andrew currently works as an architect for Infragistics working with windows forms and WPF. You can check out his blog here.

Josh Smith
Software Developer (Senior) Cynergy Systems
United States United States
Josh creates software, for iOS and Windows.
 
He works at Cynergy Systems as a Senior Experience Developer.
 
Read his iOS Programming for .NET Developers[^] book to learn how to write iPhone and iPad apps by leveraging your existing .NET skills.
 
Use his Master WPF[^] app on your iPhone to sharpen your WPF skills on the go.
 
Check out his Advanced MVVM[^] book.
 
Visit his WPF blog[^] or stop by his iOS blog[^].
Follow on   Twitter

Karl Shifflett
Architect Gayle Manufacturing Company
United States United States
Karl loves .NET, WPF, WCF, ASP.NET, VB.NET and C#.
 
Awards:
 
  • December 2008 VB.NET Code Project Article Award
  • 2009 Code Project MVP
  • 2008 Code Project MVP
  • 2008 Microsoft MVP - Client App Dev
  • December 2007 VB.NET Code Project Article Award
  • Gold Medal Winner at IBM's 1998 PROIV Programming Contest in Las Vegas
Click here to check out my Blog
 
Click here to learn about Mole 2010 debugging tool for Visual Studio 2010
 
Click here to read about XAML Power Toys
 

Just a grain of sand on the worlds beaches.

Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141220.1 | Last Updated 18 Dec 2007
Article Copyright 2007 by Andrew Smith, Josh Smith, Karl Shifflett
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid