<UserControl x:Class="ConfigFileManager.Controls.ConfigFilePlot"
             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.Controls"
             xmlns:uicommon="clr-namespace:UICommon;assembly=UICommon"
             mc:Ignorable="d" 
             x:Name="This"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary Source="/UICommon;component/Resources.xaml"/>
    </UserControl.Resources>
    <Border BorderBrush="DarkGray" Background="#f2f2f2" CornerRadius="16" BorderThickness="1" Margin="8" VerticalAlignment="Center" HorizontalAlignment="Center">
        <Grid Margin="16,8" VerticalAlignment="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto"/>
                <ColumnDefinition Width="16"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="16"/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="2"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="2"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="2"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="2"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" FontSize="14" FontWeight="Bold" Text="{Binding ElementName=This,Path=DeviceInfo.DeviceModel}"/>
                <TextBlock Grid.Row="2" VerticalAlignment="Center" Text="{Binding ElementName=This,Path=DeviceInfo.DeviceSubModel}"/>

                <TextBlock Grid.Row="4" VerticalAlignment="Center" Text="{Binding ElementName=This,Path=DeviceInfo.DeviceName}"/>
                <TextBlock Grid.Row="6" VerticalAlignment="Center" Text="{Binding ElementName=This,Path=DeviceInfo.Position}"/>
                <TextBlock Grid.Row="8" VerticalAlignment="Center" >
                    <Run>Ver:</Run>
                    <Run Text="{Binding ElementName=This,Path=DeviceInfo.SoftwareVersion}"/>
                </TextBlock>
            </Grid>

            <Grid Grid.Column="2"  VerticalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="auto"/>
                </Grid.ColumnDefinitions>
                <Button x:Name="ConfigButton" VerticalAlignment="Center" HorizontalAlignment="Center" Background="Transparent" BorderBrush="{StaticResource ThemeColor}"
                        Command="{Binding ElementName=This, Path=CheckConfigCommand}" CommandParameter="{Binding ElementName=This, Path=DeviceInfo}">
                    <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Margin="4">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="8"/>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Image Source="{StaticResource Icon_File}" Height="48"></Image>
                        <TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource ThemeColor}">Configs</TextBlock>
                    </Grid>
                </Button>

                <Button x:Name="RecipeButton" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Background="Transparent" BorderBrush="{StaticResource ThemeColor}"
                        Command="{Binding ElementName=This, Path=CheckRecipeCommand}" CommandParameter="{Binding ElementName=This, Path=DeviceInfo}">
                    <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Margin="4">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="8"/>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Image Source="{StaticResource Icon_File}" Height="48"></Image>
                        <TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource ThemeColor}">Recipes</TextBlock>
                    </Grid>
                </Button>

            </Grid>

            <Grid Grid.Row="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="60"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="60"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="auto"/>
                </Grid.ColumnDefinitions>

                <Button Grid.Column="0" Background="Transparent"  
                        BorderBrush="{StaticResource ThemeColor}" TextElement.Foreground="{StaticResource ThemeColor}"
                        Command="{Binding ElementName=This, Path=UpdateCommand}"
                        CommandParameter="{Binding ElementName=This, Path=DeviceInfo}">更新</Button>
                <Button Grid.Column="2" Background="Transparent"  x:Name="MigrateButton"
                        BorderBrush="{StaticResource ThemeColor}" TextElement.Foreground="{StaticResource ThemeColor}"
                        Command="{Binding ElementName=This,Path=MigrateCommand}"
                        CommandParameter="{Binding ElementName=This, Path=DeviceInfo}">迁移</Button>
            </Grid>
            <Grid Grid.Row="2" Grid.Column="2" HorizontalAlignment="Left">
                <Grid Background="#f2f2f2" Panel.ZIndex="1" x:Name="UpdateBar">
                    <uicommon:CycleRingLoading/>
                </Grid>
                <StackPanel>
                    <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Text="更新时间:"></TextBlock>
                    <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding ElementName=This, Path=DeviceInfo.UpdateTime, StringFormat=yyyy-MM-dd HH:mm:ss}"></TextBlock>
                </StackPanel>
            </Grid>
        </Grid>
    </Border>
</UserControl>
