فهرست منبع

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

OYXH\oyxh 2 سال پیش
والد
کامیت
c99860d69f

+ 44 - 12
PDF Office/Helper/PopControlHelper.cs

@@ -372,7 +372,7 @@ namespace PDF_Office.Helper
         }
 
         //按索引号设置子菜单
-        public void SetSubMenuBinding(int index, int subIndex, ICommand command, object comTarget = null)
+        public void SetSubMenuBinding(int index, int subIndex, ICommand command, object comTarget = null,bool isChecked = false)
         {
             var menuItem = ContainterOfIndex(index);
 
@@ -384,25 +384,57 @@ namespace PDF_Office.Helper
                     if(item is RadioButton)
                     {
                         var radioItem = item as RadioButton;
-                        radioItem.CommandParameter = radioItem.IsChecked;
+                        radioItem.IsChecked = isChecked;
+                        if (CommandTarget == null)
+                            CommandTarget = comTarget;
 
-                        if (comTarget == null)
-                            radioItem.DataContext = (UIElement)CommandTarget;
-                        else
-                            radioItem.DataContext = (UIElement)comTarget;
+                        radioItem.DataContext = CommandTarget;
+                        radioItem.CommandParameter = radioItem;
 
                         radioItem.Command = command;
                     }
                     else if(item is MenuItem)
                     {
-                        var menuitem = item as MenuItem;
-      
+                        var submenuitem = item as MenuItem;
+
                         if (comTarget == null)
-                            menuitem.CommandTarget = (UIElement)CommandTarget;
+                        {
+                            if (CommandTarget is UIElement)
+                            {
+                                submenuitem.CommandTarget = (UIElement)CommandTarget;
+                            }
+
+                            
+                            if (isChecked)
+                            {
+                                submenuitem.DataContext = CommandTarget;
+                                submenuitem.CommandParameter = submenuitem;//isChecked为true时,可拿MenuItem
+                            }
+                            else
+                            {
+                                submenuitem.DataContext = CommandTarget;
+                                submenuitem.CommandParameter = CommandTarget;
+                            }
+                            
+                        }
+
                         else
-                            menuitem.CommandTarget = (UIElement)comTarget;
-                      
-                        menuItem.Command = command;
+                        {
+                            if (comTarget is UIElement)
+                            {
+                                submenuitem.CommandTarget = (UIElement)comTarget;
+                            }
+                            if (isChecked)
+                            {
+                                submenuitem.CommandParameter = submenuitem;//isChecked为true时,可拿MenuItem
+                            }
+                            else
+                            {
+                                submenuitem.CommandParameter = CommandTarget;
+                            }
+                           
+                        }
+                        submenuitem.Command = command;
                     }
                 }
                 

+ 35 - 20
PDF Office/Styles/ContextMenuStyle.xaml

@@ -187,9 +187,9 @@
             Name="LineStyleFreeHandAnnotMenuItem"
             Header="线段样式"
             IsEnabled="True">
-            <RadioButton x:Name="SolidLineStyleFreeHandAnnotMenuItem" GroupName="LineStyle" Content="实线">
+            <RadioButton x:Name="SolidLineStyleFreeHandAnnotMenuItem" Tag="solid" GroupName="LineStyle" Content="实线">
             </RadioButton>
-            <RadioButton x:Name="DashLineStyleFreeHandAnnotMenuItem" GroupName="LineStyle" Content="虚线">
+            <RadioButton x:Name="DashLineStyleFreeHandAnnotMenuItem" Tag="dash" GroupName="LineStyle" Content="虚线">
             </RadioButton>
         </MenuItem>
 
@@ -290,27 +290,42 @@
             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="线段样式"
+            Header="文本样式"
             IsEnabled="True">
-            <MenuItem
+            <RadioButton
             Name="LeftAglinFreeTextAnnotMenuItem"
-            Header="左对齐"
+            Content="左对齐" Tag="Left"
             IsEnabled="True">
-            </MenuItem>
-            <MenuItem
+            </RadioButton>
+            <RadioButton
             Name="CenterAglinFreeTextAnnotMenuItem"
-            Header="居中对齐"
+            Content="居中对齐" Tag="Center"
             IsEnabled="True">
-            </MenuItem>
-            <MenuItem
+            </RadioButton>
+            <RadioButton
             Name="RightAglinFreeTextAnnotMenuItem"
-            Header="右对齐"
+            Content="右对齐" Tag="Right"
             IsEnabled="True">
-            </MenuItem>
+            </RadioButton>
         </MenuItem>
 
         <MenuItem
@@ -492,16 +507,16 @@
             Name="LineStyleShapeAnnotMenuItem"
             Header="线段样式"
             IsEnabled="True">
-            <MenuItem
+            <RadioButton
             Name="SolidLineStyleShapeAnnotMenuItem"
-            Header="实线"
+            Content="实线" Tag="solid"
             IsEnabled="True">
-            </MenuItem>
-            <MenuItem
+            </RadioButton>
+            <RadioButton
             Name="DashLineStyleShapeAnnotMenuItem"
-            Header="虚线"
+            Content="虚线" Tag="dash"
             IsEnabled="True">
-            </MenuItem>
+            </RadioButton>
         </MenuItem>
 
         <MenuItem
@@ -510,12 +525,12 @@
             IsEnabled="True">
             <MenuItem
             Name="VeriLineDirectShapeAnnotMenuItem"
-            Header="垂直"
+            Header="垂直" Tag="ver"
             IsEnabled="True">
             </MenuItem>
             <MenuItem
             Name="HoriLineDirectShapeAnnotMenuItem"
-            Header="水平"
+            Header="水平" Tag="hor"
             IsEnabled="True">
             </MenuItem>
         </MenuItem>

+ 7 - 7
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -381,29 +381,29 @@ namespace PDF_Office.ViewModels.Tools
                                         break;
 
                                     case AnnotArgsType.AnnotFreehand:
-                                        e.PopupMenu = SelectFreeHandAnnotMenu(sender);
+                                        e.PopupMenu = SelectFreeHandAnnotMenu(selectedAnnot);
                                         break;
 
                                     case AnnotArgsType.AnnotFreeText:
-                                        e.PopupMenu = SelectFreeTextAnnotMenu(sender);
+                                        e.PopupMenu = SelectFreeTextAnnotMenu(selectedAnnot);
                                         break;
 
                                     case AnnotArgsType.AnnotSticky:
-                                        e.PopupMenu = SelectStrickNoteAnnotMenu(sender);
+                                        e.PopupMenu = SelectStrickNoteAnnotMenu(selectedAnnot);
                                         break;
 
                                     case AnnotArgsType.AnnotSquare:
                                     case AnnotArgsType.AnnotLine:
                                     case AnnotArgsType.AnnotCircle:
-                                        e.PopupMenu = SelectShapeAnnotMenu(sender);
+                                        e.PopupMenu = SelectShapeAnnotMenu(selectedAnnot);
                                         break;
 
                                     case AnnotArgsType.AnnotLink:
-                                        e.PopupMenu = SelectHightAnnotMenu(sender);
+                                        e.PopupMenu = SelectHightAnnotMenu(selectedAnnot);
                                         break;
 
                                     case AnnotArgsType.AnnotStamp:
-                                        e.PopupMenu = SelectHightAnnotMenu(sender);
+                                        e.PopupMenu = SelectHightAnnotMenu(selectedAnnot);
                                         break;
                                 }
                             }
@@ -419,7 +419,7 @@ namespace PDF_Office.ViewModels.Tools
                                     }
                                 }
 
-                                e.PopupMenu = SelectMultiAnnotMenu(sender, isHigh);
+                                e.PopupMenu = SelectMultiAnnotMenu(e.AnnotEventArgsList, isHigh);
                             }
                         }
                         if (e.PopupMenu != null)

+ 86 - 3
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -1107,9 +1107,25 @@ namespace PDF_Office.ViewModels.Tools
                 var annot = (sender as FrameworkElement).DataContext as AnnotHandlerEventArgs;
                 if (annot != null)
                 {
-                    var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
-                    AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
-                    AnnotEvent?.UpdateAnnot();
+                    if(annot is FreehandAnnotArgs || annot is StickyAnnotArgs || annot is LineAnnotArgs)
+                    {
+                        var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
+                        AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
+                        AnnotEvent?.UpdateAnnot();
+                    }
+                    else if(annot is FreeTextAnnotArgs)
+                    {
+                        var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
+                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FontColor, e);
+                        AnnotEvent?.UpdateAnnot();
+                    }
+                    else if (annot is SquareAnnotArgs || annot is CircleAnnotArgs)
+                    {
+                        var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
+                        AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
+                        AnnotEvent?.UpdateAnnot();
+                    }
+
                 }
             }
         }
@@ -1162,7 +1178,29 @@ namespace PDF_Office.ViewModels.Tools
         {
             if (obj != null)
             {
+                if (obj is System.Windows.Controls.RadioButton)
+                {
+                    var btn = obj as System.Windows.Controls.RadioButton;
 
+                    var annot = btn.DataContext as AnnotHandlerEventArgs;
+                    if (annot != null)
+                    {
+                        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();
+                    }
+                }
             }
         }
 
@@ -1182,7 +1220,27 @@ namespace PDF_Office.ViewModels.Tools
         {
             if (obj != null)
             {
+                if( obj is System.Windows.Controls.RadioButton)
+                {
+                    var btn = obj as System.Windows.Controls.RadioButton;
 
+                    var annot = btn.DataContext as AnnotHandlerEventArgs;
+                    if (annot != null)
+                    {
+                        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();
+                    }
+                }
             }
         }
 
@@ -1190,7 +1248,22 @@ namespace PDF_Office.ViewModels.Tools
         {
             if (obj != null)
             {
+                if(obj is MenuItem)
+                {
+                    var btn = obj as MenuItem;
+                    var annot = btn.DataContext as LineAnnotArgs;
+                    var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
+                    if (btn.Tag.ToString() == "ver")
+                    {
+                        annot.SetLineVertical();
+                    }
+                    else
+                    {
+                        annot.SetLineHorizontal();
+                    }
+                      
 
+                }
             }
         }
 
@@ -1202,6 +1275,16 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
+        //图章
+        private void StampExportPicture_Menu(object obj)
+        {
+            if (obj != null)
+            {
+
+            }
+        }
+        
+
         #endregion 注释右键菜单事件
 
 

+ 54 - 18
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Layout.cs

@@ -392,8 +392,15 @@ namespace PDF_Office.ViewModels.Tools
             //颜色
             customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
             //线段样式
-            customMenu.SetSubMenuBinding(5, 0, ApplicationCommands.Delete);//
-            customMenu.SetSubMenuBinding(5, 1, ApplicationCommands.Delete);//
+            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);
             //设置当前属性为默认值
@@ -417,13 +424,16 @@ namespace PDF_Office.ViewModels.Tools
             //文本颜色
             customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
             //字体
-            customMenu.SetSubMenuBinding(5, 0, ApplicationCommands.Delete);//
-            customMenu.SetSubMenuBinding(5, 1, ApplicationCommands.Delete);//
-            customMenu.SetSubMenuBinding(5, 2, ApplicationCommands.Delete);//
+            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, ApplicationCommands.Delete);//
-            customMenu.SetSubMenuBinding(6, 1, ApplicationCommands.Delete);//
-            customMenu.SetSubMenuBinding(6, 2, ApplicationCommands.Delete);//
+            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;
@@ -444,6 +454,10 @@ namespace PDF_Office.ViewModels.Tools
             customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
             //颜色
             customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
+            if(sender as StickyAnnotArgs != null)
+            {
+                
+            }
             //编辑便签
             customMenu.SetMenuBinding(5, ApplicationCommands.Delete);//
             //设置当前属性为默认值
@@ -467,13 +481,35 @@ namespace PDF_Office.ViewModels.Tools
             //颜色
             customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
             //线段样式
-            customMenu.SetSubMenuBinding(6, 0, ApplicationCommands.Delete);//
-            customMenu.SetSubMenuBinding(6, 1, ApplicationCommands.Delete);//
+            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);
+            }
+
+            customMenu.SetSubMenuBinding(5, 0, ShapeLineStyle_MenuCommand, null, IsSolid);
+            customMenu.SetSubMenuBinding(5, 1, ShapeLineStyle_MenuCommand, null, !IsSolid);
             //线段方向
-            customMenu.SetSubMenuBinding(7, 0, ApplicationCommands.Delete);//
-            customMenu.SetSubMenuBinding(7, 1, ApplicationCommands.Delete);//
+            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(8, AnnotAddNoteText_MenuCommand);
+            customMenu.SetMenuBinding(7, AnnotAddNoteText_MenuCommand);
             //设置当前属性为默认值
             customMenu.SetMenuBinding(8, AnnotDefaultValue_MenuCommand);
             return popMenu;
@@ -509,15 +545,15 @@ namespace PDF_Office.ViewModels.Tools
             //删除
             customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
             //导出
-            customMenu.SetSubMenuBinding(4, 0, ApplicationCommands.Paste);//
-            customMenu.SetSubMenuBinding(4, 1, ApplicationCommands.Paste);//
-            customMenu.SetSubMenuBinding(4, 2, ApplicationCommands.Paste);//
+            customMenu.SetSubMenuBinding(4, 0, StampExportPicture_MenuCommand);//
+            customMenu.SetSubMenuBinding(4, 1, StampExportPicture_MenuCommand);//
+            customMenu.SetSubMenuBinding(4, 2, StampExportPicture_MenuCommand);//
             //添加笔记
-            customMenu.SetMenuBinding(5, ApplicationCommands.Paste);//
+            customMenu.SetMenuBinding(5, AnnotAddNoteText_MenuCommand);
             return popMenu;
         }
 
-        //多选
+        //多选注释
         private ContextMenu SelectMultiAnnotMenu(object sender, bool isHightAnnot)
         {
             var popMenu = App.Current.FindResource("MultiSelectAnnotContextMenu") as ContextMenu;

+ 19 - 1
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Properties.cs

@@ -36,7 +36,7 @@ namespace PDF_Office.ViewModels.Tools
         { }
 
         //外部UI控件选中状态
-        public bool IsSolidStyle(DashStyle LineDash)
+        public static bool IsSolidStyle(DashStyle LineDash)
         {
             bool isSolid = true;
             if (LineDash == null || LineDash.Dashes.Count == 0)
@@ -55,6 +55,22 @@ namespace PDF_Office.ViewModels.Tools
             return isSolid;
         }
 
+        public static DashStyle GetLineDashStyle(bool isSolid)
+        {
+            DashStyle newDash = new DashStyle();
+            if(isSolid == false)
+            {
+                newDash.Dashes.Add(2);
+                newDash.Dashes.Add(2);
+            }
+            else
+            {
+                newDash = DashStyles.Solid;
+            }
+
+            return newDash;
+        }
+
         //单个属性更改
         public void UpdateAnnotAAttrib(AnnotAttrib annotAttrib, object obj)
         {
@@ -263,6 +279,8 @@ namespace PDF_Office.ViewModels.Tools
         public DelegateCommand<object> ShapeLineStyle_MenuCommand { get; set; }
         public DelegateCommand<object> ShapeLineDirect_MenuCommand { get; set; }
 
+        //图章
+        public DelegateCommand<object> StampExportPicture_MenuCommand { get; set; }
         #endregion 注释 - 右键菜单
 
         #endregion 事件

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

@@ -78,6 +78,8 @@ namespace PDF_Office.ViewModels.Tools
             //形状
             ShapeLineStyle_MenuCommand = new DelegateCommand<object>(ShapeLineStyle_Menu);
             ShapeLineDirect_MenuCommand = new DelegateCommand<object>(ShapeLineDirect_Menu);
+            //图章
+            StampExportPicture_MenuCommand = new DelegateCommand<object>(StampExportPicture_Menu);
             #endregion 注释 - 右键菜单
         }