<UserControl x:Class="DBInStudio.Desktop.View.TagGroupDetailView"
             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:DBInStudio.Desktop"
             mc:Ignorable="d"  Foreground="{DynamicResource Window.Forground}"
             d:DesignHeight="450" d:DesignWidth="1024" Name="tgd" Background="#7F000000">
    <UserControl.Resources>
        <local:IndexConverter x:Key="ic" />
        <BooleanToVisibilityConverter x:Key="btv" />
        <local:BoolInvertConvert x:Key="biv" />
        <local:DoubleValueConvert x:Key="dvc" />
        <ContextMenu x:Key="ctxmenu">
            <MenuItem Header="{local:ResMarker Add}" Command="{Binding AddCommand}" />
            <MenuItem Header="{local:ResMarker Remove}" Command="{Binding RemoveCommand}" />
            <MenuItem Header="{local:ResMarker Import}" Command="{Binding ImportCommand}" />
            <MenuItem Header="{local:ResMarker Export}" Command="{Binding ExportCommand}" />
            <MenuItem Header="{local:ResMarker Copy}" Command="{Binding CopyCommand}" />
            <MenuItem Header="{local:ResMarker Paste}" Command="{Binding PasteCommand}" />
            <MenuItem Header="{local:ResMarker PropertyCopy}" Command="{Binding CellCopyCommand}" />
            <MenuItem Header="{local:ResMarker PropertyPaste}" Command="{Binding CellPasteCommand}" />
        </ContextMenu>
    </UserControl.Resources>
    <Grid Background="Transparent">
        
        <Grid.RowDefinitions>
            <RowDefinition Height="89" MaxHeight="89" />
            <RowDefinition Height="*" />
            <RowDefinition Height="32" />
        </Grid.RowDefinitions>
        <Grid  VerticalAlignment="Stretch" Background="#0FFFFFFF">
            <Grid.RowDefinitions>
                <RowDefinition Height="24"/>
                <RowDefinition Height="Auto" x:Name="row2"/>
            </Grid.RowDefinitions>
            <Label Background="#1FFFFFFF"  Foreground="{DynamicResource Window.Forground}" Content="{local:ResMarker TagFilter}" VerticalContentAlignment="Center"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
            <Grid Grid.Row="1"  TextElement.FontSize="12" Name="fg" Height="60" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="30" />
                </Grid.RowDefinitions>
                <TextBlock Text="{local:ResMarker Keyword,:}"  VerticalAlignment="Center" Margin="5,0" />
                <TextBox x:Name="kwinput" VerticalContentAlignment="Center" CaretBrush="White" Margin="10,0"  Foreground="{DynamicResource Window.Forground}" Background="#1FFFFFFF" Grid.Column="1" Text="{Binding FilterKeyName,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Width="160" HorizontalAlignment="Left" VerticalAlignment="Center" Height="20" KeyDown="kwinput_KeyDown" />

                <CheckBox Background="Transparent" HorizontalAlignment="Right" Foreground="{DynamicResource Window.Forground}" Grid.Column="2" IsChecked="{Binding TagTypeFilterEnable}" Content="{local:ResMarker Type,:}" VerticalAlignment="Center" Margin="10,0" />
                <ComboBox VerticalAlignment="Center"   Grid.Column="3" Margin="10,0" Width="100"  BorderThickness="1" IsEnabled="{Binding TagTypeFilterEnable}" ItemsSource="{Binding TagTypeList}" SelectedIndex="{Binding FilterType}" />

                <CheckBox Background="Transparent" HorizontalAlignment="Right"  Foreground="{DynamicResource Window.Forground}" Grid.Column="4" IsChecked="{Binding ReadWriteModeFilterEnable}" Content="{local:ResMarker ReadWriteMode}" VerticalAlignment="Center" Margin="10,0" />
                <ComboBox  VerticalAlignment="Center"  Grid.Column="5" Margin="10,0" Width="100"  BorderThickness="1" IsEnabled="{Binding ReadWriteModeFilterEnable}" ItemsSource="{Binding ReadWriteModeList}" SelectedIndex="{Binding FilterReadWriteMode}" />

                <CheckBox Background="Transparent" HorizontalAlignment="Left"  Foreground="{DynamicResource Window.Forground}" Grid.Column="6" IsChecked="{Binding RecordFilterEnable}" Content="{local:ResMarker Record}" VerticalAlignment="Center" Margin="10,0" />
                <RadioButton GroupName="rt" BorderBrush="{DynamicResource Window.Forground}" Background="Transparent" HorizontalAlignment="Left" Foreground="{DynamicResource Window.Forground}" IsEnabled="{Binding RecordFilterEnable}" Grid.Column="7" IsChecked="{Binding TimerRecordFilterEnable}" Content="{local:ResMarker Timer}" VerticalAlignment="Center" Margin="10,0" />
                <RadioButton GroupName="rt" BorderBrush="{DynamicResource Window.Forground}" Background="Transparent" HorizontalAlignment="Left" Foreground="{DynamicResource Window.Forground}" IsEnabled="{Binding RecordFilterEnable}"  Grid.Column="8" IsChecked="{Binding ValueChangedRecordFilterEnable}" Content="{local:ResMarker ValueChanged}" VerticalAlignment="Center" Margin="10,0" />

                <CheckBox Background="Transparent" HorizontalAlignment="Right"  Foreground="{DynamicResource Window.Forground}" Grid.Row="2" Grid.Column="6" IsChecked="{Binding CompressFilterEnable}" Content="{local:ResMarker CompressType}" VerticalAlignment="Center" Margin="10,0" />
                <ComboBox VerticalAlignment="Center"  Grid.Column="7" Margin="10,0" Width="100" Grid.Row="2"  BorderThickness="1" IsEnabled="{Binding CompressFilterEnable}" ItemsSource="{Binding CompressTypeList}" SelectedIndex="{Binding FilterCompressType}" />

                <CheckBox Background="Transparent" Foreground="{DynamicResource Window.Forground}" Content="{local:ResMarker Driver}" IsChecked="{Binding DriverFilterEnable}" HorizontalAlignment="Left" Grid.Column="2" Grid.Row="2" VerticalAlignment="Center" Margin="10,0" />
                <ComboBox VerticalAlignment="Center"  Grid.Row="2" Grid.Column="3" Margin="10,0" Width="100"  BorderThickness="1" IsEnabled="{Binding DriverFilterEnable}" ItemsSource="{Binding DriverList}" SelectedItem="{Binding FilterDriver}" />

                <CheckBox Background="Transparent" Foreground="{DynamicResource Window.Forground}" Content="{local:ResMarker Registor}" IsChecked="{Binding RegistorFilterEnable}" HorizontalAlignment="Left" Grid.Column="4" Grid.Row="2" VerticalAlignment="Center" Margin="10,0" />
                <ComboBox VerticalAlignment="Center" IsEditable="False" Grid.Row="2" Grid.Column="5" Margin="10,0" Width="100" IsEnabled="{Binding RegistorFilterEnable}" BorderThickness="1" ItemsSource="{Binding RegistorList}" Text="{Binding FilterRegistorName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />

                <StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="10" HorizontalAlignment="Right" VerticalAlignment="Center">
                    <ToggleButton Style="{DynamicResource ToggleButtonStyle1}" Width="24" Margin="5,0" BorderThickness="0" Background="Transparent" IsChecked="{Binding RowSelectMode,Mode=TwoWay}" Grid.Row="1" VerticalAlignment="Center">
                        <Image Height="16" Source="/Image/rowselect.png" />
                    </ToggleButton>
                    <ToggleButton Style="{DynamicResource ToggleButtonStyle1}" Width="24" Margin="0,0,10,0"  Background="Transparent" BorderThickness="0" IsChecked="{Binding CellSelectMode,Mode=TwoWay}" Grid.Row="1" VerticalAlignment="Center">
                        <Image Height="16" Source="/Image/cellselect.png" />
                    </ToggleButton>
                </StackPanel>
                

            </Grid>
        </Grid>
        <GridSplitter HorizontalAlignment="Stretch" Height="5" VerticalAlignment="Bottom" Background="Transparent" />
        <DataGrid x:Name="dg" Grid.Row="1"  SelectedCellsChanged="DataGrid_SelectedCellsChanged"  RowHeaderWidth="36" SelectionUnit="{Binding SelectMode}" Style="{DynamicResource DataGridStyle1}" ColumnHeaderStyle="{DynamicResource DataGridColumnHeaderStyle1}" CellStyle="{DynamicResource DataGridCellStyle1}" RowHeaderStyle="{DynamicResource DataGridRowHeaderStyle1}" RowStyle="{DynamicResource DataGridRowStyle1}" ScrollViewer.CanContentScroll="True" ContextMenu="{StaticResource ctxmenu}" VerticalScrollBarVisibility="Auto" ScrollViewer.ScrollChanged="DataGrid_ScrollChanged"  VirtualizingPanel.IsVirtualizing="True" RowDetailsVisibilityMode="VisibleWhenSelected" MinRowHeight="24" Margin="0,0,0,0" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding SelectGroupTags}" SelectedItem="{Binding CurrentSelectTag,Mode=TwoWay}"   BorderThickness="0,1,0,1" Background="Transparent" >
            <DataGrid.InputBindings>
                <KeyBinding Command="{Binding CopyCommand}" Key="C" Modifiers="Ctrl" />
                <KeyBinding Command="{Binding CellCopyCommand}" Key="C" Modifiers="Alt" />
                <KeyBinding Command="{Binding PasteCommand}" Key="V" Modifiers="Ctrl" />
                <KeyBinding Command="{Binding CellPasteCommand}" Key="V" Modifiers="Alt" />
                <KeyBinding Command="{Binding RemoveCommand}" Key="Delete" />
                <KeyBinding Command="{Binding AddCommand}" Key="A"  Modifiers="Alt" />
                <KeyBinding Command="{Binding ImportCommand}" Key="I"  Modifiers="Alt" />
                <KeyBinding Command="{Binding ExportCommand}" Key="O" Modifiers="Alt" />
            </DataGrid.InputBindings>
            <DataGrid.RowHeaderTemplate>
                <DataTemplate>
                    <TextBlock  DataContext="{Binding DataContext,RelativeSource={RelativeSource AncestorType=DataGridRow}}" Foreground="{DynamicResource Window.Forground}" HorizontalAlignment="Center" VerticalAlignment="Center" >
                        <TextBlock.Text>
                            <MultiBinding Converter="{StaticResource ic}">
                                <Binding />
                                <Binding Path="DataContext.SelectGroupTags" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}" />
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                </DataTemplate>
            </DataGrid.RowHeaderTemplate>

            <DataGrid.Columns>

                <!--<DataGridTemplateColumn  IsReadOnly="True" Width="Auto" MinWidth="30" Header="{local:ResMarker Id}" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Foreground="{DynamicResource Window.Forground}" HorizontalAlignment="Center" VerticalAlignment="Center" >
                                <TextBlock.Text>
                                    <MultiBinding Converter="{StaticResource ic}">
                                        <Binding />
                                        <Binding Path="DataContext.SelectGroupTags" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}" />
                                    </MultiBinding>
                                </TextBlock.Text>
                            </TextBlock>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>-->

                <DataGridTemplateColumn Header="{local:ResMarker Name}" Width="100" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Margin="5,0" Foreground="{DynamicResource Window.Forground}" Text="{Binding Name}" VerticalAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Margin="0,0"  Loaded="TextBox_Loaded"  CaretBrush="White" Background="#1FFFFFFF" Foreground="{DynamicResource Window.Forground}" Padding="3,0" BorderThickness="0" Text="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" VerticalAlignment="Stretch" VerticalContentAlignment="Center"  />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>


                <DataGridTemplateColumn Header="{local:ResMarker Type}" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Margin="5,0" Foreground="{DynamicResource Window.Forground}" Text="{Binding TypeString}" VerticalAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox  VerticalContentAlignment="Center" Padding="5,0" Margin="0" Background="#1FFFFFFF"  BorderThickness="0" SelectionChanged="Type_SelectionChanged" ItemsSource="{Binding TagTypeList}" SelectedIndex="{Binding Type,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="{local:ResMarker ReadWriteMode}" MinWidth="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Margin="5,0" Foreground="{DynamicResource Window.Forground}" Text="{Binding ReadWriteModeString}" VerticalAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox  VerticalContentAlignment="Center" Padding="5,0" Margin="0" Background="#1FFFFFFF"  BorderThickness="0" SelectionChanged="Type_SelectionChanged" ItemsSource="{Binding ReadWriteModeList}" SelectedIndex="{Binding ReadWriteMode,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn  Header="{local:ResMarker Convert}" MinWidth="100" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock  Margin="5,0" Foreground="{DynamicResource Window.Forground}" Text="{Binding ConvertString}" VerticalAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <Grid Margin="0,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <TextBlock Foreground="{DynamicResource Window.Forground}" Margin="5,0" Text="{Binding ConvertString}" VerticalAlignment="Center" MinWidth="60" />
                                <Button Grid.Column="1" Margin="4,0" Background="#1FFFFFFF" Foreground="{DynamicResource Window.Forground}" Content="..." VerticalAlignment="Center" VerticalContentAlignment="Top" Command="{Binding ConvertEditCommand}" Width="24" />
                                <Button Grid.Column="2" Margin="4,0" Command="{Binding ConvertRemoveCommand}" BorderThickness="0"  Background="Transparent" >
                                    <Button.ContentTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal" Margin="0">
                                                <Image Source="/Image/close.png" Height="12" RenderOptions.BitmapScalingMode="NearestNeighbor" Margin="0,0,4,0"/>
                                            </StackPanel>
                                        </DataTemplate>
                                    </Button.ContentTemplate>
                                </Button>
                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="{local:ResMarker MaxValue}" MinWidth="100"  IsReadOnly="{Binding IsNumberTag,Converter={StaticResource biv}}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Margin="5,0" Foreground="{DynamicResource Window.Forground}" Text="{Binding MaxValue,Converter={StaticResource dvc}}" IsEnabled="{Binding IsNumberTag}" VerticalAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox   Padding="3,0"  Loaded="TextBox_Loaded"  CaretBrush="White" Background="#1FFFFFFF" Margin="-1" Foreground="{DynamicResource Window.Forground}" Text="{Binding MaxValue,Mode=TwoWay,UpdateSourceTrigger=LostFocus,Converter={StaticResource dvc}}"  IsEnabled="{Binding IsNumberTag}" VerticalAlignment="Stretch" VerticalContentAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="{local:ResMarker MinValue}" MinWidth="100" IsReadOnly="{Binding IsNumberTag,Converter={StaticResource biv}}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Margin="5,0" Foreground="{DynamicResource Window.Forground}"  IsEnabled="{Binding IsNumberTag}" Text="{Binding MinValue,Converter={StaticResource dvc}}" VerticalAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Padding="3,0"   Loaded="TextBox_Loaded" CaretBrush="White" Background="#1FFFFFFF" Margin="-1" Foreground="{DynamicResource Window.Forground}"  IsEnabled="{Binding IsNumberTag}" Text="{Binding MinValue,Mode=TwoWay,UpdateSourceTrigger=LostFocus,Converter={StaticResource dvc}}" VerticalAlignment="Stretch" VerticalContentAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="{local:ResMarker Precision}" MinWidth="100" IsReadOnly="{Binding IsFloatingTag,Converter={StaticResource biv}}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Margin="5,0" Foreground="{DynamicResource Window.Forground}" Text="{Binding Precision}" IsEnabled="{Binding IsFloatingTag}" VerticalAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox  Padding="3,0"   Loaded="TextBox_Loaded" CaretBrush="White" Background="#1FFFFFFF" Margin="-1" Foreground="{DynamicResource Window.Forground}" Text="{Binding Precision,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" IsEnabled="{Binding IsFloatingTag}" VerticalAlignment="Stretch" VerticalContentAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="{local:ResMarker Record}" Width="120">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <CheckBox Background="#1FFFFFFF" Foreground="{DynamicResource Window.Forground}" BorderBrush="{DynamicResource Window.Forground}"  VerticalAlignment="Center" IsChecked="{Binding HasHisTag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Margin="5,0" />
                                <TextBlock Foreground="{DynamicResource Window.Forground}" Text="{Binding RecordTypeString}" VerticalAlignment="Center" />
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="{local:ResMarker Driver}" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Foreground="{DynamicResource Window.Forground}" Margin="5,0" Text="{Binding DriverName}" VerticalAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox   Padding="5,0" Loaded="ComboBox_Loaded" Background="#1FFFFFFF"  SelectionChanged="Type_SelectionChanged"  Margin="0" VerticalContentAlignment="Center" BorderThickness="0" ItemsSource="{Binding DriverList}" IsEditable="True" Text="{Binding DriverName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="{local:ResMarker Registor}" Width="*">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Foreground="{DynamicResource Window.Forground}" Margin="5,0" Text="{Binding RegistorName}" VerticalAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox  Padding="5,0" Loaded="ComboBox_Loaded" Background="#1FFFFFFF" SelectionChanged="Type_SelectionChanged"  Margin="0" VerticalContentAlignment="Center" BorderThickness="0" ItemsSource="{Binding RegistorList}"  IsEditable="True" Text="{Binding RegistorName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>

                <!--<DataGridTextColumn Header="{local:ResMarker Desc}" Width="*" Binding="{Binding Desc,Mode=TwoWay}" />-->

                <DataGridTemplateColumn Header="{local:ResMarker Desc}" Width="*">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Foreground="{DynamicResource Window.Forground}" Margin="5,0" Text="{Binding Desc}" VerticalAlignment="Center" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox  Loaded="TextBox_Loaded"  CaretBrush="White" Background="#1FFFFFFF" Foreground="{DynamicResource Window.Forground}" Margin="0,0" Padding="3,0" BorderThickness="0" Text="{Binding Desc,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" VerticalAlignment="Stretch" VerticalContentAlignment="Center"  />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
            <DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <Grid  Margin="10,4" Visibility="{Binding HasHisTag,Converter={StaticResource btv}}" Height="36">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="{local:ResMarker RecordType,:}" Foreground="{DynamicResource Window.Forground}" VerticalAlignment="Center" />
                        <ComboBox Margin="4,0" Grid.Column="1" Width="160" VerticalAlignment="Center"  SelectedIndex="{Binding RecordType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding RecordTypeList}">
                            
                        </ComboBox>
                        <StackPanel Grid.Column="2" Orientation="Horizontal">
                            <Grid Margin="4,0"  Visibility="{Binding IsTimerRecord,Converter={StaticResource btv}}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Foreground="{DynamicResource Window.Forground}" Text="{local:ResMarker Circle,:}" VerticalAlignment="Center" />
                                <TextBox  CaretBrush="White"  Background="#1FFFFFFF" Foreground="{Binding Foreground,RelativeSource={RelativeSource AncestorType=UserControl}}" Margin="8,0" Grid.Column="1" Width="60" Text="{Binding CompressCircle,Mode=TwoWay}" VerticalAlignment="Center" />
                            </Grid>
                            <TextBlock Foreground="{DynamicResource Window.Forground}" Text="{local:ResMarker CompressType,:}"  VerticalAlignment="Center"/>
                            <ComboBox  Background="#1FFFFFFF"  Margin="8,0" Width="160" VerticalAlignment="Center" ItemsSource="{Binding CompressTypeList}" SelectedIndex="{Binding CompressType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
                            <ContentControl  VerticalAlignment="Center" Content="{Binding CompressParameterModel}" HorizontalAlignment="Stretch" />
                        </StackPanel>

                    </Grid>
                </DataTemplate>
            </DataGrid.RowDetailsTemplate>
        </DataGrid>
        <StackPanel Grid.Row="2" Orientation="Horizontal" Grid.Column="1" Height="32" VerticalAlignment="Bottom"  Background="#0FFFFFFF">
            <Button  BorderBrush="Green"  BorderThickness="0,0,0,2"  Content="{local:ResMarker Add}" Command="{Binding AddCommand}" Width="80" HorizontalAlignment="Left" VerticalAlignment="Center" Height="26" Margin="5,0" Padding="0">
                <Button.ContentTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Margin="0">

                            <Image Source="/Image/Add.png" Height="12" RenderOptions.BitmapScalingMode="NearestNeighbor" Margin="0,0,4,0"/>
                            <TextBlock Foreground="{DynamicResource Window.Forground}" Text="{Binding}" Grid.Column="1" />
                        </StackPanel>
                    </DataTemplate>
                </Button.ContentTemplate>
            </Button>
            <Button  BorderBrush="IndianRed"  BorderThickness="0,0,0,2" Content="{local:ResMarker Remove}" Command="{Binding RemoveCommand}" Width="80" HorizontalAlignment="Left" VerticalAlignment="Center" Height="26" Margin="5,0" Padding="0" >
                <Button.ContentTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Margin="0">
                            <Image Source="/Image/Remove.png" Height="12" RenderOptions.BitmapScalingMode="NearestNeighbor" Margin="0,0,4,0"/>
                            <TextBlock Foreground="{DynamicResource Window.Forground}" Text="{Binding}" />
                        </StackPanel>
                    </DataTemplate>
                </Button.ContentTemplate>
            </Button>
            <Button  BorderBrush="SkyBlue"  BorderThickness="0,0,0,2" Content="{local:ResMarker Import}" Command="{Binding ImportCommand}" Width="80" HorizontalAlignment="Left" VerticalAlignment="Center" Height="26" Margin="5,0" >
                <Button.ContentTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Margin="0">
                            <Image Source="/Image/Import.png" Height="16" RenderOptions.BitmapScalingMode="NearestNeighbor" Margin="0,0,4,0"/>
                            <TextBlock Foreground="{DynamicResource Window.Forground}" Text="{Binding}" />
                        </StackPanel>
                    </DataTemplate>
                </Button.ContentTemplate>
            </Button>
            <Button  BorderBrush="Yellow"  BorderThickness="0,0,0,2" Content="{local:ResMarker Export}" Command="{Binding ExportCommand}" Width="80" HorizontalAlignment="Left" VerticalAlignment="Center" Height="26" Margin="5,0" >
                <Button.ContentTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Margin="0">
                            <Image Source="/Image/Export.png" Height="12" RenderOptions.BitmapScalingMode="NearestNeighbor" Margin="0,0,4,0"/>
                            <TextBlock Foreground="{DynamicResource Window.Forground}" Text="{Binding}" />
                        </StackPanel>
                    </DataTemplate>
                </Button.ContentTemplate>
            </Button>
        </StackPanel>
        <StackPanel Grid.Row="2" Orientation="Horizontal" Grid.Column="1" Height="32" HorizontalAlignment="Right" VerticalAlignment="Bottom" >
            <Label VerticalAlignment="Center" Content="{local:ResMarker TagCount,:}" Foreground="{DynamicResource Window.Forground}"/>
            <Label VerticalAlignment="Center" Content="{Binding TagCount}" Foreground="{DynamicResource Window.Forground}"/>
        </StackPanel>
    </Grid>
</UserControl>
