<UserControl x:Class="TwoCamWPF.Settings.CamSettingsPage"
             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:t="http://schemas.microsoft.com/wpf/2008/toolkit"
             mc:Ignorable="d" xmlns:local="clr-namespace:TwoCamWPF.Settings"
             d:DesignHeight="300" d:DesignWidth="300"
                       >

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="271*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <t:DataGrid ItemsSource="{Binding camerasModel}"   AutoGenerateColumns="False" Grid.Row="0">
            <t:DataGrid.Columns>
                <t:DataGridTemplateColumn Header="Использовать" IsReadOnly="True">
                    <t:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding IsUsing, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10"/>
                        </DataTemplate>
                    </t:DataGridTemplateColumn.CellTemplate>
                </t:DataGridTemplateColumn>
                <t:DataGridTemplateColumn Header="Камера"  IsReadOnly="True">
                    <t:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}"  IsEnabled="{Binding IsUsing}"  />
                        </DataTemplate>
                    </t:DataGridTemplateColumn.CellTemplate>
                </t:DataGridTemplateColumn>
                <t:DataGridTemplateColumn Header="Разрешение"  IsReadOnly="True">
                    <t:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox  Name="cmbCamera" Height="23" VerticalAlignment="Top"
                                   ItemsSource="{Binding Capabilites}" 
                                   SelectedItem="{Binding Capability, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                   IsEnabled="{Binding IsUsing}" 
                                   Margin="5">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding}"/>
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </DataTemplate>
                    </t:DataGridTemplateColumn.CellTemplate>
                </t:DataGridTemplateColumn>

                <t:DataGridTemplateColumn Header="Превью"  IsReadOnly="True">
                    <t:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="{Binding Image}"
                                               
                                    Width="100"
                                    Stretch="Uniform"
                                    Height="100" >
                                <Image.Style>
                                    <Style TargetType="{x:Type Image}">
                                        <Style.Triggers>
                                            <DataTrigger  Binding="{Binding IsUsing}"  Value="True">
                                                <Setter Property="Visibility" Value="Visible"/>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding IsUsing}" Value="False" >
                                                <Setter Property="Visibility" Value="Hidden"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Image.Style>


                            </Image>
                        </DataTemplate>
                    </t:DataGridTemplateColumn.CellTemplate>
                </t:DataGridTemplateColumn>
                <t:DataGridTemplateColumn Header="FPS"  IsReadOnly="True">
                    <t:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding fps}">
                                <TextBlock.Style>
                                    <Style TargetType="{x:Type TextBlock}">
                                        <Style.Triggers>
                                            <DataTrigger  Binding="{Binding IsUsing}"  Value="True">
                                                <Setter Property="Visibility" Value="Visible"/>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding IsUsing}" Value="False" >
                                                <Setter Property="Visibility" Value="Hidden"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBlock.Style>
                            </TextBlock>
                        </DataTemplate>
                    </t:DataGridTemplateColumn.CellTemplate>
                </t:DataGridTemplateColumn>
            </t:DataGrid.Columns>
        </t:DataGrid>
        <Button Content="Обновить список камер" Grid.Row="1" Margin="0,5,5,5" Name="button1" HorizontalAlignment="Right" Width="148" Click="button1_Click" />
        <StackPanel Grid.Row="1" HorizontalAlignment="Left" Margin="5,5,0,5" Orientation="Horizontal"   >
            <Label Content="Размер буфера" HorizontalAlignment="Left" Name="label1" Height="26" />
            <TextBox Text="{Binding bufSize}" HorizontalAlignment="Left" Name="txtBufSize" Height="26" Width="30"  />
            <Label Content="%"  HorizontalAlignment="Left" Height="26" />

        </StackPanel>
    </Grid>
</UserControl>
