Browse Source

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

zhuyi 2 years ago
parent
commit
e3de914ec7

+ 33 - 0
PDF Office/ViewModels/BOTA/AnnotationContentViewModel.cs

@@ -42,6 +42,7 @@ using System.Windows.Forms;
 using System.Windows.Markup;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
+using System.Windows.Media.Media3D;
 using System.Windows.Shapes;
 using static Dropbox.Api.Files.SearchMatchType;
 using static Dropbox.Api.TeamLog.SpaceCapsType;
@@ -1115,6 +1116,16 @@ namespace PDF_Office.ViewModels.BOTA
                     //原型图上,目前对波浪线的类型,在注释列表不显示
                     if (item.EventType != AnnotArgsType.AnnotRedaction && item.EventType != AnnotArgsType.AnnotSquiggly)
                     {
+                        if (item.EventType == AnnotArgsType.AnnotLink)
+                        {
+                            if(item is LinkAnnotArgs link)
+                            {
+                                if(link.LinkType== LINK_TYPE.URI)
+                                {
+                                    continue;
+                                }
+                            }
+                        }
                         AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(item);
                         if (args.AnnotHandlerEventArgs != null)
                         {
@@ -1186,6 +1197,20 @@ namespace PDF_Office.ViewModels.BOTA
 
                     int drawWidth = (int)paintRect.Width;
                     int drawHeight = (int)paintRect.Height;
+                    switch (docPage.Rotation)
+                    {
+                        case 0:
+                        case 2:
+                            drawWidth = (int)paintRect.Width;
+                            drawHeight = (int)paintRect.Height;
+                            break;
+
+                        case 1:
+                        case 3:
+                            drawWidth = (int)paintRect.Height;
+                            drawHeight = (int)paintRect.Width;
+                            break;
+                    }
                     byte[] bitmapArray = new byte[drawWidth * drawHeight * 4];
                     annot.UpdateAp();
                     annot.RenderAnnot(drawWidth, drawHeight, bitmapArray);
@@ -1195,6 +1220,14 @@ namespace PDF_Office.ViewModels.BOTA
                     BitmapImage bitmapImage = ConvertWriteableBitmapToBitmapImage(wirteBitmap, docPage.Rotation);
 
                     cPDFInk.SetRect(rawRect);
+
+                    // 测试
+                    //using (FileStream stream = new FileStream(@"C:\Users\oyxh\Desktop\images\1.png", FileMode.Create))
+                    //{
+                    //    PngBitmapEncoder bitmapEncoder = new PngBitmapEncoder();
+                    //    bitmapEncoder.Frames.Add(BitmapFrame.Create(wirteBitmap));
+                    //    bitmapEncoder.Save(stream);
+                    //}
                     return bitmapImage;
                 }
             }

+ 80 - 45
PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs

@@ -430,7 +430,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         private bool isLoaded = false;
         private bool isMail = false;
         private bool isSelected = false;
-
+        private bool IsAnnotSelect = true;
         private string historyBtnGOorBackTag = string.Empty;
         private int totalPage = 0;
         private int backPageIndex = 0;
@@ -590,11 +590,16 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 }
                 else
                 {
+                    BtnLocationIsEnabled = true;
                     ImagePreviewVisibility = Visibility.Collapsed;
                     BtnGOorBackVisibility = Visibility.Collapsed;
                     isSelected = false;
                 }
             }
+            else
+            {
+                BtnLocationIsEnabled = true;
+            }
         }
 
         /// <summary>
@@ -686,6 +691,16 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         /// <param name="obj"></param>
         private void LocationPage(object obj)
         {
+            //没有选择注释工具、也不是右键添加注释
+            //在阅读页,选择注释后,点击按钮
+            //需要设置相关参数
+            if (AnnotAttribEvent.IsAnnotCreateReset == false)
+            {
+                pdfViewer.SetMouseMode(MouseModes.AnnotCreate);
+                pdfViewer.SetToolParam(linkAnnotArgs);
+                IsAnnotSelect = false;
+            }
+
             pdfViewer.EnableDrawSelectArea(true);
             historyPageIndex = pdfViewer.CurrentIndex;
             PageNumTextIsEnabled = false;
@@ -708,8 +723,62 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 region.RequestNavigate(viewContentViewModel.TipContentRegionName, "LinkAnnotTip");
             }
-            //if(string.IsNullOrEmpty(PageNumTextContent))
+
             viewContentViewModel.ShowTip(true);
+            //AnnotAttribEvent.IsAnnotCreateReset = true;
+        }
+
+        /// <summary>
+        /// 定位目标范围完成时,触发
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private async void PDFViewer_CustomNotifyHandler(object sender, CustomNotityData e)
+        {
+            if (e.NotifyType == CustomNotifyType.LinkAreaLocate)
+            {
+                if (e.NotifyData is AreaLocate areaInfo)
+                {
+                    if (pdfViewer.ToolManager.CurrentAnnotArgs.EventType == AnnotArgsType.AnnotLink && pdfViewer.MouseMode == MouseModes.AnnotCreate)
+                    {
+                        LinkAnnotArgs linkArgs = pdfViewer.ToolManager.CurrentAnnotArgs as LinkAnnotArgs;
+                        System.Windows.Size pageSize = pdfViewer.Document.GetPageSize(areaInfo.PageIndex);
+                        linkArgs.IsPositionSet = true;
+                        linkArgs.DestIndex = areaInfo.PageIndex;
+                        linkArgs.DestinationPos = new System.Windows.Point(areaInfo.Area.X, pageSize.Height - areaInfo.Area.Y);
+
+                        historyPageIndex = linkArgs.PageIndex;
+                        LinkAnnotArgs = linkArgs;
+                        //LinkAnnotArgs.PageIndex = historyPageIndex;
+
+                        AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.GOTO);
+                        AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkDestIndx, areaInfo.PageIndex);
+                        AnnotAttribEvent?.UpdateAnnot();
+
+                        LinkAnnotArgs.InvokeLinkSaveCalled(this, EventArgs.Empty);
+
+                        PageNumTextContent = (areaInfo.PageIndex + 1).ToString();
+                        SetImagePreview(areaInfo.PageIndex);
+
+                        //viewContentViewModel.LinkAnnotTipVisibility = Visibility.Collapsed;
+                        viewContentViewModel.TipVisible = Visibility.Collapsed;
+                        BtnLocationIsChecked = false;
+
+                        //没有选择注释工具、也不是右键添加注释
+                        //在阅读页,选择注释后,点击按钮
+                        //需要设置相关参数
+                        if (IsAnnotSelect == false)
+                        {
+                            pdfViewer.SetMouseMode(MouseModes.PanTool);
+                        }
+
+                        await System.Threading.Tasks.Task.Delay(2);
+                        SelectAnnotation();
+
+                        pdfViewer.GoToPage(historyPageIndex);
+                    }
+                }
+            }
         }
 
         /// <summary>
@@ -1049,6 +1118,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 }
                 if (AnnotAttribEvent.IsAnnotCreateReset == false)
                 {
+                    //根据选择的,链接,获取对应的信息
                     GetAnnotAttribute();
                 }
 
@@ -1082,49 +1152,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        /// <summary>
-        /// 定位目标范围完成时,触发
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private async void PDFViewer_CustomNotifyHandler(object sender, CustomNotityData e)
-        {
-            if (e.NotifyType == CustomNotifyType.LinkAreaLocate)
-            {
-                if (e.NotifyData is AreaLocate areaInfo)
-                {
-                    if (pdfViewer.ToolManager.CurrentAnnotArgs.EventType == AnnotArgsType.AnnotLink && pdfViewer.MouseMode == MouseModes.AnnotCreate)
-                    {
-                        LinkAnnotArgs linkArgs = pdfViewer.ToolManager.CurrentAnnotArgs as LinkAnnotArgs;
-                        System.Windows.Size pageSize = pdfViewer.Document.GetPageSize(areaInfo.PageIndex);
-                        linkArgs.IsPositionSet = true;
-                        linkArgs.DestIndex = areaInfo.PageIndex;
-                        linkArgs.DestinationPos = new System.Windows.Point(areaInfo.Area.X, pageSize.Height - areaInfo.Area.Y);
-
-                        LinkAnnotArgs = linkArgs;
-                        LinkAnnotArgs.PageIndex = historyPageIndex;
-
-                        AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.GOTO);
-                        AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkDestIndx, areaInfo.PageIndex);
-                        AnnotAttribEvent?.UpdateAnnot();
-
-                        LinkAnnotArgs.InvokeLinkSaveCalled(this, EventArgs.Empty);
-
-                        PageNumTextContent = (areaInfo.PageIndex + 1).ToString();
-                        SetImagePreview(areaInfo.PageIndex);
-
-                        await System.Threading.Tasks.Task.Delay(2);
-                        SelectAnnotation();
-
-                        pdfViewer.GoToPage(historyPageIndex);
-                        //viewContentViewModel.LinkAnnotTipVisibility = Visibility.Collapsed;
-                        viewContentViewModel.TipVisible = Visibility.Collapsed;
-                        BtnLocationIsChecked = false;
-                    }
-                }
-            }
-        }
-
         /// <summary>
         /// 选择链接后,显示参数
         /// </summary>
@@ -1132,6 +1159,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         {
             if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkType))
             {
+                //设置显示的链接模块
                 SetLinkType((LINK_TYPE)AnnotAttribEvent.Attribs[AnnotAttrib.LinkType]);
             }
             if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkDestIndx) && !AnnotAttribEvent.IsAnnotCreateReset)
@@ -1222,6 +1250,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             BtnLinkPageIsChecked = false;
             BtnLinkMailIsChecked = false;
             BtnLinkWebIsChecked = false;
+            //暂定 第一版 不显示邮箱、web链接模块
+            if (linkType == LINK_TYPE.URI)
+            {
+                BtnLinkPageIsChecked = true;
+                BtnGOorBackVisibility = Visibility.Collapsed;
+                return;
+            }
             switch (linkType)
             {
                 case LINK_TYPE.GOTO:

+ 14 - 20
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -127,7 +127,6 @@ namespace PDF_Office.ViewModels.Tools
                 PDFViewer.SnapshotCommandHandler -= PDFViewer_SnapshotCommandHandler;
                 PDFViewer.PDFActionHandler -= PDFViewer_PDFActionHandler;
                 PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
-                
             }
         }
 
@@ -150,6 +149,7 @@ namespace PDF_Office.ViewModels.Tools
                 return false;
             }
         }
+
         //是否为高亮注释
         private bool isHightAnnot(AnnotHandlerEventArgs annot)
         {
@@ -166,7 +166,7 @@ namespace PDF_Office.ViewModels.Tools
                 return false;
             }
         }
-        
+
         private void GetSelectedAnnots(AnnotAttribEvent e)
         {
             var annot = e.AnnotItemsList[0];
@@ -230,6 +230,7 @@ namespace PDF_Office.ViewModels.Tools
 
                 case AnnotArgsType.AnnotLink:
                     //viewContentViewModel.IsCreateLink = false;
+                    //e.IsAnnotCreateReset= true;
                     GetLink(e.AnnotItemsList, e);
 
                     break;
@@ -246,7 +247,7 @@ namespace PDF_Office.ViewModels.Tools
             }
         }
 
-        #endregion
+        #endregion 与触发事件调用相关的函数
 
         #region PDFViewer事件
 
@@ -288,7 +289,7 @@ namespace PDF_Office.ViewModels.Tools
                                 if (ToolExpandDict.ContainsValue(e.AnnotItemsList[0].EventType))
                                 {
                                     var strLineAnnotTag = "";
-                                    if(e.AnnotItemsList[0] is LineAnnotArgs)
+                                    if (e.AnnotItemsList[0] is LineAnnotArgs)
                                     {
                                         var lineAnnot = e.AnnotItemsList[0] as LineAnnotArgs;
                                         if (lineAnnot.HeadLineType == C_LINE_TYPE.LINETYPE_NONE && lineAnnot.TailLineType == C_LINE_TYPE.LINETYPE_NONE)
@@ -306,27 +307,26 @@ namespace PDF_Office.ViewModels.Tools
                                         if (item.Value == e.AnnotItemsList[0].EventType)
                                         {
                                             annot = null;//新建注释时,回到默认值
-                                            if(string.IsNullOrEmpty(strLineAnnotTag))
+                                            if (string.IsNullOrEmpty(strLineAnnotTag))
                                             {
                                                 FindAnnotTypeKey(item.Key, ref annot);
                                                 break;
                                             }
                                             else
                                             {
-                                                if(strLineAnnotTag == item.Key)
+                                                if (strLineAnnotTag == item.Key)
                                                 {
                                                     FindAnnotTypeKey(item.Key, ref annot);
                                                     break;
                                                 }
-                                                    
                                             }
-                                           
                                         }
                                     }
                                 }
                             }
                             //else
                             PDFViewer.SetToolParam(annot);
+
                             #region TO DO
 
                             //设计重新调整,阅读页空白处,右键菜单,添加链接需要显示,其他和pro mac一样的效果,不显示属性栏
@@ -395,20 +395,18 @@ namespace PDF_Office.ViewModels.Tools
             {
                 if (BtnLinkIsChecked == false)
                 {
-                    if (PDFViewer.MouseMode != MouseModes.AnnotCreate && PDFViewer.MouseMode != MouseModes.PanTool)
+                    if (PDFViewer.MouseMode != MouseModes.AnnotCreate)
                         viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
                 }
-
             }
         }
 
-
         //在注释工具的状态下,右键菜单
         private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
         {
             if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
                 return;
-            
+
             switch (e.CommandType)
             {
                 case CommandType.Context:
@@ -670,7 +668,6 @@ namespace PDF_Office.ViewModels.Tools
                                 PDFViewer.SelectAnnotation(annot.PageIndex, annot.AnnotIndex);
                             }
 
-
                             break;
 
                         case ActionType.Del:
@@ -729,10 +726,7 @@ namespace PDF_Office.ViewModels.Tools
                 Pen hoverPen = new Pen(new SolidColorBrush(Color.FromArgb(0xff, 0x11, 0x8A, 0xff)), 1);
                 hoverPen.DashStyle = DashStyles.Dash;
                 e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
-
-            
             }
- 
         }
 
         #endregion PDFViewer事件
@@ -829,8 +823,8 @@ namespace PDF_Office.ViewModels.Tools
                             break;
 
                         case AnnotArgsType.AnnotFreehand:
-            
-                            if(e[argsType] is FreehandAnnotArgs)
+
+                            if (e[argsType] is FreehandAnnotArgs)
                             {
                                 var annot = e[argsType] as FreehandAnnotArgs;
                                 if (annot != null)
@@ -845,8 +839,8 @@ namespace PDF_Office.ViewModels.Tools
                                         propertyPanel.AnnotEvents = AnnotEvents;
                                         propertyPanel.annot = annot;
                                         //手绘注释工具按钮的属性
-                                       // FreehandPath.Opacity = annot.Transparency;
-                                       // FreehandPath.Fill = new SolidColorBrush(annot.InkColor);
+                                        // FreehandPath.Opacity = annot.Transparency;
+                                        // FreehandPath.Fill = new SolidColorBrush(annot.InkColor);
                                     }
                                     PDFViewer.SetToolParam(annot);
                                 }

+ 1 - 1
PDF Office/Views/BOTA/AnnotationContent.xaml

@@ -256,7 +256,7 @@
                                     Name="MenuCollapseAll"
                                     Click="MenuCollapseAll_Click"
                                     Header="全部折叠" />
-                                <MenuItem Name="MenuSort">
+                                <MenuItem Name="MenuSort" Visibility="Collapsed">
                                     <MenuItem.Header>
                                         <TextBlock Name="MenuSortText" Text="排序" />
                                     </MenuItem.Header>