view Glimpse/Glimpse Controls/GlimpseViewer.xaml.vb @ 60:fc62c971a117

upload to blog
author Steven Hollidge <stevenhollidge@hotmail.com>
date Sat, 21 Apr 2012 21:19:39 +0100
parents 3591c26bd63e
children
line wrap: on
line source

Partial Public Class GlimpseViewer
    Inherits UserControl

    Public Sub New()
        InitializeComponent()
        Me.DataContext = GlimpseService.CreateInstance
        AddHandler GlimpseService.CreateInstance.HostExceptions.CollectionChanged, AddressOf HostExceptions_CollectionChanged
    End Sub

    Private Sub btnContract_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnContract.Click
        Me.layoutViewer.Visibility = Windows.Visibility.Collapsed
    End Sub

    Private Sub btnExpand_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnExpand.Click
        Me.layoutViewer.Visibility = Windows.Visibility.Visible
    End Sub

    Private Sub HostExceptions_CollectionChanged(ByVal sender As Object, ByVal e As System.Collections.Specialized.NotifyCollectionChangedEventArgs)

        Dim intUnhandledExceptionCount As Integer = 0
        Dim intValidationExceptionCount As Integer = 0

        For Each ew As ExceptionWrapper In GlimpseService.CreateInstance.HostExceptions

            If ew.IsValidationException Then
                intValidationExceptionCount += 1

            Else
                intUnhandledExceptionCount += 1
            End If

        Next

        Me.tbValidationExceptions.Text = intValidationExceptionCount.ToString

        If intValidationExceptionCount = 0 Then
            Me.elpValidationExceptions.Fill = Me.noExceptionsBrush

        Else
            Me.elpValidationExceptions.Fill = Me.hasExceptionsBrush
        End If

        Me.tbUnhandledExceptions.Text = intUnhandledExceptionCount.ToString

        If intUnhandledExceptionCount = 0 Then
            Me.elpUnhandledExceptions.Fill = Me.noExceptionsBrush

        Else
            Me.elpUnhandledExceptions.Fill = Me.hasExceptionsBrush
        End If

    End Sub

End Class