|
| 1 | +<UserControl x:Class="Rubberduck.UI.CodeExplorer.CodeExplorerControl" |
| 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:explorer="clr-namespace:Rubberduck.UI.CodeExplorer" |
| 7 | + xmlns:resx="clr-namespace:Rubberduck.UI" |
| 8 | + xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" |
| 9 | + mc:Ignorable="d" |
| 10 | + d:DesignHeight="300" d:DesignWidth="300"> |
| 11 | + <UserControl.Resources> |
| 12 | + |
| 13 | + <BooleanToVisibilityConverter x:Key="BoolToVisibility"/> |
| 14 | + |
| 15 | + <Style x:Key="LinkButton" TargetType="Button" BasedOn="{StaticResource ResourceKey={x:Type Button}}"> |
| 16 | + |
| 17 | + <Setter Property="Width" Value="Auto"/> |
| 18 | + |
| 19 | + <Setter Property="Template"> |
| 20 | + <Setter.Value> |
| 21 | + <ControlTemplate TargetType="Button"> |
| 22 | + <ContentPresenter Content="{TemplateBinding Content}" |
| 23 | + ContentTemplate="{TemplateBinding ContentTemplate}" |
| 24 | + VerticalAlignment="Center"> |
| 25 | + <ContentPresenter.Resources> |
| 26 | + <Style TargetType="{x:Type TextBlock}"> |
| 27 | + <Setter Property="TextDecorations" Value="Underline" /> |
| 28 | + </Style> |
| 29 | + </ContentPresenter.Resources> |
| 30 | + </ContentPresenter> |
| 31 | + </ControlTemplate> |
| 32 | + </Setter.Value> |
| 33 | + </Setter> |
| 34 | + <Setter Property="Foreground" Value="Blue" /> |
| 35 | + <Setter Property="Cursor" Value="Hand" /> |
| 36 | + <Style.Triggers> |
| 37 | + <Trigger Property="IsMouseOver" Value="true"> |
| 38 | + <Setter Property="Foreground" Value="Red" /> |
| 39 | + </Trigger> |
| 40 | + <Trigger Property="IsEnabled" Value="false"> |
| 41 | + <Setter Property="Foreground" Value="Gray" /> |
| 42 | + </Trigger> |
| 43 | + </Style.Triggers> |
| 44 | + </Style> |
| 45 | + |
| 46 | + <LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" EndPoint="0,1" StartPoint="0,0"> |
| 47 | + <GradientStop Color="#FFD9F4FF" Offset="0"/> |
| 48 | + <GradientStop Color="#FF9BDDFB" Offset="1"/> |
| 49 | + </LinearGradientBrush> |
| 50 | + <LinearGradientBrush x:Key="{x:Static SystemColors.ControlBrushKey}" EndPoint="0,1" StartPoint="0,0"> |
| 51 | + <GradientStop Color="#FFEEEDED" Offset="0"/> |
| 52 | + <GradientStop Color="#FFDDDDDD" Offset="1"/> |
| 53 | + </LinearGradientBrush> |
| 54 | + <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" /> |
| 55 | + <SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="Black" /> |
| 56 | + |
| 57 | + <Style x:Key="ShinyTreeView" |
| 58 | + TargetType="{x:Type TreeViewItem}"> |
| 59 | + <Setter Property="BorderThickness" Value="1.5"/> |
| 60 | + <Style.Triggers> |
| 61 | + <Trigger Property="IsSelected" Value="True"> |
| 62 | + <Setter Property="BorderBrush" Value="#adc6e5"/> |
| 63 | + </Trigger> |
| 64 | + <MultiTrigger> |
| 65 | + <MultiTrigger.Conditions> |
| 66 | + <Condition Property="IsSelected" Value="True"/> |
| 67 | + <Condition Property="IsSelectionActive" Value="False"/> |
| 68 | + </MultiTrigger.Conditions> |
| 69 | + <Setter Property="BorderBrush" Value="LightGray"/> |
| 70 | + </MultiTrigger> |
| 71 | + </Style.Triggers> |
| 72 | + <Style.Resources> |
| 73 | + <Style TargetType="Border"> |
| 74 | + <Setter Property="CornerRadius" Value="2"/> |
| 75 | + </Style> |
| 76 | + </Style.Resources> |
| 77 | + </Style> |
| 78 | + |
| 79 | + <!--<explorer:InspectionSeverityImageSourceConverter x:Key="SeverityIconConverter" /> |
| 80 | + <explorer:InspectionImageSourceConverter x:Key="InspectionIconConverter" /> |
| 81 | + <explorer:InspectionDescriptionConverter x:Key="InspectionDescriptionConverter" />--> |
| 82 | + |
| 83 | + <Style x:Key="IconStyle" TargetType="Image"> |
| 84 | + <Setter Property="Height" Value="16" /> |
| 85 | + <Setter Property="Width" Value="16" /> |
| 86 | + <Setter Property="Margin" Value="4" /> |
| 87 | + </Style> |
| 88 | + |
| 89 | + <CollectionViewSource x:Key="InspectionTypeGroupViewSource" Source="{Binding Results}"> |
| 90 | + <CollectionViewSource.GroupDescriptions> |
| 91 | + <PropertyGroupDescription PropertyName="Inspection.InspectionType" /> |
| 92 | + <PropertyGroupDescription PropertyName="Inspection" /> |
| 93 | + </CollectionViewSource.GroupDescriptions> |
| 94 | + </CollectionViewSource> |
| 95 | + |
| 96 | + <CollectionViewSource x:Key="CodeModuleGroupViewSource" Source="{Binding Results}"> |
| 97 | + <CollectionViewSource.GroupDescriptions> |
| 98 | + <PropertyGroupDescription PropertyName="QualifiedSelection.QualifiedName" /> |
| 99 | + <PropertyGroupDescription PropertyName="Inspection" /> |
| 100 | + </CollectionViewSource.GroupDescriptions> |
| 101 | + </CollectionViewSource> |
| 102 | + |
| 103 | + <HierarchicalDataTemplate x:Key="InspectionGroupsTemplate" |
| 104 | + DataType="{x:Type CollectionViewGroup}" |
| 105 | + ItemsSource="{Binding Items}" |
| 106 | + ItemTemplate="{StaticResource InspectionResultTemplate}"> |
| 107 | + |
| 108 | + <StackPanel Orientation="Horizontal" Margin="2" HorizontalAlignment="Stretch"> |
| 109 | + <Image Style="{StaticResource IconStyle}" |
| 110 | + Source="{Binding Name, Converter={StaticResource InspectionIconConverter}}" |
| 111 | + VerticalAlignment="Center" /> |
| 112 | + <TextBlock Margin="4" |
| 113 | + VerticalAlignment="Center" |
| 114 | + Text="{Binding Name, Converter={StaticResource InspectionDescriptionConverter}}" |
| 115 | + TextWrapping="Wrap"/> |
| 116 | + <TextBlock Margin="0,4,4,4" |
| 117 | + VerticalAlignment="Center" |
| 118 | + Text="{Binding ItemCount, StringFormat=({0})}" |
| 119 | + TextWrapping="Wrap"/> |
| 120 | + </StackPanel> |
| 121 | + </HierarchicalDataTemplate> |
| 122 | + |
| 123 | + <HierarchicalDataTemplate x:Key="InspectionTypeGroupsTemplate" |
| 124 | + DataType="{x:Type CollectionViewGroup}" |
| 125 | + ItemsSource="{Binding Items}" |
| 126 | + ItemTemplate="{StaticResource InspectionGroupsTemplate}"> |
| 127 | + <StackPanel Orientation="Horizontal" Margin="2" HorizontalAlignment="Stretch"> |
| 128 | + <TextBlock VerticalAlignment="Center" |
| 129 | + Text="{Binding Name}" |
| 130 | + FontWeight="Bold" |
| 131 | + TextWrapping="Wrap"/> |
| 132 | + <TextBlock Margin="4,0,4,0" |
| 133 | + VerticalAlignment="Center" |
| 134 | + Text="{Binding ItemCount, StringFormat=({0})}" |
| 135 | + TextWrapping="Wrap"/> |
| 136 | + </StackPanel> |
| 137 | + </HierarchicalDataTemplate> |
| 138 | + |
| 139 | + <HierarchicalDataTemplate x:Key="CodeModuleGroupsTemplate" |
| 140 | + DataType="{x:Type CollectionViewGroup}" |
| 141 | + ItemsSource="{Binding Items}" |
| 142 | + ItemTemplate="{StaticResource InspectionGroupsTemplate}"> |
| 143 | + |
| 144 | + <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch"> |
| 145 | + <Image Style="{StaticResource IconStyle}" Source="../../Resources/Microsoft/PNG/VSObject_Module.png" /> |
| 146 | + <TextBlock VerticalAlignment="Center" |
| 147 | + Text="{Binding Name}" |
| 148 | + FontWeight="Bold" |
| 149 | + TextWrapping="Wrap"/> |
| 150 | + <TextBlock Margin="4,0,4,0" |
| 151 | + VerticalAlignment="Center" |
| 152 | + Text="{Binding ItemCount, StringFormat=({0})}" |
| 153 | + TextWrapping="Wrap"/> |
| 154 | + </StackPanel> |
| 155 | + </HierarchicalDataTemplate> |
| 156 | + |
| 157 | + </UserControl.Resources> |
| 158 | + |
| 159 | + <Grid> |
| 160 | + <Grid.RowDefinitions> |
| 161 | + <RowDefinition Height="30"/> |
| 162 | + <RowDefinition Height="*" MinHeight="64" /> |
| 163 | + <RowDefinition Height="5"/> |
| 164 | + <RowDefinition Height="Auto" MinHeight="48"/> |
| 165 | + </Grid.RowDefinitions> |
| 166 | + |
| 167 | + <Border Grid.Row="0" Grid.RowSpan="3" Background="#FFEEF5FD" /> |
| 168 | + |
| 169 | + <ToolBar Grid.Row="0"> |
| 170 | + |
| 171 | + <Button Command="{Binding RefreshCommand}" IsEnabled="{Binding CanRefresh}"> |
| 172 | + <Image Height="16" Source="../../Resources/arrow-circle-double.png" /> |
| 173 | + </Button> |
| 174 | + |
| 175 | + <Separator /> |
| 176 | + |
| 177 | + |
| 178 | + <Button Command="{Binding ToggleSignatures}" |
| 179 | + IsEnabled="{Binding CanRefresh}" |
| 180 | + ToolTip="Toggle signatures"> |
| 181 | + <Image Height="16" Source="../../Resources/Microsoft/PNG/DisplayFullSignature_13393_32.png" /> |
| 182 | + </Button> |
| 183 | + |
| 184 | + <Button Command="{Binding ToggleNamespaces}" |
| 185 | + IsEnabled="{Binding CanRefresh}" |
| 186 | + ToolTip="Toggle namespace folders"> |
| 187 | + <Image Height="16" Source="../../Resources/blue-folder-horizontal-open.png" /> |
| 188 | + </Button> |
| 189 | + |
| 190 | + <Button Command="{Binding ToggleFolders}" |
| 191 | + IsEnabled="{Binding CanRefresh}" |
| 192 | + ToolTip="Toggle component type folders"> |
| 193 | + <Image Height="16" Source="../../Resources/folder-horizontal.png" /> |
| 194 | + </Button> |
| 195 | + |
| 196 | + <Separator /> |
| 197 | + |
| 198 | + <Label Content="{Binding ToolbarText}" /> |
| 199 | + |
| 200 | + </ToolBar> |
| 201 | + |
| 202 | + <!-- todo: implement item template --> |
| 203 | + <TreeView Grid.Row="1" x:Name="ExplorerTreeView" |
| 204 | + IsEnabled="{Binding CanRefresh}" |
| 205 | + ItemsSource="{Binding Source={StaticResource InspectionTypeGroupViewSource}, Path=Groups}" |
| 206 | + ItemTemplate="{StaticResource InspectionTypeGroupsTemplate}" |
| 207 | + ItemContainerStyle="{StaticResource ShinyTreeView}" |
| 208 | + HorizontalContentAlignment="Stretch" |
| 209 | + MouseDoubleClick="TreeView_OnMouseDoubleClick"> |
| 210 | + <i:Interaction.Behaviors> |
| 211 | + <resx:BindableSelectedItemBehavior SelectedItem="{Binding SelectedItem, Mode=TwoWay}" /> |
| 212 | + </i:Interaction.Behaviors> |
| 213 | + </TreeView> |
| 214 | + |
| 215 | + <resx:BusyIndicator Grid.Row="1" Width="36" Height="36" Visibility="{Binding IsBusy, Converter={StaticResource BoolToVisibility}}" /> |
| 216 | + |
| 217 | + <GridSplitter Grid.Row="2" Height="5" ShowsPreview="True" Cursor="SizeNS" HorizontalAlignment="Stretch"/> |
| 218 | + |
| 219 | + <Border Grid.Row="3" BorderThickness="0,1,0,0" BorderBrush="DimGray"> |
| 220 | + |
| 221 | + <Grid Background="Gainsboro"> |
| 222 | + |
| 223 | + <Grid.RowDefinitions> |
| 224 | + <RowDefinition Height="*" /> |
| 225 | + <RowDefinition Height="Auto" /> |
| 226 | + </Grid.RowDefinitions> |
| 227 | + |
| 228 | + <StackPanel Orientation="Vertical"> |
| 229 | + <StackPanel Orientation="Horizontal" |
| 230 | + HorizontalAlignment="Stretch"> |
| 231 | + |
| 232 | + <!-- todo: implement converter for SelectedItem.DeclarationType --> |
| 233 | + <Image Style="{StaticResource IconStyle}" |
| 234 | + Source="{Binding SelectedItem.DeclarationType}" |
| 235 | + VerticalAlignment="Center" /> |
| 236 | + |
| 237 | + <TextBlock Margin="4" Text="{Binding SelectedItem.IdentifierName}" |
| 238 | + FontWeight="Bold" TextWrapping="Wrap" /> |
| 239 | + |
| 240 | + </StackPanel> |
| 241 | + |
| 242 | + <TextBlock Margin="8,0,8,0" Text="{Binding SelectedItem.SummaryComment}" |
| 243 | + TextWrapping="Wrap" |
| 244 | + Visibility="{Binding HasSummaryComment, Converter={StaticResource BoolToVisibility}}" /> |
| 245 | + |
| 246 | + <TextBlock Margin="8,0,8,0" Text="{Binding SelectedItem.QualifiedSelection}" |
| 247 | + TextWrapping="Wrap" FontSize="8" |
| 248 | + Visibility="{Binding HasQualifiedSelection, Converter={StaticResource BoolToVisibility}}" /> |
| 249 | + </StackPanel> |
| 250 | + |
| 251 | + <WrapPanel Grid.ColumnSpan="2" Grid.Column="0" Grid.Row="1"> |
| 252 | + <Button Style="{StaticResource LinkButton}" Margin="4" |
| 253 | + Visibility="{Binding CanExecuteIndenterCommand, Converter={StaticResource BoolToVisibility}}" |
| 254 | + Command="{Binding IndenterCommand}" |
| 255 | + Content="Indent" /> |
| 256 | + <Button Style="{StaticResource LinkButton}" Margin="4" |
| 257 | + Visibility="{Binding CanExecuteRefactorRename, Converter={StaticResource BoolToVisibility}}" |
| 258 | + Command="{Binding RefactorRenameCommand}" |
| 259 | + Content="{x:Static resx:RubberduckUI.RefactorMenu_Rename}" /> |
| 260 | + <Button Style="{StaticResource LinkButton}" Margin="4" |
| 261 | + Visibility="{Binding CanExecuteFindAllReferences, Converter={StaticResource BoolToVisibility}}" |
| 262 | + Command="{Binding FindAllReferencesCommand}" |
| 263 | + Content="{x:Static resx:RubberduckUI.ContextMenu_FindAllReferences}" /> |
| 264 | + </WrapPanel> |
| 265 | + </Grid> |
| 266 | + </Border> |
| 267 | + |
| 268 | + </Grid> |
| 269 | +</UserControl> |
0 commit comments