Click here to Skip to main content
15,893,564 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.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"
             xmlns:Controls="clr-namespace:CBR.Components.Controls"
             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" 
                       Text="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.Title, DefaultValue=Supported device configuration}" />
            <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"
                       Text="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.Devices, DefaultValue=Device(s)}" />
            
            <Controls:FilterControl MinHeight="29" Margin="5" FilterText="{Binding SearchedText, Mode=TwoWay}"
                      Header="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.Filter, DefaultValue=Type your criteria}"/>
            
            <ListBox  Name="lbDevices" Margin="5" Padding="5" MaxHeight="450"
                      ItemsSource="{Binding SupportedDevices}"
                      ItemTemplate="{StaticResource DeviceItemTemplate}" ItemContainerStyle="{StaticResource CBRListItemStyle}" />
            
            <Button Style="{StaticResource CBROnWhiteButtonStyle}" Margin="30,10,30,10" ToolTip="Delete the selected device"
                    Content="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.Delete, DefaultValue=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"
                      Text ="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.DeviceInfo, DefaultValue=Device informations}" />
            
            <UniformGrid Columns="2" Margin="5">
                <Label Margin="5" Content="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.Model, DefaultValue=Model}" />
                <TextBox Margin="5" Text="{Binding ElementName=lbDevices, Path=SelectedItem.Model}" />
                <Label Margin="5" Content="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.Manufacturer, DefaultValue=Manufacturer}" />
                <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"
                      Text="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.SupportedFormat, DefaultValue=Supported format(s)}" />
            <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"
                      Text="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.Add, DefaultValue=Add a new device}" />
            <StackPanel>
                <UniformGrid Columns="2" Margin="5">
                    <Label Margin="5" Content="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.Model, DefaultValue=Model}"/>
                    <TextBox Margin="5" Name="tbModel"></TextBox>
                    <Label Margin="5" Content="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.Manufacturer, DefaultValue=Manufacturer}" />
                    <TextBox Margin="5" Name="tbManufacturer"></TextBox>
                </UniformGrid>
                <Button Style="{StaticResource CBROnWhiteButtonStyle}" Height="25" Margin="30,10,30,10" Name="btnAddDevice"  Click="btnAddDevice_Click"
                        Content="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.Add, DefaultValue=Add}" />
            </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 Style="{StaticResource CBROnWhiteButtonStyle}" Width="80" Height="80" Margin="10" ToolTip="Save parameters"
                    Content="{LocalizationExtension ResModul=CBR.Backstage, Key=DeviceConfigView.Save, DefaultValue=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