|
| 1 | +<UserControl x:Class="Rubberduck.UI.CodeMetrics.CodeMetricsControl" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 5 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 6 | + xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" |
| 7 | + xmlns:codeMetrics="clr-namespace:Rubberduck.Navigation.CodeMetrics" |
| 8 | + xmlns:controls="clr-namespace:Rubberduck.UI.Controls" |
| 9 | + xmlns:converters="clr-namespace:Rubberduck.UI.Converters" |
| 10 | + ResxExtension.DefaultResxName="Rubberduck.UI.RubberduckUI" |
| 11 | + Language="{UICulture}" |
| 12 | + Name="CodeMetrics" |
| 13 | + mc:Ignorable="d" |
| 14 | + d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance codeMetrics:CodeMetricsViewModel}"> |
| 15 | + <UserControl.Resources> |
| 16 | + <ResourceDictionary> |
| 17 | + <ResourceDictionary.MergedDictionaries> |
| 18 | + <ResourceDictionary Source="../Controls/ToolBar.xaml"/> |
| 19 | + </ResourceDictionary.MergedDictionaries> |
| 20 | + |
| 21 | + <BitmapImage x:Key="RefreshImage" UriSource="../../Resources/arrow-circle-double.png" /> |
| 22 | + <BitmapImage x:Key="CollaseNodesImage" UriSource="../../Resources/folder.png" /> |
| 23 | + <BitmapImage x:Key="ExpandNodesImage" UriSource="../../Resources/folder-open.png" /> |
| 24 | + <BitmapImage x:Key="UndoImage" UriSource="../../Resources/arrow-circle-left.png" /> |
| 25 | + <BitmapImage x:Key="PrintImage" UriSource="../../Resources/printer.png" /> |
| 26 | + <BitmapImage x:Key="SearchImage" UriSource="../../Resources/magnifier-medium.png" /> |
| 27 | + |
| 28 | + <BooleanToVisibilityConverter x:Key="BoolToVisibility"/> |
| 29 | + <converters:BoolToHiddenVisibilityConverter x:Key="BoolToHiddenVisibility" /> |
| 30 | + <converters:StringHasValueToVisibilityConverter x:Key="StringHasValueToVisibility" /> |
| 31 | + <converters:StringHasNoValueToVisibilityConverter x:Key="StringHasNoValueToVisibility" /> |
| 32 | + |
| 33 | + <LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" EndPoint="0,1" StartPoint="0,0"> |
| 34 | + <GradientStop Color="#FFD9F4FF" Offset="0"/> |
| 35 | + <GradientStop Color="#FF9BDDFB" Offset="1"/> |
| 36 | + </LinearGradientBrush> |
| 37 | + <LinearGradientBrush x:Key="{x:Static SystemColors.ControlBrushKey}" EndPoint="0,1" StartPoint="0,0"> |
| 38 | + <GradientStop Color="#FFEEEDED" Offset="0"/> |
| 39 | + <GradientStop Color="#FFDDDDDD" Offset="1"/> |
| 40 | + </LinearGradientBrush> |
| 41 | + <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" /> |
| 42 | + <SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="Black" /> |
| 43 | + |
| 44 | + <Style x:Key="XButtonStyle" TargetType="Button"> |
| 45 | + <Setter Property="Background" Value="Transparent"/> |
| 46 | + <Setter Property="Content" Value="✕"/> |
| 47 | + <Setter Property="BorderThickness" Value="0"/> |
| 48 | + <Setter Property="HorizontalContentAlignment" Value="Center"/> |
| 49 | + <Setter Property="VerticalContentAlignment" Value="Center"/> |
| 50 | + <Setter Property="Template"> |
| 51 | + <Setter.Value> |
| 52 | + <ControlTemplate TargetType="Button"> |
| 53 | + <Grid> |
| 54 | + <VisualStateManager.VisualStateGroups> |
| 55 | + <VisualStateGroup x:Name="CommonStates"> |
| 56 | + <VisualState x:Name="Normal"/> |
| 57 | + <VisualState x:Name="MouseOver"> |
| 58 | + <Storyboard> |
| 59 | + <ColorAnimation Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="PaleGoldenrod"/> |
| 60 | + <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity" To="1"/> |
| 61 | + </Storyboard> |
| 62 | + </VisualState> |
| 63 | + <VisualState x:Name="Pressed"> |
| 64 | + <Storyboard> |
| 65 | + <ColorAnimation Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="PaleGoldenrod"/> |
| 66 | + <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity" To="1"/> |
| 67 | + </Storyboard> |
| 68 | + </VisualState> |
| 69 | + </VisualStateGroup> |
| 70 | + <VisualStateGroup x:Name="FocusStates"> |
| 71 | + <VisualState x:Name="Focused"> |
| 72 | + <Storyboard> |
| 73 | + <DoubleAnimation Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity" To="1"/> |
| 74 | + </Storyboard> |
| 75 | + </VisualState> |
| 76 | + <VisualState x:Name="Unfocused" /> |
| 77 | + </VisualStateGroup> |
| 78 | + </VisualStateManager.VisualStateGroups> |
| 79 | + <Border x:Name="Background" CornerRadius="3" Background="White" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"> |
| 80 | + <Grid Background="{TemplateBinding Background}" Margin="1"> |
| 81 | + <Border Opacity="0" x:Name="BackgroundAnimation" Background="PaleGoldenrod" /> |
| 82 | + </Grid> |
| 83 | + </Border> |
| 84 | + <ContentPresenter |
| 85 | + x:Name="contentPresenter" |
| 86 | + Content="{TemplateBinding Content}" |
| 87 | + ContentTemplate="{TemplateBinding ContentTemplate}" |
| 88 | + VerticalAlignment="{TemplateBinding VerticalContentAlignment}" |
| 89 | + HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
| 90 | + Margin="{TemplateBinding Padding}"/> |
| 91 | + <Rectangle x:Name="DisabledVisualElement" RadiusX="3" RadiusY="3" Fill="#FFFFFFFF" Opacity="0" IsHitTestVisible="false" /> |
| 92 | + <Rectangle x:Name="FocusVisualElement" RadiusX="2" RadiusY="2" Margin="1" Stroke="PaleGoldenrod" StrokeThickness="1" Opacity="0" IsHitTestVisible="false" /> |
| 93 | + </Grid> |
| 94 | + </ControlTemplate> |
| 95 | + </Setter.Value> |
| 96 | + </Setter> |
| 97 | + </Style> |
| 98 | + </ResourceDictionary> |
| 99 | + </UserControl.Resources> |
| 100 | + |
| 101 | + <Grid UseLayoutRounding="True"> |
| 102 | + <Grid.RowDefinitions> |
| 103 | + <RowDefinition Height="30"/> |
| 104 | + <RowDefinition Height="20"/> |
| 105 | + <RowDefinition Height="*" MinHeight="64" /> |
| 106 | + </Grid.RowDefinitions> |
| 107 | + |
| 108 | + <ToolBarTray Grid.Row="0" IsLocked="True"> |
| 109 | + <ToolBar Style="{DynamicResource ToolBarWithOverflowOnlyShowingWhenNeededStyle}"> |
| 110 | + |
| 111 | + <Button Command="{Binding RefreshCommand}"> |
| 112 | + <Image Height="16" Source="../../Resources/arrow-circle-double.png"> |
| 113 | + <Image.Style> |
| 114 | + <Style TargetType="Image"> |
| 115 | + <Style.Triggers> |
| 116 | + <Trigger Property="IsEnabled" Value="False"> |
| 117 | + <Setter Property="Opacity" Value="0.3" /> |
| 118 | + </Trigger> |
| 119 | + </Style.Triggers> |
| 120 | + </Style> |
| 121 | + </Image.Style> |
| 122 | + </Image> |
| 123 | + <Button.ToolTip> |
| 124 | + <TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Refresh}" /> |
| 125 | + </Button.ToolTip> |
| 126 | + </Button> |
| 127 | + </ToolBar> |
| 128 | + </ToolBarTray> |
| 129 | + |
| 130 | + <Border Grid.Row="1" |
| 131 | + BorderBrush="{StaticResource {x:Static SystemColors.ControlBrushKey}}" |
| 132 | + BorderThickness="1"> |
| 133 | + <Grid> |
| 134 | + <TextBox x:Name="SearchBox" |
| 135 | + VerticalContentAlignment="Center" |
| 136 | + IsEnabled="{Binding CanSearch}" |
| 137 | + MinHeight="20" |
| 138 | + PreviewKeyDown="SearchBox_OnPreviewKeyDown" |
| 139 | + TextChanged="SearchBox_OnTextChanged" /> |
| 140 | + |
| 141 | + <Image Source="{StaticResource SearchImage}" |
| 142 | + HorizontalAlignment="Right" VerticalAlignment="Center" |
| 143 | + MaxHeight="16" Margin="0,0,1,0" |
| 144 | + IsEnabled="{Binding CanSearch}" |
| 145 | + Visibility="{Binding ElementName=SearchBox, Path=Text.Length, Converter={StaticResource StringHasValueToVisibility}}" |
| 146 | + MouseDown="SearchIcon_OnMouseDown" /> |
| 147 | + |
| 148 | + <Button Style="{StaticResource XButtonStyle}" |
| 149 | + HorizontalAlignment="Right" VerticalAlignment="Center" |
| 150 | + Height="18" Width="18" Margin="0,1,1,0" |
| 151 | + IsEnabled="{Binding CanSearch}" |
| 152 | + Visibility="{Binding ElementName=SearchBox, Path=Text.Length, Converter={StaticResource StringHasNoValueToVisibility}}" |
| 153 | + Click="ButtonBase_OnClick" /> |
| 154 | + </Grid> |
| 155 | + </Border> |
| 156 | + <controls:EmptyUIRefresh Grid.Row="2" /> |
| 157 | + |
| 158 | + <TreeView ItemsSource="{Binding ModuleMetrics}" Grid.Row="2" > |
| 159 | + <TreeView.ItemTemplate> |
| 160 | + <HierarchicalDataTemplate> |
| 161 | + <Grid> |
| 162 | + <TextBlock Grid.Column="0" Text="{Binding Path=ModuleName}"/> |
| 163 | + <TextBlock Grid.Column="1" Text="{Binding Path=Result.Lines}" /> |
| 164 | + <TextBlock Grid.Column="2" Text="{Binding Path=Result.CyclomaticComplexity}" /> |
| 165 | + <TextBlock Grid.Column="3" Text="{Binding Path=Result.MaximumNesting}" /> |
| 166 | + </Grid> |
| 167 | + <HierarchicalDataTemplate.ItemTemplate ItemsSource="{Binding MemberResults}"> |
| 168 | + <DataTemplate> |
| 169 | + <Grid> |
| 170 | + <TextBlock Grid.Column="0" Text="{Binding Path=Key}"/> |
| 171 | + <TextBlock Grid.Column="1" Text="{Binding Path=Value.Lines}" /> |
| 172 | + <TextBlock Grid.Column="2" Text="{Binding Path=Value.CyclomaticComplexity}" /> |
| 173 | + <TextBlock Grid.Column="3" Text="{Binding Path=Value.MaximumNesting}" /> |
| 174 | + </Grid> |
| 175 | + </DataTemplate> |
| 176 | + </HierarchicalDataTemplate.ItemTemplate> |
| 177 | + </HierarchicalDataTemplate> |
| 178 | + </TreeView.ItemTemplate> |
| 179 | + </TreeView> |
| 180 | + <controls:BusyIndicator Grid.Row="2" Width="120" Height="120" Visibility="{Binding IsBusy, Converter={StaticResource BoolToVisibility}}" /> |
| 181 | + </Grid> |
| 182 | +</UserControl> |
0 commit comments