Browse Source

注释-链接-页码-定位区域

OYXH\oyxh 2 years ago
parent
commit
fba993dc4a

BIN
PDF Office/ComPDFKit.Viewer.dll


+ 4 - 4
PDF Office/Styles/CheckBoxStyle.xaml

@@ -163,10 +163,10 @@
                             <Setter TargetName="CheckBoxRectangle" Property="Fill" Value="#FF00A8E0" />
                             <Setter TargetName="CheckBoxRectangle" Property="Opacity" Value="1" />
                             <Setter TargetName="CheckBoxRectangleOut" Property="Stroke" Value="Transparent" />
-                            <Setter TargetName="CheckedMark" Property="Visibility" Value="Visible"></Setter>
-                            <Setter TargetName="CheckBoxRectangle" Property="Fill" Value="#000000"></Setter>
-                            <Setter TargetName="CheckBoxRectangle" Property="Opacity" Value="1"></Setter>
-                            <Setter TargetName="CheckBoxRectangleOut" Property="Stroke" Value="Transparent"></Setter>
+                            <Setter TargetName="CheckedMark" Property="Visibility" Value="Visible" />
+                            <Setter TargetName="CheckBoxRectangle" Property="Fill" Value="#000000" />
+                            <Setter TargetName="CheckBoxRectangle" Property="Opacity" Value="1" />
+                            <Setter TargetName="CheckBoxRectangleOut" Property="Stroke" Value="Transparent" />
                         </Trigger>
                     </ControlTemplate.Triggers>
                 </ControlTemplate>

+ 77 - 51
PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs

@@ -40,26 +40,26 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         private AnnotPropertyPanel PropertyPanel;
         private AnnotArgsType annotType;
 
-        private LinkAnnotArgs annotArgs;
+        private LinkAnnotArgs linkAnnotArgs;
 
-        public LinkAnnotArgs AnnotArgs
+        public LinkAnnotArgs LinkAnnotArgs
         {
             get
             {
-                return annotArgs;
+                return linkAnnotArgs;
             }
             set
             {
-                if (annotArgs != null)
+                if (linkAnnotArgs != null)
                 {
-                    annotArgs.LinkDrawFinished -= annotArgs_LinkDrawFinished;
+                    linkAnnotArgs.LinkDrawFinished -= linkAnnotArgs_LinkDrawFinished;
                 }
 
-                annotArgs = value;
+                linkAnnotArgs = value;
 
-                if (annotArgs != null)
+                if (linkAnnotArgs != null)
                 {
-                    annotArgs.LinkDrawFinished += annotArgs_LinkDrawFinished;
+                    linkAnnotArgs.LinkDrawFinished += linkAnnotArgs_LinkDrawFinished;
                 }
             }
         }
@@ -83,12 +83,12 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 if (CheckPageNumVaild(out int pageNum, pageNumTextContent))
                 {
-                    if (AnnotArgs != null)
+                    if (LinkAnnotArgs != null)
                     {
-                        AnnotArgs.DestIndex = pageNum - 1;
-                        AnnotArgs.Content = string.Format($"To Page {AnnotArgs.DestIndex}");
+                        LinkAnnotArgs.DestIndex = pageNum - 1;
+                        LinkAnnotArgs.Content = string.Format($"To Page {LinkAnnotArgs.DestIndex}");
                         //isTextChanged = (int)AnnotAttribEvent.Attribs[AnnotAttrib.LinkDestIndx] != AnnotArgs.DestIndex ? true : false;
-                        //SetImagePreview(AnnotArgs.DestIndex);
+                        SetImagePreview(LinkAnnotArgs.DestIndex);
                     }
                 }
                 else
@@ -117,10 +117,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     {
                         pageWebTextContent = "http://" + pageWebTextContent;
                     }
-                    if (AnnotArgs != null)
+                    if (LinkAnnotArgs != null)
                     {
-                        AnnotArgs.URI = pageWebTextContent;
-                        AnnotArgs.Content = AnnotArgs.URI;
+                        LinkAnnotArgs.URI = pageWebTextContent;
+                        LinkAnnotArgs.Content = LinkAnnotArgs.URI;
                         //isTextChanged = (string)AnnotAttribEvent.Attribs[AnnotAttrib.LinkUri] != AnnotArgs.URI ? true : false;
                     }
                 }
@@ -141,10 +141,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             {
                 if (CheckPageMailVaild(pageMailTextContent))
                 {
-                    if (!string.IsNullOrEmpty(pageMailTextContent) && AnnotArgs != null)
+                    if (!string.IsNullOrEmpty(pageMailTextContent) && LinkAnnotArgs != null)
                     {
-                        AnnotArgs.URI = "mailto:" + pageMailTextContent.Trim();
-                        AnnotArgs.Content = AnnotArgs.URI;
+                        LinkAnnotArgs.URI = "mailto:" + pageMailTextContent.Trim();
+                        LinkAnnotArgs.Content = LinkAnnotArgs.URI;
                         //isTextChanged = (string)AnnotAttribEvent.Attribs[AnnotAttrib.LinkUri] != AnnotArgs.URI ? true : false;
                     }
                 }
@@ -455,6 +455,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 }
             }
         }
+
         private void PageNumTextLostFocus(object obj)
         {
             if (!string.IsNullOrEmpty(PageNumTextContent))
@@ -465,9 +466,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                     AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkDestIndx, pageNum - 1);
                     AnnotAttribEvent?.UpdateAnnot();
 
-                    AnnotArgs?.InvokeLinkSaveCalled(this, EventArgs.Empty);
+                    LinkAnnotArgs?.InvokeLinkSaveCalled(this, EventArgs.Empty);
                     //isTextChanged = false;
-                    SetImagePreview(AnnotArgs.DestIndex);
+                    SetImagePreview(LinkAnnotArgs.DestIndex);
+                    BtnLocationIsEnabled = false;
                 }
                 else
                 {
@@ -484,8 +486,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 switch (radioButton.Tag)
                 {
                     case "Page":
-                        AnnotArgs.LinkType = LINK_TYPE.GOTO;
-                        AnnotArgs.URI = string.Empty;
+                        LinkAnnotArgs.LinkType = LINK_TYPE.GOTO;
+                        LinkAnnotArgs.URI = string.Empty;
                         AnnotAttribEvent.Attribs[AnnotAttrib.LinkType] = LINK_TYPE.GOTO;
                         AnnotAttribEvent.Attribs[AnnotAttrib.LinkUri] = string.Empty;
                         isMail = false;
@@ -504,8 +506,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                         break;
 
                     case "Web":
-                        AnnotArgs.LinkType = LINK_TYPE.URI;
-                        AnnotArgs.URI = string.Empty;
+                        LinkAnnotArgs.LinkType = LINK_TYPE.URI;
+                        LinkAnnotArgs.URI = string.Empty;
                         AnnotAttribEvent.Attribs[AnnotAttrib.LinkType] = LINK_TYPE.URI;
                         AnnotAttribEvent.Attribs[AnnotAttrib.LinkUri] = string.Empty;
                         isMail = false;
@@ -519,8 +521,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                         break;
 
                     case "Mail":
-                        AnnotArgs.LinkType = LINK_TYPE.URI;
-                        AnnotArgs.URI = string.Empty;
+                        LinkAnnotArgs.LinkType = LINK_TYPE.URI;
+                        LinkAnnotArgs.URI = string.Empty;
                         AnnotAttribEvent.Attribs[AnnotAttrib.LinkType] = LINK_TYPE.URI;
                         AnnotAttribEvent.Attribs[AnnotAttrib.LinkUri] = string.Empty;
                         isMail = true;
@@ -534,7 +536,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                         break;
 
                     default:
-                        AnnotArgs.LinkType = LINK_TYPE.GOTO;
+                        LinkAnnotArgs.LinkType = LINK_TYPE.GOTO;
                         AnnotAttribEvent.Attribs[AnnotAttrib.LinkType] = LINK_TYPE.GOTO;
                         isMail = false;
                         if (btnGOorBack != null)
@@ -560,18 +562,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         /// <param name="obj"></param>
         private void LocationPage(object obj)
         {
-            if (string.IsNullOrEmpty(PageNumTextContent))
-            {
-                //if (CheckPageNumVaild(out int pageNum, PageNumTextContent))
-                //{
-                //    AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.GOTO);
-                //    AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkDestIndx, pageNum - 1);
-                //    AnnotAttribEvent?.UpdateAnnot();
-
-                //    AnnotArgs?.InvokeLinkSaveCalled(this, EventArgs.Empty);
-                //    //isTextChanged = false;
-                //}
-            }
+            historyPageIndex = pdfViewer.CurrentIndex;
+            PageNumTextIsEnabled = false;
+            pdfViewer.EnableDrawSelectArea(true);
         }
 
         /// <summary>
@@ -615,7 +608,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkUri, "mailto:" + PageMailTextContent.Trim());
                 AnnotAttribEvent?.UpdateAnnot();
 
-                AnnotArgs?.InvokeLinkSaveCalled(this, EventArgs.Empty);
+                LinkAnnotArgs?.InvokeLinkSaveCalled(this, EventArgs.Empty);
 
                 Process.Start("mailto:?to=" + PageMailTextContent.Trim());
             }
@@ -633,7 +626,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 }
                 AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkUri, PageWebTextContent);
                 AnnotAttribEvent?.UpdateAnnot();
-                AnnotArgs?.InvokeLinkSaveCalled(this, EventArgs.Empty);
+                LinkAnnotArgs?.InvokeLinkSaveCalled(this, EventArgs.Empty);
 
                 if (PageWebTextContent.StartsWith("http://") || PageWebTextContent.StartsWith("https://"))
                 {
@@ -656,7 +649,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 //AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkDestIndx, pageIndex);
                 //AnnotAttribEvent?.UpdateAnnot();
 
-                historyPageIndex = AnnotArgs != null ? AnnotArgs.PageIndex : backPageIndex;
+                historyPageIndex = LinkAnnotArgs != null ? LinkAnnotArgs.PageIndex : backPageIndex;
                 pdfViewer.GoToPage(pageIndex);
 
                 ChangeBtnGOorBack("BACK", btnGOorBack);
@@ -838,7 +831,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
-        private void annotArgs_LinkDrawFinished(object sender, bool e)
+        private void linkAnnotArgs_LinkDrawFinished(object sender, bool e)
         {
             //linkAnnot.SetTextBoxEnableOrNot(e, totalPage);
             //AnnotArgs.DestIndex = -1;
@@ -876,6 +869,9 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 
             if (PropertyPanel != null && pdfViewer != null)
             {
+                pdfViewer.CustomNotifyHandler -= PDFViewer_CustomNotifyHandler;
+
+                pdfViewer.CustomNotifyHandler += PDFViewer_CustomNotifyHandler;
                 AnnotAttribEvent = PropertyPanel.AnnotEvent;
                 AnnotType = PropertyPanel.annot.EventType;
 
@@ -898,22 +894,52 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                         }
                         if (AnnotAttribEvent.IsAnnotCreateReset)
                         {
-                            AnnotArgs = pdfViewer.ToolManager.CurrentAnnotArgs as LinkAnnotArgs;
-                            if (AnnotArgs == null)
+                            LinkAnnotArgs = pdfViewer.ToolManager.CurrentAnnotArgs as LinkAnnotArgs;
+                            if (LinkAnnotArgs == null)
                             {
                                 backPageIndex = pdfViewer.CurrentIndex;
                             }
                             else
                             {
-                                AnnotArgs.PageIndex = pdfViewer.CurrentIndex;
+                                LinkAnnotArgs.PageIndex = pdfViewer.CurrentIndex;
                             }
                         }
                     }
                 }
 
-                if (AnnotArgs == null)
+                if (LinkAnnotArgs == null)
+                {
+                    LinkAnnotArgs = (LinkAnnotArgs)PropertyPanel.annot;
+                }
+            }
+        }
+
+        private void PDFViewer_CustomNotifyHandler(object sender, CustomNotityData e)
+        {
+            if (e.NotifyType == CustomNotifyType.LinkAreaLocate)
+            {
+                if (e.NotifyData is AreaLocate areaInfo)
                 {
-                    AnnotArgs = (LinkAnnotArgs)PropertyPanel.annot;
+                    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);
+
+                        AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.GOTO);
+                        AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkDestIndx, areaInfo.PageIndex);
+                        AnnotAttribEvent?.UpdateAnnot();
+
+                        linkArgs.InvokeLinkSaveCalled(this, EventArgs.Empty);
+
+                        pdfViewer.GoToPage(historyPageIndex);
+                        LinkAnnotArgs = linkArgs;
+                        LinkAnnotArgs.PageIndex = historyPageIndex;
+                        PageNumTextContent = (areaInfo.PageIndex + 1).ToString();
+                        SetImagePreview(areaInfo.PageIndex);
+                    }
                 }
             }
         }
@@ -927,13 +953,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkDestIndx) && !AnnotAttribEvent.IsAnnotCreateReset)
             {
                 SetLinkPageNum((int)AnnotAttribEvent.Attribs[AnnotAttrib.LinkDestIndx] + 1);
-                if (AnnotArgs == null)
+                if (LinkAnnotArgs == null)
                 {
                     backPageIndex = pdfViewer.CurrentIndex;
                 }
                 else
                 {
-                    AnnotArgs.PageIndex = pdfViewer.CurrentIndex;
+                    LinkAnnotArgs.PageIndex = pdfViewer.CurrentIndex;
                 }
             }
             if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkUri))
@@ -994,7 +1020,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 ImagePreviewVisibility = Visibility.Visible;
 
                 SetImagePreview(pageNum - 1);
-
+                BtnLocationIsEnabled = true;
                 //if (btnGOorBack != null)
                 //{
                 //    ChangeBtnGOorBack("GO", btnGOorBack);

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

@@ -352,9 +352,12 @@ namespace PDF_Office.ViewModels.Tools
 
                 PDFViewer.WidgetClickHander -= PDFViewer_WidgetClickHander;
                 PDFViewer.WidgetClickHander += PDFViewer_WidgetClickHander;
+
             }
         }
 
+
+
         private void PDFViewer_WidgetClickHander(object sender, WidgetArgs e)
         {
         }

+ 2 - 1
PDF Office/Views/BOTA/AnnotationListItem.xaml

@@ -320,7 +320,7 @@
                         </Grid>
                     </customControl:CustomIconToggleBtn>
                 </Grid>
-                <WrapPanel Grid.Column="1" Orientation="Horizontal" Margin="8,0,0,0">
+                <WrapPanel Grid.Column="1" Orientation="Horizontal" Margin="5,5,0,0" HorizontalAlignment="Right">
                     <TextBlock
                         Name="txtAuthor"
 
@@ -332,6 +332,7 @@
                         TextAlignment="Left" />
                     <TextBlock
                         Name="txtDate"
+                        Margin="5,0,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         FontFamily="Segoe UI"

+ 8 - 7
PDF Office/Views/BOTA/AnnotationListItem.xaml.cs

@@ -206,15 +206,16 @@ namespace PDF_Office.Views.BOTA
                     BtnAnnotLink.Visibility = Visibility.Visible;
                     if (data is LinkAnnotArgs linkAnnotArgs)
                     {
-                        //Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
-                        //annotAttribsList[AnnotAttrib.LinkType] = linkAnnotArgs.LinkType;
-                        //annotAttribsList[AnnotAttrib.LinkUri] = linkAnnotArgs.URI;
-                        //annotAttribsList[AnnotAttrib.LinkDestIndx] = linkAnnotArgs.DestIndex;
-                        //AnnotAttribEvent annotAttribEvent = AnnotAttribEvent.GetAnnotAttribEvent(linkAnnotArgs, annotAttribsList);
                         if (string.IsNullOrEmpty(linkAnnotArgs.Content))
                         {
-                            //if(data.)
-                            TxbContext.Text = string.Format($"To Page {linkAnnotArgs.PageIndex}");
+                            if (linkAnnotArgs.DestIndex != -1)
+                            {
+                                TxbContext.Text = string.Format($"To Page {linkAnnotArgs.DestIndex}");
+                            }
+                            else
+                            {
+                                TxbContext.Text = string.Format($"To Page {linkAnnotArgs.URI}");
+                            }
                         }
                     }
 

+ 1 - 1
PDF Office/Views/PropertyPanel/ViewModular/ThemesContent.xaml

@@ -126,7 +126,7 @@
         </ResourceDictionary>
     </UserControl.Resources>
 
-    <WrapPanel Name="btnsPanel" Width="auto">
+    <WrapPanel Name="btnsPanel" Width="auto" Orientation="Horizontal">
         <RadioButton
             Name="RBtnLight"
             Margin="4,0,4,0"

File diff suppressed because it is too large
+ 335 - 280
PDF Office/Views/PropertyPanel/ViewModular/ViewModularContent.xaml


BIN
PDFSettings/bin/Debug/ComPDFKit.Viewer.dll