Click here to Skip to main content
15,895,142 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.6K   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.RealtimeSelector"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:sysCon="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
 	xmlns:menu="clr-namespace:ContextMenuControls;assembly=ContextMenuControls"
	xmlns:ldsu="clr-namespace:DiagnosticExplorer.Silverlight.Util"
    xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
	xmlns:dsc="clr-namespace:DiagnosticExplorer.Silverlight.Controls"
    xmlns:sysWin="clr-namespace:System.Windows;assembly=System.Windows.Controls"
	mc:Ignorable="d" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    d:DesignHeight="169" d:DesignWidth="153">
	<UserControl.Resources>
		<ldsu:GroupStatusConverter x:Key="groupStatus" NABrush="Purple" OnlineBrush="Green" OfflineBrush="Red" UnknownBrush="Black" />
		<ldsu:IsTargetVisibilityConverter x:Key="targetVisConverter" />
		<ldsu:IsFolderVisibilityConverter x:Key="folderVisConverter" />
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot" ShowGridLines="False" UseLayoutRounding="True">
    <controlsToolkit:TreeViewDragDropTarget x:Name="ddTarget" AllowDrop="true"  
                                                HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
      <sysCon:TreeView x:Name="tree" Grid.Row="1"
							ItemsSource="{Binding Group.Items}" SelectedItemChanged="HandleSelectedItemChanged">

				<menu:ContextMenu.ContextMenu>
					<menu:ContextMenu DataContext="{Binding}">
	          <menu:MenuItem Text="Add Folder" Click="ClickAddFolder" />
						<menu:MenuItem Text="Register Process" Click="ClickRegisterProcess" />
            <menu:MenuItem Text="Refresh" Click="ClickRefresh" />
	        </menu:ContextMenu>
				</menu:ContextMenu.ContextMenu>

				<sysCon:TreeView.Resources>
					<Style TargetType="sysCon:TreeViewItem">
						<Setter Property="IsExpanded" Value="False" />
					</Style>
				</sysCon:TreeView.Resources>
	                
				<sysCon:TreeView.ItemTemplate>
					<sysWin:HierarchicalDataTemplate ItemsSource="{Binding Items}">
						<StackPanel Orientation="Horizontal">
							<menu:ContextMenu.ContextMenu>
								<menu:ContextMenu DataContext="{Binding}">
									<menu:MenuItem Text="Rename" Click="ClickRename" />
									<menu:MenuItem Text="Delete" Click="ClickDelete" />
									<menu:MenuItem Text="Add Folder" Click="ClickAddFolder" Visibility="{Binding Uri, Converter={StaticResource folderVisConverter}}" />
									<menu:MenuItem Text="Register Process" Click="ClickRegisterProcess" Visibility="{Binding Uri, Converter={StaticResource folderVisConverter}}" />
								</menu:ContextMenu>
							</menu:ContextMenu.ContextMenu>

							<Image Source="{Binding ImagePath}" Margin="0,0,10,0" />
							<TextBlock Margin="0,0,5,0" MouseRightButtonDown="HandleRightMouseDown" Text="{Binding Name}" Foreground="{Binding State, Converter={StaticResource groupStatus}}"/>
							<TextBlock Text="{Binding ProcessId}" 
												 FontSize="8" 
												 VerticalAlignment="Center"
												 Foreground="{Binding State, Converter={StaticResource groupStatus}}"
												 Visibility="{Binding Uri, Converter={StaticResource targetVisConverter}}" />
						</StackPanel>
					</sysWin:HierarchicalDataTemplate>
				</sysCon:TreeView.ItemTemplate>
			</sysCon:TreeView>
    </controlsToolkit:TreeViewDragDropTarget>

		<Popup x:Name="popupRename" HorizontalOffset="100" VerticalOffset="100">
			<dsc:NamePrompt x:Name="namePrompt" Width="400" Background="White"
                        Prompt="Please enter a new name" 
                        Value="New name here"
                        OkClicked="HandleNameOk" 
                        CancelClicked="HandleNameCancel" />
		</Popup>

		<Popup x:Name="popupRegister" HorizontalOffset="100" VerticalOffset="100">
			<dsc:RegistrationPrompt x:Name="regPrompt" Width="500" Background="White"
                        OkClicked="HandleNewRegOk" 
                        CancelClicked="HandleNewRegCancel" />
		</Popup>
	</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