<Window x:Class="uBIMEarthTools.PileCheck.PileCheckWindow"
        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:utils="clr-namespace:uBIMEarthTools.Utils"
        mc:Ignorable="d"
        Title="地质参数配置 - 桩" Height="450" Width="850">
    <Window.Resources>
        <Style TargetType="DataGridColumnHeader">
            <Setter Property="MinWidth" Value="95"/>
        </Style>
        <Style TargetType="TextBlock" x:Key="gridTextBlockStyle">
            <Setter Property="Margin" Value="5,0"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
        <Style TargetType="Button" x:Key="bottomButtonStyle">
            <Setter Property="Width" Value="75"/>
            <Setter Property="Height" Value="30"/>
            <Setter Property="Margin" Value="5,0,0,0"/>
        </Style>
        <Style TargetType="utils:TextBoxDoubleEx">
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="MinWidth" Value="80"/>
            <Setter Property="Margin" Value="5,0"/>
        </Style>
        <Style TargetType="ComboBox">
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Margin" Value="5,0"/>
        </Style>
        <Style TargetType="DataGridRow">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Height" Value="30"/>
        </Style>
        <Style TargetType="DataGridCell">
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Background" Value="Transparent"/>
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Foreground" Value="Blue"/>
                    <Setter Property="BorderBrush" Value="#FF3399FF"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>

    <DockPanel Margin="10">
        <DockPanel DockPanel.Dock="Top">
            <TextBlock Text="文件路径：" VerticalAlignment="Center"/>
            <Button DockPanel.Dock="Right" Content="打开" Width="100" Height="30" Command="{Binding OpenFileCmd}"/>
            <TextBox Margin="5,0" Height="30" VerticalAlignment="Center" VerticalContentAlignment="Center" ToolTip="手动修改后请按回车！"
                     Text="{Binding Path=FilePath,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" KeyDown="FilePath_KeyDown"/>
        </DockPanel>
        <WrapPanel Orientation="Horizontal" DockPanel.Dock="Bottom" HorizontalAlignment="Right" Margin="0,5,0,0">
            <Button Content="提交" Style="{StaticResource bottomButtonStyle}" Command="{Binding SubmitCmd}"/>
            <Button Content="取消" Style="{StaticResource bottomButtonStyle}" Command="{Binding CancelCmd}"/>
        </WrapPanel>
        <DataGrid Margin="0,10,0,0" Background="White" AutoGenerateColumns="False" CanUserAddRows="False" SelectionUnit="FullRow" GridLinesVisibility="None" RowHeaderWidth="0" HeadersVisibility="Column" SelectionMode="Single"
                  ItemsSource="{Binding Path=PileItems,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="区域">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Style="{StaticResource gridTextBlockStyle}" Text="{Binding Region}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="地块编号">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Style="{StaticResource gridTextBlockStyle}" Text="{Binding Number}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="类型">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Style="{StaticResource gridTextBlockStyle}" Text="{Binding Type}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="坐标(X,Y)">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Style="{StaticResource gridTextBlockStyle}">
                                <TextBlock.Text>
                                    <MultiBinding StringFormat="{}{0},{1}">
                                        <Binding Path="LocationX"/>
                                        <Binding Path="LocationY"/>
                                    </MultiBinding>
                                </TextBlock.Text>
                            </TextBlock>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="桩径(mm)">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <utils:TextBoxDoubleEx Text="{Binding Path=Diameter,Mode=TwoWay,UpdateSourceTrigger=LostFocus}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="桩顶高(mm)">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <utils:TextBoxDoubleEx Text="{Binding Path=TopOffset,Mode=TwoWay,UpdateSourceTrigger=LostFocus}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="持力层">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox ItemsSource="{Binding BearingStratumItems}" SelectedItem="{Binding Path=SelectedBearingStratumItem,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="入岩深度(Min～Max)">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <WrapPanel Orientation="Horizontal" VerticalAlignment="Center">
                                <utils:TextBoxDoubleEx Text="{Binding Path=DepthOfRockMin,Mode=TwoWay,UpdateSourceTrigger=LostFocus}"/>
                                <TextBlock Text="～" Margin="0,0,5,0"/>
                                <utils:TextBoxDoubleEx Text="{Binding Path=DepthOfRockMax,Mode=TwoWay,UpdateSourceTrigger=LostFocus}"/>
                            </WrapPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </DockPanel>
</Window>
