<Window x:Class="MeterVision.Stand.SelecteStationDlg"
        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:MeterVision.Stand"
        mc:Ignorable="d"
        Background="WhiteSmoke"
        ResizeMode="CanResizeWithGrip"
        WindowStartupLocation="CenterOwner"
        ShowInTaskbar="False"
        Title="选择要导出的站点" Height="800" Width="600">
    <Grid Margin="10 10 10 10">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="40" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="20" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="35" />
                <RowDefinition Height="*" />
                <RowDefinition Height="40" />
            </Grid.RowDefinitions>

            <StackPanel Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" Orientation="Horizontal">
                <TextBlock Text="备选站点: " FontSize="14px" VerticalAlignment="Center" Margin="5 0 10 0"/>
                <TextBox Width="100" FontSize="14px" Height="26" Text="{Binding StationId}" VerticalContentAlignment="Center" />
                <Button x:Name="btnQuery" Content="查询" FontSize="14px" Width="55" Height="26" Margin="10 0 0 0" Click="BtnQuery_Click" />
            </StackPanel>

            <DataGrid Name="dgStation1" Grid.Column="0" Grid.Row="1" GridLinesVisibility="All" HorizontalGridLinesBrush="#D3D3D3" VerticalGridLinesBrush="#D3D3D3" RowHeight="30" BorderBrush="#D3D3D3"
                  HeadersVisibility="Column" SelectionMode="Single" SelectionUnit="FullRow" HorizontalScrollBarVisibility="Auto" CanUserResizeColumns="False"  
                  FrozenColumnCount="0"
                  SelectedItem="{Binding SelectedStationItem1,Mode=TwoWay}"
                  AutoGenerateColumns="False" CanUserAddRows="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="White">
                <DataGrid.Resources>
                    <Style TargetType="DataGridColumnHeader">
                        <Setter Property="Height" Value="40" />
                        <!--Setter Property="Background" Value="White" /-->
                        <Setter Property="Foreground" Value="Black" />
                        <Setter Property="FontSize" Value="13px" />
                        <Setter Property="FontWeight" Value="Bold" />
                        <Setter Property="BorderBrush" Value="#D3D3D3" />
                        <Setter Property="BorderThickness" Value="0,0,1,1" />
                        <Setter Property="HorizontalContentAlignment" Value="Center" />
                    </Style>
                    <!-- 自定义行的选中样式 -->
                    <Style TargetType="DataGridRow">
                        <Style.Triggers>
                            <!-- 当行被选中时 -->
                            <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                                <!-- 设置选中行的背景色 -->
                                <Setter Property="Background" Value="AliceBlue"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>

                    <!-- 自定义选中单元格的背景色 -->
                    <Style TargetType="DataGridCell">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                                <!-- 设置选中单元格的背景色 -->
                                <Setter Property="Background" Value="AliceBlue"/>
                                <Setter Property="BorderBrush" Value="Transparent" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </DataGrid.Resources>
                
                <DataGrid.Columns>
                    <!--使用自定义模板-->
                    <!--<DataGridTemplateColumn Header="序号" Width="50">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Index}" FontSize="13px" Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>-->

                    <DataGridTemplateColumn Header="站点" Width="120">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <!--<TextBlock Text="{Binding StationId}" FontSize="13px" Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>-->
                                <TextBlock Text="{Binding StationId}" FontSize="13px" Foreground="{Binding StationIdColor}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <!--<DataGridTemplateColumn Header="标注" Width="50">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding MarkCountName}" FontSize="13px" Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>-->

                    <DataGridTemplateColumn Header="看图" Width="60" Visibility="Visible">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                    <Button x:Name="btnViewImage" Width="Auto" FontSize="13px" Content="查看" Foreground="#2196F3" VerticalAlignment="Center"
                                        BorderBrush="Transparent" BorderThickness="0 0 0 0" Background="Transparent" Margin="0 0 0 0"
                                        Click="BtnViewImage_Click"  />
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTemplateColumn Header="选中" Width="*">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                    <Button x:Name="btnAddStation" Width="Auto" FontSize="13px" Content="选中" Foreground="#2196F3" VerticalAlignment="Center"
                                        BorderBrush="Transparent" BorderThickness="0 0 0 0" Background="Transparent" Margin="0 0 0 0"
                                        Click="BtnAddStation_Click"  />
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                </DataGrid.Columns>
            </DataGrid>

            <StackPanel Grid.Column="0" Grid.Row="2" VerticalAlignment="Center">
                <!--<TextBlock Text="共 {0} 个备选站点" FontSize="14px" />-->
                <TextBlock Text="{Binding StationList1.Count,StringFormat='共 {0} 个备选站点'}" FontSize="14px" />
            </StackPanel>
            

            <StackPanel Grid.Column="2" Grid.Row="0" VerticalAlignment="Center">
                <TextBlock Text="已选择站点列表:" VerticalAlignment="Center" FontSize="14px" Margin="5 0 0 0" />
            </StackPanel>
            
            <DataGrid Name="dgStation2" Grid.Column="2" Grid.Row="1" GridLinesVisibility="All" HorizontalGridLinesBrush="#D3D3D3" VerticalGridLinesBrush="#D3D3D3" RowHeight="30" BorderBrush="#D3D3D3"
                  HeadersVisibility="Column" SelectionMode="Single" SelectionUnit="FullRow" HorizontalScrollBarVisibility="Auto" CanUserResizeColumns="False"  
                  FrozenColumnCount="0"
                  SelectedItem="{Binding SelectedStationItem2,Mode=TwoWay}"
                  AutoGenerateColumns="False" CanUserAddRows="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="White">
                <DataGrid.Resources>
                    <Style TargetType="DataGridColumnHeader">
                        <Setter Property="Height" Value="40" />
                        <!--Setter Property="Background" Value="White" /-->
                        <Setter Property="Foreground" Value="Black" />
                        <Setter Property="FontSize" Value="13px" />
                        <Setter Property="FontWeight" Value="Bold" />
                        <Setter Property="BorderBrush" Value="#D3D3D3" />
                        <Setter Property="BorderThickness" Value="0,0,1,1" />
                        <Setter Property="HorizontalContentAlignment" Value="Center" />
                    </Style>
                    <!-- 自定义行的选中样式 -->
                    <Style TargetType="DataGridRow">
                        <Style.Triggers>
                            <!-- 当行被选中时 -->
                            <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                                <!-- 设置选中行的背景色 -->
                                <Setter Property="Background" Value="AliceBlue"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>

                    <!-- 自定义选中单元格的背景色 -->
                    <Style TargetType="DataGridCell">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                                <!-- 设置选中单元格的背景色 -->
                                <Setter Property="Background" Value="AliceBlue"/>
                                <Setter Property="BorderBrush" Value="Transparent" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </DataGrid.Resources>

                <DataGrid.Columns>
                    <DataGridTemplateColumn Header="站点" Width="120">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <!--<TextBlock Text="{Binding StationId}" FontSize="13px" Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>-->
                                <TextBlock Text="{Binding StationId}" FontSize="13px" Foreground="{Binding StationIdColor}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>


                    <DataGridTemplateColumn Header="看图" Width="60" Visibility="Visible">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                    <Button x:Name="btnViewImage" Width="Auto" FontSize="13px" Content="查看" Foreground="#2196F3" VerticalAlignment="Center"
                                        BorderBrush="Transparent" BorderThickness="0 0 0 0" Background="Transparent" Margin="0 0 0 0"
                                        Click="BtnViewImage_Click"  />
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTemplateColumn Header="移除" Width="*">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                    <Button x:Name="btnRemoveStation" Width="Auto" FontSize="13px" Content="移除" Foreground="#2196F3" VerticalAlignment="Center"
                                        BorderBrush="Transparent" BorderThickness="0 0 0 0" Background="Transparent" Margin="0 0 0 0"
                                        Click="BtnRemoveStation_Click"  />
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                </DataGrid.Columns>
            </DataGrid>

            <StackPanel Grid.Column="2" Grid.Row="2" VerticalAlignment="Center">
                <!--<TextBlock Text="共 {0} 个已选站点" FontSize="14px" />-->
                <TextBlock Text="{Binding StationList2.Count,StringFormat='共 {0} 个已选站点'}" FontSize="14px" />
            </StackPanel>

        </Grid>
                
        <!--按钮区域-->
        <Border Grid.Row="1" BorderThickness="0 1 0 0" BorderBrush="#D3D3D3" >
            <StackPanel  Orientation="Horizontal" HorizontalAlignment="Center">
                <Button x:Name="btnOK" Content="确定" Width="80" Height="26" FontSize="14px"
                    HorizontalAlignment="Center" Margin="0 0 20 0" Click="BtnOK_Click"/>
                <Button x:Name="btnClose" Content="取消" Width="80" Height="26" FontSize="14px"
                    VerticalAlignment="Center" HorizontalAlignment="Center" Click="BtnClose_Click"/>
            </StackPanel>
        </Border>

    </Grid>
</Window>
