Click here to Skip to main content
15,897,187 members
Articles / Desktop Programming / WPF

C.B.R.

Rate me:
Please Sign up or sign in to vote.
4.96/5 (52 votes)
22 Oct 2012GPL329 min read 125.8K   1.8K   132  
Comic and electronic publication reader with library management, extended file conversion, and devices support.
<UserControl x:Class="CBR.Views.ExplorerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:se="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
             mc:Ignorable="d"
             xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
             xmlns:Converters="clr-namespace:CBR.Components.Converters"
             xmlns:Controls="clr-namespace:CBR.Components.Controls"
             xmlns:Models="clr-namespace:CBR.Core.Models;assembly=CBR.Core"
             xmlns:Views="clr-namespace:CBR.Views"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>

        <!-- group expander style -->
        <Style x:Key="ExpanderGroupContainerStyle"  TargetType="Expander">
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="Foreground" Value="{DynamicResource DefaultFontBrush}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Expander">
                        <Grid Margin="2" HorizontalAlignment="Stretch">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Name="ContentRow" Height="0"/>
                            </Grid.RowDefinitions>
                            
                            <ToggleButton IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
                                      OverridesDefaultStyle="True">
                                <ToggleButton.Template>
                                    <ControlTemplate TargetType="ToggleButton">
                                        <Grid Background="Transparent" HorizontalAlignment="Stretch">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="*" />
                                            </Grid.ColumnDefinitions>
                                            <Path Width="12" Height="12" x:Name="ExpandPath" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="1"
                                                  Fill="{DynamicResource DefaultFontBrush}" Data="M 4 0 L 8 4 L 4 8 Z"/>
                                            <ContentPresenter Grid.Column="1" VerticalAlignment="Center" />
                                        </Grid>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsChecked" Value="True">
                                                <Setter Property="LayoutTransform" TargetName="ExpandPath">
                                                    <Setter.Value>
                                                        <RotateTransform Angle="-90"></RotateTransform>
                                                    </Setter.Value>
                                                </Setter>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </ToggleButton.Template>
                                
                                <Border Name="Content" Grid.Row="1" Background="{DynamicResource ButtonBorderBrush}"
                                        BorderBrush="{DynamicResource ButtonBorderBrush}" BorderThickness="1,0,1,1" CornerRadius="5" >
                                    <ContentPresenter Margin="4" ContentSource="Header" RecognizesAccessKey="True" />
                                </Border>    
                            </ToggleButton>
                            
                            <ContentPresenter Grid.Row="1" Margin="12,0,4,4" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="True">
                                <Setter TargetName="ContentRow" Property="Height" Value="{Binding ElementName=Content,Path=DesiredHeight}" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="AlphaGroupContainerStyle" TargetType="{x:Type GroupItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Expander Header="{Binding Name}" IsExpanded="True" Style="{StaticResource ExpanderGroupContainerStyle}">
                            <ItemsPresenter />
                        </Expander>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- TOOLTIP style and associated data template -->
        <Style x:Key="TransparentToolTipStyle" TargetType="{x:Type ToolTip}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToolTip}">
                        <Border >
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <DataTemplate x:Key="BookToolTipTemplate" DataType="{x:Type Models:Book}">
            <Grid >
                <Grid.Resources>
                    <Style TargetType="{x:Type TextBlock}" x:Key="TextBlockBase">
                        <Setter Property="Foreground" Value="Silver"/>
                    </Style>
                    <Style TargetType="{x:Type TextBlock}" x:Key="{x:Type TextBlock}" BasedOn="{StaticResource TextBlockBase}">
                    </Style>
                    <Style TargetType="{x:Type TextBlock}" x:Key="Data" BasedOn="{StaticResource TextBlockBase}">
                        <Setter Property="Foreground" Value="White"/>
                        <Setter Property="FontWeight" Value="Bold"/>
                    </Style>
                </Grid.Resources>
                <Border Padding="2,2,2,2" CornerRadius="8" BorderBrush="#40000000" BorderThickness="2">
                    <Border CornerRadius="6" ClipToBounds="True" Padding="6,6,6,6">
                        <Border.Background>
                            <LinearGradientBrush EndPoint="0.75,0.319" StartPoint="0.213,0.672">
                                <GradientStop Color="#99000000"/>
                                <GradientStop Color="#EA000000" Offset="1"/>
                            </LinearGradientBrush>
                        </Border.Background>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="80"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Path=FileName}" FontSize="14" DockPanel.Dock="Left" Style="{StaticResource Data}" />
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=FilePath}" />
                            <Image Grid.Column="0" Grid.RowSpan="3" Source="{Binding Path=Cover}" Width="70"/>
                            <Grid Grid.Column="1" Grid.Row="2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="12" />
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <TextBlock Grid.Column="0" Grid.Row="0" Text="File size:" />
                                <TextBlock Grid.Column="2" Grid.Row="0" Text="{Binding Path=Size}"  Style="{StaticResource Data}"/>
                                <TextBlock Grid.Column="0" Grid.Row="1" Text="Page count:" />
                                <TextBlock Grid.Column="2" Grid.Row="1" Text="{Binding Path=PageCount}"  Style="{StaticResource Data}"/>
                            </Grid>
                        </Grid>
                    </Border>
                </Border>
            </Grid>
        </DataTemplate>

        <!--  style for menu items in sort/group dropdown buttons -->
        <Style x:Key="PropertyViewModel">
            <Setter Property="MenuItem.Header" Value="{Binding ToDisplay}"/>
            <Setter Property="MenuItem.Command" Value="{Binding GenericCommand}" />
            <Setter Property="MenuItem.IsCheckable" Value="true" />
        </Style>

        <Style x:Key="GroupMenuItemStyle" BasedOn="{StaticResource PropertyViewModel}" >
            <Setter Property="MenuItem.CommandParameter" Value="group" />
        </Style>

        <Style x:Key="SortMenuItemStyle" BasedOn="{StaticResource PropertyViewModel}" >
            <Setter Property="MenuItem.CommandParameter" Value="sort" />
        </Style>

        <!--  view for explorer -->
        <DataTemplate x:Key="Image">
            <DockPanel>
                <Image Width="16" Source="/CBR;component/Resources/Images/16x16/sort_alpha.png" Stretch="None"></Image>
            </DockPanel>
        </DataTemplate>
        
        <GridView x:Key="ExplorerGridView">
            <GridView.Columns>
                <GridViewColumn Header="File" DisplayMemberBinding="{Binding Path=FileName}" />
                <GridViewColumn Header="Size" DisplayMemberBinding="{Binding Path=Size}" />
                <GridViewColumn Header="Pages" DisplayMemberBinding="{Binding Path=PageCount}" />
                
                <GridViewColumn Header="Rating">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Controls:RatingControl Grid.Row="1" HorizontalAlignment="Center" Height="15" RatingValue="{Binding Rating}" IsEnabled="False" />
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>

                <GridViewColumn>
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Image Width="24" Height="24" VerticalAlignment="Center" HorizontalAlignment="Center"
                             Source="/CBR;component/Resources/Images/32x32/push_pin.png"
                             Visibility="{Binding Bookmark, Converter={x:Static Converters:BookmarkToVisibilityConverter.Instance}, ConverterParameter=true}"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>

                <GridViewColumn Width="34">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Image Width="22" Height="22" VerticalAlignment="Center" HorizontalAlignment="Center"
                             Source="/CBR;component/Resources/Images/32x32/is_read.png"
                             Visibility="{Binding IsRead, Converter={x:Static Converters:BoolToVisibilityConverter.Instance}, ConverterParameter=true}"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
                
                <GridViewColumn Width="34">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Image Width="24" Height="24" VerticalAlignment="Center" HorizontalAlignment="Center"
                             Source="/CBR;component/Resources/Images/32x32/lock.png"
                             Visibility="{Binding IsSecured, Converter={x:Static Converters:BoolToVisibilityConverter.Instance}, ConverterParameter=true}"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>

                <GridViewColumn Width="34">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Image Width="24" Height="24" VerticalAlignment="Center" HorizontalAlignment="Center"
                            Source="{Binding Path=Type, Converter={x:Static Converters:TypeToImageConverter.Instance}}" />
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>

            </GridView.Columns>
        </GridView>

        <Style x:Key="GridViewColumnHeaderGripper" TargetType="Thumb">
            <Setter Property="Width" Value="18"/>
            <Setter Property="Background" Value="#2e566b"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <Border Padding="{TemplateBinding Padding}" Background="Transparent">
                            <Rectangle HorizontalAlignment="Center" Width="1" Fill="{TemplateBinding Background}"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="{x:Type GridViewColumnHeader}" TargetType="GridViewColumnHeader">
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Foreground" Value="{DynamicResource DefaultFontBrush}" />
            <Setter Property="Padding" Value="4"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="GridViewColumnHeader">
                        <Grid>
                            <Border Name="HeaderBorder" Padding="{TemplateBinding Padding}" BorderThickness="0,1,0,1"
                                 Background="{DynamicResource ButtonBackgroundBrush}"   >
                                <ContentPresenter Name="HeaderContent" Margin="0,0,0,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </Border>
                            <Thumb x:Name="PART_HeaderGripper" HorizontalAlignment="Right" Margin="0,0,-9,0"
                                   Style="{StaticResource GridViewColumnHeaderGripper}"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter TargetName="HeaderBorder" Property="Background" Value="{StaticResource ButtonHoverInnerBackgroundBrush}"/>
                                <Setter TargetName="HeaderContent" Property="TextElement.Foreground" Value="Black"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <Setter TargetName="HeaderBorder" Property="Background" Value="{StaticResource ButtonPressedInnerBorderBrush}"/>
                                <Setter TargetName="HeaderContent" Property="Margin" Value="1,1,0,0"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="Role" Value="Floating">
                    <Setter Property="Opacity" Value="0.7"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="GridViewColumnHeader">
                                <Canvas Name="PART_FloatingHeaderCanvas">
                                    <Rectangle Fill="#60000000" Width="{TemplateBinding ActualWidth}"
                                               Height="{TemplateBinding ActualHeight}"/>
                                </Canvas>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <!--<Trigger Property="Role" Value="Padding">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="GridViewColumnHeader">
                                <Border Name="HeaderBorder" BorderThickness="0,1,0,1" BorderBrush="{StaticResource BorderBrush}"
                                        Background="{StaticResource BackgroundBrush}"/>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>-->
            </Style.Triggers>
        </Style>

        <DataTemplate x:Key="HeaderTemplateArrowUp">
            <DockPanel>
                <TextBlock HorizontalAlignment="Center" Text="{Binding}"/>
                <Path x:Name="arrow" StrokeThickness = "1" Fill= "gray"
                    Data = "M 5,10 L 15,10 L 10,5 L 5,10"/>
            </DockPanel>
        </DataTemplate>

        <DataTemplate x:Key="HeaderTemplateArrowDown">
            <DockPanel>
                <TextBlock HorizontalAlignment="Center" Text="{Binding }"/>
                <Path x:Name="arrow" StrokeThickness = "1" Fill = "gray"
                    Data = "M 5,5 L 10,10 L 15,5 L 5,5"/>
            </DockPanel>
        </DataTemplate>

        <Style x:Key="TextBlockItemStyle" >
            <Setter Property="TextBlock.TextTrimming" Value="CharacterEllipsis" />
            <Setter Property="TextBlock.VerticalAlignment" Value="Center" />
        </Style>
        
        <DataTemplate x:Key="ImageDetailTemplate">
            <Grid x:Name="MainItemGrid" Margin="4">
            	<Grid.ColumnDefinitions>
                	<ColumnDefinition Width="80"/>
                	<ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
				<Grid>
	                <Grid.RowDefinitions>
	                    <RowDefinition Height="0.9*"/>
	                    <RowDefinition Height="0.1*"/>
	                </Grid.RowDefinitions>
	                <Border x:Name="BorderStatus" Width="72" BorderThickness="3" CornerRadius="5" BorderBrush="Black">
	                    <Image x:Name="CoverImage" Width="70" Source="{Binding Path=Cover}" />
	                </Border>
	                <Controls:RatingControl Grid.Row="1" HorizontalAlignment="Center" Height="15" RatingValue="{Binding Rating}" />
				</Grid>
				<Grid Grid.Column="1" Grid.Row="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
					    <RowDefinition />
					    <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.ColumnSpan="4" Text="{Binding Path=FileName}" FontWeight="Bold" Style="{StaticResource TextBlockItemStyle}" />
                    <TextBlock Grid.ColumnSpan="4" Grid.Row="1" Text="{Binding Path=Folder}" Style="{StaticResource TextBlockItemStyle}" />
                    <TextBlock Grid.Column="0" Grid.Row="2" Text="Size" Style="{StaticResource TextBlockItemStyle}" />
                    <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding Path=Size}" Style="{StaticResource TextBlockItemStyle}" />
                    <Image Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2" Width="24" Height="24"
                        Source="/CBR;Component/Resources/Images/32x32/push_pin.png" 
                        Visibility="{Binding Path=Bookmark, Converter={x:Static Converters:BookmarkToVisibilityConverter.Instance}}" />
                    <TextBlock Grid.Column="0" Grid.Row="3" Text="Page(s)" Style="{StaticResource TextBlockItemStyle}" />
                    <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding Path=PageCount}" Style="{StaticResource TextBlockItemStyle}" />
                    <Image Grid.Column="2" Grid.Row="3" Grid.ColumnSpan="2" Width="24" Height="24"
	                    Source="{Binding Path=Type, Converter={x:Static Converters:TypeToImageConverter.Instance}}" />
                </Grid>
				<Grid.ToolTip>
                	<ToolTip Style="{DynamicResource TransparentToolTipStyle}">
                		<ContentControl Content="{Binding}" ContentTemplate="{StaticResource BookToolTipTemplate}"/>
                	</ToolTip>
                </Grid.ToolTip>
            </Grid>
            <DataTemplate.Triggers>
        		<DataTrigger Binding="{Binding IsSecured}" Value="True">
        			<Setter Property="Source" TargetName="CoverImage" Value="/CBR;component/Resources/Images/32x32/forbidden.png" />
                    <Setter Property="IsEnabled" TargetName="MainItemGrid" Value="False" />
        		</DataTrigger>
        		<DataTrigger Binding="{Binding IsRead}" Value="True">
        			<Setter TargetName="BorderStatus" Property="BorderBrush" Value="Red" />
        		</DataTrigger>
        	</DataTemplate.Triggers>
        </DataTemplate>
		
        <Controls:ThumbView x:Key="ExplorerImageDetailView" ItemTemplate="{StaticResource ImageDetailTemplate}" />

        <DataTemplate x:Key="ImageViewTemplate">
            <Grid x:Name="MainItemGrid" Margin="4">
                <Grid.RowDefinitions>
                    <RowDefinition Height="0.9*"/>
                    <RowDefinition Height="0.1*"/>
                </Grid.RowDefinitions>
                    <Grid>
                    <Border x:Name="BorderStatus" Width="72" BorderThickness="3" CornerRadius="5" BorderBrush="Black">
                        <Image x:Name="CoverImage" Width="70" Source="{Binding Path=Cover}" />
                    </Border>
                    <Image Source="/CBR;Component/Resources/Images/32x32/push_pin.png" Height="30" HorizontalAlignment="Right" VerticalAlignment="Top"
					        Visibility="{Binding Path=Bookmark, Converter={x:Static Converters:BookmarkToVisibilityConverter.Instance}}" Grid.RowSpan="2"></Image>
                        <Image Grid.RowSpan="2"  Width="32" Height="32" VerticalAlignment="Top" HorizontalAlignment="Left"
                            Source="{Binding Path=Type, Converter={x:Static Converters:TypeToImageConverter.Instance}}" />
                    </Grid>
                
                <Controls:RatingControl Grid.Row="1" HorizontalAlignment="Center" Height="15" RatingValue="{Binding Rating}" />
                
				<Grid.ToolTip>
                	<ToolTip Style="{DynamicResource TransparentToolTipStyle}">
                		<ContentControl Content="{Binding}" ContentTemplate="{StaticResource BookToolTipTemplate}"/>
                	</ToolTip>
                </Grid.ToolTip>
            </Grid>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding IsSecured}" Value="True">
                    <Setter Property="Source" TargetName="CoverImage" Value="/CBR;component/Resources/Images/32x32/forbidden.png" />
                    <Setter Property="IsEnabled" TargetName="MainItemGrid" Value="False" />
                </DataTrigger>
                <DataTrigger Binding="{Binding IsRead}" Value="True">
        			<Setter TargetName="BorderStatus" Property="BorderBrush" Value="Red" />
        		</DataTrigger>
        	</DataTemplate.Triggers>
        </DataTemplate>
		
        <Controls:ThumbView x:Key="ExplorerImageView" ItemTemplate="{StaticResource ImageViewTemplate}" />

        <!-- Style for an individual list view item -->

        <Style x:Key="ViewItemBase" TargetType="{x:Type ListViewItem}">
            <EventSetter Event="MouseDoubleClick" Handler="Item_MouseDoubleClick" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="Foreground" Value="{DynamicResource DefaultFontBrush}" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
        </Style>

        <Style x:Key="GridViewItemStyle" TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource ViewItemBase}" >
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}" >
                        <Border CornerRadius="4" SnapsToDevicePixels="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                            Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}">
                            <GridViewRowPresenter />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Background" Value="{DynamicResource ButtonPressedInnerBackgroundBrush}"/>
                                <Setter Property="BorderBrush" Value="{DynamicResource ButtonPressedOuterBorderBrush}"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}"/>
                                <Setter Property="BorderBrush" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="ThumbViewItemStyle" TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource ViewItemBase}" >
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}" >
                        <Border CornerRadius="4" SnapsToDevicePixels="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                            Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}">
                            <ContentPresenter />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Background" Value="{DynamicResource ButtonPressedInnerBackgroundBrush}"/>
                                <Setter Property="BorderBrush" Value="{DynamicResource ButtonPressedOuterBorderBrush}"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}"/>
                                <Setter Property="BorderBrush" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </UserControl.Resources>
    
    <Grid>
        <Grid >
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <DockPanel LastChildFill="True">

                <Fluent:DropDownButton Header="View" ToolTip="View mode" SizeDefinition="Small" Icon="/CBR;Component/Resources/Images/32x32/library_view.png"
                                       IsEnabled ="{Binding IsHeaderEnabled, Mode=OneWay}">

                    <Fluent:MenuItem Header="{LocalizationExtension ResModul=CBR, Key=ContextMenu.ExplorerView.ViewGrid, DefaultValue=Grid}"
                                         Command="{Binding ViewModeCommand}" CommandParameter="ExplorerGridView" 
                                         IsChecked="{Binding ElementName=CatalogListView, Path=DataContext.IsViewGrid, Mode=OneWay}"
                                         Icon="/CBR;Component/Resources/Images/16x16/view_details.png" IsCheckable="True" />

                    <Fluent:MenuItem Header="{LocalizationExtension ResModul=CBR, Key=ContextMenu.ExplorerView.ThumbnailSimple, DefaultValue=Thumbnail simple}"
                                         Command="{Binding ViewModeCommand}" CommandParameter="ExplorerImageView" 
                                         IsChecked="{Binding ElementName=CatalogListView, Path=DataContext.IsViewThumbSimple, Mode=OneWay}"
                                         Icon="/CBR;Component/Resources/Images/16x16/view_thumb.png" IsCheckable="True" />

                    <Fluent:MenuItem Header="{LocalizationExtension ResModul=CBR, Key=ContextMenu.ExplorerView.ThumbnailDetails, DefaultValue=Thumbnail details}"
                                         Command="{Binding ViewModeCommand}" CommandParameter="ExplorerImageDetailView" 
                                         IsChecked="{Binding ElementName=CatalogListView, Path=DataContext.IsViewThumbDetails, Mode=OneWay}"
                                         Icon="/CBR;Component/Resources/Images/16x16/view_thumb.png" IsCheckable="True" />

                </Fluent:DropDownButton>
                
                <Fluent:DropDownButton Header="Sort by" ToolTip="Sort by" SizeDefinition="Small" Icon="/CBR;Component/Resources/Images/16x16/sort_alpha.png"
                                       ItemsSource="{Binding SortProperties}" ItemContainerStyle="{StaticResource SortMenuItemStyle}"
                                       IsEnabled ="{Binding IsHeaderEnabled, Mode=OneWay}" />

                <Fluent:DropDownButton Header="Group by" ToolTip="Group by" SizeDefinition="Small" Icon="/CBR;Component/Resources/Images/16x16/sort_category.png"
                                       ItemsSource="{Binding GroupProperties}" ItemContainerStyle="{StaticResource GroupMenuItemStyle}"
                                       IsEnabled ="{Binding IsHeaderEnabled}" />

                <Controls:FilterControl Header="{LocalizationExtension ResModul=CBR, Key=Explorer.Filter, DefaultValue=Type your search here...}"
                                        Margin="4" FilterText="{Binding SearchedText, Mode=TwoWay}"
                                        IsEnabled ="{Binding IsHeaderEnabled}"  />
            </DockPanel>
            
            <ListView Grid.Row="1" BorderThickness="0" Background="#FF3D3D3D"
                      VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling"
                      HorizontalAlignment="Stretch" Margin="5" Name="CatalogListView" VerticalAlignment="Stretch" 
                      ItemsSource="{Binding Books}" SelectionMode="Single" IsSynchronizedWithCurrentItem="True"
                      GridViewColumnHeader.Click="CatalogListViewHeader_Click" >
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged" >
                        <se:CallMethodAction MethodName="NotifyColleagues" TargetObject="{Binding ElementName=CatalogListView, Path=DataContext}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <ListView.View>
                    <MultiBinding Converter="{x:Static Converters:StringToResourceConverter.Instance}">
                        <Binding RelativeSource="{RelativeSource Self}"/>
                        <Binding Path="CurrentViewMode" />
                    </MultiBinding>
                </ListView.View>
                <ListView.ItemContainerStyle>
                    <MultiBinding Converter="{x:Static Converters:StringToResourceConverter.Instance}">
                        <Binding RelativeSource="{RelativeSource Self}"/>
                        <Binding Path="CurrentItemStyle" />
                    </MultiBinding>
                </ListView.ItemContainerStyle>
                <ListView.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="{LocalizationExtension ResModul=CBR, Key=ContextMenu.ExplorerView.Read, DefaultValue=Read}"
                                  Command="{Binding ForwardCommand}" CommandParameter="BookReadCommand">
                            <MenuItem.Icon>
                                <Image Source="/CBR;component/Resources/Images/32x32/book_read.png" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem Header="{LocalizationExtension ResModul=CBR, Key=ContextMenu.ExplorerView.MarkRead, DefaultValue=Mark as (un)read}"
                                  Command="{Binding ForwardCommand}" CommandParameter="BookMarkAsReadCommand"/>
                        <Separator></Separator>

                        <MenuItem Header="{LocalizationExtension ResModul=CBR, Key=ContextMenu.ExplorerView.Protect, DefaultValue=Protect}"
                                  Command="{Binding ForwardCommand}" CommandParameter="BookProtectCommand">
                            <MenuItem.Icon>
                                <Image Source="/CBR;component/Resources/Images/32x32/book_protect.png" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem Header="{LocalizationExtension ResModul=CBR, Key=ContextMenu.ExplorerView.Remove, DefaultValue=Remove}"
                                  Command="{Binding ForwardCommand}" CommandParameter="BookRemoveCommand">
                            <MenuItem.Icon>
                                <Image Source="/CBR;component/Resources/Images/32x32/book_remove.png" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <Separator></Separator>
                        <MenuItem Header="{LocalizationExtension ResModul=CBR, Key=ContextMenu.ExplorerView.Delete, DefaultValue=Delete}"
                                  Command="{Binding ForwardCommand}" CommandParameter="BookDeleteCommand">
                            <MenuItem.Icon>
                                <Image Source="/CBR;component/Resources/Images/32x32/book_delete.png" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <Separator></Separator>
                        <MenuItem Header="{LocalizationExtension ResModul=CBR, Key=ContextMenu.ExplorerView.Properties, DefaultValue=Properties}"
                                  Command="{Binding ForwardCommand}" CommandParameter="BookPropertyCommand" />
                    </ContextMenu>
                </ListView.ContextMenu>
            </ListView>
        </Grid>
    </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 General Public License (GPLv3)


Written By
Architect
France France
WPF and MVVM fan, I practice C # in all its forms from the beginning of the NET Framework without mentioning C ++ / MFC and other software packages such as databases, ASP, WCF, Web & Windows services, Application, and now Core and UWP.
In my wasted hours, I am guilty of having fathered C.B.R. and its cousins C.B.R. for WinRT and UWP on the Windows store.
But apart from that, I am a great handyman ... the house, a rocket stove to heat the jacuzzi and the last one: a wood oven for pizza, bread, and everything that goes inside

https://guillaumewaser.wordpress.com/
https://fouretcompagnie.wordpress.com/

Comments and Discussions