<UserControl x:Class="VIZ.Framework.ImageContrastTool.MainView"
             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:local="clr-namespace:VIZ.Framework.ImageContrastTool"
             xmlns:common="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
             xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
             d:DataContext="{d:DesignInstance Type=local:MainViewModel}" 
             mc:Ignorable="d"  Background="White"
             d:DesignHeight="450" d:DesignWidth="1400">
    <UserControl.Resources>
        <local:PathToImageConverter x:Key="PathToImageConverter"></local:PathToImageConverter>
        <local:PathToFileNameConverter x:Key="PathToFileNameConverter"></local:PathToFileNameConverter>
    </UserControl.Resources>

    <behaviors:Interaction.Triggers>
        <behaviors:EventTrigger EventName="Loaded">
            <behaviors:InvokeCommandAction Command="{Binding LoadedCommand}" />
        </behaviors:EventTrigger>
    </behaviors:Interaction.Triggers>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="240"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="100"></RowDefinition>
        </Grid.RowDefinitions>
        <GroupBox Header="图片列表" Margin="5">
            <ListBox Margin="5" ItemsSource="{Binding Path=ImageFiles,Mode=OneWay}"
                     SelectedValue="{Binding Path=SelectedImageFile,Mode=TwoWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding .,Converter={StaticResource PathToFileNameConverter}}"></TextBlock>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </GroupBox>

        <GroupBox Header="Left" Margin="5" Grid.Column="1">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="80"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="120"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <common:LabelValue Label="图片文件夹路径" Text="{Binding LeftPath}" ToolTip="{Binding LeftPath}"
                                       Height="30" Margin="5,0,5,0"></common:LabelValue>
                    <Button Grid.Column="1" Width="100" Height="30" Content="选择图片文件夹" Command="{Binding Path=SelectLeftPathCommand}"></Button>
                </Grid>
                <Image Grid.Row="1" Stretch="Uniform" Source="{Binding Path=SelectedImageFile,Converter={StaticResource PathToImageConverter}}"></Image>
            </Grid>
        </GroupBox>
        <GroupBox Header="Right" Grid.Column="2" Margin="5">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="80"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="120"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <common:LabelValue Label="图片文件夹路径"  Text="{Binding RightPath}" ToolTip="{Binding RightPath}"
                                       Height="30" Margin="5,0,5,0"></common:LabelValue>
                    <Button Grid.Column="1" Width="100" Height="30" Content="选择图片文件夹" Command="{Binding SelectRightPathCommand}"></Button>
                </Grid>
                <Image Grid.Row="1" Stretch="Uniform" Source="{Binding Path=RightImageFile,Converter={StaticResource PathToImageConverter}}"></Image>
            </Grid>
        </GroupBox>
        <GroupBox Header="控制" Grid.Row="1" Grid.ColumnSpan="3" Margin="5">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Width="120" Height="40" Content="刷新" Margin="5" Command="{Binding RefreshCommand}"></Button>
                <Rectangle Width="2" Fill="#ffd5dfe5" Margin="20,0,20,0" Height="40"></Rectangle>
                <Button Width="120" Height="40" Content="上一张" Margin="5" Command="{Binding PrevCommand}"></Button>
                <Button Width="120" Height="40" Content="下一张" Margin="5" Command="{Binding NextCommand}"></Button>
            </StackPanel>
        </GroupBox>
    </Grid>
</UserControl>
