Click here to Skip to main content
15,886,137 members
Articles / Desktop Programming / XAML

Diagnostic Explorer

Rate me:
Please Sign up or sign in to vote.
4.93/5 (41 votes)
29 Nov 2010LGPL315 min read 82.3K   1.5K   120  
A .NET library and website which allows developers to expose and view arbitrary diagnostic information about their .NET processes.
<UserControl x:Class="DiagnosticExplorer.Silverlight.Controls.RetroDisplayer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
		xmlns:ldsu="clr-namespace:DiagnosticExplorer.Silverlight.Util"
		xmlns:ldsc="clr-namespace:DiagnosticExplorer.Silverlight.Controls"
		xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
		xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
		xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
		xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
	<UserControl.Resources>
		<ldsu:StringFormatConverter x:Key="sfc" />
		<ldsu:MessageConverter x:Key="msgConvert" />
		<ldsu:LevelToSeverityConverter x:Key="levelToSeverity" />
		<CollectionViewSource x:Key="EventView" />
	</UserControl.Resources>

	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="200" />
		</Grid.RowDefinitions>

		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition Width="*" />
				<ColumnDefinition Width="Auto" />
			</Grid.ColumnDefinitions>

			<TextBlock Grid.Column="0" Text="Retro Diagnostics" FontWeight="Bold" Foreground="Purple" VerticalAlignment="Bottom" Margin="5,0,0,0" FontSize="15" />
			<TextBlock Grid.Column="1" Text="" VerticalAlignment="Bottom" Margin="20,0,0,0" FontSize="10" />
			<TextBlock Grid.Column="2" Text="{Binding RequestInfo}" VerticalAlignment="Bottom" Margin="20,0,10,0" FontSize="10"/>
		</Grid>

		<data:DataGrid Grid.Row="1" x:Name="grid"
						 IsReadOnly="True"
						 ItemsSource="{Binding Source={StaticResource EventView}}"
						 SelectionChanged="HandleSelectionChanged"
						 AutoGenerateColumns="False">
			<data:DataGrid.RowStyle>
				<Style TargetType="data:DataGridRow">
					<Setter Property="IsTabStop" Value="False" />
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="data:DataGridRow">
								<primitives:DataGridFrozenGrid Name="Root"
									MouseLeftButtonDown="HandleGridMouseDown"
									MouseLeftButtonUp="HandleGridMouseUp"
									MouseMove="HandleMouseRowMove">

									<vsm:VisualStateManager.VisualStateGroups>
										<vsm:VisualStateGroup x:Name="CommonStates">
											<vsm:VisualStateGroup.Transitions>
												<vsm:VisualTransition GeneratedDuration="0" />
											</vsm:VisualStateGroup.Transitions>
											<vsm:VisualState x:Name="Normal" >
												<Storyboard>
													<DoubleAnimation Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="Opacity" Duration="0" To=".5"/>
													<!--<ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
									<SplineColorKeyFrame KeyTime="0" Value="#ebf4fa"/>
								</ColorAnimationUsingKeyFrames>-->
												</Storyboard>
											</vsm:VisualState>
											<vsm:VisualState x:Name="Normal AlternatingRow">
												<Storyboard>
													<DoubleAnimation Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="Opacity" Duration="0" To="0"/>
													<!--<ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
									<SplineColorKeyFrame KeyTime="0" Value="#bbd9ee"/>
								</ColorAnimationUsingKeyFrames>-->
												</Storyboard>
											</vsm:VisualState>
											<vsm:VisualState x:Name="MouseOver">
												<Storyboard>
													<DoubleAnimation Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="Opacity" Duration="0" To=".5"/>
													<!--<ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
									<SplineColorKeyFrame KeyTime="0" Value="#ffab35"/>
								</ColorAnimationUsingKeyFrames>-->
												</Storyboard>
											</vsm:VisualState>
											<vsm:VisualState x:Name="Normal Selected">
												<Storyboard>
													<DoubleAnimation Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/>
													<!--<ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
									<SplineColorKeyFrame KeyTime="0" Value="#54a4de"/>
								</ColorAnimationUsingKeyFrames>-->
												</Storyboard>
											</vsm:VisualState>
											<vsm:VisualState x:Name="MouseOver Selected">
												<Storyboard>
													<DoubleAnimation Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/>
													<!--<ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
									<SplineColorKeyFrame KeyTime="0" Value="Orange"/>
								</ColorAnimationUsingKeyFrames>-->
												</Storyboard>
											</vsm:VisualState>
											<vsm:VisualState x:Name="Unfocused Selected">
												<Storyboard>
													<DoubleAnimation Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/>
													<!--<ColorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
									<SplineColorKeyFrame KeyTime="0" Value="#54a4de"/>
								</ColorAnimationUsingKeyFrames>-->
												</Storyboard>
											</vsm:VisualState>
										</vsm:VisualStateGroup>
									</vsm:VisualStateManager.VisualStateGroups>

									<Grid.RowDefinitions>
										<RowDefinition Height="*"/>
										<RowDefinition Height="Auto"/>
										<RowDefinition Height="Auto"/>
									</Grid.RowDefinitions>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="Auto" />
										<ColumnDefinition Width="*" />
									</Grid.ColumnDefinitions>

									<Grid.Resources>
										<Storyboard x:Key="DetailsVisibleTransition">
											<DoubleAnimation Storyboard.TargetName="DetailsPresenter" Storyboard.TargetProperty="ContentHeight" Duration="00:00:0.1" />
										</Storyboard>
									</Grid.Resources>

									<Rectangle x:Name="BackgroundRectangle" Grid.RowSpan="2" Grid.ColumnSpan="2" Opacity="0" Fill="#1A000000"/>
									<primitives:DataGridRowHeader Grid.RowSpan="3" Name="RowHeader" primitives:DataGridFrozenGrid.IsFrozen="True" />
									<primitives:DataGridCellsPresenter Grid.Column="1" IsHitTestVisible="False" Name="CellsPresenter" primitives:DataGridFrozenGrid.IsFrozen="True" />
									<primitives:DataGridDetailsPresenter Grid.Row="1" Grid.Column="1" Name="DetailsPresenter" />
									<Rectangle Grid.Row="2" Grid.Column="1" Name="BottomGridLine" HorizontalAlignment="Stretch" Height="1" />
								</primitives:DataGridFrozenGrid>
							</ControlTemplate>
						</Setter.Value>

					</Setter>
				</Style>
			</data:DataGrid.RowStyle>
			<data:DataGrid.Columns>

				<data:DataGridTemplateColumn Header="Date">
					<data:DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Margin="3,1" Text="{Binding Date, Converter={StaticResource sfc}, ConverterParameter='d MMM yyyy HH:mm:ss'}" />
						</DataTemplate>
					</data:DataGridTemplateColumn.CellTemplate>
				</data:DataGridTemplateColumn>

				<data:DataGridTemplateColumn Header="Severity">
					<data:DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Margin="3,1" Text="{Binding Level, Converter={StaticResource levelToSeverity}}" />
						</DataTemplate>
					</data:DataGridTemplateColumn.CellTemplate>
				</data:DataGridTemplateColumn>

				<data:DataGridTemplateColumn Header="Machine">
					<data:DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Margin="3,1" Text="{Binding Machine}" />
						</DataTemplate>
					</data:DataGridTemplateColumn.CellTemplate>
				</data:DataGridTemplateColumn>

				<data:DataGridTemplateColumn Header="User">
					<data:DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Margin="3,1" Text="{Binding User}" />
						</DataTemplate>
					</data:DataGridTemplateColumn.CellTemplate>
				</data:DataGridTemplateColumn>

				<data:DataGridTemplateColumn Header="Process">
					<data:DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Margin="3,1" Text="{Binding Process}" />
						</DataTemplate>
					</data:DataGridTemplateColumn.CellTemplate>
				</data:DataGridTemplateColumn>

				<data:DataGridTemplateColumn Header="Message">
					<data:DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock Margin="3,1" Text="{Binding Message, Converter={StaticResource msgConvert}}" />
						</DataTemplate>
					</data:DataGridTemplateColumn.CellTemplate>
				</data:DataGridTemplateColumn>
			</data:DataGrid.Columns>
		</data:DataGrid>
		<ldsc:SinkFilter x:Name="eventFilter" Grid.Row="1" HorizontalAlignment="Right" FilterChanged="HandleFilterChanged" VerticalAlignment="Top" />

		<controls:GridSplitter Grid.Row="2" Height="5"
									HorizontalAlignment="Stretch"
									VerticalAlignment="Center"
									Background="Silver"
									ShowsPreview="True" />

		<controls:TabControl x:Name="tabControl" Grid.Row="3">

			<controls:TabItem Header="Detail">
				<ldsc:EventDetailControl x:Name="eventDetail" />
			</controls:TabItem>

			<controls:TabItem Header="TraceScope">
				<ldsc:TraceScopeViewer x:Name="traceViewer" />
			</controls:TabItem>

		</controls:TabControl>
	</Grid>
</UserControl>

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 GNU Lesser General Public License (LGPLv3)


Written By
Software Developer
United Kingdom United Kingdom
I am a software developer originally from Auckland, New Zealand. I have lived and worked in London since 2005.

Comments and Discussions