Browse Source

注释 - 右键菜单样式、封装菜单栏

chenrongqian@kdanmobile.com 2 years ago
parent
commit
781c0ade29

+ 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">

+ 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)

+ 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()