<Window x:Class="AdbTools.MainWindow"
        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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:AdbTools" xmlns:customcontrol="clr-namespace:AdbTools.CustomControl"
        mc:Ignorable="d"
        Title="Adb连接工具" Height="450" Width="350" FontSize="16" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" Unloaded="Window_Unloaded" >
    <Window.Resources>
        <ContextMenu x:Key="ListBoxItemContextMenu"  FontSize="13">
            <MenuItem x:Name="installApkItem" Header="安装应用" Click="installApkItem_Click" Cursor="Hand"   Margin="0,2" />
            <MenuItem x:Name="disconnectDeviceItem" Header="断开设备" Click="disconnectDeviceItem_Click"  Cursor="Hand" Margin="0,2"/>
            <Separator  Margin="0,5"/>
            <MenuItem Header="查看日志" Cursor="Hand" Margin="0,2" >
                <MenuItem x:Name="logcatItem" Header="实时日志" Cursor="Hand"   Margin="0,2" Click="logcatItem_Click" />
                <MenuItem x:Name="logcatDebugItem" Header="Debug日志" Cursor="Hand" Margin="0,2" Click="logcatDebugItem_Click" />
            </MenuItem>
            <Separator  Margin="0,5"/>
            <MenuItem Header="恢复默认" Cursor="Hand" Margin="0,2" >
                <MenuItem x:Name="resetPXItem" Header="恢复默认分辨率" Cursor="Hand"   Margin="0,2" Click="resetPXItem_Click" />
                <MenuItem x:Name="resetDPIItem" Header="恢复默认DPI" Cursor="Hand" Margin="0,2" Click="resetDPIItem_Click"/>
            </MenuItem>
            <Separator  Margin="0,5"/>
            <MenuItem x:Name="disconnectAllDeviceItem" Header="断开所有设备" Click="disconnectAllDeviceItem_Click" Cursor="Hand" Margin="0,2" />
        </ContextMenu>
        <ContextMenu x:Key="ComboBoxItemContextMenu" FontSize="13">
            <MenuItem x:Name="deleteHistory" Header="删除记录" Cursor="Hand"  Margin="0,2" Click="deleteHistory_Click"/>
            <Separator  Margin="0,5"/>
            <MenuItem x:Name="deleteAllHistory" Header="清空所有记录" Click="deleteAllHistory_Click" Cursor="Hand"  Margin="0,2"/>
        </ContextMenu>
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Command="{x:Static local:MainWindow.CommandF5}"
                    Key="F5"/>
        <KeyBinding Command="{x:Static local:MainWindow.CommandF8}"
                    Key="F8"/>
    </Window.InputBindings>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Grid.ColumnSpan="3" Margin="0,0,0,10">
            <Label Content="IP和端口" Margin="10,10,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="85"/>
            <ComboBox x:Name="deviceAddress" IsEditable="True" ToolTip="示例：192.168.0.1:5555，使用英文【:】连接IP和端口" Margin="100,10,10,0" IsSynchronizedWithCurrentItem="False" Height="30" VerticalAlignment="Top" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" BorderBrush="{x:Null}" Background="{x:Null}" TabIndex="0" >
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}" ContextMenu="{StaticResource ComboBoxItemContextMenu}" Cursor="Hand" Margin="0,0,0,0"/>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <Label Content="配对码" Margin="10,50,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="85"/>
            <TextBox x:Name="pairCode" Margin="100,50,10,0" Height="30" ToolTip="配对设备时输入配对码"  VerticalAlignment="Top" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" MaxLength="10" TabIndex="1"/>
            <Button x:Name="connectDevice" IsDefault="True" Content="连接(Enter)" ToolTip="输入连接的IP和端口进行连接"  Foreground="White" Background="#FF2A9FFF"  Margin="10,90,0,0" VerticalAlignment="Top" Height="30" HorizontalAlignment="Left" Width="110" Click="connectDevice_Click" Cursor="Hand" TabIndex="2"/>
            <Button x:Name="pairDevice" Content="配对(F8)" ToolTip="输入配对的IP和端口进行配对" Margin="0,90,10,0"  Foreground="White" Background="#FFE87D00"  VerticalAlignment="Top" Height="30" HorizontalAlignment="Right" Width="110" Click="pairDevice_Click" Cursor="Hand" TabIndex="3"/>

        </Grid>

        <Grid Grid.Row="1" Grid.ColumnSpan="3">
            <Label Content="连接列表" Margin="10,5,10,0" VerticalAlignment="Top" HorizontalContentAlignment="Center"/>
            <ListBox x:Name="deviceList" Margin="10,40,10,50" ToolTip="右键连接的设备进行操作" ItemsSource="{Binding}" HorizontalContentAlignment="Center" TabIndex="4">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel Orientation="Vertical" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Cursor="Hand" Width="300" Margin="0,5" ContextMenu="{StaticResource ListBoxItemContextMenu}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="50"/>
                            </Grid.ColumnDefinitions>
                            <Grid Grid.Column="0">
                                <StackPanel>
                                    <TextBlock Text="{Binding Path=DeviceInfo, Mode=Default}" TextWrapping="Wrap"/>
                                    <TextBlock Text="{Binding Path=DeviceMark, Mode=Default}" TextWrapping="Wrap" Foreground="#FF2A9FFF" FontSize="13"/>
                                </StackPanel>
                            </Grid>
                            <Grid Grid.Column="1" Margin="0">
                                <Label Content="{Binding Path=ConnectWay}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Foreground="{Binding Path=ConnectWayColor}"/>
                            </Grid>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <Button x:Name="refreshList" Content="刷新(F5)" ToolTip="刷新已连接列表" Margin="0,0,0,10" Width="110" Cursor="Hand" Height="30" VerticalAlignment="Bottom" Click="refreshList_Click" Foreground="White" BorderBrush="{x:Null}" Background="#FF06AB26" TabIndex="5"/>
        </Grid>

        <Grid Grid.RowSpan="2" Visibility="Collapsed" x:Name="processBarGrid" Background="#7F000000" >
            <customcontrol:RoundProcessBarLoading x:Name="waitProcessBar" Height="130" Width="130"/>
            <Label Content="处理中"  Height="120" Width="120" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"/>
        </Grid>
    </Grid>
</Window>
