<UserControl
    x:Class="PDF_Master.Views.PropertyPanel.AnnotPanel.SharpsAnnotProperty"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:CompositeControl="clr-namespace:PDF_Master.CustomControl.CompositeControl"
    xmlns:Convert="clr-namespace:PDF_Master.DataConvert"
    xmlns:DashConvert="clr-namespace:PDF_Master.ViewModels.PropertyPanel.AnnotPanel"
    xmlns:convert="clr-namespace:PDF_Master.Views.Tools"
    xmlns:cus="clr-namespace:PDF_Master.CustomControl"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
    xmlns:local="clr-namespace:PDF_Master.Views.PropertyPanel.AnnotPanel"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:prism="http://prismlibrary.com/"
    d:DesignHeight="800"
    d:DesignWidth="260"
    prism:ViewModelLocator.AutoWireViewModel="True"
    Background="{StaticResource color.sys.layout.mg}"
    mc:Ignorable="d">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../../Styles/SliderStyle.xaml" />
                <ResourceDictionary Source="../../../Styles/CustomBtnStyle.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Convert:ColorToBrushConverter x:Key="ColorToBrushConvert" />
            <Convert:CheckToVisibleMutiConvert x:Key="CheckToVisibleMutiConvert" />
            <convert:AnnotToolIsCheckedConvert x:Key="AnnotToolIsCheckedConvert" />
            <DashConvert:DashStyleConverter x:Key="DashStyleConverter" />
            <Convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert" />
            <Convert:BoolToVisible x:Key="BoolToVisible" />
            <Style x:Key="line1Style" TargetType="{x:Type Line}">
                <Setter Property="Visibility">
                    <Setter.Value>
                        <MultiBinding Converter="{StaticResource CheckToVisibleMutiConvert}">
                            <Binding ElementName="SharpRectBtn" Path="IsChecked" />
                            <Binding ElementName="SharpCircleBtn" Path="IsChecked" />
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="line2Style" TargetType="{x:Type Line}">
                <Setter Property="Visibility">
                    <Setter.Value>
                        <MultiBinding Converter="{StaticResource CheckToVisibleMutiConvert}">
                            <Binding ElementName="SharpCircleBtn" Path="IsChecked" />
                            <Binding ElementName="SharpArrowBtn" Path="IsChecked" />
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="line3Style" TargetType="{x:Type Line}">
                <Setter Property="Visibility">
                    <Setter.Value>
                        <MultiBinding Converter="{StaticResource CheckToVisibleMutiConvert}">
                            <Binding ElementName="SharpArrowBtn" Path="IsChecked" />
                            <Binding ElementName="SharpLineBtn" Path="IsChecked" />
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid Margin="16,0,16,0">
        <StackPanel>
            <TextBlock
                Name="AnnotTypeTitle"
                Margin="0,14"
                HorizontalAlignment="Left"
                FontFamily="Segoe UI"
                FontSize="14"
                FontWeight="SemiBold"
                LineHeight="24"
                Text="{Binding BasicVm.AnnotTypeTitle}" />
            <Border
                Width="228"
                Height="100"
                Background="White"
                BorderBrush="#DDDDDD"
                BorderThickness="1"
                CornerRadius="2"
                Visibility="{Binding BasicVm.IsMultiSelected, Converter={StaticResource InvertBoolToVisibleConvert}}">
                <Grid>
                    <Path
                        Name="SharpPath"
                        Width="36"
                        Height="36"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Data="{Binding DataPath}"
                        Fill="{Binding BasicVm.FillColor}"
                        Opacity="{Binding BasicVm.FillOpacity}"
                        Stroke="{Binding BasicVm.BorderColor}"
                        StrokeDashArray="{Binding Dash, Converter={StaticResource DashStyleConverter}}"
                        StrokeStartLineCap="Flat"
                        StrokeThickness="{Binding BasicVm.AnnotThickness}">
                        <!--  ,Converter={StaticResource ColorToBrushConvert}  -->
                    </Path>
                </Grid>
            </Border>

            <Border
                Width="162"
                Height="32"
                Margin="0,12,0,0"
                HorizontalAlignment="Left"
                BorderBrush="#FFE2E3E6"
                BorderThickness="0"
                Visibility="{Binding BasicVm.IsSharpAnnotSelected, Converter={StaticResource BoolToVisible}}">
                <Grid Name="ToolGrid">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="40.5" />
                        <ColumnDefinition Width="40.5" />
                        <ColumnDefinition Width="40.5" />
                        <ColumnDefinition Width="40.5" />
                    </Grid.ColumnDefinitions>

                    <RadioButton
                        x:Name="SharpRectBtn"
                        Width="32"
                        Height="32"
                        Margin="0,0"
                        Padding="7,0,0,0"
                        VerticalContentAlignment="Center"
                        Background="Transparent"
                        GroupName="Shape"
                        IsChecked="{Binding IsRect}"
                        Style="{DynamicResource GreyBgRadioBtnStyle}"
                        Tag="Rect"
                        ToolTip="矩形">
                        <RadioButton.Content>
                            <Rectangle
                                Width="16"
                                Height="16"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Stroke="#273C62" />
                        </RadioButton.Content>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Checked">
                                <i:InvokeCommandAction Command="{Binding SharpsTypeCommand}" CommandParameter="{Binding ElementName=SharpRectBtn, Path=Tag}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </RadioButton>

                    <RadioButton
                        x:Name="SharpCircleBtn"
                        Grid.Column="1"
                        Width="32"
                        Height="32"
                        Margin="0,0"
                        Padding="7,0,0,0"
                        VerticalContentAlignment="Center"
                        Background="Transparent"
                        GroupName="Shape"
                        IsChecked="{Binding IsCircle}"
                        Style="{DynamicResource GreyBgRadioBtnStyle}"
                        Tag="Circle"
                        ToolTip="圆">
                        <RadioButton.Content>
                            <Ellipse
                                Width="16"
                                Height="16"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Stroke="#273C62" />
                        </RadioButton.Content>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Checked">
                                <i:InvokeCommandAction Command="{Binding SharpsTypeCommand}" CommandParameter="{Binding ElementName=SharpCircleBtn, Path=Tag}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </RadioButton>

                    <RadioButton
                        x:Name="SharpArrowBtn"
                        Grid.Column="2"
                        Width="32"
                        Height="32"
                        Margin="0,0"
                        Padding="7,0,0,0"
                        VerticalContentAlignment="Center"
                        Background="Transparent"
                        GroupName="Shape"
                        IsChecked="{Binding IsArrow}"
                        Style="{DynamicResource GreyBgRadioBtnStyle}"
                        Tag="Arrow"
                        ToolTip="箭头">
                        <RadioButton.Content>
                            <Path
                                Width="16"
                                Height="16"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Fill="#273C62">
                                <Path.Data>
                                    M13.4,2.6 L13.4,8 L12.2,8 L12.1997359,4.648 L2.02426407,14.8242641 L1.17573593,13.9757359 L11.3517359,3.799 L8,3.8 L8,2.6 L13.4,2.6 Z
                                </Path.Data>
                            </Path>
                        </RadioButton.Content>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Checked">
                                <i:InvokeCommandAction Command="{Binding SharpsTypeCommand}" CommandParameter="{Binding ElementName=SharpArrowBtn, Path=Tag}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </RadioButton>

                    <RadioButton
                        x:Name="SharpLineBtn"
                        Grid.Column="3"
                        Width="32"
                        Height="32"
                        Margin="0,0"
                        Padding="7,8,0,0"
                        Background="Transparent"
                        GroupName="Shape"
                        IsChecked="{Binding IsLine}"
                        Style="{DynamicResource GreyBgRadioBtnStyle}"
                        Tag="Line"
                        ToolTip="线条">
                        <RadioButton.Content>
                            <Polygon
                                Width="16"
                                Height="16"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Fill="#273C62">
                                <Polygon.Points>
                                    13.1757359 1.97573593 14.0242641 2.82426407 2.82426407 14.0242641 1.97573593 13.1757359
                                </Polygon.Points>
                            </Polygon>
                        </RadioButton.Content>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Checked">
                                <i:InvokeCommandAction Command="{Binding SharpsTypeCommand}" CommandParameter="{Binding ElementName=SharpLineBtn, Path=Tag}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </RadioButton>
                </Grid>
            </Border>

            <Grid
                x:Name="GridFill"
                Margin="0,18,0,0"
                Visibility="{Binding IsLineAnnot, Converter={StaticResource InvertBoolToVisibleConvert}}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock
                    VerticalAlignment="Center"
                    Foreground="{StaticResource color.sys.text.neutral.lv2}"
                    Text="Fill" />
                <CompositeControl:SlidContent
                    x:Name="layerFill"
                    HorizontalAlignment="Right"
                    InitValue="{Binding BasicVm.FillOpacity, Mode=OneWay}"
                    Visibility="{Binding BasicVm.IsMultiSelected, Converter={StaticResource InvertBoolToVisibleConvert}}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectedValueChanged">
                            <i:InvokeCommandAction Command="{Binding SelectedOpacityValueCommand}" CommandParameter="{Binding ElementName=layerFill, Path=Value}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </CompositeControl:SlidContent>
                <CompositeControl:ColorContent
                    x:Name="cusFillColor"
                    Grid.Row="1"
                    Margin="0,8,0,0"
                    ColorType="Fill"
                    ItemSource="{Binding BasicVm.FillColorItems}"
                    UIColor="{Binding BasicVm.CurrentFillColor, Mode=OneWay}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectedColorInvoke">
                            <i:InvokeCommandAction Command="{Binding SelectedFillColorCommand}" CommandParameter="{Binding ElementName=cusFillColor, Path=SelectedColor}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </CompositeControl:ColorContent>
            </Grid>

            <Grid Margin="0,18,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock
                    VerticalAlignment="Center"
                    Foreground="{StaticResource color.sys.text.neutral.lv2}"
                    Text="Border" />
                <CompositeControl:SlidContent
                    x:Name="layerThick"
                    HorizontalAlignment="Right"
                    InitValue="{Binding BasicVm.FillOpacity, Mode=OneWay}"
                    Visibility="{Binding BasicVm.IsMultiSelected, Converter={StaticResource InvertBoolToVisibleConvert}}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectedValueChanged">
                            <i:InvokeCommandAction Command="{Binding SelectedOpacityValueCommand}" CommandParameter="{Binding ElementName=layerThick, Path=Value}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </CompositeControl:SlidContent>

                <CompositeControl:ColorContent
                    x:Name="cusColor"
                    Grid.Row="1"
                    Margin="0,8,0,0"
                    ColorType="Border"
                    ItemSource="{Binding BasicVm.ColorItems}"
                    UIColor="{Binding BasicVm.CurrentBorderColor, Mode=OneWay}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectedColorInvoke">
                            <i:InvokeCommandAction Command="{Binding SelectedBorderColorCommand}" CommandParameter="{Binding ElementName=cusColor, Path=SelectedColor}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </CompositeControl:ColorContent>
            </Grid>

            <CompositeControl:SlidComboControl
                x:Name="thickness"
                Margin="0,0,0,0"
                ItemsSource="{Binding ThicknessItems}"
                Value="{Binding BasicVm.AnnotThickness, Mode=TwoWay}">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="ValueChanged">
                        <i:InvokeCommandAction Command="{Binding SelectedThickCommand}" CommandParameter="{Binding ElementName=thickness, Path=Value}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </CompositeControl:SlidComboControl>

            <StackPanel
                x:Name="PnlLineStyle"
                Margin="0,20,0,0"
                Orientation="Horizontal">

                <RadioButton
                    x:Name="BtnSolid"
                    Width="105"
                    Height="32"
                    Margin="0,0,10,0"
                    VerticalContentAlignment="Center"
                    Background="Transparent"
                    Command="{Binding LineStyleCommand}"
                    CommandParameter="{Binding ElementName=BtnSolid, Path=Tag}"
                    Foreground="#616469"
                    GroupName="LineMode"
                    IsChecked="{Binding BasicVm.IsSolidLine}"
                    Style="{DynamicResource GreyBgRadioBtnStyle}"
                    Tag="Solid">
                    <RadioButton.Content>
                        <Line
                            Stroke="Black"
                            StrokeThickness="2"
                            X1="10"
                            X2="90"
                            Y1="5"
                            Y2="5" />
                    </RadioButton.Content>
                </RadioButton>

                <RadioButton
                    x:Name="BtnDashed"
                    Width="105"
                    Height="32"
                    Margin="0,0"
                    VerticalContentAlignment="Center"
                    Background="Transparent"
                    Command="{Binding LineStyleCommand}"
                    CommandParameter="{Binding ElementName=BtnDashed, Path=Tag}"
                    Foreground="#616469"
                    GroupName="LineMode"
                    IsChecked="{Binding BasicVm.IsDashLine}"
                    Style="{DynamicResource GreyBgRadioBtnStyle}"
                    Tag="Dashed">
                    <RadioButton.Content>
                        <Line
                            Stroke="Black"
                            StrokeDashArray="2"
                            StrokeThickness="2"
                            X1="10"
                            X2="90"
                            Y1="5"
                            Y2="5" />
                    </RadioButton.Content>
                </RadioButton>
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>