<Window
    x:Class="XHWK.WKTool.DeviceWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:gif="http://wpfanimatedgif.codeplex.com"
    xmlns:local="clr-namespace:XHWK.WKTool"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:view="clr-namespace:XHWK.WKTool.View"
    Title="设备检测"
    Width="569"
    Height="367"
    ShowInTaskbar="True"
    Style="{StaticResource ZWinStyle}"
    WindowStartupLocation="CenterScreen"
    WindowStyle="SingleBorderWindow"
    mc:Ignorable="d">

    <Window.Resources>
        <!--  摄像头样式  -->
        <Style x:Key="stlToggleButton" TargetType="ToggleButton">
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border
                            x:Name="Back"
                            Background="#FFFFFFFF"
                            BorderBrush="Transparent"
                            BorderThickness="0">
                            <Path
                                Name="PathFill"
                                Width="8"
                                Height="6"
                                Data="M5,0 L10,10 L0,10 z"
                                Fill="Black"
                                RenderTransformOrigin="0.5,0.5"
                                Stretch="Fill"
                                StrokeThickness="0">
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform />
                                        <SkewTransform />
                                        <RotateTransform Angle="180" />
                                        <TranslateTransform />
                                    </TransformGroup>
                                </Path.RenderTransform>
                            </Path>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="PathFill" Property="Fill" Value="White" />
                                <Setter TargetName="Back" Property="Background" Value="#FFDCDCDC" />
                                <Setter TargetName="Back" Property="BorderBrush" Value="#FFDCDCDC" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="stlComboBox" TargetType="ComboBox">
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
            <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Foreground" Value="Black" />
            <Setter Property="Height" Value="30" />
            <Setter Property="Margin" Value="0,0,0,0" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ComboBox">
                        <Grid Background="#F7FDF7">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="0.8*" />
                                <ColumnDefinition Width="0.2*" MaxWidth="20" />
                            </Grid.ColumnDefinitions>
                            <TextBox
                                Grid.Column="0"
                                VerticalContentAlignment="Center"
                                IsReadOnly="True"
                                Text="{TemplateBinding Text}" />
                            <Border
                                Grid.Column="0"
                                BorderBrush="#FFDCDCDC"
                                BorderThickness="1,1,1,1"
                                CornerRadius="1,0,0,1" />
                            <Border
                                Grid.Column="1"
                                BorderBrush="#FFDCDCDC"
                                BorderThickness="0,1,1,1"
                                CornerRadius="0,1,1,0">
                                <ToggleButton
                                    ClickMode="Press"
                                    IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                    Style="{StaticResource stlToggleButton}" />
                            </Border>
                            <Popup
                                x:Name="Popup"
                                AllowsTransparency="True"
                                Focusable="False"
                                IsOpen="{TemplateBinding IsDropDownOpen}"
                                Placement="Bottom"
                                PopupAnimation="Slide">
                                <Border
                                    x:Name="DropDown"
                                    MinWidth="{TemplateBinding ActualWidth}"
                                    MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                    CornerRadius="1"
                                    SnapsToDevicePixels="True">
                                    <Border.Effect>
                                        <DropShadowEffect
                                            BlurRadius="2"
                                            Opacity="0.5"
                                            ShadowDepth="0"
                                            Color="Black" />
                                    </Border.Effect>
                                    <ScrollViewer
                                        MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                        Margin="4,6,4,6"
                                        CanContentScroll="True"
                                        HorizontalScrollBarVisibility="Auto"
                                        SnapsToDevicePixels="True"
                                        Style="{DynamicResource ScrollViewerStyle}"
                                        VerticalScrollBarVisibility="Auto">
                                        <!--  StackPanel 用于显示子级，方法是将 IsItemsHost 设置为 True  -->
                                        <StackPanel
                                            Background="White"
                                            IsItemsHost="True"
                                            KeyboardNavigation.DirectionalNavigation="Contained" />
                                    </ScrollViewer>
                                </Border>
                            </Popup>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid
            x:Name="GridTitle_Black"
            Grid.Row="0"
            Margin="0,0"
            Background="#3f6fff"
            MouseLeftButtonDown="Window_MouseLeftButtonDown">
            <TextBlock
                Grid.RowSpan="2"
                Margin="16,0,0,0"
                VerticalAlignment="Center"
                FontSize="16"
                Foreground="White"
                Text="设备检测" />
            <Button
                x:Name="btnDown_Black"
                Grid.Row="0"
                Width="46"
                HorizontalAlignment="Right"
                Click="BtnDown_Click"
                Content="×"
                Cursor="Hand"
                FontSize="30"
                Foreground="White" />
        </Grid>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="140" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="0">
                <Border BorderBrush="#FFE9E9E9" BorderThickness="0,0,1,0">
                    <StackPanel Margin="0,10" VerticalAlignment="Top">
                        <Button
                            x:Name="BtnCamera"
                            Height="40"
                            Margin="0,0,0,0"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            IsEnabled="False">
                            <StackPanel Orientation="Horizontal">
                                <Image
                                    Height="18"
                                    Margin="6,0"
                                    HorizontalAlignment="Left"
                                    Source="/BlackImages/Device_Camera.png" />
                                <TextBlock
                                    Width="100"
                                    Padding="0,0,0,0"
                                    HorizontalAlignment="Center"
                                    FontSize="16"
                                    Text="摄像头" />
                            </StackPanel>
                        </Button>
                        <Button
                            x:Name="BtnSpeaker"
                            Height="40"
                            Margin="0,0,0,0"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            IsEnabled="False">
                            <StackPanel Orientation="Horizontal">
                                <Image
                                    Height="18"
                                    Margin="6,0"
                                    HorizontalAlignment="Left"
                                    Source="/BlackImages/Device_Voice.png" />
                                <TextBlock
                                    Width="100"
                                    Padding="0,0,0,0"
                                    HorizontalAlignment="Center"
                                    FontSize="16"
                                    Text="扬声器" />
                            </StackPanel>
                        </Button>
                        <Button
                            x:Name="BtnMicrophone"
                            Height="40"
                            Margin="0,0,0,0"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            Cursor="Hand"
                            IsEnabled="False">
                            <StackPanel Orientation="Horizontal">
                                <Image
                                    Height="18"
                                    Margin="6,0"
                                    HorizontalAlignment="Left"
                                    Source="/BlackImages/Device_Microphone.png" />
                                <TextBlock
                                    Width="100"
                                    Padding="0,0,0,0"
                                    HorizontalAlignment="Center"
                                    FontSize="16"
                                    Text="麦克风" />
                            </StackPanel>
                        </Button>
                        <Button
                            x:Name="BtnDetectionPage"
                            Height="40"
                            Margin="0,0,0,0"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            IsEnabled="False">
                            <StackPanel Orientation="Horizontal">
                                <Image
                                    Height="18"
                                    Margin="6,0"
                                    HorizontalAlignment="Left"
                                    Source="/BlackImages/Device_JC.png" />
                                <TextBlock
                                    Width="100"
                                    Padding="0,0,0,0"
                                    HorizontalAlignment="Center"
                                    FontSize="16"
                                    Text="检测结果" />
                            </StackPanel>
                        </Button>
                    </StackPanel>
                </Border>
            </Grid>

            <Grid
                x:Name="GridCamera"
                Grid.Column="1"
                Visibility="Visible">
                <Grid.RowDefinitions>
                    <RowDefinition Height="64" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="64" />
                </Grid.RowDefinitions>
                <StackPanel
                    Grid.Row="0"
                    Margin="30,0,0,0"
                    Orientation="Horizontal">
                    <TextBlock
                        Margin="0,5,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Center"
                        FontSize="16"
                        Foreground="#FF000000"
                        Text="摄像头" />
                    <ComboBox
                        x:Name="CmbCameraList"
                        Width="236"
                        Margin="16,0,0,0"
                        Padding="30,0,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Center"
                        HorizontalContentAlignment="Center"
                        VerticalContentAlignment="Center"
                        Background="White"
                        BorderThickness="0"
                        Cursor="Hand"
                        DisplayMemberPath="Name"
                        FontSize="14"
                        SelectionChanged="CmbCameraList_SelectionChanged"
                        Style="{StaticResource stlComboBox}"
                        Text="请选择" />
                </StackPanel>
                <Grid
                    Grid.Row="1"
                    Width="300"
                    Height="160"
                    Margin="30,0,0,0"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Top">
                    <Image
                        x:Name="imgPlayer"
                        RenderTransformOrigin="0.5,0.5"
                        Stretch="Fill"
                        Visibility="Visible">
                        <Image.RenderTransform>
                            <ScaleTransform ScaleX="-1" />
                        </Image.RenderTransform>
                    </Image>
                </Grid>
                <StackPanel
                    Grid.Row="2"
                    Margin="30,0,0,0"
                    HorizontalAlignment="Right"
                    Orientation="Horizontal">
                    <Button
                        x:Name="btn_camera_good"
                        Width="100"
                        Height="30"
                        Margin="0,0,10,0"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Center"
                        Background="#3f6fff"
                        Click="btn_camera_good_Click"
                        Content="可以看见"
                        Cursor="Hand"
                        FontSize="15"
                        Foreground="White"
                        IsDefault="True" />
                    <Button
                        x:Name="btn_camera_bad"
                        Width="100"
                        Height="30"
                        Margin="0,0,10,0"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Center"
                        Background="#F1F2F3"
                        Click="btn_camera_bad_Click"
                        Content="看不见"
                        Cursor="Hand"
                        FontSize="15"
                        Foreground="#333333"
                        IsDefault="True" />
                </StackPanel>
            </Grid>
            <Grid
                x:Name="GridSpeaker"
                Grid.Column="1"
                Visibility="Collapsed">
                <Grid.RowDefinitions>
                    <RowDefinition Height="64" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="64" />
                </Grid.RowDefinitions>
                <Grid Grid.Row="0">
                    <StackPanel
                        Margin="30,20,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Orientation="Horizontal">
                        <Button
                            x:Name="BtnSpeakerDetection"
                            Grid.Row="2"
                            Width="100"
                            Height="30"
                            Margin="0"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            Click="BtnSpeakerDetection_Click"
                            Content="播放音频"
                            Cursor="Hand"
                            FontSize="15"
                            Foreground="White"
                            IsDefault="True">
                            <Button.Template>
                                <ControlTemplate TargetType="{x:Type Button}">
                                    <Border
                                        BorderBrush="{TemplateBinding BorderBrush}"
                                        BorderThickness="1"
                                        CornerRadius="7">
                                        <Border.Background>
                                            <Brush>#3f6fff</Brush>
                                        </Border.Background>
                                        <ContentPresenter
                                            HorizontalAlignment="Center"
                                            VerticalAlignment="Center"
                                            Content="{TemplateBinding Content}" />
                                    </Border>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>

                        <MediaElement
                            x:Name="MediaAudio"
                            Width="0"
                            LoadedBehavior="Manual"
                            MediaEnded="MediaAudio_MediaEnded"
                            MediaOpened="MediaAudio_MediaOpened"
                            Stretch="Fill"
                            Visibility="Hidden"
                            Volume="1" />
                    </StackPanel>
                </Grid>
                <Grid Grid.Row="1">

                    <Grid
                        Width="300"
                        Height="100"
                        Margin="30,0,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Background="#FFF1F2F8">
                        <Image
                            x:Name="ImgAcousticWave"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            gif:ImageBehavior.AnimatedSource="/SkinImages/Other/Dev_AcousticWave2.gif"
                            gif:ImageBehavior.AutoStart="True"
                            gif:ImageBehavior.RepeatBehavior="Forever"
                            Visibility="Hidden" />
                    </Grid>
                </Grid>
                <Grid Grid.Row="2">
                    <StackPanel
                        Grid.Row="2"
                        Margin="30,0,0,0"
                        HorizontalAlignment="Right"
                        Orientation="Horizontal">
                        <Button
                            x:Name="btn_speaker_good"
                            Width="100"
                            Height="30"
                            Margin="0,0,10,0"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            Background="#3f6fff"
                            Click="btn_speaker_good_Click"
                            Content="可以听见"
                            Cursor="Hand"
                            FontSize="15"
                            Foreground="White"
                            IsDefault="True" />
                        <Button
                            x:Name="btn_speaker_bad"
                            Width="100"
                            Height="30"
                            Margin="0,0,10,0"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            Background="#F1F2F3"
                            Click="btn_speaker_bad_Click"
                            Content="听不见"
                            Cursor="Hand"
                            FontSize="15"
                            Foreground="#333333"
                            IsDefault="True" />
                    </StackPanel>
                </Grid>
            </Grid>
            <Grid
                x:Name="GridMicrophone"
                Grid.Column="1"
                Visibility="Collapsed">
                <Grid.RowDefinitions>
                    <RowDefinition Height="64" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="64" />
                </Grid.RowDefinitions>
                <StackPanel
                    Grid.Row="0"
                    Margin="30,0,0,0"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    Orientation="Horizontal">
                    <TextBlock
                        Margin="0,5,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        FontSize="16"
                        Foreground="#FF000000"
                        Text="麦克风" />
                    <ComboBox
                        x:Name="CmbMicrophoneList"
                        Width="236"
                        Margin="16,0,0,0"
                        Padding="30,0,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        HorizontalContentAlignment="Center"
                        VerticalContentAlignment="Center"
                        Background="White"
                        BorderThickness="0"
                        Cursor="Hand"
                        DisplayMemberPath="Value"
                        FontSize="14"
                        SelectedValuePath="Key"
                        SelectionChanged="CmbMicrophoneList_SelectionChanged"
                        Style="{StaticResource stlComboBox}"
                        Text="请选择" />

                    <Button
                        x:Name="MicrophoneSetting"
                        Width="60"
                        Margin="20,0,0,0"
                        Background="#3f6fff"
                        Content="设置"
                        FontSize="14"
                        Foreground="White" />
                </StackPanel>

                <Grid Grid.Row="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="64" />
                    </Grid.RowDefinitions>
                    <view:ZClippingBorder
                        x:Name="GridMicImg"
                        Width="300"
                        Height="20"
                        Margin="30,0,0,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Background="#FFF1F2F8"
                        ClipToBounds="True"
                        CornerRadius="10"
                        Visibility="Visible">
                        <ProgressBar
                            x:Name="volumeProgressBar"
                            BorderThickness="0"
                            Maximum="100" />
                    </view:ZClippingBorder>
                </Grid>

                <Grid Grid.Row="2">
                    <StackPanel
                        Grid.Row="2"
                        Margin="30,0,0,0"
                        HorizontalAlignment="Right"
                        Orientation="Horizontal">
                        <Button
                            x:Name="btn_microphone_good"
                            Width="100"
                            Height="30"
                            Margin="0,0,10,0"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            Background="#3f6fff"
                            Click="btn_microphone_good_Click"
                            Content="可以看见"
                            Cursor="Hand"
                            FontSize="15"
                            Foreground="White"
                            IsDefault="True" />
                        <Button
                            x:Name="btn_microphone_bad"
                            Width="100"
                            Height="30"
                            Margin="0,0,10,0"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            Background="#F1F2F3"
                            Click="btn_microphone_bad_Click"
                            Content="看不见"
                            Cursor="Hand"
                            FontSize="15"
                            Foreground="#333333"
                            IsDefault="True" />
                    </StackPanel>
                </Grid>
            </Grid>
            <Grid
                x:Name="GridDetection"
                Grid.Column="1"
                Margin="25,15"
                Visibility="Collapsed">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50*" />
                    <ColumnDefinition Width="50*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="50*" />
                    <RowDefinition Height="50*" />
                    <RowDefinition Height="50*" />
                    <RowDefinition Height="50*" />
                    <RowDefinition Height="50*" />
                    <RowDefinition Height="50*" />
                    <RowDefinition Height="50*" />
                </Grid.RowDefinitions>
                <Grid Grid.Row="0" Grid.Column="0">
                    <TextBlock
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        FontSize="16"
                        Foreground="#FF999999"
                        Text="设备名称" />
                </Grid>
                <Grid Grid.Row="0" Grid.Column="1">
                    <TextBlock
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        FontSize="16"
                        Foreground="#FF999999"
                        Text="检测结果" />
                </Grid>
                <!--  摄像头  -->
                <Grid Grid.Row="1" Grid.Column="0">
                    <TextBlock
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        FontSize="16"
                        Foreground="#FF000000"
                        Text="摄像头" />
                </Grid>
                <Grid Grid.Row="1" Grid.Column="1">
                    <TextBlock
                        x:Name="TxbCamera"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        FontSize="16"
                        Foreground="#FF000000"
                        Text="" />
                </Grid>
                <!--  扬声器  -->
                <Grid Grid.Row="2" Grid.Column="0">
                    <TextBlock
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        FontSize="16"
                        Foreground="#FF000000"
                        Text="扬声器" />
                </Grid>
                <Grid Grid.Row="2" Grid.Column="1">
                    <TextBlock
                        x:Name="TxbSpeaker"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        FontSize="16"
                        Foreground="#FF000000"
                        Text="" />
                </Grid>
                <!--  麦克风  -->
                <Grid Grid.Row="3" Grid.Column="0">
                    <TextBlock
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        FontSize="16"
                        Foreground="#FF000000"
                        Text="麦克风" />
                </Grid>
                <Grid Grid.Row="3" Grid.Column="1">
                    <TextBlock
                        x:Name="TxbMicrophone"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        FontSize="16"
                        Foreground="#FF000000"
                        Text="" />
                </Grid>

                <Grid Grid.Row="6" Grid.Column="1">
                    <Button
                        x:Name="BtnDetection"
                        Grid.Row="2"
                        Width="116"
                        Height="30"
                        Margin="0"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Stretch"
                        Background="#3f6fff"
                        Click="BtnDetection_Click"
                        Content="重新检测"
                        Cursor="Hand"
                        FontSize="14"
                        Foreground="White"
                        IsDefault="True" />
                </Grid>
            </Grid>
        </Grid>
    </Grid>
</Window>
