<UserControl x:Class="SlnMesnac.WPF.Page.IndexPage.MiddleWare"
             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:SlnMesnac.WPF.Page.IndexPage" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                xmlns:converters="clr-namespace:SlnMesnac.WPF.Converter.Generate"
             mc:Ignorable="d" 
             d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" Loaded="UserControl_Loaded">

    <UserControl.Resources>
        <Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="FontSize" Value="18"/>
        </Style>
        <Style TargetType="DataGrid">
            <!--网格线颜色-->
            <Setter Property="CanUserResizeColumns" Value="false"/>
            <Setter Property="Background" Value="#1152AC" />
            <Setter Property="BorderBrush" Value="#4285DE" />
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="HorizontalGridLinesBrush">
                <Setter.Value>
                    <SolidColorBrush Color="#4285DE"/>
                </Setter.Value>
            </Setter>
            <Setter Property="VerticalGridLinesBrush">
                <Setter.Value>
                    <SolidColorBrush Color="#1152AC"/>
                </Setter.Value>
            </Setter>
        </Style>
        <!--列头标题栏样式-->
        <Style TargetType="DataGridColumnHeader">

            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="BorderBrush" Value="#dddddd" />
            <Setter Property="Height" Value="40"/>
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="Background" Value="#4285DE"/>
            <Setter Property="Foreground" Value="White"/>
        </Style>

        <!--单元格样式-->
        <Style TargetType="DataGridCell">
            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="BorderBrush" Value="#4285DE" />
            <Setter Property="Height" Value="40"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type DataGridCell}">
                        <Grid Background="{TemplateBinding Background}" >
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="#4285DE"/>
                    <Setter Property="Foreground" Value="#dddddd"/>
                </Trigger>
            </Style.Triggers>

        </Style>
        <converters:ConfigToDynamicGridViewConverter  x:Key="ConfigToDynamicGridViewConverter"/>
        <DataTemplate x:Key="LogMsgTemplate">
            <TextBlock Text="{Binding}" FontSize="20"  Foreground="Black" TextWrapping="Wrap" MaxWidth="800"/>
        </DataTemplate>
        <DataTemplate x:Key="FlightTemplate">
            <StackPanel Margin="10,0,0,0">
                <Button Content="{Binding StationName}" Foreground="Black"/>
            </StackPanel>
        
        </DataTemplate>
    </UserControl.Resources>
    <Grid Margin="1 5 1 0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" Grid.Column="0" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" Background="Transparent" Margin="3,1,5,5">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="9*"/>
                </Grid.RowDefinitions>

                <Border Grid.Row="0" BorderBrush="#0288d1" BorderThickness="0,0,0,1" CornerRadius="0" Background="#1157b9" Margin="1,1,3,5" >
                    <TextBlock Text="日志信息" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold"/>
                </Border>
                <!--扫描信息-->
                <Border Grid.Row="1" BorderBrush="#0288d1" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,3,5">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>


                        <Border  BorderThickness="0"   Background="Transparent" CornerRadius="5" Margin="10,10,0,0" Grid.ColumnSpan="2">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="9*"/>
                                </Grid.RowDefinitions>
                                <!--<TextBlock Grid.Row="0" Text="日志信息" FontSize="18" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center"/>-->

                                <ScrollViewer Grid.Row="0" Foreground="Black"  HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
                                    <ItemsControl Foreground="Black"  ItemsSource="{Binding LogMessages}" ItemTemplate="{StaticResource LogMsgTemplate}" />
                                </ScrollViewer>
                            </Grid>
                        </Border>
                    </Grid>
                </Border>
            </Grid>
        </Border>
        <Border Grid.Row="1" Grid.ColumnSpan="2"  BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" Background="Transparent" Margin="3,1,3,5">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="9*"/>

                </Grid.RowDefinitions>
                <Border Grid.Row="0" BorderBrush="#0288d1" BorderThickness="0,0,0,1" CornerRadius="0" Background="Transparent" Margin="1,1,5,5" >
                    <TextBlock Text="传感器信息" FontSize="20" FontWeight="Bold" Foreground="Black" VerticalAlignment="Center" HorizontalAlignment="Center"  />
                </Border>
                <Border  Grid.Row="1" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="10" Background="Transparent" Margin="5,1,5,5">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="3*"/>
                        </Grid.ColumnDefinitions>
                        <StackPanel x:Name="stackpanel1">
                            <DataGrid x:Name="senorlistDataGrid"  Grid.Row="0" ItemsSource="{Binding Senorinfo}" Background="#00000000" 
   ColumnHeaderHeight="35"   Height="{Binding Path=ActualHeight, ElementName=ScanPanel}" 
  RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"  FontSize="20"
  GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto" 
  ScrollViewer.VerticalScrollBarVisibility="Auto"  BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True" MaxHeight="400" VerticalScrollBarVisibility="Auto"
  Foreground="Black"  >
                                <DataGrid.RowStyle>
                                    <Style TargetType="DataGridRow">
                                        <!-- 右键按下事件（最常用，右键点击立即触发） -->
                                        <EventSetter Event="MouseRightButtonDown" 
                                 Handler="DataGridRow_MouseRightButtonDown"/>
                                        <!-- 可选：右键释放事件（右键松开时触发） -->
                                        <!-- <EventSetter Event="MouseRightButtonUp" Handler="DataGridRow_MouseRightButtonUp"/> -->
                                    </Style>
                                </DataGrid.RowStyle>
                                <DataGrid.Columns>
                                    <DataGridTextColumn Binding="{Binding Combineid}" Header="编号" Width="1*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>
                                    <DataGridTextColumn Binding="{Binding Name}" Header="名称" Width="1.5*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                    <!--<DataGridTextColumn Binding="{Binding Sensorser}" Header="序号" Width="0.2*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                    <DataGridTextColumn Binding="{Binding Sensortypeid}" Header="类型" Width="0.5*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />-->
                                    <DataGridTextColumn Binding="{Binding Deviceid}" Header="设备编号" Width="1*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                    <DataGridTextColumn Binding="{Binding Readinterval}" Header="时间间隔" Width="0.5*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                    <DataGridTextColumn Binding="{Binding Readdata}" Header="数据" Width="1*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />

                                    <DataGridTextColumn Binding="{Binding Readtime}" Header="时间" Width="1*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />

                                </DataGrid.Columns>
                            </DataGrid>
                        </StackPanel>
                    </Grid>
                </Border>


            </Grid>
        </Border>
        <!--日志信息-->
        <Border Grid.Row="0" Grid.Column="1" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" Background="Transparent" Margin="3,1,3,5">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="9*"/>

                </Grid.RowDefinitions>
                <Border Grid.Row="0" BorderBrush="#0288d1" BorderThickness="0,0,0,1" CornerRadius="0" Background="Transparent" Margin="1,1,1,5" >
                    <Grid>
                        <TextBlock Text="设备信息" FontSize="20" FontWeight="Bold" Foreground="Black" VerticalAlignment="Center" HorizontalAlignment="Center" />

                    </Grid>
                </Border>

                <Border  Grid.Row="1" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="10" Background="Transparent" Margin="5,1,5,5">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="3*"/>
                        </Grid.ColumnDefinitions>
                        <StackPanel x:Name="stackpanel2">
                            <DataGrid Grid.Row="0" ItemsSource="{Binding Deviceinfo}"  Background="#00000000" 
   ColumnHeaderHeight="35"   Height="{Binding Path=ActualHeight, ElementName=ScanPanel}" 
  RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"  FontSize="20"
  GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto" 
  ScrollViewer.VerticalScrollBarVisibility="Auto"  BorderThickness="0" CanUserAddRows="False" IsReadOnly="True" SelectionMode="Extended"  MaxHeight="400" VerticalScrollBarVisibility="Auto"
  Foreground="Black"  >

                                <DataGrid.Columns>
                                    <DataGridTextColumn Binding="{Binding Deviceid}" Header="编号" Width="1*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>
                                    <DataGridTextColumn Binding="{Binding Name}" Header="名称" Width="2.5*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                    <DataGridTextColumn Binding="{Binding Connectstr}" Header="连接串" Width="2*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                    <!--<DataGridTextColumn Binding="{Binding Connectmode}" Header="连接方式" Width="1*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />-->
                                    <DataGridTextColumn Binding="{Binding Devicetype}" Header="设备类型" Width="1*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                    <DataGridTextColumn Binding="{Binding Collectid}" Header="所属汇集" Width="0.7*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                    <DataGridTextColumn Binding="{Binding IsOnline}" Header="连接状态" Width="1*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />

                                </DataGrid.Columns>
                            </DataGrid>
                        </StackPanel>
                    </Grid>
                </Border>
            </Grid>
        </Border>


    </Grid>
</UserControl>
