Click here to Skip to main content
15,897,891 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.DeviceConfigView"
             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:Models="clr-namespace:CBR.Core.Models;assembly=CBR.Core"
             mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="800" >
    
    <UserControl.Resources>

        <DataTemplate x:Key="DeviceItemTemplate" DataType="{x:Type Models:DeviceInfo }">
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*" SharedSizeGroup="LabelCol" />
                    <ColumnDefinition Width="2*" SharedSizeGroup="ValueCol" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                
                <Label Grid.Column="0" Grid.Row="0" Margin="2">Device model</Label>
                <TextBlock Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" Text="{Binding Model}" FontWeight="Bold"></TextBlock>
                <Label Grid.Column="0" Grid.Row="1" Margin="2">by manufacturer</Label>
                <TextBlock Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Text="{Binding Manufacturer}" FontWeight="Bold"></TextBlock>
            </Grid>
        </DataTemplate>

    </UserControl.Resources>
    
    <Grid Margin="15" HorizontalAlignment="Left" VerticalAlignment="Stretch">
        <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">Supported device configuration</TextBlock>
            <Line Style="{StaticResource DashedSeparator}" X1="0" X2="1" />
        </StackPanel>

        <StackPanel Grid.Row="1" Orientation="Vertical" Margin="10" Name="stack1">
            <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5">Device(s)</TextBlock>
            <UniformGrid Columns="2" Margin="5">
                <Label Margin="5">Search models</Label>
                <TextBox Margin="5"></TextBox>
            </UniformGrid>
            <ListBox  Name="lbDevices" Margin="5" Padding="5" MaxHeight="450"
                      ItemsSource="{Binding SupportedDevices}"
                      ItemTemplate="{StaticResource DeviceItemTemplate}" ItemContainerStyle="{StaticResource CBRListItemStyle}"
                      />
            <Button Margin="30,10,30,10" ToolTip="Delete the selected device" Content="Delete..." Name="btnDeleteDevice" Click="btnDeleteDevice_Click" />

        </StackPanel>

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

        <StackPanel Grid.Column="2" Grid.Row="1" Margin="10" Name="stack2">

            <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5">Device informations</TextBlock>
            
            <UniformGrid Columns="2" Margin="5">
                <Label Margin="5">Model</Label>
                <TextBox Margin="5" Text="{Binding ElementName=lbDevices, Path=SelectedItem.Model}" />
                <Label Margin="5">Manufacturer</Label>
                <TextBox Margin="5" Text="{Binding ElementName=lbDevices, Path=SelectedItem.Manufacturer}" />
            </UniformGrid>
            <Line Style="{StaticResource DashedSeparator}" X1="0" X2="1" />
            
            <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5">Supported formats</TextBlock>
            <UniformGrid Columns="4" Margin="15,5,15,5">
                <Label>Images</Label>
                <CheckBox IsChecked="{Binding ElementName=lbDevices, Path=SelectedItem.CanImages}" VerticalAlignment="Center" />
                <Label>RAR based</Label>
                <CheckBox IsChecked="{Binding ElementName=lbDevices, Path=SelectedItem.CanRAR}" VerticalAlignment="Center" />
                <Label>ZIP based</Label>
                <CheckBox IsChecked="{Binding ElementName=lbDevices, Path=SelectedItem.CanZIP}" VerticalAlignment="Center" />
                <Label>PDF</Label>
                <CheckBox IsChecked="{Binding ElementName=lbDevices, Path=SelectedItem.CanPDF}" VerticalAlignment="Center" />
                <Label>XPS</Label>
                <CheckBox IsChecked="{Binding ElementName=lbDevices, Path=SelectedItem.CanXPS}" VerticalAlignment="Center" />
                <Label>ePUB</Label>
                <CheckBox IsChecked="{Binding ElementName=lbDevices, Path=SelectedItem.CanEPUB}" VerticalAlignment="Center" />
            </UniformGrid>

            <Line Style="{StaticResource DashedSeparator}" X1="0" X2="1" />
            
            <TextBlock Style="{StaticResource SubTitleLabel}" Margin="5">Add new device</TextBlock>
            <StackPanel>
                <UniformGrid Columns="2" Margin="5">
                    <Label Margin="5">Model</Label>
                    <TextBox Margin="5" Name="tbModel"></TextBox>
                    <Label Margin="5">Manufacturer</Label>
                    <TextBox Margin="5" Name="tbManufacturer"></TextBox>
                </UniformGrid>
                <Button Margin="30,10,30,10" ToolTip="Add a new property and save the settings automatically" Content="Add..." Name="btnAddDevice" Click="btnAddDevice_Click" />
            </StackPanel>

        </StackPanel>

        <Line Grid.Column="3" Grid.Row="1" Grid.RowSpan="2"  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 parameters" Content="Save" Name="btnSave" Click="btnSave_Click" />
        </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