|
<UserControl x:Class="Catel.Windows.Controls.TraceOutputControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:sysdiagnostics="clr-namespace:System.Diagnostics;assembly=System"
xmlns:localconverters="clr-namespace:Catel.Windows.Data.Converters"
xmlns:Input="clr-namespace:Catel.Windows.Input;assembly=Catel.Windows"
SnapsToDevicePixels="True">
<!-- Resources -->
<UserControl.Resources>
<!-- Converters -->
<localconverters:OutputTypeConverter x:Key="OutputTypeConverter" />
<!-- object data providers -->
<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="AvailableTraceLevelCollection">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="sysdiagnostics:TraceLevel" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<!-- Context menu -->
<ContextMenu x:Key="LogEntryContextMenu">
<MenuItem Command="Input:WindowCommands.CopyToClipboard" />
</ContextMenu>
</UserControl.Resources>
<!-- Content -->
<DockPanel LastChildFill="True" DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}">
<!-- Toolbar -->
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<!-- Combobox with modes -->
<Label Content="Details: " />
<ComboBox DataContext="{StaticResource AvailableTraceLevelCollection}" ItemsSource="{Binding}"
SelectedValue="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=TraceLevelOutput}" />
<!-- Clear button -->
<Button Command="Input:WindowCommands.Clear" Style="{DynamicResource SmallImageButtonStyle}">
<Image Source="/Catel.Windows;component/Resources/Images/ClearOutput.png" />
</Button>
</StackPanel>
<!-- Listview with output -->
<ListView x:Name="logListView" ItemsSource="{DynamicResource FilteredTraceEntryCollection}">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<!-- Error -->
<DataTrigger Binding="{Binding TraceLevel}">
<DataTrigger.Value>
<sysdiagnostics:TraceLevel>Error</sysdiagnostics:TraceLevel>
</DataTrigger.Value>
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
<!-- Warning-->
<DataTrigger Binding="{Binding TraceLevel}">
<DataTrigger.Value>
<sysdiagnostics:TraceLevel>Warning</sysdiagnostics:TraceLevel>
</DataTrigger.Value>
<Setter Property="Foreground" Value="DarkOrange" />
</DataTrigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="LightGray" />
</Trigger>
</Style.Triggers>
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="ContextMenu" Value="{StaticResource LogEntryContextMenu}" />
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<!-- Icon -->
<GridViewColumn Header="" Width="27">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ContentControl Content="{Binding TraceLevel, Converter={StaticResource OutputTypeConverter}}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!-- Time (Default Width = 120) -->
<GridViewColumn Header="Time">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Time}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!-- Level -->
<GridViewColumn Header="Level" Width="75">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding TraceLevel}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!-- Message -->
<GridViewColumn Header="Message" Width="1000">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Message}" FontFamily="Courier New" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
</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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.