<UserControl x:Class="PDF_Office.Views.PropertyPanel.AnnotPanel.SignatureCreateDialog"
             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:PDF_Office.Views.PropertyPanel.AnnotPanel" xmlns:cus="clr-namespace:PDF_Office.CustomControl" xmlns:annotpanel="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel" xmlns:dataconvert="clr-namespace:PDF_Office.DataConvert" xmlns:i="http://schemas.microsoft.com/xaml/behaviors" d:DataContext="{d:DesignInstance Type=annotpanel:SignatureCreateDialogViewModel}"
             mc:Ignorable="d" >
    <UserControl.Resources>

        <Style TargetType="{x:Type TabItem}">
            <Setter Property="Width" Value="74.67 " />
            <Setter Property="Height" Value="28" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Template" Value="{DynamicResource Segmented}" />
        </Style>
        <dataconvert:UnVisivleConvert x:Key="UnVisivleConvert"/>
        <dataconvert:IntAndTagToBoolMultiBinding x:Key="IntAndTagToBoolMultiBinding"/>
        <dataconvert:IntToColorBrush x:Key="IntToColorBrush"/>
    </UserControl.Resources>
    <cus:DialogContent Header="新建签名">
        <cus:DialogContent.Content>
            <TabControl
                Style="{StaticResource FormTabControl }"
                SelectedIndex="{Binding TabItemIndex,Mode=TwoWay}">
                <TabItem Header="Input">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="32"/>
                        </Grid.RowDefinitions>
                        <cus:TextBoxEx PlaceholderText="Input" Text="{Binding InputText,Mode=TwoWay}" Foreground ="{Binding RadioButtonIndex,Converter={StaticResource IntToColorBrush}}"  />
                        <ComboBox Grid.Row="1"
                        Width="200"
                        HorizontalAlignment="Left"
                        VerticalContentAlignment="Center" 
                        ItemsSource="{Binding FontNameList}"
                        SelectedIndex="{Binding FontNameIndex,Mode=TwoWay}"/>
                        <StackPanel Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal">
                            <RadioButton Tag="1" Checked="TextRadioButton_Checked">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <i:InvokeCommandAction Command="{Binding CheckedCommnad}" 
                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=RadioButton},Path=Tag}"
                                                               PassEventArgsToCommand="True" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <RadioButton.IsChecked>
                                    <MultiBinding Converter="{StaticResource IntAndTagToBoolMultiBinding }" Mode="OneWay">
                                        <Binding Source="1"/>
                                        <Binding Path="RadioButtonIndex"/>
                                    </MultiBinding>
                                </RadioButton.IsChecked>
                            </RadioButton>
                            <RadioButton Tag="2" Checked="TextRadioButton_Checked">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <i:InvokeCommandAction Command="{Binding CheckedCommnad}" 
                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=RadioButton},Path=Tag}"
                                                               PassEventArgsToCommand="True" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <RadioButton.IsChecked>
                                    <MultiBinding Converter="{StaticResource IntAndTagToBoolMultiBinding }" Mode="OneWay">
                                        <Binding Source="2"/>
                                        <Binding Path="RadioButtonIndex"/>
                                    </MultiBinding>
                                </RadioButton.IsChecked>
                            </RadioButton>
                            <RadioButton Tag="3" Checked="TextRadioButton_Checked">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <i:InvokeCommandAction Command="{Binding CheckedCommnad}" 
                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=RadioButton},Path=Tag}"
                                                               PassEventArgsToCommand="True" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <RadioButton.IsChecked>
                                    <MultiBinding Converter="{StaticResource IntAndTagToBoolMultiBinding }" Mode="OneWay">
                                        <Binding Source="3"/>
                                        <Binding Path="RadioButtonIndex"/>
                                    </MultiBinding>
                                </RadioButton.IsChecked>
                            </RadioButton>
                            <RadioButton Tag="4" Checked="TextRadioButton_Checked">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <i:InvokeCommandAction Command="{Binding CheckedCommnad}" 
                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=RadioButton},Path=Tag}"
                                                               PassEventArgsToCommand="True" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <RadioButton.IsChecked>
                                    <MultiBinding Converter="{StaticResource IntAndTagToBoolMultiBinding }" Mode="OneWay">
                                        <Binding Source="4"/>
                                        <Binding Path="RadioButtonIndex"/>
                                    </MultiBinding>
                                </RadioButton.IsChecked>
                            </RadioButton>
                        </StackPanel>
                    </Grid>
                </TabItem>
                <TabItem Header="Drawing">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="32"/>
                        </Grid.RowDefinitions>
                        <InkCanvas x:Name="inkCanvas" Width="240" Height="240" DefaultDrawingAttributes="{Binding DrawingAttributeObject}" Strokes="{Binding StrokesObject}"/>
                        <ComboBox Grid.Row="1"
                        Width="80"
                        HorizontalAlignment="Left"
                        VerticalContentAlignment="Center" 
                        ItemsSource="{Binding ThicknessList}"
                        SelectedIndex="{Binding ThicknessListIndex,Mode=TwoWay}"/>
                        <StackPanel Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal">
                            <RadioButton Tag="1" Checked="ImageRadioButton_Checked">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <i:InvokeCommandAction Command="{Binding CheckedCommnad}" 
                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=RadioButton},Path=Tag}"
                                                               PassEventArgsToCommand="True" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <RadioButton.IsChecked>
                                    <MultiBinding Converter="{StaticResource IntAndTagToBoolMultiBinding }" Mode="OneWay">
                                        <Binding Source="1"/>
                                        <Binding Path="ImageRadioButtonIndex"/>
                                    </MultiBinding>
                                </RadioButton.IsChecked>
                            </RadioButton>
                            <RadioButton Tag="2" Checked="ImageRadioButton_Checked">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <i:InvokeCommandAction Command="{Binding CheckedCommnad}" 
                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=RadioButton},Path=Tag}"
                                                               PassEventArgsToCommand="True" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <RadioButton.IsChecked>
                                    <MultiBinding Converter="{StaticResource IntAndTagToBoolMultiBinding }" Mode="OneWay">
                                        <Binding Source="2"/>
                                        <Binding Path="ImageRadioButtonIndex"/>
                                    </MultiBinding>
                                </RadioButton.IsChecked>
                            </RadioButton>
                            <RadioButton Tag="3" Checked="ImageRadioButton_Checked">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <i:InvokeCommandAction Command="{Binding CheckedCommnad}" 
                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=RadioButton},Path=Tag}"
                                                               PassEventArgsToCommand="True" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <RadioButton.IsChecked>
                                    <MultiBinding Converter="{StaticResource IntAndTagToBoolMultiBinding }" Mode="OneWay">
                                        <Binding Source="3"/>
                                        <Binding Path="ImageRadioButtonIndex"/>
                                    </MultiBinding>
                                </RadioButton.IsChecked>
                            </RadioButton>
                            <RadioButton Tag="4" Checked="ImageRadioButton_Checked">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked">
                                        <i:InvokeCommandAction Command="{Binding CheckedCommnad}" 
                                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=RadioButton},Path=Tag}"
                                                               PassEventArgsToCommand="True" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <RadioButton.IsChecked>
                                    <MultiBinding Converter="{StaticResource IntAndTagToBoolMultiBinding }" Mode="OneWay">
                                        <Binding Source="4"/>
                                        <Binding Path="ImageRadioButtonIndex"/>
                                    </MultiBinding>
                                </RadioButton.IsChecked>
                            </RadioButton>
                        </StackPanel>
                    </Grid>
                </TabItem>
                <TabItem Header="Picture">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="20"/>
                        </Grid.RowDefinitions>
                        <Button x:Name="BtnAdd" Width="50" Height="50" Content="添加图片" Command="{Binding OpenImageCommnad}" Visibility="{Binding ShowImageButton}"/>
                        <Grid Visibility="{Binding ElementName=BtnAdd,Path=Visibility,Converter={StaticResource UnVisivleConvert}}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="24"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Image Grid.RowSpan="2" Width="200" Height="200" Source="{Binding ImagePreviewSource}" />
                        </Grid>
                        <CheckBox Grid.Row="1" Width="20" Height="20" IsChecked="{Binding IsRemoveBackground}"/>
                    </Grid>
                </TabItem>
            </TabControl>
        </cus:DialogContent.Content>

        <cus:DialogContent.BottmBar>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50*" />
                    <ColumnDefinition Width="50*" />
                </Grid.ColumnDefinitions>
                <Button
                    Style="{StaticResource Btn.cta}"
                    Grid.Column="0"
                    Width="150"
                    Height="32"
                    Margin="25,0,0,0"
                    HorizontalAlignment="Right"
                    Command="{Binding CreateCommnad}"
                    Content="确定" />
                <Button
                    Style="{StaticResource btn.sec}"
                    Grid.Column="1"
                    Width="150"
                    Height="32"
                    Margin="0,0,25,0"
                    HorizontalAlignment="Right"
                    Command="{Binding CancelCommand}"
                    Content="取消" />
            </Grid>
        </cus:DialogContent.BottmBar>
    </cus:DialogContent>
</UserControl>
