Click here to Skip to main content
15,893,487 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.3K   1.8K   132  
Comic and electronic publication reader with library management, extended file conversion, and devices support.
<UserControl x:Class="CBR.Views.HomeView"
             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:Controls="clr-namespace:CBR.Components.Controls"
             xmlns:Converters="clr-namespace:CBR.Components.Converters"
             xmlns:model="clr-namespace:CBR.ViewModels"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="600" Loaded="UserControl_Loaded">
    
    <UserControl.Resources>

        <Style x:Key="WhiteLabel" TargetType="{x:Type Label}">
            <Setter Property="Foreground" Value="White" />
        </Style>

        <Style x:Key="HeadlineSeparator" TargetType="{x:Type Line}">
            <Setter Property="SnapsToDevicePixels" Value="true" />
            <Setter Property="StrokeDashArray" Value="8 8" />
            <Setter Property="Stretch" Value="Fill" />
            <Setter Property="Stroke" Value="#FF666666" />
            <Setter Property="Margin" Value="40,2,40,-2" />
        </Style>
        
        <DataTemplate x:Key="HeadlineTemplate" DataType="{x:Type model:Headline}">
            <Grid Margin="2" Cursor="Hand">
                <Border x:Name="border" Background="#FF3D3D3D" />
                <StackPanel Margin="3" >
                    <StackPanel Orientation="Horizontal">
                        <Image Width="32" Source="{Binding Path=ImageUri}" />
                        <TextBlock VerticalAlignment="Center" FontWeight="Bold" TextTrimming="WordEllipsis" Foreground="Black"
                                    Text="{Binding Title}" />
                    </StackPanel>
                    <TextBlock FontStyle="Italic" TextTrimming="None" TextWrapping="WrapWithOverflow"
                                Text="{Binding Description}" />
                </StackPanel>
                <Line Style="{StaticResource HeadlineSeparator}" X1="0" X2="1" VerticalAlignment="Bottom" />
            </Grid>
            <DataTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" TargetName="border" Value="#FF525252"/>
                </Trigger>
            </DataTemplate.Triggers>
        </DataTemplate>

        <Style TargetType="{x:Type ItemsControl}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ItemsControl}">
                            <ScrollViewer VerticalScrollBarVisibility="Auto">
                                <ItemsPresenter />
                            </ScrollViewer>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </UserControl.Resources>
    
    <Grid Background="#FF3D3D3D">
        <Grid.RowDefinitions>
            <RowDefinition Height="90" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Border Grid.ColumnSpan="3" Margin="5" BorderThickness="2" BorderBrush="Black" Visibility="Collapsed" >
                <Border.Background>
                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                        <GradientStop Color="#FFB7B7B7" Offset="0" />
                        <GradientStop Color="#FFD8D8D8" Offset="1" />
                        <GradientStop Color="#70E8E8E8" Offset="0.488" />
                    </LinearGradientBrush>
                </Border.Background>
            </Border>
            <Image Source="/CBR;component/Resources/Images/book.ico" Margin="10" />
            <StackPanel Grid.Column="1" Orientation="Vertical">
                <Label Content="Comic Book Reader" HorizontalAlignment="Left" Margin="5,5,0,0" FontSize="20" FontWeight="ExtraBold" Foreground="White" />
                <Label HorizontalAlignment="Left" Margin="5,0,0,5" Foreground="White"
                       Content="{LocalizationExtension ResModul=CBR, Key=HomeView.LblSlogan, DefaultValue=The new standard to manage and read your eBooks !}" />
            </StackPanel>
        </Grid>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="2*" />
            </Grid.ColumnDefinitions>

            <StackPanel Grid.Column="0" Margin="10">
                <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5"
                       Text="{LocalizationExtension ResModul=CBR, Key=HomeView.LblActions, DefaultValue=Quick Actions}" Foreground="White"></TextBlock>
                <Line Style="{StaticResource DashedSeparator}" X1="0" X2="1" />
                <ItemsControl Margin="0,15,0,0">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Vertical" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <Button Style="{DynamicResource CBRButtonStyle}" Command="{Binding ForwardCommand}" CommandParameter="CatalogNewCommand" >
                        <DockPanel Margin="10">
                            <Image Source="/CBR;component/Resources/Images/32x32/library_new.png" Width="32"></Image>
                            <Label VerticalAlignment="Center"
                                   Content="{LocalizationExtension ResModul=CBR, Key=HomeView.LblActionNew, DefaultValue=Start a new library}" />
                        </DockPanel>
                    </Button>
                    <Button Style="{DynamicResource CBRButtonStyle}" Command="{Binding ForwardCommand}" CommandParameter="BookOpenCommand" >
                        <DockPanel Margin="10">
                            <Image Source="/CBR;component/Resources/Images/32x32/book_read.png" Width="32"></Image>
                            <Label VerticalAlignment="Center"
                                   Content="{LocalizationExtension ResModul=CBR, Key=HomeView.LblActionRead, DefaultValue=Read a book}" />
                        </DockPanel>
                    </Button>
                    <Button Style="{DynamicResource CBRButtonStyle}" Command="{Binding ForwardCommand}" CommandParameter="SysHelpCommand">
                        <DockPanel Margin="10">
                            <Image Source="/CBR;component/Resources/Images/32x32/help.png" Width="32"></Image>
                            <Label VerticalAlignment="Center"
                                   Content ="{LocalizationExtension ResModul=CBR, Key=HomeView.LblActionHelp, DefaultValue=Find online help}" />
                        </DockPanel>
                    </Button>
                </ItemsControl>
            </StackPanel>

            <Line Grid.Column="1" X1="0" Y2="1" Style="{StaticResource VerticalSeparator}" />

            <Grid Grid.Column="2" Margin="10">
                <StackPanel>
                <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5" Foreground="White"
                       Text="{LocalizationExtension ResModul=CBR, Key=HomeView.LblRssFeed, DefaultValue=Headlines}" />
                <Line Style="{StaticResource DashedSeparator}" X1="0" X2="1" />
                </StackPanel>
                <Grid Margin="0,50,0,0">
                    <ItemsControl Name="RssViewer" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0" Background="#00000000"
                             Visibility="{Binding HasError, Converter={x:Static Converters:BoolToVisibilityConverter.Instance}, ConverterParameter=false}"
                             ItemsSource="{Binding ItemsSource}" ItemTemplate="{StaticResource HeadlineTemplate}">
                        <ItemsControl.ItemContainerStyle>
                            <Style TargetType="{x:Type ContentPresenter}">
                                <EventSetter Event="MouseUp" Handler="ListBoxItem_MouseUp"/>
                            </Style>
                        </ItemsControl.ItemContainerStyle>

                    </ItemsControl>
                    
                    <Image Visibility="{Binding HasError, Converter={x:Static Converters:BoolToVisibilityConverter.Instance}, ConverterParameter=true}" 
                           Source="/CBR;component/Resources/Images/32x32/forbidden.png" Stretch="None" />
                    <Controls:WaitSpin x:Name="WaitPanel" AutoPlay="False" Play="{Binding IsLoading}" Elem="{Binding ElementName=RssViewer}"/>
                </Grid>
            </Grid>

        </Grid>
		
		<Line Grid.Row="2" Style="{StaticResource DashedSeparator}" X1="0" X2="1" VerticalAlignment="Top" />
		
		<WrapPanel Grid.Row="2">
            <Label Style="{StaticResource WhiteLabel}"
                   Content="{LocalizationExtension ResModul=CBR, Key=HomeView.LblAuthor, DefaultValue=Author:}" />
            <Label Style="{StaticResource WhiteLabel}">G.Waser</Label>
            <Label Style="{StaticResource WhiteLabel}"
                   Content="{LocalizationExtension ResModul=CBR, Key=HomeView.LblCopyRight, DefaultValue=- Copyright:}" />
            <Label Style="{StaticResource WhiteLabel}">2011</Label>
            <Label Style="{StaticResource WhiteLabel}"
                   Content="{LocalizationExtension ResModul=CBR, Key=HomeView.LblVersion, DefaultValue=- Version:}" />
            <Label Style="{StaticResource WhiteLabel}" Content="{Binding ApplicationVersion}" />
            <Label Style="{StaticResource WhiteLabel}"
                   Content="{LocalizationExtension ResModul=CBR, Key=HomeView.LblWebSite, DefaultValue=- Web site:}" />
            <Label Style="{StaticResource WhiteLabel}">
                <Hyperlink NavigateUri="http://wfpbookreader.codeplex.com/" RequestNavigate="Hyperlink_RequestNavigate">Codeplex</Hyperlink>
            </Label>
        </WrapPanel>
    </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