<UserControl x:Class="VIZ.Package.Module.PluginMappingSettingView"
             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:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
             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:PluginMappingSettingViewModel}" 
             d:Background="White"
             mc:Ignorable="d" 
             d:DesignHeight="800" d:DesignWidth="800">

    <dxmvvm:Interaction.Behaviors>
        <dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand>
    </dxmvvm:Interaction.Behaviors>

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/VIZ.Package.Module.Resource;component/Style/IconButton/IconButton_Default.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
            <resource:RowHandleConverter x:Key="RowHandleConverter"></resource:RowHandleConverter>
        </ResourceDictionary>
    </UserControl.Resources>

    <GroupBox Header="插件映射" Padding="10" Margin="10">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="40"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <!-- 按钮组 -->
            <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
                <fcommon:IconButton Icon="/VIZ.Package.Module.Resource;component/Icons/add_32x32.png"
                                    Width="40" ToolTip="添加"
                                    Command="{Binding AddCommand}"
                                    Style="{StaticResource IconButton_Menu_Mask}"></fcommon:IconButton>
                <fcommon:IconButton Icon="/VIZ.Package.Module.Resource;component/Icons/delete_32x32.png"
                                    Width="40" ToolTip="删除"
                                    Command="{Binding DeleteCommand}"
                                    Style="{StaticResource IconButton_Menu_Mask}"></fcommon:IconButton>
            </StackPanel>

            <!-- 列表 -->
            <dxg:GridControl Grid.Row="1" ItemsSource="{Binding Path=Mappings}"
                             SelectedItem="{Binding Path=SelectedMapping,Mode=TwoWay}">
                <dxg:GridControl.Columns>
                    <dxg:GridColumn Header="序号" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="40" AllowResizing="False">
                        <dxg:GridColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding RowData.RowHandle,Converter={StaticResource RowHandleConverter}}"></TextBlock>
                            </DataTemplate>
                        </dxg:GridColumn.CellTemplate>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="场景" FieldName="Scene" AllowSorting="False" AllowColumnFiltering="False" Width="120" AllowResizing="False">
                        <dxg:GridColumn.EditSettings>
                            <dxe:TextEditSettings AcceptsReturn="False"></dxe:TextEditSettings>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="插件" FieldName="PluginID" AllowSorting="False" AllowColumnFiltering="False" Width="120" AllowResizing="False">
                        <dxg:GridColumn.EditSettings>
                            <dxe:ComboBoxEditSettings ItemsSource="{Binding Path=PluginInfos}" IsTextEditable="False"
                                                      SelectItemWithNullValue="True"
                                                      DisplayMember="Name" ValueMember="ID"></dxe:ComboBoxEditSettings>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                </dxg:GridControl.Columns>
                <dxg:GridControl.View>
                    <dxg:TableView IsColumnMenuEnabled="False"
                               AllowEditing="True" ShowIndicator="False"
                               NavigationStyle="Cell" ShowVerticalLines="False"
                               ShowGroupPanel="False" EditorShowMode="MouseDown"
                               AllowDragDrop="False"
                               ShowBandsPanel="False"
                               ShowTotalSummary="False"
                               ShowFixedTotalSummary="False"
                               ShowDragDropHint="False"
                               ShowTargetInfoInDragDropHint="false">
                    </dxg:TableView>
                </dxg:GridControl.View>
            </dxg:GridControl>
        </Grid>
    </GroupBox>
</UserControl>