Click here to Skip to main content
15,891,372 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.9K   1.8K   132  
Comic and electronic publication reader with library management, extended file conversion, and devices support.
<UserControl x:Class="CBR.Views.OptionsView"
             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" 
             mc:Ignorable="d"
             xmlns:Converters="clr-namespace:CBR.Components.Converters">

    <Grid Margin="15" HorizontalAlignment="Left" VerticalAlignment="Top">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="20" />
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="20" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <StackPanel Grid.ColumnSpan="5">
            <TextBlock Style="{StaticResource TitleLabel}" Margin="5">Application Settings</TextBlock>
            <Line Style="{StaticResource DashedSeparator}" X1="0" X2="1" />
        </StackPanel>
        
        <StackPanel Grid.Row="1" Orientation="Vertical" Margin="10">
            <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5">Images</TextBlock>
            <Label Margin="5" HorizontalAlignment="Stretch">Number of images in cache</Label>
            <DockPanel>
                <Label Margin="5" HorizontalAlignment="Stretch" Content="{Binding ElementName=sliderImageCache, Path=Value}"/>
                <Slider Margin="15,0,15,0" Name="sliderImageCache" VerticalAlignment="Center" Value="{Binding ImageCacheCount}"
                    SmallChange="1" LargeChange="1" Maximum="10" TickPlacement="Both" TickFrequency="1" IsSnapToTickEnabled="True" AutoToolTipPlacement="None"
                    ToolTip="From 0 to 10, How long the images stays in memory from his last acces"/>
            </DockPanel>
            <Label Margin="5" HorizontalAlignment="Stretch">Image duration (sec. after expiration) </Label>
            <DockPanel>
                <Label Margin="5" HorizontalAlignment="Stretch" Content="{Binding ElementName=sliderDurationCache, Path=Value}"/>
                <Slider Margin="15,0,15,0"  Name="sliderDurationCache" VerticalAlignment="Center"  Value="{Binding ImageCacheDuration}"
                    SmallChange="1" LargeChange="1" Maximum="10" TickPlacement="Both" TickFrequency="1" IsSnapToTickEnabled="True" AutoToolTipPlacement="None" ToolTip="From 0 to 10, How long the images stays in memory from his last acces"/>
            </DockPanel>

            <Line Style="{StaticResource DashedSeparator}" X1="0" X2="1" />

                <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5">Auto fit mode</TextBlock>
                <RadioButton GroupName="AutoFit" Margin="5" Name="rbNone"
                             IsChecked="{Binding Path=AutoFitMode, Converter={x:Static Converters:IntToRadioConverter.Instance}, ConverterParameter=0}">None : the images are displayed with the zoom factor</RadioButton>
                <RadioButton GroupName="AutoFit" Margin="5" Name="rbWidth"
                             IsChecked="{Binding Path=AutoFitMode, Converter={x:Static Converters:IntToRadioConverter.Instance}, ConverterParameter=1}">Width : each time an image is displayed, it is adjusted to fill in width</RadioButton>
                <RadioButton GroupName="AutoFit" Margin="5" Name="rbHeight"
                             IsChecked="{Binding Path=AutoFitMode, Converter={x:Static Converters:IntToRadioConverter.Instance}, ConverterParameter=2}">Height : each time an image is displayed, it is adjusted to fill in height</RadioButton>

            <Line Style="{StaticResource DashedSeparator}" X1="0" X2="1" />

            <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5">Magnifier</TextBlock>
            <Label Margin="5" HorizontalAlignment="Stretch">Size of the magnifier</Label>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Label Grid.Column="0" Margin="5" HorizontalAlignment="Stretch" Content="{Binding ElementName=sliderMagnifierSize, Path=Value }" ContentStringFormat="F1" Grid.ColumnSpan="2" />
                <Slider Grid.Column="1" Margin="15,0" Name="sliderMagnifierSize" VerticalAlignment="Center" Value="{Binding MagnifierSize}"
                        SmallChange="0.1" LargeChange="0.1" Minimum="0.5" Maximum="2" TickPlacement="Both" AutoToolTipPlacement="None"
                        ToolTip="The size of the magnifier, related to his original size" Grid.ColumnSpan="2" IsSnapToTickEnabled="True" TickFrequency="0.1" />
            </Grid>
            <Label Margin="5" HorizontalAlignment="Stretch">Scaling factor</Label>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Label Grid.Column="0" Margin="5" HorizontalAlignment="Stretch" Content="{Binding ElementName=sliderMagnifierScale, Path=Value, StringFormat=D}" Grid.ColumnSpan="2" />
                <Slider Grid.Column="1" Margin="15,0"  Name="sliderMagnifierScale" VerticalAlignment="Center" Value="{Binding MagnifierScaleFactor}"
                        SmallChange="10" LargeChange="30" Minimum="100" Maximum="300" TickPlacement="Both" AutoToolTipPlacement="None"
                        ToolTip="How much pixel (from the original image) in the magnifier view " Grid.ColumnSpan="2" IsSnapToTickEnabled="True" TickFrequency="10" />
            </Grid>

        </StackPanel>

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

        <StackPanel Grid.Column="2" Grid.Row="1" Orientation="Vertical" Margin="10">
            <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5">ePUB Viewer</TextBlock>
            <Label Margin="5" HorizontalAlignment="Stretch">ePUB files can be viewed in original format or in flow viewer</Label>
            <CheckBox Margin="5" >Yes, I prefer flow formatted viewer</CheckBox>
            <Line Style="{StaticResource DashedSeparator}" X1="0" X2="1" />
            
            <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5">Recent files</TextBlock>
            <Label Margin="5" HorizontalAlignment="Stretch">Number of recent book or library in the recent file list</Label>
            <DockPanel>
                <Label Margin="5" HorizontalAlignment="Stretch" Content="{Binding ElementName=sliderRecentFileMax, Path=Value}"/>
                <Slider Margin="15,0,15,0" Name="sliderRecentFileMax" VerticalAlignment="Center" Value="{Binding MaxRecentFile}"
                    SmallChange="2" LargeChange="1" Maximum="20" TickPlacement="Both" TickFrequency="2" IsSnapToTickEnabled="True" AutoToolTipPlacement="None"
                    Minimum="5" ToolTip="From 0 to 50, how long the files stays in list from his last acces"/>
            </DockPanel>
            <Line Style="{StaticResource DashedSeparator}" X1="0" X2="1" />

            <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5">Dynamic properties</TextBlock>
            <Label Margin="5" HorizontalAlignment="Stretch">Existing properties</Label>
            <StackPanel Margin="5">
                <ListBox ItemsSource="{Binding Dynamics}" Name="lbProperties" />
                <Button Margin="30,10,30,10" ToolTip="Delete an existing property and save the settings automatically" Content="Delete..."
                           Command="{Binding DeletePropertyCommand}" CommandParameter="{Binding ElementName=lbProperties, Path=SelectedValue}" />
            </StackPanel>
            <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5">Add new property</TextBlock>
                <StackPanel>
                    <Label Margin="5" HorizontalAlignment="Stretch">Property name</Label>
                    <TextBox Margin="30,0,30,0" ToolTip="Type the new property name here" Name="tbProperty"></TextBox>
                    <Button Margin="30,10,30,10" ToolTip="Add a new property and save the settings automatically" Content="Add..."
                           Command="{Binding AddPropertyCommand}" CommandParameter="{Binding ElementName=tbProperty, Path=Text}" />
                </StackPanel>
            <Line Style="{StaticResource DashedSeparator}" X1="0" X2="1" />

        </StackPanel>

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

        <StackPanel Grid.Row="1" Grid.Column="5" Orientation="Vertical" Margin="10" >
            <Button Width="80" Height="80" Margin="10" ToolTip="Save the settings" Content="Save" Command="{Binding SaveSettingsCommand}" />
            <Button Width="80" Height="80" Margin="10" ToolTip="Reset to default settings" Content="Reset" Command="{Binding ResetSettingsCommand}" />
        </StackPanel>
        
    </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