<UserControl x:Class="DeviceScanner.Views.Scanner"
             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:DeviceScanner.Views"
             mc:Ignorable="d"
             xmlns:controls="clr-namespace:DeviceScanner.Controls"
             xmlns:UICommon="clr-namespace:UICommon;assembly=UICommon"
             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="16"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto"/>
                <ColumnDefinition Width="8"/>
                <ColumnDefinition Width="auto"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>
            <Button Width="100" Height="32" Background="Transparent" BorderBrush="{StaticResource ThemeColor}" TextElement.Foreground="{StaticResource ThemeColor}"
                    Command="{Binding ScanCommand}" CommandParameter="Start">开始扫描</Button>
            <Button Grid.Column="2" Width="100" Height="32" Margin="8,0" Background="Transparent" BorderBrush="{StaticResource EmergencyColor}" TextElement.Foreground="{StaticResource EmergencyColor}"
                    Command="{Binding ScanCommand}" CommandParameter="Stop">停止扫描</Button>

            <Button Grid.Column="4" Width="100" Height="32" Margin="8,0" Background="Transparent" BorderBrush="{StaticResource ThemeColor}" TextElement.Foreground="{StaticResource ThemeColor}"
                    Command="{Binding ScanCommand}" CommandParameter="Clear">清空列表</Button>
        </Grid>

        <Border Grid.Row="2" BorderBrush="{StaticResource DarkBorderColor}" BorderThickness="1">
            <Grid>
                <Grid Background="#50e1e1e1" Panel.ZIndex="1" Visibility="{Binding ShaderVisibility}">
                    <UICommon:CycleRingLoading IsActive="{Binding EnableShader}" Width="100"/>
                </Grid>
                <ScrollViewer>
                    <ItemsControl Margin="8" ItemsSource="{Binding ScanningDevices}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <controls:NewDevicePlot DeviceInfo="{Binding Value}" 
                                                        CreateCommand="{Binding RelativeSource={RelativeSource AncestorType=local:Scanner, Mode=FindAncestor}, Path=DataContext.CreateDeviceCommand}"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>
                </ScrollViewer>

            </Grid>
        </Border>
    </Grid>
</UserControl>
