<UserControl x:Class="DeviceManagement.Controls.DevicePlot"
             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:DeviceManagement.Controls"
             xmlns:resource="clr-namespace:UICommon;assembly=UICommon"
             mc:Ignorable="d" 
             x:Name="This"
             d:DesignHeight="450" d:DesignWidth="800">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/UICommon;component/Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <local:DeviceImageConverter x:Key="ImageConverter"/>
            <local:ConnectToImageConverter x:Key="ConnectConvert"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <Border BorderBrush="DarkGray" Background="#f2f2f2" CornerRadius="16" BorderThickness="1" Width="320">
        <Grid Margin="12,6">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="8"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="8"/>
            </Grid.RowDefinitions>
            <Grid Margin="0,8">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="4"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="4"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="4"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Grid.Row="0" FontSize="18" VerticalAlignment="Center" Text="{Binding ElementName=This, Path=DeviceInfo.DeviceModel}"/>
                    <Image Source="{Binding ElementName=This, Path=DeviceInfo.IsConnected, Converter={StaticResource ConnectConvert}}" VerticalAlignment="Center" Margin="8,0" Height="18"/>
                </StackPanel>
                <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}" TextWrapping="WrapWithOverflow"/>

                <StackPanel Grid.Row="8"  Orientation="Horizontal">
                    <Button Background="Transparent" BorderThickness="0" 
                   Command="{Binding ElementName=This, Path=SettingCommand}" CommandParameter="{Binding ElementName=This, Path=DeviceInfo}">
                        <Image Source="{StaticResource Icon_Edit}" Height="24" />
                    </Button>
                    <Button Background="Transparent" BorderThickness="0" Margin="8,0"
                       Command="{Binding ElementName=This, Path=DeleteCommand}" CommandParameter="{Binding ElementName=This, Path=DeviceInfo}">
                        <Image Source="{StaticResource delete_fillDrawingImage}" Height="24" />
                    </Button>
                </StackPanel>


            </Grid>


            <Image Grid.Column="1" Source="{Binding ElementName=This, Path=DeviceInfo.DeviceModel, Converter={StaticResource ImageConverter}}" Height="148" Stretch="Uniform"/>

            <Grid Grid.Row="2" Grid.ColumnSpan="3" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="16"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Button Height="32" Background="Transparent" HorizontalContentAlignment="Center" BorderBrush="{StaticResource ThemeColor}"
                  Command="{Binding ElementName=This, Path=DetailCommand}" CommandParameter="{Binding ElementName=This, Path=DeviceInfo}">
                    <TextBlock Foreground="{StaticResource ThemeColor}" Margin="8,0">数据分析</TextBlock>
                </Button>
                <Button Grid.Column="2" Height="32" Background="Transparent" HorizontalContentAlignment="Center" BorderBrush="{StaticResource ThemeColor}"
                  Command="{Binding ElementName=This, Path=RemoteControlCommand}" CommandParameter="{Binding ElementName=This, Path=DeviceInfo}">
                    <TextBlock Foreground="{StaticResource ThemeColor}" Margin="8,0">远程操作</TextBlock>
                </Button>
            </Grid>

            <!--<TextBlock Grid.Row="2" Grid.ColumnSpan="2" >
                <Run>UID:</Run>
                <Run Text="{Binding ElementName=This, Path=DeviceInfo.Guid}"/>
            </TextBlock>-->
        </Grid>
    </Border>
</UserControl>
