|
@@ -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);
|