Browse Source

填充与签名

liyijie 2 years ago
parent
commit
da88821089

+ 195 - 3
PDF Office/ViewModels/FillAndSign/FillAndSignContentViewModel.cs

@@ -17,6 +17,10 @@ using PDF_Office.Helper;
 using PDF_Office.Properties;
 using PDFSettings;
 using System.Windows.Media;
+using ComPDFKit.PDFDocument.Action;
+using ComPDFKit.PDFDocument;
+using System.Diagnostics;
+using ComPDFKit.PDFAnnotation;
 
 namespace PDF_Office.ViewModels.FillAndSign
 {
@@ -26,8 +30,9 @@ namespace PDF_Office.ViewModels.FillAndSign
         private CPDFViewer PDFViewer;
         private AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
         private ViewContentViewModel viewContentViewModel;
-
+        private bool isRightMenuAddAnnot = false;
         private IRegionManager regions { get; set; }
+        private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
         #endregion
 
         #region Command
@@ -44,7 +49,7 @@ namespace PDF_Office.ViewModels.FillAndSign
             regions = regionManager;
 
             CheckCommand = new DelegateCommand<RoutedEventArgs>(CheckedEvent);
-
+            ToolExpandDict.Add("Freetext", AnnotArgsType.AnnotFreeText);
             InitDictionary();
         }
 
@@ -53,8 +58,53 @@ namespace PDF_Office.ViewModels.FillAndSign
             var control = e.OriginalSource as Control;
 
             NavigateToProperty(control.Name);
+            //不创建注释,属于注释模板
+            //bool isTemplateAnnot = false;
+            //bool isSnapshotEdit = false;
+            //AnnotHandlerEventArgs annotArgs = null;
+
+           
+            //    var tag = control.Name;
+            //    if (control.Name == "RbtnSign") {  FindAnnotTypeKey("Signature", ref annotArgs); isTemplateAnnot = true; }
+            //    if (control.Name == "RbtnText") { FindAnnotTypeKey("Freetext", ref annotArgs);  }
+            //if (control.Name == "RbtnDate") { FindAnnotTypeKey("Freetext", ref annotArgs); } 
+
+            //    if (tag == "SnapshotEdit")
+            //    {
+            //        isSnapshotEdit = true;
+            //    }
+            //    else if (tag == "Signature" || tag == "Stamp")
+            //    {
+            //        isTemplateAnnot = true;
+            //    }
+
+            //    if (annotArgs != null)
+            //    {
+            //        annotArgs.Author = Settings.Default.AppProperties.Description.Author;
+            //        PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
+            //        PDFViewer.SetToolParam(annotArgs);
+            //        isRightMenuAddAnnot = false;
+            //    }
+            
 
-            if(control.Name== "RbtnSign") { AnnotHandlerEventArgs annotArgs = null; FindAnnotTypeKey("Signature", ref annotArgs); }
+            ////当不是注释模板,且无创建注释时,属性面板显示为空内容
+            //if (isTemplateAnnot == false && annotArgs == null)
+            //{
+            //    PDFViewer.SetMouseMode(MouseModes.PanTool);
+            //    viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+            //}
+            //else
+            //{
+            //    if (isSnapshotEdit == true)
+            //    {
+            //        ShowPropertyPanel(false);
+            //        isSnapshotEdit = false;
+            //    }
+            //    else
+            //    {
+            //        ShowPropertyPanel(true);
+            //    }
+            //}
             
         }
 
@@ -261,6 +311,147 @@ namespace PDF_Office.ViewModels.FillAndSign
             btnToProperty["RbtnDate"] = "DateFillProperty";
             btnToProperty["RbtnSign"] = "";
 
+        }
+
+        private void BindingPDFViewerHandler()
+        {
+            //来自PDFViewer的响应事件
+            if (PDFViewer != null)
+            {
+                
+
+                PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
+                PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
+
+            
+            }
+        }
+
+
+        //选中和非选中注释,右键菜单
+        private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
+        {
+            if (e != null)
+            {
+                var annot = e.AnnotItemsList[0];
+                if (annot != null)
+                {
+                    if (e.AnnotItemsList.Count == 1)
+                    {
+                        //IsAnnotCreateReset:是否为创建注释的状态
+                        if (e.IsAnnotCreateReset == false)
+                        {
+                            GetSelectedAnnots(e);
+                            //记录这次选中的注释,之后创建注释会跟随上次选中注释的属性值
+                            PDFViewer.SetToolParam(annot);
+                        }
+                        else
+                        {
+                            
+                            //TODO: 设计已重新调整为(仅限高亮注释):修改注释后,会作用到之后添加的注释中。因此先把此逻辑“创建注释后,会自动回到默认值”注释掉
+                            if (annot.EventType != AnnotArgsType.AnnotStrikeout &&
+                                annot.EventType != AnnotArgsType.AnnotUnderline &&
+                                annot.EventType != AnnotArgsType.AnnotHighlight &&
+                                annot.EventType != AnnotArgsType.AnnotSquiggly &&
+                                annot.EventType != AnnotArgsType.AnnotLink &&
+                                annot.EventType != AnnotArgsType.AnnotFreehand &&
+                                annot.EventType != AnnotArgsType.AnnotSticky
+                                )
+                            {
+                                if (ToolExpandDict.ContainsValue(e.AnnotItemsList[0].EventType))
+                                {
+                                    foreach (var item in ToolExpandDict)
+                                    {
+                                        if (item.Value == e.AnnotItemsList[0].EventType)
+                                        {
+                                            annot = null;//新建注释时,回到默认值
+                                            FindAnnotTypeKey(item.Key, ref annot);
+                                            break;
+                                        }
+                                    }
+                                }
+                            }
+                            //else
+                            PDFViewer.SetToolParam(annot);
+                            //设计重新调整,阅读页空白处,右键菜单,添加链接,和pro mac一样的效果,不显示属性栏
+                            if (isRightMenuAddAnnot)
+                            {
+                                ShowPropertyPanel(false);
+                            }
+                            else
+                            {
+                                ShowPropertyPanel();
+                            }
+                        }
+                    }
+                    else
+                    {
+                        bool isDifferentAnnotTyle = false;
+                        var lastAnnot = annot;
+                        foreach (var item in e.AnnotItemsList)
+                        {
+                            if (lastAnnot.EventType != item.EventType)
+                            {
+                                if (isShapAnnot(annot) == true && isShapAnnot(item) == true)
+                                {
+                                    lastAnnot = item;
+                                    continue;
+                                }
+
+                                lastAnnot = item;
+                                isDifferentAnnotTyle = true;
+                                break;
+                            }
+                        }
+
+
+                        if (isDifferentAnnotTyle)
+                            viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+                        else
+                            GetSelectedAnnots(e);
+                    }
+
+                }
+            }
+            else
+            {
+                viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+            }
+        }
+        private bool isShapAnnot(AnnotHandlerEventArgs annot)
+        {
+            if (annot.EventType == AnnotArgsType.AnnotCircle ||
+                annot.EventType == AnnotArgsType.AnnotSquare ||
+                annot.EventType == AnnotArgsType.AnnotLine
+                )
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+        private void GetSelectedAnnots(AnnotAttribEvent e)
+        {
+            var annot = e.AnnotItemsList[0];
+            switch (annot.EventType)
+            {
+                
+
+
+                case AnnotArgsType.AnnotFreeText:
+                    GetFreetext(e.AnnotItemsList);
+                    break;
+
+                
+
+           
+            }
+        }
+        private void ShowPropertyPanel(bool show = true)
+        {
+            viewContentViewModel.IsPropertyOpen = show;
         }
 
         #region Navigation
@@ -279,6 +470,7 @@ namespace PDF_Office.ViewModels.FillAndSign
         {
             navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            BindingPDFViewerHandler();
         }
         #endregion
     }

+ 206 - 4
PDF Office/ViewModels/FillAndSign/PropertyPanel/ShapFillPropertyViewModel.cs

@@ -1,20 +1,220 @@
-using Prism.Mvvm;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer;
+using Prism.Mvvm;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
-
+using System.Windows;
+using System.Windows.Media;
+using Prism.Commands;
+using System.Windows.Controls;
+using ComPDFKit.PDFAnnotation;
+using PDF_Office.Helper;
+
 namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
 {
     public class ShapFillPropertyViewModel : BindableBase, INavigationAware
-    {
+    {
+
+        private Geometry dataPath = null;
+        public Geometry DataPath
+        {
+            get { return dataPath; }
+            set
+            {
+                SetProperty(ref dataPath, value);
+            }
+        }
+
+        private Brush selectColor = new SolidColorBrush(Colors.GreenYellow);
+        public Brush SelectColor
+        {
+            get { return selectColor; }
+            set
+            {
+                SetProperty(ref selectColor, value);
+                //AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (selectColor as SolidColorBrush).Color);
+                //AnnotEvent?.UpdateAnnot();
+            }
+        }
+
+        private double fillOpacity = 1;
+        public double FillOpacity
+        {
+            get { return fillOpacity; }
+            set
+            {
+                SetProperty(ref fillOpacity, value);
+            }
+        }
+
+        private double lineWidth = 1;
+        public double LineWidth
+        {
+            get { return lineWidth; }
+            set
+            {
+                SetProperty(ref lineWidth, value);
+
+                //if (annotType == AnnotArgsType.AnnotLine)
+                //    AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, lineWidth);
+                //else
+                //    AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, lineWidth);
+
+                //AnnotEvent?.UpdateAnnot();
+            }
+        }
+        public DelegateCommand<object> SelectedThickCommand { get; set; }
+        public DelegateCommand<object> SelectedColorCommand { get; set; }
+
+
+        //public DelegateCommand<object> LineStyleCommand { get; set; }
+
+        public DelegateCommand<object> SharpsTypeCommand { get; set; }
+        public DelegateCommand<object> ThicknessChangedCommand { get; set; }
+        public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
+
         public ShapFillPropertyViewModel()
         {
+            SelectedThickCommand = new DelegateCommand<object>(SelectedThick_Command);
+            SelectedColorCommand = new DelegateCommand<object>(SelectedColor_Command);
+            //LineStyleCommand = new DelegateCommand<object>(LineStyle_Command);
+            SharpsTypeCommand = new DelegateCommand<object>(SharpsType_Command);
+            ThicknessChangedCommand = new DelegateCommand<object>(ThicknessChanged_Command);
+            SelectedOpacityValueCommand = new DelegateCommand<object>(SelectedOpacityValue);
+        }
+
+        private void SharpsType_Command(object obj)
+        {
+            if (obj != null)
+            {
+                var tag = (string)obj;
+                SharpsType(tag,obj);
+            }
+        }
+        private void SharpsType(string tag, object obj, bool isFromToolsBtn = false)
+        {
+            Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+            switch (tag)
+            {
+                case "HookShape":
+                    var hookShape = new PathGeometry();
+                    hookShape.AddGeometry(Geometry.Parse("M0.599976 7.0286L5.57775 11.8L13.4 1.40002"));
+
+                    DataPath = hookShape;
+                    changeData[AnnotArgsType.AnnotLine] = tag;
+                    break;
+
+                case "ForkShape":
+                    var forkShape = new PathGeometry();
+                    forkShape.AddGeometry(Geometry.Parse(" M3.19995 3.20001L12.8 12.8 M12.8 3.20001L3.20005 12.8"));
+                    DataPath = forkShape;
+                    changeData[AnnotArgsType.AnnotLine] = tag;
+                    break;
+
+                case "RectShape":
+                    {
+                        RectangleGeometry rectPath = new RectangleGeometry();
+                        rectPath.Rect = new Rect(0, 5, 28, 22);
+                        DataPath = rectPath;
+                        changeData[AnnotArgsType.AnnotSquare] = tag;
+                    }
+
+                    break;
+                case "LineShape":
+                    {
+                        var lineShape = new PathGeometry();
+                        lineShape.AddGeometry(Geometry.Parse(" M0,10L20,10"));
+                        DataPath = lineShape;
+                        changeData[AnnotArgsType.AnnotLine] = tag;
+                    }
+
+                    break;
+
+                case "DotShape":
+                    {
+                        EllipseGeometry circlePath = new EllipseGeometry();
+                        circlePath.RadiusX = 2.4;
+                        circlePath.RadiusY = 2.4;
+                        circlePath.Center = new Point(2.4,2.4);
+                        DataPath = circlePath;
+                        changeData[AnnotArgsType.AnnotCircle] = tag;
+                    }
+
+                    break;
+            }
+
+            //if (isFromToolsBtn == false)
+            //    PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
+
+        }
+        private void SelectedThick_Command(object obj)
+        {
+            if (obj is double)
+            {
+                var tran = (double)obj;
+                //BorderOpacity = tran;
+                SelectColor.Opacity = tran;
 
+                //AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, tran);
+                //AnnotEvent?.UpdateAnnot();
+            }
+        }
+        private void ThicknessChanged_Command(object obj)
+        {
+            if (obj != null)
+            {
+                var item = (ComboBoxItem)obj;
+                var content = (string)item.Content;
+                if (content != null)
+                {
+                    var intData = int.Parse(content);
+                    LineWidth = intData;
+                }
+            }
         }
 
+        private void SelectedColor_Command(object obj)
+        {
+            if (obj != null)
+            {
+                var colorValue = (Color)obj;
+                if (colorValue != null)
+                {
+
+                    SelectColor = new SolidColorBrush(colorValue);
+                    SelectColor.Opacity = FillOpacity;
+
+                    Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                    changeData[AnnotArgsType.AnnotFreehand] = obj;
+                    //PropertyPanel.DataChangedInvoke(this, changeData);
+                }
+
+            }
+
+        }
+
+        private void SelectedOpacityValue(object obj)
+        {
+            if (obj != null)
+            {
+                FillOpacity = (double)obj;
+                SelectColor.Opacity = FillOpacity;
+
+                //AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, FillOpacity);
+                //AnnotEvent?.UpdateAnnot();
+                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                changeData[AnnotArgsType.AnnotFreehand] = FillOpacity;
+                //PropertyPanel.DataChangedInvoke(this, changeData);
+            }
+
+        }
+
+        
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -27,7 +227,9 @@ namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
 
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
-
+            RectangleGeometry rectPath = new RectangleGeometry();
+            rectPath.Rect = new Rect(0, 5, 28, 22);
+            DataPath = rectPath;
         }
     }
 }

+ 309 - 5
PDF Office/Views/FillAndSign/PropertyPanel/ShapFillProperty.xaml

@@ -2,6 +2,11 @@
     x:Class="PDF_Office.Views.FillAndSign.PropertyPanel.ShapFillProperty"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl"
+    xmlns:cus="clr-namespace:PDF_Office.CustomControl"
+    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+    xmlns:Convert="clr-namespace:PDF_Office.DataConvert"
+    xmlns:DashConvert="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:local="clr-namespace:PDF_Office.Views.FillAndSign.PropertyPanel"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -10,10 +15,309 @@
     d:DesignWidth="260"
     prism:ViewModelLocator.AutoWireViewModel="True"
     mc:Ignorable="d">
-    <Grid Margin="16">
-        <TextBlock
-            FontSize="16"
-            LineHeight="24"
-            Text="勾形" />
+    <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" />
+            <DashConvert:DashStyleConverter x:Key="DashStyleConverter" />
+            <Convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert"/>
+        </ResourceDictionary>
+    </UserControl.Resources>
+    <Grid Background="#F3F3F3">
+        <StackPanel Margin="16,0,16,0">
+            <TextBlock
+                Name="AnnotTypeTitle"
+                Margin="10,8,0,0"
+                HorizontalAlignment="Left"
+                FontFamily="SegoeUI"
+                FontSize="18"
+                FontWeight="Bold"
+                LineHeight="24"
+                Text="{Binding AnnotTypeTitle}" />
+            <Border
+                Width="228"
+                Height="100"
+                Margin="0,8,0,0"
+                Background="White"
+                BorderBrush="#DDDDDD"
+                BorderThickness="1"
+                CornerRadius="2"
+                Visibility="{Binding IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"
+                >
+                
+                <Grid>
+                    <Path
+                        Name="SharpPath"
+                        Width="36"
+                        Height="36"
+                        HorizontalAlignment="Center"
+                        VerticalAlignment="Center"
+                        Data="{Binding DataPath}"
+                        Stroke="{Binding SelectColor}"
+                        Opacity="{Binding FillOpacity}"
+                        StrokeDashArray="{Binding Dash, Converter={StaticResource DashStyleConverter}}"
+                        StrokeStartLineCap="Flat"
+                        StrokeThickness="{Binding LineWidth}">
+                        <!--Fill="{Binding FillColor}"-->
+                        <!--  ,Converter={StaticResource ColorToBrushConvert}  -->
+                    </Path>
+                </Grid>
+            </Border>
+
+            <Grid Margin="0,18,0,0">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="auto" />
+                    <RowDefinition />
+                </Grid.RowDefinitions>
+                <TextBlock Text="Color" VerticalAlignment="Center"/>
+                <CompositeControl:SlidContent x:Name="layerThick"  HorizontalAlignment="Right" 
+                                              Visibility="{Binding 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" />
+
+            </Grid>
+
+            <Grid Margin="0,18,0,0">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="auto" />
+                    <RowDefinition />
+                </Grid.RowDefinitions>
+                <TextBlock Text="Line Style" VerticalAlignment="Center"/>
+                <Grid Grid.Row="1" Margin="0,10,0,0">
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="*" />
+                        <ColumnDefinition Width="80" />
+                    </Grid.ColumnDefinitions>
+                    <Slider
+                    Name="BorderSlider"
+                    Margin="0,0,4,0"
+                    VerticalAlignment="Center"
+                    IsMoveToPointEnabled="True"
+                    IsSelectionRangeEnabled="True"
+                    IsSnapToTickEnabled="True"
+                    Maximum="12"
+                    Minimum="1"
+                    Style="{StaticResource RoundThumbSlider}"
+                    TickFrequency="1"
+                    Value="{Binding LineWidth}">
+                        <Slider.Resources>
+                            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#477EDE" />
+                            <SolidColorBrush x:Key="{x:Static SystemColors.ControlDarkDarkBrushKey}" Color="#E2E3E6" />
+                        </Slider.Resources>
+                    </Slider>
+
+                    <Border
+                    Grid.Column="1"
+                    Width="80"
+                    Height="32"
+                    
+                    BorderBrush="#E2E3E6"
+                    BorderThickness="0">
+                        <Grid>
+                            <ComboBox
+                                
+                            Name="BorderDropBox"
+                            Padding="10,10,0,0"
+                            Background="Transparent"
+                            BorderBrush="#FFE2E3E6"
+                            BorderThickness="1">
+                                <ComboBox.ItemContainerStyle>
+                                    <Style TargetType="{x:Type ComboBoxItem}">
+                                        <Setter Property="Padding" Value="10,0,0,0" />
+                                    </Style>
+                                </ComboBox.ItemContainerStyle>
+                                <ComboBoxItem
+                                Height="32"
+                                VerticalContentAlignment="Center"
+                                Content="1"
+                                Template="{StaticResource comboxitem}" />
+                                <ComboBoxItem
+                                Height="32"
+                                VerticalContentAlignment="Center"
+                                Content="3"
+                                Template="{StaticResource comboxitem}" />
+                                <ComboBoxItem
+                                Height="32"
+                                VerticalContentAlignment="Center"
+                                Content="6"
+                                Template="{StaticResource comboxitem}" />
+                                <ComboBoxItem
+                                Height="32"
+                                VerticalContentAlignment="Center"
+                                Content="9"
+                                Template="{StaticResource comboxitem}" />
+                                <ComboBoxItem
+                                Height="32"
+                                VerticalContentAlignment="Center"
+                                Content="12"
+                                Template="{StaticResource comboxitem}" />
+                                <i:Interaction.Triggers>
+                                    <i:EventTrigger EventName="SelectionChanged">
+                                        <i:InvokeCommandAction Command="{Binding ThicknessChangedCommand}" CommandParameter="{Binding ElementName=BorderDropBox, Path=SelectedItem}" />
+                                    </i:EventTrigger>
+                                </i:Interaction.Triggers>
+                            </ComboBox>
+                            <TextBox
+                            Height="20"
+                            Margin="10,0,35,0"
+                            VerticalAlignment="Center"
+                            Background="White"
+                            BorderThickness="0"
+                            FontFamily="Segoe UI"
+                            FontSize="14"
+                            IsReadOnly="True"
+                            Text="{Binding ElementName=BorderSlider, Path=Value}"
+                            TextAlignment="Left" />
+                        </Grid>
+                    </Border>
+                </Grid>
+            </Grid>
+
+            <Border
+                Width="228"
+                Height="32"
+                Margin="0,12,0,0"
+                BorderBrush="#FFE2E3E6"
+                BorderThickness="1" 
+                Visibility="{Binding IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"
+                >
+                <Grid Name="ToolGrid">
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="40.5" />
+                        <ColumnDefinition Width="40.5" />
+                        <ColumnDefinition Width="40.5" />
+                        <ColumnDefinition Width="40.5" />
+                        <ColumnDefinition Width="40.5" />
+                    </Grid.ColumnDefinitions>
+
+
+                    <ToggleButton
+                        Name="HookShapeBtn"
+                        Width="40.5"
+                        Background="Transparent"
+                        BorderThickness="0"
+                        Click="SharpsBtn_Click"
+                        Command="{Binding SharpsTypeCommand}"
+                        CommandParameter="{Binding ElementName=HookShapeBtn, Path=Tag}"
+                        Tag="HookShape">
+                        <Path
+                            Width="15"
+                            Height="13"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center"
+                            StrokeThickness="1.6"
+                            StrokeLineJoin="Round"
+                           Stroke="#616469">
+                            <Path.Data>M0.599976 7.0286L5.57775 11.8L13.4 1.40002
+                            </Path.Data>
+                        </Path>
+                    </ToggleButton>
+
+
+
+                    <ToggleButton
+                        Name="ForkShapeBtn"
+                        Grid.Column="1"
+                        Width="40.5"
+                        Margin="0,0,0,0"
+                        Background="Transparent"
+                        BorderThickness="0"
+                        Click="SharpsBtn_Click"
+                        Command="{Binding SharpsTypeCommand}"
+                        CommandParameter="{Binding ElementName=ForkShapeBtn, Path=Tag}"
+                        Tag="ForkShape">
+                        <Path
+                            Width="16"
+                            Height="16"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center"
+                            StrokeThickness="1.6"
+                            StrokeLineJoin="Round"
+                           Stroke="#616469">
+                            <Path.Data>
+                                M3.19995 3.20001L12.8 12.8
+                               M12.8 3.20001L3.20005 12.8
+                            </Path.Data>
+                        </Path>
+                    </ToggleButton>
+
+
+
+                    <ToggleButton
+                        Name="RectShapeBtn"
+                        Grid.Column="2"
+                        Width="40.5"
+                        Background="Transparent"
+                        BorderThickness="0"
+                        Click="SharpsBtn_Click"
+                        Command="{Binding SharpsTypeCommand}"
+                        CommandParameter="{Binding ElementName=RectShapeBtn, Path=Tag}"
+                        Tag="RectShape">
+                        <Rectangle
+                            Width="9.6"
+                            Height="9.6"
+                           StrokeThickness="1.6"
+                            RadiusX="1.20002"
+                            RadiusY="1.20002"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center"
+                            Stroke="#616469" />
+                    </ToggleButton>
+
+
+                    <ToggleButton
+                        Name="LineShapeBtn"
+                        Grid.Column="3"
+                        Width="40.5"
+                        Background="Transparent"
+                        BorderThickness="0"
+                        Click="SharpsBtn_Click"
+                        Command="{Binding SharpsTypeCommand}"
+                        CommandParameter="{Binding ElementName=LineShapeBtn, Path=Tag}"
+                        Tag="LineShape">
+                        <Path
+                            Width="14"
+                            Height="2"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center"
+                            StrokeThickness="1.6"
+                            StrokeLineJoin="Round"
+                           Stroke="#616469">
+                            <Path.Data>
+                                M13.4 1L0.600024 1
+                            </Path.Data>
+                        </Path>
+                    </ToggleButton>
+
+                    <ToggleButton
+                        Name="DotShapeBtn"
+                        Width="40.5"
+                        Grid.Column="4"
+                        Background="Transparent"
+                        BorderThickness="0"
+                        Click="SharpsBtn_Click"
+                        Command="{Binding SharpsTypeCommand}"
+                        CommandParameter="{Binding ElementName=DotShapeBtn, Path=Tag}"
+                        Tag="DotShape">
+                        <Ellipse
+                            Width="4.8"
+                            Height="4.8"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center"
+                            Fill="#616469" />
+                    </ToggleButton>
+                </Grid>
+            </Border>
+        </StackPanel>
     </Grid>
 </UserControl>

+ 41 - 3
PDF Office/Views/FillAndSign/PropertyPanel/ShapFillProperty.xaml.cs

@@ -1,10 +1,14 @@
-using System;
+using ComPDFKitViewer;
+using PDF_Office.ViewModels.FillAndSign.PropertyPanel;
+using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
 using System.Windows.Data;
 using System.Windows.Documents;
 using System.Windows.Input;
@@ -19,10 +23,44 @@ namespace PDF_Office.Views.FillAndSign.PropertyPanel
     /// ShapFillProperty.xaml 的交互逻辑
     /// </summary>
     public partial class ShapFillProperty : UserControl
-    {
+    {
+        private ShapFillPropertyViewModel ViewModel => DataContext as ShapFillPropertyViewModel;
         public ShapFillProperty()
         {
             InitializeComponent();
-        }
+            InitializeComponent();
+            cusColor.SelectedColorHandler += cusColor_SelectedColor;
+
+            //ViewModel.LoadPropertyHandler += ViewModel_LoadPropertyHandler;
+        }
+        private void cusColor_SelectedColor(object sender, Color e)
+        {
+            if (ViewModel != null)
+            {
+                ViewModel.SelectedColorCommand?.Execute(e);
+            }
+        }
+
+        private void SharpsBtn_Click(object sender, RoutedEventArgs e)
+        {
+            var btn = sender as ToggleButton;
+            foreach (var item in ToolGrid.Children)
+            {
+                var btnItem = item as ToggleButton;
+                if (btnItem != null)
+                {
+                    if (btnItem != btn)
+                    {
+
+                        btnItem.IsChecked = false;
+                    }
+                    else
+                    {
+                        btnItem.IsChecked = true;
+                   
+                    }
+                }
+            }
+        }
     }
 }