Browse Source

Merge branch 'dev' of http://git.kdan.cc:8865/Windows/PDFOffice_Windows_exe into dev

OYXH\oyxh 2 years ago
parent
commit
71a42650b0

+ 69 - 36
PDF Office/Helper/PopControlHelper.cs

@@ -507,11 +507,13 @@ namespace PDF_Office.Helper
 
     }
 
+    //菜单按钮类
     public class CusMenuItem
     {
-        public Control control { get; private set; }
-        public object Parameter { get; private set; }
-        public object tag { get; private set; }
+        public Control control { get; private set; }//菜单按钮控件
+        public int Level { get; private set; }//菜单按钮的层级数。Level为0是一级菜单
+        public object Parameter { get; private set; }//核心处理的参数
+        public object tag { get; private set; }//菜单控件Tag
         public void SetFlagControl(Control control)
         {
             this.control = control;
@@ -523,39 +525,52 @@ namespace PDF_Office.Helper
             Parameter = parameter;
         }
     }
+
+
+
+
     public class PopMenu
     {
+        /// <summary>
+        /// 菜单栏
+        /// </summary>
         public ContextMenu ContMenu { get; private set; }
+        /// <summary>
+        /// 菜单按钮集合
+        /// </summary>
         public List<CusMenuItem> Controls { get; private set; }
-        public PopMenu(ContextMenu popMenu,Style style = null)
-        {
-            if (style != null)
-                popMenu.Style = style;
 
+        public PopMenu(ContextMenu popMenu)
+        {
             ContMenu = popMenu;
         }
 
-        //打开右键菜单
-        public ContextMenu OpenMenu(object parameter)
+        /// <summary>
+        /// 打开右键菜单(parameter:commmand核心参数,uiParameter:响应复制粘贴等指令的参数)
+        /// </summary>
+        public ContextMenu OpenMenu(object parameter, object uiParameter = null)
         {
             if (Controls == null) return null;
 
             foreach(var item in Controls)
             {
-                BindingParameter(item, parameter);
+                item.control.DataContext = parameter;
+                if (uiParameter is UIElement && uiParameter != null)
+                    BindingParameter(item, parameter, (UIElement)uiParameter);
+                else
+                    BindingParameter(item, parameter);
             }
 
             return ContMenu;
         }
 
-        //右键菜单:创建菜单按钮、单选按钮
-        public CusMenuItem AddItem(Control control,Style style = null)
+        /// <summary>
+        /// 右键菜单:创建菜单按钮、单选按钮等
+        /// </summary>
+        public CusMenuItem AddItem(Control control)
         {
             if (control == null) return null;
 
-            if (style != null)
-                control.Style = style;
-
             CusMenuItem controlMenu = new CusMenuItem();
             controlMenu.SetFlagControl(control);
             if (Controls == null)
@@ -567,13 +582,11 @@ namespace PDF_Office.Helper
             return controlMenu;
         }
 
-        public CusMenuItem AddChild(string parentName, Control child, Style style = null)
+        //在某菜单按钮的子级,新增子菜单按钮
+        public CusMenuItem AddChild(string parentName, Control child)
         {
             if (Controls == null || child == null) return null;
 
-            if (style != null)
-                child.Style = style;
-
             CusMenuItem childItem = null;
             foreach (var item in Controls)
             {
@@ -592,10 +605,12 @@ namespace PDF_Office.Helper
         }
 
         //菜单按钮事件绑定
-        public void BindingEvent(CusMenuItem controlMenu,ICommand command, object CommandParameter)
+        public void BindingEvent(CusMenuItem controlMenu,ICommand command)
         {
             if (controlMenu == null) return;
 
+
+
             if(controlMenu.control is RadioButton)
             {
                 var Btn = (RadioButton)controlMenu.control;
@@ -605,36 +620,32 @@ namespace PDF_Office.Helper
             else if(controlMenu.control is MenuItem)
             {
                 var Btn = (MenuItem)controlMenu.control;
-
-                if(CommandParameter is UIElement)
-                {
-                    Btn.CommandTarget = (UIElement)CommandParameter;
-                }
-
                 Btn.CommandParameter = controlMenu;
                 Btn.Command = command;
             }
-
-            controlMenu.SetParameter(CommandParameter);
         }
 
-        private void BindingParameter(CusMenuItem controlMenu, object CommandParameter)
+        /// <summary>
+        /// 右键菜单时,菜单按钮command需要的参数
+        /// </summary>
+        private void BindingParameter(CusMenuItem controlMenu, object CommandParameter, UIElement uIElement = null)
         {
             if (controlMenu == null) return;
 
             if (controlMenu.control is RadioButton)
             {
                 var Btn = (RadioButton)controlMenu.control;
+                if (uIElement != null)
+                    Btn.CommandTarget = uIElement;
+
                 Btn.CommandParameter = controlMenu;
             }
             else if (controlMenu.control is MenuItem)
             {
                 var Btn = (MenuItem)controlMenu.control;
 
-                if (CommandParameter is UIElement)
-                {
-                    Btn.CommandTarget = (UIElement)CommandParameter;
-                }
+                if(uIElement != null)
+                Btn.CommandTarget = uIElement;
 
                 Btn.CommandParameter = controlMenu;
             }
@@ -642,20 +653,42 @@ namespace PDF_Office.Helper
             controlMenu.SetParameter(CommandParameter);
         }
 
-        //菜单按钮是否可见
-        public void SetVisual(string name,bool isVisible)
+        /// <summary>
+        /// 菜单按钮是否可见
+        /// </summary>
+        public void SetVisual(string controlName, bool isVisible)
         {
             if (Controls == null) return;
 
             foreach(var item in Controls)
             {
-                if(item.control.Name == name)
+                if(item.control.Name == controlName)
                 {
                     item.control.Visibility = (isVisible?Visibility.Visible:Visibility.Collapsed);
                     break;
                 }
             }
         }
+
+        /// <summary>
+        /// 菜单按钮选中状态(若菜单为单选按钮)
+        /// </summary>
+        public void SetIsChecked(string controlName, bool isChecked)
+        {
+            if (Controls == null) return;
+
+            foreach (var item in Controls)
+            {
+                if (item.control.Name == controlName && (item.control as RadioButton) != null)
+                {
+                    var btn = item.control as RadioButton;
+                    btn.IsChecked = isChecked;
+                    break;
+                }
+            }
+
+        }
+
     }
 
     #endregion

+ 0 - 669
PDF Office/Styles/ContextMenuStyle.xaml

@@ -51,675 +51,6 @@
         </Setter>
     </Style>
 
-    <ContextMenu x:Key="HightAnnotContextMenu" FontSize="14">
-        <ContextMenu.ItemContainerStyle>
-            <Style TargetType="MenuItem">
-                <Setter Property="Padding" Value="0,7,0,7" />
-                <Setter Property="VerticalContentAlignment" Value="Center" />
-            </Style>
-        </ContextMenu.ItemContainerStyle>
-        <MenuItem
-            Name="HightColorAnnotMenuItem"
-            Header="颜色列表" Style="{StaticResource UIElementMenuItem}"
-            IsEnabled="True">
-        </MenuItem>
-        <MenuItem
-            Name="CopyTextMenuItem"
-            Header="复制文本"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="DeleteHightAnnotMenuItem"
-            Header="删除"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="NoteHightAnnotMenuItem"
-            Header="添加笔记"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="DefaultHightAnnotMenuItem"
-            Header="设置当前属性为默认值"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-    </ContextMenu>
-
-    <!--注释 - 手绘 -右键菜单-->
-    <ContextMenu x:Key="FreeHandAnnotContextMenu" FontSize="14">
-        <ContextMenu.ItemContainerStyle>
-            <Style TargetType="MenuItem">
-                <Setter Property="Padding" Value="0,7,0,7" />
-                <Setter Property="VerticalContentAlignment" Value="Center" />
-            </Style>
-        </ContextMenu.ItemContainerStyle>
-        <MenuItem
-            Name="CopyFreeHandAnnotMenuItem"
-            Header="复制"
-            IsEnabled="True">
-        </MenuItem>
-
-        <MenuItem
-            Name="CutFreeHandAnnotMenuItem"
-            Header="剪切"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="PasteFreeHandAnnotMenuItem"
-            Header="粘贴"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-
-        <MenuItem
-            Name="DeleteFreeHandAnnotMenuItem"
-            Header="删除"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="ColorFreeHandAnnotMenuItem"
-            Header="颜色"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="LineStyleFreeHandAnnotMenuItem"
-            Header="线段样式"
-            IsEnabled="True">
-            <RadioButton x:Name="SolidLineStyleFreeHandAnnotMenuItem" Tag="solid" GroupName="LineStyle" Content="实线">
-            </RadioButton>
-            <RadioButton x:Name="DashLineStyleFreeHandAnnotMenuItem" Tag="dash" GroupName="LineStyle" Content="虚线">
-            </RadioButton>
-        </MenuItem>
-
-        <MenuItem
-            Name="NoteFreeHandAnnotMenuItem"
-            Header="添加笔记"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="DefaultFreeHandAnnotMenuItem"
-            Header="设置当前属性为默认值"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-    </ContextMenu>
-
-    <!--注释 - 文本 -右键菜单-->
-    <ContextMenu x:Key="FreeTextAnnotContextMenu" FontSize="14">
-        <ContextMenu.ItemContainerStyle>
-            <Style TargetType="MenuItem">
-                <Setter Property="Padding" Value="0,7,0,7" />
-                <Setter Property="VerticalContentAlignment" Value="Center" />
-            </Style>
-        </ContextMenu.ItemContainerStyle>
-        <MenuItem
-            Name="CopyFreeTextAnnotMenuItem"
-            Header="复制"
-            IsEnabled="True">
-        </MenuItem>
-
-        <MenuItem
-            Name="CutFreeTextAnnotMenuItem"
-            Header="剪切"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="PasteFreeTextAnnotMenuItem"
-            Header="粘贴"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-
-        <MenuItem
-            Name="DeleteFreeTextAnnotMenuItem"
-            Header="删除"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="ColorFreeTextAnnotMenuItem"
-            Header="文本颜色"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-        <MenuItem
-            Name="FontFamilyFreeTextAnnotMenuItem"
-            Header="字体"
-            IsEnabled="True">
-            <RadioButton
-            Name="ArialMenuItem"
-            Content="Arial"
-            IsEnabled="True">
-            </RadioButton>
-            <RadioButton
-            Name="ArialMenuItem2"
-            Content="Arial"
-            IsEnabled="True">
-            </RadioButton>
-            <RadioButton
-            Name="TimesNewRomanMenuItem"
-            Content="Times New Roman"
-            IsEnabled="True">
-            </RadioButton>
-        </MenuItem>
-
-        <MenuItem
-            Name="AglinFreeTextAnnotMenuItem"
-            Header="文本样式"
-            IsEnabled="True">
-            <RadioButton
-            Name="LeftAglinFreeTextAnnotMenuItem"
-            Content="左对齐" Tag="Left"
-            IsEnabled="True">
-            </RadioButton>
-            <RadioButton
-            Name="CenterAglinFreeTextAnnotMenuItem"
-            Content="居中对齐" Tag="Center"
-            IsEnabled="True">
-            </RadioButton>
-            <RadioButton
-            Name="RightAglinFreeTextAnnotMenuItem"
-            Content="右对齐" Tag="Right"
-            IsEnabled="True">
-            </RadioButton>
-        </MenuItem>
-
-        <MenuItem
-            Name="DefaultFreeTextAnnotMenuItem"
-            Header="设置当前属性为默认值"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-    </ContextMenu>
-
-    <!--注释 - 便签 -右键菜单-->
-    <ContextMenu x:Key="StrickNoteAnnotContextMenu" FontSize="14">
-        <ContextMenu.ItemContainerStyle>
-            <Style TargetType="MenuItem">
-                <Setter Property="Padding" Value="0,7,0,7" />
-                <Setter Property="VerticalContentAlignment" Value="Center" />
-            </Style>
-        </ContextMenu.ItemContainerStyle>
-        <MenuItem
-            Name="CopyStrickNoteAnnotMenuItem"
-            Header="复制"
-            IsEnabled="True">
-        </MenuItem>
-
-        <MenuItem
-            Name="CutStrickNoteAnnotMenuItem"
-            Header="剪切"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="PasteStrickNoteAnnotMenuItem"
-            Header="粘贴"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-
-        <MenuItem
-            Name="DeleteStrickNoteAnnotMenuItem"
-            Header="删除"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="ColorStrickNoteAnnotMenuItem"
-            Header="颜色"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-        
-        <MenuItem
-            Name="EditStrickNoteAnnotMenuItem"
-            Header="编辑便签"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="DefaultStrickNoteAnnotMenuItem"
-            Header="设置当前属性为默认值"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-    </ContextMenu>
-
-    <!--注释 - 形状 -右键菜单-->
-    <ContextMenu x:Key="ShapeAnnotContextMenu" FontSize="14">
-        <ContextMenu.ItemContainerStyle>
-            <Style TargetType="MenuItem">
-                <Setter Property="Padding" Value="0,7,0,7" />
-                <Setter Property="VerticalContentAlignment" Value="Center" />
-            </Style>
-        </ContextMenu.ItemContainerStyle>
-        <MenuItem
-            Name="CopyShapeAnnotMenuItem"
-            Header="复制"
-            IsEnabled="True">
-        </MenuItem>
-
-        <MenuItem
-            Name="CutShapeAnnotMenuItem"
-            Header="剪切"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="PasteShapeAnnotMenuItem"
-            Header="粘贴"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-
-        <MenuItem
-            Name="DeleteShapeAnnotMenuItem"
-            Header="删除"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="ColorShapeAnnotMenuItem"
-            Header="颜色"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="LineStyleShapeAnnotMenuItem"
-            Header="线段样式"
-            IsEnabled="True">
-            <RadioButton
-            Name="SolidLineStyleShapeAnnotMenuItem"
-            Content="实线" Tag="solid"
-            IsEnabled="True">
-            </RadioButton>
-            <RadioButton
-            Name="DashLineStyleShapeAnnotMenuItem"
-            Content="虚线" Tag="dash"
-            IsEnabled="True">
-            </RadioButton>
-        </MenuItem>
-
-        <MenuItem
-            Name="LineDirectShapeAnnotMenuItem"
-            Header="线段方向"
-            IsEnabled="True">
-            <MenuItem
-            Name="VeriLineDirectShapeAnnotMenuItem"
-            Header="垂直" Tag="ver"
-            IsEnabled="True">
-            </MenuItem>
-            <MenuItem
-            Name="HoriLineDirectShapeAnnotMenuItem"
-            Header="水平" Tag="hor"
-            IsEnabled="True">
-            </MenuItem>
-        </MenuItem>
-
-        <MenuItem
-            Name="NoteShapeAnnotMenuItem"
-            Header="添加笔记"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="DefaultShapeAnnotMenuItem"
-            Header="设置当前属性为默认值"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-    </ContextMenu>
-
-    <!--注释 - 链接 -右键菜单-->
-    <ContextMenu x:Key="LinkAnnotContextMenu" FontSize="14">
-        <ContextMenu.ItemContainerStyle>
-            <Style TargetType="MenuItem">
-                <Setter Property="Padding" Value="0,7,0,7" />
-                <Setter Property="VerticalContentAlignment" Value="Center" />
-            </Style>
-        </ContextMenu.ItemContainerStyle>
-        <MenuItem
-            Name="CopyLinkAnnotMenuItem"
-            Header="复制"
-            IsEnabled="True">
-        </MenuItem>
-
-        <MenuItem
-            Name="CutLinkAnnotMenuItem"
-            Header="剪切"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="PasteLinkAnnotMenuItem"
-            Header="粘贴"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="DeleteLinkAnnotMenuItem"
-            Header="删除"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-    </ContextMenu>
-
-    <!--注释 - 图章 -右键菜单-->
-    <ContextMenu x:Key="StampAnnotContextMenu" FontSize="14">
-        <ContextMenu.ItemContainerStyle>
-            <Style TargetType="MenuItem">
-                <Setter Property="Padding" Value="0,7,0,7" />
-                <Setter Property="VerticalContentAlignment" Value="Center" />
-            </Style>
-        </ContextMenu.ItemContainerStyle>
-        <MenuItem
-            Name="CopyStampAnnotMenuItem"
-            Header="复制"
-            IsEnabled="True">
-        </MenuItem>
-
-        <MenuItem
-            Name="CutStampAnnotMenuItem"
-            Header="剪切"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="PasteStampAnnotMenuItem"
-            Header="粘贴"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="DeleteStampAnnotMenuItem"
-            Header="删除"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-
-        <MenuItem
-            Name="ExportStampAnnotMenuItem"
-            Header="导出"
-            IsEnabled="True">
-            <MenuItem
-            Name="ExportPNGStampAnnotMenuItem"
-            Header="PNG"
-            IsEnabled="True">
-            </MenuItem>
-            <MenuItem
-            Name="ExportJPGStampAnnotMenuItem"
-            Header="JPG"
-            IsEnabled="True">
-            </MenuItem>
-            <MenuItem
-            Name="ExportPDFStampAnnotMenuItem"
-            Header="PDF"
-            IsEnabled="True">
-            </MenuItem>
-        </MenuItem>
-
-    </ContextMenu>
-
-    <!--注释 - 多选注释 -右键菜单-->
-    <ContextMenu x:Key="MultiSelectAnnotContextMenu" FontSize="14">
-        <ContextMenu.ItemContainerStyle>
-            <Style TargetType="MenuItem">
-                <Setter Property="Padding" Value="0,7,0,7" />
-                <Setter Property="VerticalContentAlignment" Value="Center" />
-            </Style>
-        </ContextMenu.ItemContainerStyle>
-        <MenuItem
-            Name="CopyMultiSelectAnnotMenuItem"
-            Header="复制"
-            IsEnabled="True">
-        </MenuItem>
-
-        <MenuItem
-            Name="CutMultiSelectAnnotMenuItem"
-            Header="剪切"
-            IsEnabled="True">
-            <MenuItem.Icon>
-                <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
-                    <Path.RenderTransform>
-                        <TranslateTransform X="3.0000" Y="0" />
-                    </Path.RenderTransform>
-                </Path>
-            </MenuItem.Icon>
-        </MenuItem>
-    </ContextMenu>
 
     <!--  注释-内容选择-右键菜单  -->
     <ContextMenu x:Key="SnapshotContextMenu" FontSize="14">

+ 252 - 125
PDF Office/ViewModels/FillAndSign/FillAndSignContentViewModel.cs

@@ -27,6 +27,7 @@ using System.Windows.Forms;
 using Control = System.Windows.Controls.Control;
 using Microsoft.Office.Interop.Word;
 using Point = System.Windows.Point;
+using System.Windows.Ink;
 
 namespace PDF_Office.ViewModels.FillAndSign
 {
@@ -37,13 +38,13 @@ namespace PDF_Office.ViewModels.FillAndSign
         private AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
         private ViewContentViewModel viewContentViewModel;
         private bool isRightMenuAddAnnot = false;
-        private List<List<Point>> ShapePoints = new List<List<Point>>();
+        public List<List<Point>> ShapePoints = new List<List<Point>>();
         private string Shape = "HookShape";
-                   
+
         private IRegionManager regions { get; set; }
         private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
-
-        public Brush SelectColor=new SolidColorBrush(Colors.GreenYellow);
+        public static bool IsEdit = false;
+        public Brush SelectColor = new SolidColorBrush(Colors.GreenYellow);
         public double FillOpacity = 1;
         public double LineWidth = 1;
         #endregion
@@ -68,6 +69,7 @@ namespace PDF_Office.ViewModels.FillAndSign
 
         private void CheckedEvent(RoutedEventArgs e)
         {
+            IsEdit = false;
             var control = e.OriginalSource as Control;
 
             //NavigateToProperty(control.Name);
@@ -139,27 +141,27 @@ namespace PDF_Office.ViewModels.FillAndSign
                     break;
                 case "RbtnTick"://勾
                     Shape = "HookShape";
-                    ShapePoints =new List<List<Point>> { new List<Point> { new Point(0.599976,7.0286), new Point(5.57775,11.8), new Point(13.4,1.40002)} };
+                    ShapePoints = new List<List<Point>> { new List<Point> { new Point(0.599976, 7.0286), new Point(5.57775, 11.8), new Point(13.4, 1.40002) } };
                     annotArgs = GetStamp();
                     break;
                 case "RbtnFork"://叉
                     Shape = "ForkShape";
-                    ShapePoints = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.20001), new Point(12.8, 12.8) } ,new List<Point> { new Point(12.8, 3.20001), new Point(3.20005, 12.8) }};
+                    ShapePoints = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.20001), new Point(12.8, 12.8) }, new List<Point> { new Point(12.8, 3.20001), new Point(3.20005, 12.8) } };
                     annotArgs = GetStamp();
                     break;
                 case "RbtnRectangle"://矩形
                     Shape = "RectShape";
-                    ShapePoints = new List<List<Point>> { new List<Point> { new Point(0, 5), new Point(28, 5),new Point(28,27),new Point(0,27) , new Point(0, 5) } };
+                    ShapePoints = new List<List<Point>> { new List<Point> { new Point(0.19995, 5), new Point(28, 5), new Point(28, 27), new Point(0.19995, 27), new Point(0.19995, 5) } };
                     annotArgs = GetStamp();
                     break;
                 case "RbtnLine"://下划线
                     Shape = "LineShape";
-                    ShapePoints = new List<List<Point>> { new List<Point> { new Point(12, 10), new Point(36, 10) } };
+                    ShapePoints = new List<List<Point>> { new List<Point> { new Point(12.19995, 10), new Point(36, 10) } };
                     annotArgs = GetStamp();
                     break;
                 case "RbtnPoint":
                     Shape = "DotShape";
-                    ShapePoints = new List<List<Point>> { new List<Point> { new Point(0, 0), new Point(2, 2) }, new List<Point> { new Point(2, 0), new Point(0,2 ) } };
+                    ShapePoints = new List<List<Point>> { new List<Point> { new Point(0.19995, 1.19995), new Point(0.19995, -1.19995) }, new List<Point> { new Point(-0.25995, 0.89995), new Point(0.25995, -0.89995) }, new List<Point> { new Point(-1.19995, 0.19995), new Point(0.19995, 1.19995) } };
                     annotArgs = GetStamp();
                     break;
                 default://图章
@@ -181,29 +183,43 @@ namespace PDF_Office.ViewModels.FillAndSign
         /// 图章
         /// </summary>
         /// <returns></returns>
-        private AnnotHandlerEventArgs GetStamp()
+        private AnnotHandlerEventArgs GetStamp(List<AnnotHandlerEventArgs> selectedArgs = null)
         {
             StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
             stampAnnotArgs.SetInkData(ShapePoints, LineWidth, (SelectColor as SolidColorBrush).Color);
             //PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
-            //PDFViewer.SetToolParam(stampArgs);
-            //StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
-            //stampAnnotArgs.Opacity = 1;
-            //stampAnnotArgs.StampText = "APPROVED";
-            //stampAnnotArgs.Type = StampType.STANDARD_STAMP;
-           // stampAnnotArgs.Type = StampType.STANDARD_STAMP;
+            //PDFViewer.SetToolParam(stampArgs);
+            //StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
+            //stampAnnotArgs.Opacity = 1;
+            //stampAnnotArgs.StampText = "APPROVED";
+            //stampAnnotArgs.Type = StampType.STANDARD_STAMP;
+            // stampAnnotArgs.Type = StampType.STANDARD_STAMP;
+            stampAnnotArgs.IsContinueMode = true;
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
             DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStamp);
             List<AnnotHandlerEventArgs> stampAnnotArgsList = new List<AnnotHandlerEventArgs>();
             if (stampAnnotArgs != null)
-                stampAnnotArgsList.Add(stampAnnotArgs);
-
+                stampAnnotArgsList.Add(stampAnnotArgs);
+            //if (selectedArgs != null) { 
+            //var annot = selectedArgs[0];
+            //if (annot != null)
+            //{
+
+            //    foreach (var item in selectedArgs)
+            //    {
+            //        selectedArgs[selectedArgs.IndexOf(item)] = stampAnnotArgs;
+            //    }
+            //    AddToPropertyPanel("ShapFillProperty", "", selectedArgs, annotAttribsList);
+            //    return stampAnnotArgs;
+            //}
+            //   }
+
             AddToPropertyPanel("ShapFillProperty", "", stampAnnotArgsList, annotAttribsList);
             return stampAnnotArgs;
         }
 
-        public void  SetStamp()
+        public void SetStamp()
         {
             StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
             stampAnnotArgs.SetInkData(ShapePoints, LineWidth, (SelectColor as SolidColorBrush).Color);
@@ -213,6 +229,7 @@ namespace PDF_Office.ViewModels.FillAndSign
             //stampAnnotArgs.Opacity = 1;
             //stampAnnotArgs.StampText = "APPROVED";
             //stampAnnotArgs.Type = StampType.STANDARD_STAMP;
+            stampAnnotArgs.IsContinueMode = true;
             stampAnnotArgs.Opacity = FillOpacity;
             Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
             annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
@@ -253,7 +270,86 @@ namespace PDF_Office.ViewModels.FillAndSign
                 {
                     ShowPropertyPanel(true);
                 }
-            } 
+            }
+        }
+        /// <summary>
+        /// 手绘
+        /// </summary>
+        /// <param name="selectedArgs"></param>
+        /// <returns></returns>
+        private AnnotHandlerEventArgs GetFreehand(List<AnnotHandlerEventArgs> selectedArgs = null)
+        {
+
+            Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
+            List<AnnotHandlerEventArgs> newSelectedArgs= new List<AnnotHandlerEventArgs>();
+            FreehandAnnotArgs freehandArgs = null;
+
+            if (selectedArgs == null || selectedArgs.Count == 0)
+            {
+                freehandArgs = new FreehandAnnotArgs();
+                var annotate = Settings.Default.AppProperties.Annotate;
+                if (annotate != null)
+                {
+                    freehandArgs.InkColor = annotate.FreeHandColor;
+                }
+                else
+                {
+                    freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
+                }
+
+                freehandArgs.Transparency = 1;
+                freehandArgs.LineWidth = 2;
+
+                if (freehandArgs != null)
+                {
+                    selectedArgs = new List<AnnotHandlerEventArgs>();
+                    selectedArgs.Add(freehandArgs);
+                }
+            }
+            else
+            {
+
+                freehandArgs = selectedArgs[0] as FreehandAnnotArgs;
+                foreach (var item in selectedArgs)
+                {
+                  
+                    //if (ListPoint((item as FreehandAnnotArgs).RawPointList, ShapePoints)){
+                    foreach (var point in viewContentViewModel.FillAndSign)
+                    {
+                        if ((item as FreehandAnnotArgs).PageIndex == point.X && (item as FreehandAnnotArgs).AnnotIndex == point.Y)
+                        {
+
+                            newSelectedArgs.Add(item);
+                        }
+                    }
+
+                }
+                annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
+                annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
+                annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
+                annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
+
+                AddToPropertyPanel("ShapFillProperty", "Freehand", newSelectedArgs, annotAttribsList);
+                //GetStamp();
+                return freehandArgs;
+            }
+
+            //annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
+            //annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
+            //annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
+            //annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
+
+            //AddToPropertyPanel("ShapFillProperty", "Freehand", selectedArgs, annotAttribsList);
+            return freehandArgs;
+        }
+        private bool ListPoint(List<List<Point>> leftpoints, List<List<Point>> rightpoints)
+        {
+
+            if (leftpoints.Count == rightpoints.Count)
+            {
+                if (leftpoints[0][0].X == rightpoints[0][0].X) { return true; }
+            }
+            return false;
         }
 
         /// <summary>
@@ -340,7 +436,7 @@ namespace PDF_Office.ViewModels.FillAndSign
         /// <param name="toolTag">导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线</param>
         /// <param name="annot">注释</param>
         /// <param name="annotAttribsList">更改注释属性的键值对,更改值后会自动记录undoRedo容器里</param>
-        private void AddToPropertyPanel(string viewContent, string toolTag = null, List<AnnotHandlerEventArgs> annots = null, Dictionary<AnnotAttrib, object> annotAttribsList = null, AnnotAttribEvent annotAttribEvent = null,bool isUpData=false)
+        private void AddToPropertyPanel(string viewContent, string toolTag = null, List<AnnotHandlerEventArgs> annots = null, Dictionary<AnnotAttrib, object> annotAttribsList = null, AnnotAttribEvent annotAttribEvent = null, bool isUpData = false)
         {
 
             if (annots != null)
@@ -375,15 +471,17 @@ namespace PDF_Office.ViewModels.FillAndSign
                 {
                     propertyPanel.AnnotEvent = annotAttribEvent;
                 }
-            }
-            
+            }
+
             if (string.IsNullOrEmpty(viewContent) == false)
-            {
-                if (isUpData) { return; }
+            {
+
+                if (isUpData) { return; }
+
                 if (viewContent == "ShapFillProperty") { NavigateToProperty(viewContent, propertyPanel); return; }
                 viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
-            }
-            
+            }
+
         }
 
         private void NavigateToProperty(string btnName, AnnotPropertyPanel annotPropertyPanel)
@@ -393,7 +491,7 @@ namespace PDF_Office.ViewModels.FillAndSign
             values.Add(ParameterNames.PropertyPanelContentViewModel, annotPropertyPanel);
             values.Add("Shape", Shape);
             values.Add("FillAndSignContentViewModel", this);
-            regions.RequestNavigate(RegionNames.PropertyRegionName,btnName,values);
+            regions.RequestNavigate(RegionNames.PropertyRegionName, btnName, values);
             viewContentViewModel.IsPropertyOpen = true;
         }
 
@@ -420,109 +518,135 @@ namespace PDF_Office.ViewModels.FillAndSign
             {
 
 
-                //PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
-                //PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
-
-
+                PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
+                PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
+                PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
+                PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
             }
         }
         private void UnBindingPDFViewerHandler()
         {
             if (PDFViewer != null)
-            { /*PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler; */}
+            {
+                PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
+                PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
+            }
         }
+        private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
+        {
+            if (e != null && e.Count > 0)
+            {
+                for (int i = 0; i < e.Count; i++)
+                {
+                    AnnotEditEvent editEvent = e[i];
+                    switch (editEvent.EditAction)
+                    {
+                        case ActionType.Add:
+                            int pageindex = editEvent.PageIndex;
+                            int annotindex = editEvent.AnnotIndex;
+                            viewContentViewModel.FillAndSign.Add(new Point(pageindex, annotindex));
+                            break;
+                    }
+                }
+            }
 
+        }
 
         //选中和非选中注释,右键菜单
-        //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);
-        //            }
+        private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
+        {
+            if (e != null)
+            {
+                var annot = e.AnnotItemsList[0];
+                if (annot != null)
+                {
+
+                    if (e.AnnotItemsList.Count == 1)
+                    {
+                        //IsEdit = false;
+                        //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);
-        //    }
-        //}
+                }
+            }
+            else
+            {
+                viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
+            }
+        }
         //private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
         //{
         //    if (e != null && e.Count > 0)
@@ -603,15 +727,16 @@ namespace PDF_Office.ViewModels.FillAndSign
             }
         }
         private void GetSelectedAnnots(AnnotAttribEvent e)
-        {
+        {
+            IsEdit = true;
             var annot = e.AnnotItemsList[0];
             switch (annot.EventType)
             {
 
 
 
-                case AnnotArgsType.AnnotFreeText:
-                    GetFreetext(e.AnnotItemsList);
+                case AnnotArgsType.AnnotFreehand:
+                    GetFreehand(e.AnnotItemsList);
                     break;
 
 
@@ -633,7 +758,8 @@ namespace PDF_Office.ViewModels.FillAndSign
 
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
-            UnBindingPDFViewerHandler();
+            UnBindingPDFViewerHandler();
+            viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
         }
 
         public void OnNavigatedTo(NavigationContext navigationContext)
@@ -641,6 +767,7 @@ namespace PDF_Office.ViewModels.FillAndSign
             navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
             BindingPDFViewerHandler();
+            IsEdit = false;
         }
         #endregion
     }

+ 46 - 22
PDF Office/ViewModels/FillAndSign/PropertyPanel/ShapFillPropertyViewModel.cs

@@ -18,6 +18,7 @@ using PDF_Office.Model;
 using PDF_Office.ViewModels.Tools;
 using Microsoft.Office.Interop.Excel;
 using Point = System.Windows.Point;
+using static Dropbox.Api.UsersCommon.AccountType;
 
 namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
 {
@@ -27,7 +28,7 @@ namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
         private AnnotHandlerEventArgs Annot;
         private AnnotPropertyPanel PropertyPanel;
         private FillAndSignContentViewModel fillAndSignContentViewModel;
-        
+
         private Geometry dataPath = null;
         public Geometry DataPath
         {
@@ -44,10 +45,14 @@ namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
             get { return selectColor; }
             set
             {
-                SetProperty(ref selectColor, value); 
-                fillAndSignContentViewModel.SelectColor = value;
-                fillAndSignContentViewModel.SetStamp();
-               
+                SetProperty(ref selectColor, value);
+                fillAndSignContentViewModel.SelectColor = value;
+                if (FillAndSignContentViewModel.IsEdit)
+                {
+                    PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Color, (selectColor as SolidColorBrush).Color);
+                }
+                else { fillAndSignContentViewModel.SetStamp(); }
+
             }
         }
 
@@ -58,9 +63,11 @@ namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
             set
             {
                 SetProperty(ref fillOpacity, value);
-                fillAndSignContentViewModel.FillOpacity = value;
-                fillAndSignContentViewModel.SetStamp( );
-                
+                fillAndSignContentViewModel.FillOpacity = value;
+
+                if (FillAndSignContentViewModel.IsEdit) { PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, fillOpacity); }
+                else { fillAndSignContentViewModel.SetStamp(); }
+
             }
         }
 
@@ -79,8 +86,12 @@ namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
             {
                 SetProperty(ref lineWidth, value);
                 fillAndSignContentViewModel.LineWidth = value;
-                fillAndSignContentViewModel.SetStamp();
-                
+                if (FillAndSignContentViewModel.IsEdit)
+                {
+                    PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, value);
+                }
+                else { fillAndSignContentViewModel.SetStamp(); }
+
             }
         }
         public DelegateCommand<object> SelectedThickCommand { get; set; }
@@ -108,9 +119,11 @@ namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
             if (obj != null)
             {
                 var tag = (string)obj;
-                SharpsType(tag,obj);
+                SharpsType(tag, obj);
             }
-        }
+        }
+
+
         private void SharpsType(string tag, object obj, bool isFromToolsBtn = false)
         {
             Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
@@ -120,14 +133,19 @@ namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
                     var hookShape = new PathGeometry();
                     hookShape.AddGeometry(Geometry.Parse("M0.599976 7.0286L5.57775 11.8L13.4 1.40002"));
                     DataPath = hookShape;
-                    changeData[AnnotArgsType.AnnotLine] = tag;
+                    //PropertyPanel.UpdateAnnotAAttrib();
+                    //fillAndSignContentViewModel.ShapePoints = new List<List<Point>> { new List<Point> { new Point(0.599976, 7.0286), new Point(5.57775, 11.8), new Point(13.4, 1.40002) } };
+                    //fillAndSignContentViewModel.SetStamp();
+                    //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;
+                    //fillAndSignContentViewModel.ShapePoints = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.20001), new Point(12.8, 12.8) }, new List<Point> { new Point(12.8, 3.20001), new Point(3.20005, 12.8) } };
+                    //fillAndSignContentViewModel.SetStamp();
+                    //changeData[AnnotArgsType.AnnotLine] = tag;
                     break;
 
                 case "RectShape":
@@ -135,7 +153,9 @@ namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
                         RectangleGeometry rectPath = new RectangleGeometry();
                         rectPath.Rect = new Rect(0, 5, 28, 22);
                         DataPath = rectPath;
-                        changeData[AnnotArgsType.AnnotSquare] = tag;
+                        //fillAndSignContentViewModel.ShapePoints = new List<List<Point>> { new List<Point> { new Point(0.19995, 5), new Point(28, 5), new Point(28, 27), new Point(0.19995, 27), new Point(0.19995, 5) } };
+                        //fillAndSignContentViewModel.SetStamp();
+                        // changeData[AnnotArgsType.AnnotSquare] = tag;
                     }
 
                     break;
@@ -143,8 +163,10 @@ namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
                     {
                         var lineShape = new PathGeometry();
                         lineShape.AddGeometry(Geometry.Parse(" M0,10L20,10"));
-                        DataPath = lineShape;
-                        changeData[AnnotArgsType.AnnotLine] = tag;
+                        DataPath = lineShape;
+                        //fillAndSignContentViewModel.ShapePoints = new List<List<Point>> { new List<Point> { new Point(12.19995, 10), new Point(36, 10) } };
+                        //fillAndSignContentViewModel.SetStamp();
+                        //changeData[AnnotArgsType.AnnotLine] = tag;
                     }
 
                     break;
@@ -154,9 +176,11 @@ namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
                         EllipseGeometry circlePath = new EllipseGeometry();
                         circlePath.RadiusX = 2.4;
                         circlePath.RadiusY = 2.4;
-                        circlePath.Center = new Point(2.4,2.4);
+                        circlePath.Center = new Point(2.4, 2.4);
                         DataPath = circlePath;
-                        changeData[AnnotArgsType.AnnotCircle] = tag;
+                        //fillAndSignContentViewModel.ShapePoints = new List<List<Point>> { new List<Point> { new Point(0.19995, 1.19995), new Point(0.19995, -1.19995) }, new List<Point> { new Point(-0.25995, 0.89995), new Point(0.25995, -0.89995) }, new List<Point> { new Point(-1.19995, 0.19995), new Point(0.19995, 1.19995) } };
+                        //fillAndSignContentViewModel.SetStamp();
+                        //changeData[AnnotArgsType.AnnotCircle] = tag;
                     }
 
                     break;
@@ -168,8 +192,8 @@ namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
         }
 
         private void InitSharpsType(string tag)
-        {
-            
+        {
+            
             switch (tag)
             {
                 case "HookShape":
@@ -296,7 +320,7 @@ namespace PDF_Office.ViewModels.FillAndSign.PropertyPanel
             navigationContext.Parameters.TryGetValue<FillAndSignContentViewModel>("FillAndSignContentViewModel", out fillAndSignContentViewModel);
             navigationContext.Parameters.TryGetValue<string>("Shape", out shape);
             InitSharpsType(shape);
-            
+            //FillAndSignContentViewModel.IsEdit = false;
             if (PropertyPanel != null)
             {
                 AnnotEvent = PropertyPanel.AnnotEvent;

+ 15 - 9
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -377,33 +377,37 @@ namespace PDF_Office.ViewModels.Tools
                                     case AnnotArgsType.AnnotUnderline:
                                     case AnnotArgsType.AnnotStrikeout:
                                     case AnnotArgsType.AnnotSquiggly:
-                                        e.PopupMenu = SelectHightAnnotMenu(selectedAnnot);
+                                        e.PopupMenu = HightAnnotPopMenu.OpenMenu(selectedAnnot, sender);
                                         break;
 
                                     case AnnotArgsType.AnnotFreehand:
-                                        e.PopupMenu = SelectFreeHandAnnotMenu(selectedAnnot);
+                                        e.PopupMenu = FreeHandAnnotPopMenu.OpenMenu(selectedAnnot, sender);
                                         break;
 
                                     case AnnotArgsType.AnnotFreeText:
-                                        e.PopupMenu = SelectFreeTextAnnotMenu(selectedAnnot);
+                                        e.PopupMenu = FreeTextAnnotPopMenu.OpenMenu(selectedAnnot, sender);
                                         break;
 
                                     case AnnotArgsType.AnnotSticky:
-                                        e.PopupMenu = SelectStrickNoteAnnotMenu(selectedAnnot);
+                                        e.PopupMenu = StrickNoteAnnotPopMenu.OpenMenu(selectedAnnot, sender);
                                         break;
 
                                     case AnnotArgsType.AnnotSquare:
-                                    case AnnotArgsType.AnnotLine:
                                     case AnnotArgsType.AnnotCircle:
-                                        e.PopupMenu = SelectShapeAnnotMenu(selectedAnnot);
+                                        ShapeAnnotPopMenu.SetVisual("ShapeDirect", false);
+                                        e.PopupMenu = ShapeAnnotPopMenu.OpenMenu(selectedAnnot, sender);
+                                        break;
+                                    case AnnotArgsType.AnnotLine:
+                                        ShapeAnnotPopMenu.SetVisual("ShapeDirect", true);
+                                        e.PopupMenu = ShapeAnnotPopMenu.OpenMenu(selectedAnnot, sender);
                                         break;
 
                                     case AnnotArgsType.AnnotLink:
-                                        e.PopupMenu = SelectHightAnnotMenu(selectedAnnot);
+                                        e.PopupMenu = LinkAnnotPopMenu.OpenMenu(selectedAnnot, sender);
                                         break;
 
                                     case AnnotArgsType.AnnotStamp:
-                                        e.PopupMenu = SelectHightAnnotMenu(selectedAnnot);
+                                        e.PopupMenu = StampAnnotPopMenu.OpenMenu(selectedAnnot, sender);
                                         break;
                                 }
                             }
@@ -419,7 +423,9 @@ namespace PDF_Office.ViewModels.Tools
                                     }
                                 }
 
-                                e.PopupMenu = SelectMultiAnnotMenu(e.AnnotEventArgsList, isHigh);
+                                MultiAnnotPopMenu.SetVisual("MultiCopy", !isHigh);
+                                MultiAnnotPopMenu.SetVisual("MultiCut", !isHigh);
+                                e.PopupMenu = MultiAnnotPopMenu.OpenMenu(e.AnnotEventArgsList,sender);//SelectMultiAnnotMenu(e.AnnotEventArgsList, isHigh);
                             }
                         }
                         if (e.PopupMenu != null)

+ 136 - 118
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -1020,96 +1020,109 @@ namespace PDF_Office.ViewModels.Tools
         //高亮、下划线、删除
         private void HightAnnotCopyText_Menu(object obj)
         {
-            if (obj != null && obj as AnnotationHandlerEventArgs != null)
+            if (obj as CusMenuItem != null)
             {
-                var annot = (AnnotationHandlerEventArgs)obj;
-                System.Windows.Clipboard.SetText(annot.Content);
+                var menu = obj as CusMenuItem;
+                var annot = menu.Parameter as AnnotHandlerEventArgs;
+                if(annot != null)
+                {
+                    System.Windows.Clipboard.SetText(annot.Content);
+                }
+                
             }
         }
 
         //更改为当前注释属性默认值
         private void AnnotDefaultValues_Menu(object obj)
         {
-            if (obj != null && obj as AnnotHandlerEventArgs != null)
+            if (obj as CusMenuItem != null)
             {
-               
-                var annot = (AnnotHandlerEventArgs)obj;
-                var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
-                if (annot is TextHighlightAnnotArgs)
-                {
-                    var color = (annot as TextHighlightAnnotArgs).Color;
-                    Settings.Default.AppProperties.Annotate.HighLightColor = color;
-                    HighLightColor = new SolidColorBrush(color);
-                }
-                else if(annot is TextUnderlineAnnotArgs)
-                {
-                    var color = (annot as TextHighlightAnnotArgs).Color;
-                    Settings.Default.AppProperties.Annotate.UnderLineColor = color;
-                    UnderLineColor = new SolidColorBrush(color);
-                }
-                else if (annot is TextStrikeoutAnnotArgs)
-                {
-                    var color = (annot as TextHighlightAnnotArgs).Color;
-                    Settings.Default.AppProperties.Annotate.StrikethroughColor = color;
-                    StrikeoutColor = new SolidColorBrush(color);
-                }
-                else if (annot is FreehandAnnotArgs)
+                var menu = obj as CusMenuItem;
+                var annot = menu.Parameter as AnnotHandlerEventArgs;
+                if (annot != null)
                 {
-                    var color = (annot as FreehandAnnotArgs).InkColor;
-                    Settings.Default.AppProperties.Annotate.FreeHandColor = color;
+                    if (annot is TextHighlightAnnotArgs)
+                    {
+                        var color = (annot as TextHighlightAnnotArgs).Color;
+                        Settings.Default.AppProperties.Annotate.HighLightColor = color;
+                        HighLightColor = new SolidColorBrush(color);
+                    }
+                    else if (annot is TextUnderlineAnnotArgs)
+                    {
+                        var color = (annot as TextHighlightAnnotArgs).Color;
+                        Settings.Default.AppProperties.Annotate.UnderLineColor = color;
+                        UnderLineColor = new SolidColorBrush(color);
+                    }
+                    else if (annot is TextStrikeoutAnnotArgs)
+                    {
+                        var color = (annot as TextHighlightAnnotArgs).Color;
+                        Settings.Default.AppProperties.Annotate.StrikethroughColor = color;
+                        StrikeoutColor = new SolidColorBrush(color);
+                    }
+                    else if (annot is FreehandAnnotArgs)
+                    {
+                        var color = (annot as FreehandAnnotArgs).InkColor;
+                        Settings.Default.AppProperties.Annotate.FreeHandColor = color;
 
+                    }
+                    else if (annot is FreeTextAnnotArgs)
+                    {
+                        var color = (annot as FreeTextAnnotArgs).FontColor;
+                        Settings.Default.AppProperties.Annotate.TextAnnoteColor = color;
+                    }
+                    else if (annot is StickyAnnotArgs)
+                    {
+                        var color = (annot as StickyAnnotArgs).Color;
+                        Settings.Default.AppProperties.Annotate.NoteAnnoteColor = color;
+                    }
+                    else if (annot is SquareAnnotArgs)
+                    {
+                        var bgColor = (annot as SquareAnnotArgs).BgColor;
+                        Settings.Default.AppProperties.Annotate.RectangleFillColor = bgColor;
+                        var borderColor = (annot as SquareAnnotArgs).LineColor;
+                        Settings.Default.AppProperties.Annotate.RectangleBorderColor = borderColor;
+                    }
+                    else if (annot is CircleAnnotArgs)
+                    {
+                        var bgColor = (annot as CircleAnnotArgs).BgColor;
+                        Settings.Default.AppProperties.Annotate.CircleFillColor = bgColor;
+                        var borderColor = (annot as CircleAnnotArgs).LineColor;
+                        Settings.Default.AppProperties.Annotate.CircleBorderColor = borderColor;
+                    }
+                    else if (annot is LineAnnotArgs)
+                    {
+                        var color = (annot as LineAnnotArgs).LineColor;
+                        Settings.Default.AppProperties.Annotate.LineColor = color;
+                    }
+
+                    Settings.Default.Save();
                 }
-                else if (annot is FreeTextAnnotArgs)
-                {
-                    var color = (annot as FreeTextAnnotArgs).FontColor;
-                    Settings.Default.AppProperties.Annotate.TextAnnoteColor = color;
-                }
-                else if (annot is StickyAnnotArgs)
-                {
-                    var color = (annot as StickyAnnotArgs).Color;
-                    Settings.Default.AppProperties.Annotate.NoteAnnoteColor = color;
-                }
-                else if (annot is SquareAnnotArgs)
-                {
-                    var bgColor = (annot as SquareAnnotArgs).BgColor;
-                    Settings.Default.AppProperties.Annotate.RectangleFillColor = bgColor;
-                    var borderColor = (annot as SquareAnnotArgs).LineColor;
-                    Settings.Default.AppProperties.Annotate.RectangleBorderColor = borderColor;
-                }
-                else if (annot is CircleAnnotArgs)
-                {
-                    var bgColor = (annot as CircleAnnotArgs).BgColor;
-                    Settings.Default.AppProperties.Annotate.CircleFillColor = bgColor;
-                    var borderColor = (annot as CircleAnnotArgs).LineColor;
-                    Settings.Default.AppProperties.Annotate.CircleBorderColor = borderColor;
-                }
-                else if (annot is LineAnnotArgs)
-                {
-                    var color = (annot as LineAnnotArgs).LineColor;
-                    Settings.Default.AppProperties.Annotate.LineColor = color;
-                }
-                Settings.Default.Save();
+               
+              
             }
         }
 
         //更改颜色
         private void AnnotColorPalette_Menu(object obj)
         {
-            if (obj != null && obj as AnnotHandlerEventArgs != null)
+            if (obj as CusMenuItem != null)
             {
-                var annot = obj as AnnotHandlerEventArgs;
-
-                var item = new ColorDropBoxPop();
-                item.DataContext = annot;
-                item.ColorSelected -= AnnotMenu_ColorSelected;
-                item.ColorSelected += AnnotMenu_ColorSelected;
-                System.Windows.Controls.Primitives.Popup popup = new System.Windows.Controls.Primitives.Popup();
-                popup.Child = item;
-                popup.PlacementRectangle = new Rect(Mouse.GetPosition(App.Current.MainWindow), new Size(item.Width, item.Height));
-                popup.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
-                popup.IsOpen = true;
-            }
+                var menu = obj as CusMenuItem;
+                var annot = menu.Parameter as AnnotHandlerEventArgs;
+                if (annot != null)
+                {
+                    var item = new ColorDropBoxPop();
+                    item.DataContext = annot;
+                    item.ColorSelected -= AnnotMenu_ColorSelected;
+                    item.ColorSelected += AnnotMenu_ColorSelected;
+                    System.Windows.Controls.Primitives.Popup popup = new System.Windows.Controls.Primitives.Popup();
+                    popup.Child = item;
+                    popup.PlacementRectangle = new Rect(Mouse.GetPosition(App.Current.MainWindow), new Size(item.Width, item.Height));
+                    popup.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
+                    popup.IsOpen = true;
+                }
 
+            }
         }
         
         private void AnnotMenu_ColorSelected(object sender, Color e)
@@ -1144,12 +1157,12 @@ namespace PDF_Office.ViewModels.Tools
         //添加笔记
         private void AnnotAddNoteText_Menu(object obj)
         {
-            if (obj != null)
+            if (obj as CusMenuItem != null)
             {
-                var annot = obj as AnnotHandlerEventArgs;
+                var menu = obj as CusMenuItem;
+                var annot = menu.Parameter as AnnotHandlerEventArgs;
                 if (annot != null)
                 {
-
                     DialogParameters value = new DialogParameters();
                     value.Add(ParameterNames.Annotation, annot);
                     dialogs.ShowDialog(DialogNames.AddAnnotationDialog, value, e =>
@@ -1163,7 +1176,9 @@ namespace PDF_Office.ViewModels.Tools
                         }
                     });
                 }
+
             }
+           
         }
 
         //手绘
@@ -1188,32 +1203,33 @@ namespace PDF_Office.ViewModels.Tools
 
         private void FreeTextAglin_Menu(object obj)
         {
-            if (obj != null)
+            if (obj as CusMenuItem != null)
             {
-                if (obj is System.Windows.Controls.RadioButton)
+                var menu = obj as CusMenuItem;
+                var annot = menu.Parameter as AnnotHandlerEventArgs;
+                var tag = menu.control.Tag;
+                if (annot != null && tag != null)
                 {
-                    var btn = obj as System.Windows.Controls.RadioButton;
+                    var strTag = tag.ToString();
 
-                    var annot = btn.DataContext as AnnotHandlerEventArgs;
-                    if (annot != null)
+                    var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
+                    if (strTag == "Left")
                     {
-                        var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
-                        if (btn.Tag.ToString() == "Left")
-                        {
-                            AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Left);
-                        }
-                        else if(btn.Tag.ToString() == "Center")
-                        {
-                            AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Center);
-                        }
-                        else if (btn.Tag.ToString() == "Right")
-                        {
-                            AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Right);
-                        }
-                        AnnotEvent?.UpdateAnnot();
+                        AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Left);
+                    }
+                    else if (strTag == "Center")
+                    {
+                        AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Center);
+                    }
+                    else if (strTag == "Right")
+                    {
+                        AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Right);
                     }
+                    AnnotEvent?.UpdateAnnot();
                 }
+
             }
+
         }
 
         //便签
@@ -1230,42 +1246,44 @@ namespace PDF_Office.ViewModels.Tools
 
         private void ShapeLineStyle_Menu(object obj)
         {
-            if (obj != null)
+            if (obj as CusMenuItem != null)
             {
-                if( obj is System.Windows.Controls.RadioButton)
+                var menu = obj as CusMenuItem;
+                var annot = menu.Parameter as AnnotHandlerEventArgs;
+                var tag = menu.control.Tag;
+                if (annot != null && tag != null)
                 {
-                    var btn = obj as System.Windows.Controls.RadioButton;
-
-                    var annot = btn.DataContext as AnnotHandlerEventArgs;
-                    if (annot != null)
+                    var strTag = tag.ToString();
+                    var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
+                    if (strTag == "Solid")
                     {
-                        var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
-                        if (btn.Tag.ToString() == "solid")
-                        {
-                            var dashStyle = AnnotPropertyPanel.GetLineDashStyle(true);
-                            AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, dashStyle);
-                        }
-                        else
-                        {
-                            var dashStyle = AnnotPropertyPanel.GetLineDashStyle(false);
-                            AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, dashStyle);
-                        }
-                        AnnotEvent?.UpdateAnnot();
+                        var dashStyle = AnnotPropertyPanel.GetLineDashStyle(true);
+                        AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, dashStyle);
                     }
+                    else
+                    {
+                        var dashStyle = AnnotPropertyPanel.GetLineDashStyle(false);
+                        AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, dashStyle);
+                    }
+                    AnnotEvent?.UpdateAnnot();
                 }
+
             }
+
         }
 
         private void ShapeLineDirect_Menu(object obj)
         {
-            if (obj != null)
+            if (obj as CusMenuItem != null)
             {
-                if(obj is MenuItem)
+                var menu = obj as CusMenuItem;
+                var annot = menu.Parameter as LineAnnotArgs;
+                var tag = menu.control.Tag;
+                if (annot != null && tag != null)
                 {
-                    var btn = obj as MenuItem;
-                    var annot = btn.DataContext as LineAnnotArgs;
+                    var strTag = tag.ToString();
                     var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
-                    if (btn.Tag.ToString() == "ver")
+                    if (strTag == "ver")
                     {
                         annot.SetLineVertical();
                     }
@@ -1273,10 +1291,10 @@ namespace PDF_Office.ViewModels.Tools
                     {
                         annot.SetLineHorizontal();
                     }
-                      
-
                 }
+
             }
+            
         }
 
         private void ShapeDefaultValues_Menu(object obj)

+ 408 - 204
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Layout.cs

@@ -336,8 +336,10 @@ namespace PDF_Office.ViewModels.Tools
 
         #region 注释-右键菜单
 
-        //高亮注释,右键菜单
-        private ContextMenu SelectHightAnnotMenu(object sender)
+        /// <summary>
+        /// 高亮注释,右键菜单
+        /// </summary>
+        private void InitSelectHightAnnotMenu()
         {
             var popMenu = new ContextMenu();
             PopMenu pop = new PopMenu(popMenu);
@@ -345,45 +347,51 @@ namespace PDF_Office.ViewModels.Tools
             colorContent.Name = "hightcolor";
             colorContent.SelectedColorHandler -= colorContent_SelectedColorHandler;
             colorContent.SelectedColorHandler += colorContent_SelectedColorHandler;
-            pop.AddItem(colorContent);
+            colorContent.VerticalAlignment = VerticalAlignment.Top;
+            colorContent.Height = 60;
+             var menuItem = new MenuItem();
+            menuItem.Name = "hightColor";
+            menuItem.Height = colorContent.Height;
+            menuItem.Header = colorContent;
+            var hightColorStyle = App.Current.FindResource("UIElementMenuItem") as Style;
+            if (hightColorStyle != null)
+                menuItem.Style = hightColorStyle;
 
-            var menuItem = new MenuItem();
+            pop.AddItem(menuItem);
+
+            pop.AddItem(GetSeparator());
+
+            menuItem = new MenuItem();
             menuItem.Name = "hightCopyText";
             menuItem.Header = "复制文本";
-            pop.BindingEvent(pop.AddItem(menuItem), HightAnnotCopyText_MenuCommand, sender);
+            pop.BindingEvent(pop.AddItem(menuItem), HightAnnotCopyText_MenuCommand);
 
             menuItem = new MenuItem();
             menuItem.Name = "hightdelete";
             menuItem.Header = "删除";
-            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete, sender);
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
+
+            pop.AddItem(GetSeparator());
 
             menuItem = new MenuItem();
             menuItem.Name = "hightAddNote";
             menuItem.Header = "添加笔记";
-            pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand, sender);
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
 
             menuItem = new MenuItem();
             menuItem.Name = "hightdefault";
             menuItem.Header = "设置当前属性为默认值";
-            pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand, sender);
-
-            //var popMenu = App.Current.FindResource("HightAnnotContextMenu") as ContextMenu;
-            //CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-            ////颜色列表
-            //ColorContent colorContent = new ColorContent();
-            //colorContent.DataContext = sender;
-            //colorContent.SelectedColorHandler -= colorContent_SelectedColorHandler;
-            //colorContent.SelectedColorHandler += colorContent_SelectedColorHandler;
-            //customMenu.SetMenuUI(0,colorContent);
-            ////复制文本
-            //customMenu.SetMenuBinding(1, HightAnnotCopyText_MenuCommand);
-            ////删除
-            //customMenu.SetMenuBinding(2, ApplicationCommands.Delete);
-            ////添加笔记
-            //customMenu.SetMenuBinding(3, AnnotAddNoteText_MenuCommand);
-            ////设置当前属性为默认值
-            //customMenu.SetMenuBinding(4, AnnotDefaultValue_MenuCommand);
-            return popMenu;
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
+            HightAnnotPopMenu = pop;
+        }
+
+        private Separator GetSeparator()
+        {
+            Separator  separator = new Separator();
+            separator.Height = 1;
+            separator.BorderBrush = new SolidColorBrush(Color.FromArgb(0x33, 0x00, 0x00, 0x00));
+            separator.BorderThickness = new Thickness(1);
+            return separator;
         }
 
         private void colorContent_SelectedColorHandler(object sender, Color e)
@@ -404,205 +412,401 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
-        //手绘
-        private ContextMenu SelectFreeHandAnnotMenu(object sender)
+        /// <summary>
+        /// 手绘
+        /// </summary>
+        private void InitSelectFreeHandAnnotMenu()
         {
-            var popMenu = App.Current.FindResource("FreeHandAnnotContextMenu") as ContextMenu;
-            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-            //复制
-            customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
-            //剪切
-            customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
-            //粘贴
-            customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
-            //删除
-            customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
-            //颜色
-            customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
-            //线段样式
-            var freeHand = sender as FreehandAnnotArgs;
-            bool IsSolid = true;
-            if (freeHand != null)
-            {
-                IsSolid = AnnotPropertyPanel.IsSolidStyle(freeHand.LineDash);
-                
-            }
-            customMenu.SetSubMenuBinding(5, 0, FreeHandLineStyle_MenuCommand,null, IsSolid);
-            customMenu.SetSubMenuBinding(5, 1, FreeHandLineStyle_MenuCommand, null, !IsSolid);
-            //添加笔记
-            customMenu.SetMenuBinding(6, AnnotAddNoteText_MenuCommand);
-            //设置当前属性为默认值
-            customMenu.SetMenuBinding(7, AnnotDefaultValue_MenuCommand);
-            return popMenu;
-        }
+            var popMenu = new ContextMenu();
+            PopMenu pop = new PopMenu(popMenu);
+            var menuItem = new MenuItem();
+            menuItem.Name = "FreeHandCopy";
+            menuItem.Header = "复制";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeHandCut";
+            menuItem.Header = "剪切";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeHandPaste";
+            menuItem.Header = "粘贴";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
 
-        //文本
-        private ContextMenu SelectFreeTextAnnotMenu(object sender)
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeHandDelete";
+            menuItem.Header = "删除";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
+
+            pop.AddItem(GetSeparator());
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeHandColor";
+            menuItem.Header = "颜色...";
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeHandLineStyle";
+            menuItem.Header = "线段样式";
+            pop.AddItem(menuItem);
+
+            RadioButton radioButton = new RadioButton();
+            radioButton.Name = "FreeHandSolid";
+            radioButton.Content = "实线";
+            radioButton.GroupName = "LineStyle";
+            radioButton.Tag = "Solid";
+            pop.BindingEvent(pop.AddChild("FreeHandLineStyle",radioButton), FreeHandLineStyle_MenuCommand);
+
+            radioButton = new RadioButton();
+            radioButton.Name = "FreeHandDash";
+            radioButton.Content = "虚线";
+            radioButton.GroupName = "LineStyle";
+            radioButton.Tag = "Dash";
+            pop.BindingEvent(pop.AddChild("FreeHandLineStyle", radioButton), FreeHandLineStyle_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeHandAddNote";
+            menuItem.Header = "添加笔记";
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeHandDefault";
+            menuItem.Header = "设置当前属性为默认值";
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
+            FreeHandAnnotPopMenu = pop;
+        }
+        /// <summary>
+        /// 文本
+        /// </summary>
+        private void InitSelectFreeTextAnnotMenu()
         {
-            var popMenu = App.Current.FindResource("FreeTextAnnotContextMenu") as ContextMenu;
-            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-            //复制
-            customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
-            //剪切
-            customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
-            //粘贴
-            customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
-            //删除
-            customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
-            //文本颜色
-            customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
-            //字体
-            var annot = sender as FreeTextAnnotArgs;
-
-            customMenu.SetSubMenuBinding(5, 0, FreeTextFontFamily_MenuCommand, null, (annot != null && annot.FontFamily.ToString() == "Arial") ?true:false);
-            customMenu.SetSubMenuBinding(5, 1, FreeTextFontFamily_MenuCommand, null,(annot != null && annot.FontFamily.ToString() == "Courier") ? true : false);
-            customMenu.SetSubMenuBinding(5, 2, FreeTextFontFamily_MenuCommand, null, (annot != null && annot.FontFamily.ToString() == "Times New Roman") ? true : false);
-
-            //文本对齐
-            customMenu.SetSubMenuBinding(6, 0, FreeTextAglin_MenuCommand, null, (annot != null && annot.Align == TextAlignment.Left) ? true : false);
-            customMenu.SetSubMenuBinding(6, 1, FreeTextAglin_MenuCommand, null, (annot != null && annot.Align == TextAlignment.Center) ? true : false);
-            customMenu.SetSubMenuBinding(6, 2, FreeTextAglin_MenuCommand, null, (annot != null && annot.Align == TextAlignment.Right) ? true : false);
-            //设置当前属性为默认值
-            customMenu.SetMenuBinding(7, AnnotDefaultValue_MenuCommand);
-            return popMenu;
+            var popMenu = new ContextMenu();
+            PopMenu pop = new PopMenu(popMenu);
+            var menuItem = new MenuItem();
+            menuItem.Name = "FreeTextCopy";
+            menuItem.Header = "复制";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeTextCut";
+            menuItem.Header = "剪切";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeTextPaste";
+            menuItem.Header = "粘贴";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeTextDelete";
+            menuItem.Header = "删除";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
+
+            pop.AddItem(GetSeparator());
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeTextColor";
+            menuItem.Header = "颜色...";
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeTextFontFamily";
+            menuItem.Header = "字体";
+            pop.AddItem(menuItem);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeTextArial";
+            menuItem.Header = "楷体";
+            menuItem.Tag = "Arial";
+            pop.BindingEvent(pop.AddChild("FreeTextFontFamily", menuItem), FreeTextFontFamily_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeTextCourier";
+            menuItem.Header = "Courier";
+            menuItem.Tag = "Courier";
+            pop.BindingEvent(pop.AddChild("FreeTextFontFamily", menuItem), FreeTextFontFamily_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeTextTimesRoman";
+            menuItem.Header = "Times New Roman";
+            menuItem.Tag = "Times New Roman";
+            pop.BindingEvent(pop.AddChild("FreeTextFontFamily", menuItem), FreeTextFontFamily_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeTextAglin";
+            menuItem.Header = "文本对齐";
+            pop.AddItem(menuItem);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeTextAglinLeft";
+            menuItem.Header = "左对齐";
+            menuItem.Tag = "Left";
+            pop.BindingEvent(pop.AddChild("FreeTextAglin", menuItem), FreeTextAglin_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeTextAglinCenter";
+            menuItem.Header = "居中对齐";
+            menuItem.Tag = "Center";
+            pop.BindingEvent(pop.AddChild("FreeTextAglin", menuItem), FreeTextAglin_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeTextAglinRight";
+            menuItem.Header = "右对齐";
+            menuItem.Tag = "Right";
+            pop.BindingEvent(pop.AddChild("FreeTextAglin", menuItem), FreeTextAglin_MenuCommand);
+
+
+            menuItem = new MenuItem();
+            menuItem.Name = "FreeHandDefault";
+            menuItem.Header = "设置当前属性为默认值";
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
+            FreeTextAnnotPopMenu = pop;
         }
 
-        //便签
-        private ContextMenu SelectStrickNoteAnnotMenu(object sender)
+        /// <summary>
+        /// 便签
+        /// </summary>
+        private void InitSelectStrickNoteAnnotMenu()
         {
-            var popMenu = App.Current.FindResource("StrickNoteAnnotContextMenu") as ContextMenu;
-            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-            //复制
-            customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
-            //剪切
-            customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
-            //粘贴
-            customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
-            //删除
-            customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
-            //颜色
-            customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
-            if(sender as StickyAnnotArgs != null)
-            {
-                
-            }
-            //编辑便签
-            customMenu.SetMenuBinding(5, ApplicationCommands.Delete);//
-            //设置当前属性为默认值
-            customMenu.SetMenuBinding(7, AnnotDefaultValue_MenuCommand);
-            return popMenu;
+            var popMenu = new ContextMenu();
+            PopMenu pop = new PopMenu(popMenu);
+            var menuItem = new MenuItem();
+            menuItem.Name = "StrickNoteCopy";
+            menuItem.Header = "复制";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StrickNoteCut";
+            menuItem.Header = "剪切";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StrickNotePaste";
+            menuItem.Header = "粘贴";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StrickNoteDelete";
+            menuItem.Header = "删除";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
+
+            pop.AddItem(GetSeparator());
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StrickNoteColor";
+            menuItem.Header = "颜色...";
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StrickNoteEdit";
+            menuItem.Header = "编辑便签";
+            pop.AddItem(menuItem);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StrickNoteDefault";
+            menuItem.Header = "设置当前属性为默认值";
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
+            StrickNoteAnnotPopMenu = pop;
         }
 
-        //形状
-        private ContextMenu SelectShapeAnnotMenu(object sender)
+        /// <summary>
+        /// 形状
+        /// </summary>
+        private void InitSelectShapeAnnotMenu()
         {
-            var popMenu = App.Current.FindResource("ShapeAnnotContextMenu") as ContextMenu;
-            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-            //复制
-            customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
-            //剪切
-            customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
-            //粘贴
-            customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
-            //删除
-            customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
-            //颜色
-            customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
-            //线段样式
-            bool IsSolid = true;
-            if (sender as SquareAnnotArgs != null)
-            {
-                IsSolid = AnnotPropertyPanel.IsSolidStyle((sender as SquareAnnotArgs).LineDash);
-            }
-            else if(sender as CircleAnnotArgs != null)
-            {
-                IsSolid = AnnotPropertyPanel.IsSolidStyle((sender as CircleAnnotArgs).LineDash);
-            }
-            else if(sender as LineAnnotArgs != null)
-            {
-                IsSolid = AnnotPropertyPanel.IsSolidStyle((sender as LineAnnotArgs).LineDash);
-            }
+            var popMenu = new ContextMenu();
+            PopMenu pop = new PopMenu(popMenu);
+            var menuItem = new MenuItem();
+            menuItem.Name = "ShapeCopy";
+            menuItem.Header = "复制";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
 
-            customMenu.SetSubMenuBinding(5, 0, ShapeLineStyle_MenuCommand, null, IsSolid);
-            customMenu.SetSubMenuBinding(5, 1, ShapeLineStyle_MenuCommand, null, !IsSolid);
-            //线段方向
-            if(sender as LineAnnotArgs != null)
-            {
-                customMenu.SetSubMenuBinding(6, 0, ShapeLineDirect_MenuCommand ,null, true);//暂无,待确认
-                customMenu.SetSubMenuBinding(6, 1, ShapeLineDirect_MenuCommand ,null, true);//
-                customMenu.SetVisibilityProperty(6, true);
-            }
-            else
-            {
-                customMenu.SetVisibilityProperty(6,false);
-            }
-            //添加笔记
-            customMenu.SetMenuBinding(7, AnnotAddNoteText_MenuCommand);
-            //设置当前属性为默认值
-            customMenu.SetMenuBinding(8, AnnotDefaultValue_MenuCommand);
-            return popMenu;
+            menuItem = new MenuItem();
+            menuItem.Name = "ShapeCut";
+            menuItem.Header = "剪切";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "ShapePaste";
+            menuItem.Header = "粘贴";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "ShapeDelete";
+            menuItem.Header = "删除";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
+
+            pop.AddItem(GetSeparator());
+
+            menuItem = new MenuItem();
+            menuItem.Name = "ShapeColor";
+            menuItem.Header = "颜色...";
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "ShapeLineStyle";
+            menuItem.Header = "线段样式";
+            pop.AddItem(menuItem);
+
+            RadioButton radioButton = new RadioButton();
+            radioButton.Name = "ShapeSolid";
+            radioButton.Content = "实线";
+            radioButton.GroupName = "LineStyle";
+            radioButton.Tag = "Solid";
+            pop.BindingEvent(pop.AddChild("ShapeLineStyle", radioButton), ShapeLineStyle_MenuCommand);
+
+            radioButton = new RadioButton();
+            radioButton.Name = "ShapeDash";
+            radioButton.Content = "虚线";
+            radioButton.GroupName = "LineStyle";
+            radioButton.Tag = "Dash";
+            pop.BindingEvent(pop.AddChild("ShapeLineStyle", radioButton), ShapeLineStyle_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "ShapeDirect";
+            menuItem.Header = "线段方向";
+            pop.AddItem(menuItem);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "ShapeVer";
+            menuItem.Header = "垂直";
+            menuItem.Tag = "Ver";
+            pop.BindingEvent(pop.AddChild("ShapeDirect", menuItem), ShapeLineDirect_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "ShapeHor";
+            menuItem.Header = "横向";
+            menuItem.Tag = "Hor";
+            pop.BindingEvent(pop.AddChild("ShapeDirect", menuItem), ShapeLineDirect_MenuCommand);
+
+
+            menuItem = new MenuItem();
+            menuItem.Name = "ShapeNoteText";
+            menuItem.Header = "添加笔记";
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "ShapeDefault";
+            menuItem.Header = "设置当前属性为默认值";
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
+            ShapeAnnotPopMenu = pop;
         }
 
-        //链接
-        private ContextMenu SelectLinkAnnotMenu(object sender)
+        /// <summary>
+        /// 链接
+        /// </summary>
+        private void InitSelectLinkAnnotMenu()
         {
-            var popMenu = App.Current.FindResource("LinkAnnotContextMenu") as ContextMenu;
-            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-            //复制
-            customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
-            //剪切
-            customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
-            //粘贴
-            customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
-            //删除
-            customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
-            return popMenu;
+            var popMenu = new ContextMenu();
+            PopMenu pop = new PopMenu(popMenu);
+            var menuItem = new MenuItem();
+            menuItem.Name = "LinkCopy";
+            menuItem.Header = "复制";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "LinkCut";
+            menuItem.Header = "剪切";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "LinkPaste";
+            menuItem.Header = "粘贴";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "LinkDelete";
+            menuItem.Header = "删除";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
+            LinkAnnotPopMenu = pop;
         }
 
-        //图章、签名
-        private ContextMenu SelectStampAnnotMenu(object sender)
+        /// <summary>
+        /// 图章、签名
+        /// </summary>
+        private void InitSelectStampAnnotMenu()
         {
-            var popMenu = App.Current.FindResource("StampAnnotContextMenu") as ContextMenu;
-            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-            //复制
-            customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
-            //剪切
-            customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
-            //粘贴
-            customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
-            //删除
-            customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
-            //导出
-            customMenu.SetSubMenuBinding(4, 0, StampExportPicture_MenuCommand);//
-            customMenu.SetSubMenuBinding(4, 1, StampExportPicture_MenuCommand);//
-            customMenu.SetSubMenuBinding(4, 2, StampExportPicture_MenuCommand);//
-            //添加笔记
-            customMenu.SetMenuBinding(5, AnnotAddNoteText_MenuCommand);
-            return popMenu;
+            var popMenu = new ContextMenu();
+            PopMenu pop = new PopMenu(popMenu);
+            var menuItem = new MenuItem();
+            menuItem.Name = "StampCopy";
+            menuItem.Header = "复制";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StampCut";
+            menuItem.Header = "剪切";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StampPaste";
+            menuItem.Header = "粘贴";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StampDelete";
+            menuItem.Header = "删除";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
+
+            pop.AddItem(GetSeparator());
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StampExportPicture";
+            menuItem.Header = "导出";
+            pop.AddItem(menuItem);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StampExportPNG";
+            menuItem.Header = "PNG";
+            menuItem.Tag = "PNG";
+            pop.BindingEvent(pop.AddChild("StampExportPicture",menuItem), StampExportPicture_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StampExportPNG";
+            menuItem.Header = "JPG";
+            menuItem.Tag = "JPG";
+            pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StampExportPNG";
+            menuItem.Header = "PDF";
+            menuItem.Tag = "PDF";
+            pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "StampAddNote";
+            menuItem.Header = "添加笔记";
+            pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
+
+            StampAnnotPopMenu = pop;
         }
 
-        //多选注释
-        private ContextMenu SelectMultiAnnotMenu(object sender, bool isHightAnnot)
+        /// <summary>
+        /// 多选注释
+        /// </summary>
+        private void InitSelectMultiAnnotMenu()
         {
-            var popMenu = App.Current.FindResource("MultiSelectAnnotContextMenu") as ContextMenu;
-            CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
-            if (isHightAnnot)
-            {
-                customMenu.SetVisibilityProperty(0, false);
-                customMenu.SetVisibilityProperty(1, false);
-            }
-            else
-            {
-                //复制
-                customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
-                //剪切
-                customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
-            }
-            //删除
-            customMenu.SetMenuBinding(2, ApplicationCommands.Delete);
-            return popMenu;
+            var popMenu = new ContextMenu();
+            PopMenu pop = new PopMenu(popMenu);
+            var menuItem = new MenuItem();
+            menuItem.Name = "MultiCopy";
+            menuItem.Header = "复制";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "MultiCut";
+            menuItem.Header = "剪切";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
+
+            menuItem = new MenuItem();
+            menuItem.Name = "MultiDelete";
+            menuItem.Header = "删除";
+            pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
+            MultiAnnotPopMenu = pop;
         }
 
+
         #endregion 注释-右键菜单
     }
 }

+ 10 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Properties.cs

@@ -2,6 +2,7 @@
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.CustomControl;
+using PDF_Office.Helper;
 using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
 using Prism.Commands;
 using Prism.Events;
@@ -248,6 +249,15 @@ namespace PDF_Office.ViewModels.Tools
         private bool isAddBookMark = true;
         private bool isRightMenuAddAnnot = false;
 
+        private PopMenu HightAnnotPopMenu;
+        private PopMenu FreeHandAnnotPopMenu;
+        private PopMenu FreeTextAnnotPopMenu;
+        private PopMenu StrickNoteAnnotPopMenu;
+        private PopMenu ShapeAnnotPopMenu;
+        private PopMenu LinkAnnotPopMenu;
+        private PopMenu StampAnnotPopMenu;
+        private PopMenu MultiAnnotPopMenu;
+
         #region 事件
 
         public DelegateCommand<CustomIconToggleBtn> MyToolsCommand { get; set; }

+ 13 - 0
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -52,6 +52,19 @@ namespace PDF_Office.ViewModels.Tools
             BindingEvent();
             InitDefaultValue();
             InitToolDict();
+            InitPopMenu();
+        }
+
+        private void InitPopMenu()
+        {
+            InitSelectHightAnnotMenu();
+            InitSelectFreeHandAnnotMenu();
+            InitSelectFreeTextAnnotMenu();
+            InitSelectStrickNoteAnnotMenu();
+            InitSelectShapeAnnotMenu();
+            InitSelectLinkAnnotMenu();
+            InitSelectStampAnnotMenu();
+            InitSelectMultiAnnotMenu();
         }
 
         private void InitCommand()

+ 2 - 0
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -82,6 +82,8 @@ namespace PDF_Office.ViewModels
 
         public string BackgroundContentRegionName { get; set; }
 
+        public List<Point>FillAndSign=new List<Point>();
+
         /// <summary>
         /// 文档的密码
         /// </summary>

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

@@ -26,6 +26,7 @@
             <Convert:CheckToVisibleMutiConvert x:Key="CheckToVisibleMutiConvert" />
             <DashConvert:DashStyleConverter x:Key="DashStyleConverter" />
             <Convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert"/>
+            <Convert:UnVisivleConvert x:Key="unVisibleConvert"/>
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid Background="#F3F3F3">
@@ -40,6 +41,7 @@
                 LineHeight="24"
                 Text="{Binding AnnotTypeTitle}" />
             <Border
+                x:Name="shapeBarder"
                 Width="228"
                 Height="100"
                 Margin="0,8,0,0"
@@ -185,14 +187,13 @@
             </Grid>
 
             <Border
-                Visibility="Hidden"
                 Width="228"
                 Height="32"
                 Margin="0,12,0,0"
                 BorderBrush="#FFE2E3E6"
                 BorderThickness="1" 
-               
-                > <!--Visibility="{Binding IsMultiSelected,Converter={StaticResource InvertBoolToVisibleConvert}}"-->
+               Visibility="{Binding ElementName=shapeBarder,Path=Visibility,Converter={StaticResource unVisibleConvert}}"
+                > 
                 <Grid Name="ToolGrid" >
                     <Grid.ColumnDefinitions>
                         <ColumnDefinition Width="40.5" />