<UserControl x:Class="VIZ.Package.Module.FieldTreeView"
             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:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
             xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
             xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
             xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
             xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
             xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
             xmlns:storage="clr-namespace:VIZ.Package.Storage;assembly=VIZ.Package.Storage"
             xmlns:resource="clr-namespace:VIZ.Package.Module.Resource;assembly=VIZ.Package.Module.Resource"
             xmlns:local="clr-namespace:VIZ.Package.Module"
             xmlns:domain="clr-namespace:VIZ.Package.Domain;assembly=VIZ.Package.Domain"
             d:DataContext="{d:DesignInstance Type=local:FieldTreeViewModel}" 
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <fcore:Bool2VisibilityConverter x:Key="Bool2VisibilityConverter"></fcore:Bool2VisibilityConverter>
        <resource:VizControlFieldTypeStringConverter x:Key="VizControlFieldTypeStringConverter"></resource:VizControlFieldTypeStringConverter>
    </UserControl.Resources>

    <Grid>
        <dxg:GridControl ItemsSource="{Binding Path=ControlObject.FieldNodes}" ShowBorder="False"
                         SelectedItem="{Binding Path=SelectedControlField,Mode=TwoWay}">
            <dxg:GridControl.Columns>
                <dxg:GridColumn Header="字段" FieldName="FieldIdentifier" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="150" AllowResizing="True"></dxg:GridColumn>
                <dxg:GridColumn Header="" FieldName="IsCustom" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="20" AllowResizing="True">
                    <dxg:GridColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="/VIZ.Package.Module.Resource;component/Icons/icon_custom_32x32.png" Width="14" Height="14"
                                   Visibility="{Binding Path=Row.IsCustom,Converter={StaticResource Bool2VisibilityConverter}}"></Image>
                        </DataTemplate>
                    </dxg:GridColumn.CellTemplate>
                </dxg:GridColumn>
                <dxg:GridColumn Header="类型" FieldName="Type" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="100" AllowResizing="True">
                    <dxg:GridColumn.CellTemplate>
                        <DataTemplate>
                            <Border Background="Transparent">
                                <TextBlock Text="{Binding Path=Row.Type,Converter={StaticResource VizControlFieldTypeStringConverter}}" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Margin="4,0,4,0" VerticalAlignment="Center"></TextBlock>
                            </Border>
                        </DataTemplate>
                    </dxg:GridColumn.CellTemplate>
                </dxg:GridColumn>
                <dxg:GridColumn Header="描述" FieldName="Description" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="*" AllowResizing="True"></dxg:GridColumn>
                <dxg:GridColumn Header="值" FieldName="Value" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="*" AllowResizing="True">
                    <dxg:GridColumn.CellTemplate>
                        <DataTemplate>
                            <Border Background="Transparent"
                                    ToolTip="{Binding Path=Row.Value}">
                                <TextBlock Text="{Binding Path=Row.Value}" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Margin="4,0,4,0" VerticalAlignment="Center"></TextBlock>
                            </Border>
                        </DataTemplate>
                    </dxg:GridColumn.CellTemplate>
                </dxg:GridColumn>
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:TreeListView AllowEditing="False" ShowIndicator="False"
                                  IsColumnMenuEnabled="False"
                                  NavigationStyle="Row" ShowVerticalLines="False"
                                  ShowHorizontalLines="False"
                                  AlternateRowBackground="#05ffffff"
                                  ShowBandsPanel="False"
                                  ShowTotalSummary="False"
                                  ShowFixedTotalSummary="False"
                                  ShowDragDropHint="False"
                                  ShowTargetInfoInDragDropHint="false"
                                  TreeDerivationMode="ChildNodesSelector" ChildNodesPath="Items">
                </dxg:TreeListView>
            </dxg:GridControl.View>
        </dxg:GridControl>

        <dx:WaitIndicator DeferedVisibility="{Binding IsLoading}" Content="Loading..." />
    </Grid>
</UserControl>
