Click here to Skip to main content
15,885,875 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 124.2K   1.8K   132  
Comic and electronic publication reader with library management, extended file conversion, and devices support.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
                    xmlns:Views="clr-namespace:CBR.Views"
                    xmlns:ViewModels="clr-namespace:CBR.ViewModels"
                    >
    <ResourceDictionary.MergedDictionaries>

        <ResourceDictionary Source="/CBR;Component/Resources/XAML/Controls/MagnifyGlass.xaml" />
        <ResourceDictionary Source="/CBR;Component/Resources/XAML/Controls/PageControl.xaml" />
        <ResourceDictionary Source="/CBR;Component/Resources/XAML/Controls/SplitterExpander.xaml" />
        <ResourceDictionary Source="/CBR;Component/Resources/XAML/Controls/RatingControl.xaml" />
        <ResourceDictionary Source="/CBR;Component/Resources/XAML/Controls/Buttons.xaml" />

        <ResourceDictionary Source="/CBR;Component/Resources/XAML/Controls/DesignerItem.xaml" />
        <ResourceDictionary Source="/CBR;Component/Resources/XAML/Controls/ResizeChrome.xaml" />

    </ResourceDictionary.MergedDictionaries>

    <!-- ################################################################################# -->
    <!--  LIST + ITEM STYLES -->

    <ControlTemplate x:Key="CBRListItemTemplate" TargetType="{x:Type ListBoxItem}">
        <Border x:Name="border" BorderThickness="1" CornerRadius="2" Background="{DynamicResource TransparentBrush}" BorderBrush="{DynamicResource TransparentBrush}" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <Border x:Name="border1" Height="Auto" BorderBrush="{DynamicResource TransparentBrush}" BorderThickness="1" CornerRadius="2" Background="{DynamicResource TransparentBrush}">
                <Grid Height="Auto">
                    <Rectangle x:Name="rectangle" StrokeThickness="0" Visibility="Collapsed">
                        <Rectangle.Fill>
                            <RadialGradientBrush Center="0.503,1" GradientOrigin="0.503,1" RadiusY="0.202">
                                <GradientStop Color="#7FFFFFFF" Offset="0"/>
                                <GradientStop Offset="1"/>
                            </RadialGradientBrush>
                        </Rectangle.Fill>
                    </Rectangle>
                    <StackPanel x:Name="stackPanel" Width="Auto" Orientation="Horizontal">
                        <ContentPresenter x:Name="content" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}" 
                                          SnapsToDevicePixels="True">
                        </ContentPresenter>
                    </StackPanel>
                </Grid>
            </Border>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" TargetName="content" Value="0.5"/>
                <Setter Property="Effect" TargetName="content">
                    <Setter.Value>
                        <Fluent:GrayscaleEffect/>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True"/>
                    <Condition Property="IsEnabled" Value="True"/>
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}"/>
                <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}"/>
                <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonHoverOuterBackgroundBrush}"/>
                <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
                <Setter Property="Visibility" TargetName="rectangle" Value="Visible"/>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="True"/>
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}"/>
                <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}"/>
                <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonHoverOuterBackgroundBrush}"/>
                <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="CBRListItemStyle" TargetType="{x:Type ListBoxItem}">
        <Setter Property="Template" Value="{StaticResource CBRListItemTemplate}"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Foreground" Value="{DynamicResource DefaultFontBrush}"/>
        <Setter Property="FocusVisualStyle" Value="{DynamicResource ControlStyleEmptyFocus}"/>
        <Setter Property="SnapsToDevicePixels" Value="False"/>
    </Style>

    <!-- ################################################################################# -->
    <!--  BACKSTAGE STYLES -->
    
    <Style x:Key="TitleLabel" TargetType="{x:Type TextBlock}">
        <Setter Property="FontWeight" Value="ExtraBold" />
        <Setter Property="FontSize" Value="18" />
        <Setter Property="Foreground" Value="Black" />
    </Style>

    <Style x:Key="SubTitleLabel" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource TitleLabel}">
        <Setter Property="FontSize" Value="16" />
        <Setter Property="FontStyle" Value="Italic" />
    </Style>
    
    <Style x:Key="DashedSeparator" TargetType="{x:Type Line}">
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="StrokeDashArray" Value="2 4" />
        <Setter Property="Stretch" Value="Fill" />
        <Setter Property="Stroke" Value="#FF666666" />
        <Setter Property="Margin" Value="2" />
    </Style>

    <Style x:Key="VerticalSeparator" TargetType="{x:Type Line}">
        <Setter Property="StrokeThickness" Value="2" />
        <Setter Property="Stretch" Value="Fill" />
        <Setter Property="Stroke">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFD1D1D1" Offset="0" />
                    <GradientStop Color="#FF555555" Offset="0.512" />
                    <GradientStop Color="#FFD1D1D1" Offset="1" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ################################################################################# -->
    <!--  DOCUMENTS DATA TEMPLATES -->
    
    <!--  This template applies a cbr/cbz document in the main window -->
    <DataTemplate DataType="{x:Type ViewModels:ComicViewModel}">
        <Views:BookView />
    </DataTemplate>

    <!-- This template applies an xps document in the main window -->
    <DataTemplate DataType="{x:Type ViewModels:XpsBookViewModel}">
        <Views:XpsBookView />
    </DataTemplate>

    <!-- This template applies an epub document in the main window -->
    <DataTemplate DataType="{x:Type ViewModels:ePUBBookViewModel}">
        <Views:ePUBBookView />
    </DataTemplate>

    <!--  This template applies a cbr/cbz document in the main window -->
    <DataTemplate DataType="{x:Type ViewModels:USBDeviceViewModel}">
        <Views:USBDeviceView />
    </DataTemplate>

    <!-- This style configures the main content areas in the main window -->
    <Style x:Key="ContentViewStyle" TargetType="{x:Type ContentControl}">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContentControl}">
                    <Grid>
                        <ContentPresenter ContentSource="Content" ContentTemplate="{TemplateBinding ContentTemplate}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <DataTemplate x:Key="ContentViewTemplate">
        <TabControl IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" BorderThickness="0" Background="#FF3D3D3D">
            <TabControl.Resources>
                <Style TargetType="TabItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="TabItem">
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TabControl.Resources>
        </TabControl>
    </DataTemplate>

</ResourceDictionary>

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