<UserControl x:Class="ConfigFileManager.Views.Dialog.Migrate"
             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:ConfigFileManager.Views.Dialog"
             xmlns:contorls="clr-namespace:ConfigFileManager.Controls"
             xmlns:cycle="clr-namespace:UICommon;assembly=UICommon"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary Source="/UICommon;component/Resources.xaml"/>
    </UserControl.Resources>
    <Grid Margin="8">

        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="8"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <GroupBox Header="设备信息">
            <Grid Margin="8">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="120"/>
                    <ColumnDefinition Width="16"/>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="16"/>
                    <ColumnDefinition Width="180"/>
                    <ColumnDefinition Width="16"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>

                <TextBlock Text="{Binding Source.DeviceName}" FontSize="14" VerticalAlignment="Center"></TextBlock>

                <TextBlock Grid.Column="2" FontSize="14" VerticalAlignment="Center" Margin="4,0" Text="{Binding Source.DeviceModel}"/>
                <TextBlock Grid.Column="4" FontSize="14" VerticalAlignment="Center" Margin="4,0" Text="{Binding Source.DeviceSubModel}"/>
                <TextBlock Grid.Column="6" FontSize="14" VerticalAlignment="Center" Margin="4,0" >
                        <Run>Ver:</Run>
                        <Run Text="{Binding Source.SoftwareVersion}"/>
                </TextBlock>
            </Grid>
        </GroupBox>

        <GroupBox Grid.Row="2" Header="设备列表">
            <ScrollViewer>

                <ItemsControl ItemsSource="{Binding Sources}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <contorls:HarewareCompare Margin="8" Target="{Binding}" 
                                                      MigrateCommand="{Binding RelativeSource={RelativeSource AncestorType=local:Migrate,Mode=FindAncestor}, Path=DataContext.MigrateCommand}"
                                                      MigrateRecipeCommand="{Binding RelativeSource={RelativeSource AncestorType=local:Migrate,Mode=FindAncestor}, Path=DataContext.MigrateRecipeCommand}"
                                                      Source="{Binding RelativeSource={RelativeSource AncestorType=local:Migrate, Mode=FindAncestor}, Path=DataContext.Source}" />
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>
        </GroupBox>

        <Grid Grid.RowSpan="3" Background="#50ffffff" Visibility="{Binding Running}">
            <Grid VerticalAlignment="Center">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="64"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <cycle:CycleRingLoading Width="60" />
                <TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Center" Panel.ZIndex="1">
                    <Run Text="{Binding Progress}"></Run>
                    <Run > %</Run>
                </TextBlock>
                <ProgressBar Grid.Row="2" Style="{StaticResource ThemeProgressBar}" VerticalAlignment="Center" Height="16" Margin="64,0" Value="{Binding Progress}"/>
            </Grid>
        </Grid>

    </Grid>
</UserControl>
