|
@@ -25,6 +25,9 @@ using PDF_Office.CustomControl;
|
|
|
using System.Windows.Markup;
|
|
|
using ComPDFKitViewer;
|
|
|
using System.Runtime.InteropServices;
|
|
|
+using System.Text.RegularExpressions;
|
|
|
+using System.Net;
|
|
|
+using System.Diagnostics;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
{
|
|
@@ -35,25 +38,26 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
private AnnotPropertyPanel PropertyPanel;
|
|
|
private AnnotArgsType annotType;
|
|
|
|
|
|
- private LinkAnnotArgs _annotArgs;
|
|
|
+ private LinkAnnotArgs annotArgs;
|
|
|
|
|
|
public LinkAnnotArgs AnnotArgs
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
- return _annotArgs;
|
|
|
+ return annotArgs;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
- if (_annotArgs != null)
|
|
|
+ if (annotArgs != null)
|
|
|
{
|
|
|
- _annotArgs.LinkDrawFinished -= _annotArgs_LinkDrawFinished;
|
|
|
+ annotArgs.LinkDrawFinished -= annotArgs_LinkDrawFinished;
|
|
|
}
|
|
|
- _annotArgs = value;
|
|
|
|
|
|
- if (_annotArgs != null)
|
|
|
+ annotArgs = value;
|
|
|
+
|
|
|
+ if (annotArgs != null)
|
|
|
{
|
|
|
- _annotArgs.LinkDrawFinished += _annotArgs_LinkDrawFinished;
|
|
|
+ annotArgs.LinkDrawFinished += annotArgs_LinkDrawFinished;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -67,6 +71,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ #region 输入框的验证、设置
|
|
|
+
|
|
|
private string pageNumTextContent;
|
|
|
|
|
|
public string PageNumTextContent
|
|
@@ -84,7 +90,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
if (AnnotArgs != null)
|
|
|
{
|
|
|
AnnotArgs.DestIndex = pageNum - 1;
|
|
|
- //BtnLocationIsEnabled = true;
|
|
|
+
|
|
|
SetImagePreview(AnnotArgs.DestIndex);
|
|
|
}
|
|
|
}
|
|
@@ -107,7 +113,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
/// <summary>
|
|
|
/// 设置预文本内容
|
|
|
/// </summary>
|
|
|
- private string pageNumPlaceHoldText = "Enter target page";
|
|
|
+ private string pageNumPlaceHoldText = "输入目标页面";
|
|
|
|
|
|
public string PageNumPlaceHoldText
|
|
|
{
|
|
@@ -157,6 +163,81 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private bool pageWebTextIsEnabled = false;
|
|
|
+
|
|
|
+ public bool PageWebTextIsEnabled
|
|
|
+ {
|
|
|
+ get { return pageWebTextIsEnabled; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref pageWebTextIsEnabled, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private string pageWebPlaceHoldText = "输入您要跳转的链接";
|
|
|
+
|
|
|
+ public string PageWebPlaceHoldText
|
|
|
+ {
|
|
|
+ get { return pageWebPlaceHoldText; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref pageWebPlaceHoldText, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Visibility showPageWebTip = Visibility.Collapsed;
|
|
|
+
|
|
|
+ public Visibility ShowPageWebTip
|
|
|
+ {
|
|
|
+ get { return showPageWebTip; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref showPageWebTip, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private string pageWebTextContent;
|
|
|
+
|
|
|
+ public string PageWebTextContent
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (CheckPageWebVaild(pageWebTextContent))
|
|
|
+ {
|
|
|
+ pageWebTextContent = pageWebTextContent.Trim().ToLower();
|
|
|
+ if (!pageWebTextContent.StartsWith("http://") && !pageWebTextContent.StartsWith("https://"))
|
|
|
+ {
|
|
|
+ pageWebTextContent = "http://" + pageWebTextContent;
|
|
|
+ }
|
|
|
+ if (AnnotArgs != null)
|
|
|
+ {
|
|
|
+ AnnotArgs.URI = pageWebTextContent;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return pageWebTextContent;
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref pageWebTextContent, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private string pageWebTipText = "Invalid link.";
|
|
|
+
|
|
|
+ public string PageWebTipText
|
|
|
+ {
|
|
|
+ get { return pageWebTipText; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref pageWebTipText, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion 输入框的验证、设置
|
|
|
+
|
|
|
+ #region 按钮、图片的设置
|
|
|
+
|
|
|
private bool btnLocationIsEnabled = false;
|
|
|
|
|
|
public bool BtnLocationIsEnabled
|
|
@@ -267,41 +348,25 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //private Visibility errorNumTipsVisibility = Visibility.Collapsed;
|
|
|
-
|
|
|
- //public Visibility ErrorNumTipsVisibility
|
|
|
- //{
|
|
|
- // get { return errorNumTipsVisibility; }
|
|
|
- // set
|
|
|
- // {
|
|
|
- // SetProperty(ref errorNumTipsVisibility, value);
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- //private Visibility errorRangeTipsVisibility = Visibility.Collapsed;
|
|
|
-
|
|
|
- //public Visibility ErrorRangeTipsVisibility
|
|
|
- //{
|
|
|
- // get { return errorRangeTipsVisibility; }
|
|
|
- // set
|
|
|
- // {
|
|
|
- // SetProperty(ref errorRangeTipsVisibility, value);
|
|
|
- // }
|
|
|
- //}
|
|
|
- private int totalPage = 0;
|
|
|
+ #endregion 按钮、图片的设置
|
|
|
|
|
|
private bool isLoaded = false;
|
|
|
- private int historyPageIndex = 0;
|
|
|
+ private bool isMail = false;
|
|
|
+ private string historyBtnGOorBackTag = string.Empty;
|
|
|
+ private int totalPage = 0;
|
|
|
private int backPageIndex = 0;
|
|
|
+ private int historyPageIndex = 0;
|
|
|
+
|
|
|
private CPDFViewer pdfViewer;
|
|
|
private CPDFDocument document;
|
|
|
+ private Button btnGOorBack = null;
|
|
|
private LinkAnnotProperty linkAnnot;
|
|
|
public DelegateCommand<object> LoadedCommand { get; set; }
|
|
|
public DelegateCommand<object> PageNumTextChangedCommand { get; set; }
|
|
|
public DelegateCommand<object> BtnGOorBackPageCommand { get; set; }
|
|
|
public DelegateCommand<object> LocationCommand { get; set; }
|
|
|
|
|
|
- //public DelegateCommand<object> ToggleButtonTabCommand { get; set; }
|
|
|
+ public DelegateCommand<object> ToggleButtonTabCommand { get; set; }
|
|
|
|
|
|
public LinkAnnotPropertyViewModel()
|
|
|
{
|
|
@@ -309,30 +374,87 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
PageNumTextChangedCommand = new DelegateCommand<object>(PageNumTextChanged);
|
|
|
BtnGOorBackPageCommand = new DelegateCommand<object>(BtnGOorBackPageEvent);
|
|
|
LocationCommand = new DelegateCommand<object>(LocationPage);
|
|
|
- //ToggleButtonTabCommand = new DelegateCommand<object>(ToggleButtonTabSelected);
|
|
|
+ ToggleButtonTabCommand = new DelegateCommand<object>(ToggleButtonTabSelected);
|
|
|
isLoaded = true;
|
|
|
}
|
|
|
|
|
|
+ private void ToggleButtonTabSelected(object obj)
|
|
|
+ {
|
|
|
+ if (obj is RadioButton radioButton)
|
|
|
+ {
|
|
|
+ switch (radioButton.Tag)
|
|
|
+ {
|
|
|
+ case "Page":
|
|
|
+ AnnotArgs.LinkType = LINK_TYPE.GOTO;
|
|
|
+ isMail = false;
|
|
|
+ if (!string.IsNullOrEmpty(historyBtnGOorBackTag))
|
|
|
+ {
|
|
|
+ ChangeBtnGOorBack(historyBtnGOorBackTag, btnGOorBack);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ChangeBtnGOorBack("GO", btnGOorBack);
|
|
|
+ }
|
|
|
+ BtnGOorBackVisibility = string.IsNullOrEmpty(PageNumTextContent) ? Visibility.Collapsed : Visibility.Visible;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "Web":
|
|
|
+ AnnotArgs.LinkType = LINK_TYPE.URI;
|
|
|
+ isMail = false;
|
|
|
+ if (btnGOorBack != null)
|
|
|
+ {
|
|
|
+ historyBtnGOorBackTag = btnGOorBack.Tag.ToString();
|
|
|
+ ChangeBtnGOorBack("GO", btnGOorBack);
|
|
|
+ }
|
|
|
+
|
|
|
+ BtnGOorBackVisibility = string.IsNullOrEmpty(PageWebTextContent) ? Visibility.Collapsed : Visibility.Visible;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "Mail":
|
|
|
+ AnnotArgs.LinkType = LINK_TYPE.URI;
|
|
|
+ isMail = true;
|
|
|
+ if (btnGOorBack != null)
|
|
|
+ {
|
|
|
+ historyBtnGOorBackTag = btnGOorBack.Tag.ToString();
|
|
|
+ ChangeBtnGOorBack("GO", btnGOorBack);
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 定位
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="obj"></param>
|
|
|
private void LocationPage(object obj)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(PageNumTextContent))
|
|
|
{
|
|
|
- AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.GOTO);
|
|
|
- AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkDestIndx, Convert.ToInt32(PageNumTextContent) - 1);
|
|
|
- AnnotAttribEvent?.UpdateAnnot();
|
|
|
-
|
|
|
- if (AnnotArgs != null)
|
|
|
+ if (CheckPageNumVaild(out int pageNum, PageNumTextContent))
|
|
|
{
|
|
|
- AnnotArgs.InvokeLinkSaveCalled(this, EventArgs.Empty);
|
|
|
+ AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.GOTO);
|
|
|
+ AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkDestIndx, pageNum - 1);
|
|
|
+ AnnotAttribEvent?.UpdateAnnot();
|
|
|
+
|
|
|
+ AnnotArgs?.InvokeLinkSaveCalled(this, EventArgs.Empty);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 前往/返回按钮
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="obj"></param>
|
|
|
private void BtnGOorBackPageEvent(object obj)
|
|
|
{
|
|
|
if (obj is object[] arry)
|
|
|
{
|
|
|
- Button btnGOorBack = arry[0] as Button;
|
|
|
+ btnGOorBack = arry[0] as Button;
|
|
|
RadioButton btnLinkPage = arry[1] as RadioButton;
|
|
|
RadioButton btnLinkWeb = arry[2] as RadioButton;
|
|
|
RadioButton btnLinkMail = arry[3] as RadioButton;
|
|
@@ -342,32 +464,56 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
if (btnLinkPage.IsChecked == true)
|
|
|
{
|
|
|
int pageIndex = Convert.ToInt32(PageNumTextContent) - 1;
|
|
|
+
|
|
|
if (btnGOorBack.Tag.ToString() == "GO")
|
|
|
{
|
|
|
- if (AnnotArgs != null)
|
|
|
- {
|
|
|
- historyPageIndex = AnnotArgs.PageIndex;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- historyPageIndex = backPageIndex;
|
|
|
- }
|
|
|
+ historyPageIndex = AnnotArgs != null ? AnnotArgs.PageIndex : backPageIndex;
|
|
|
pdfViewer.GoToPage(pageIndex);
|
|
|
|
|
|
ChangeBtnGOorBack("BACK", btnGOorBack);
|
|
|
- SetImagePreview(historyPageIndex);
|
|
|
+ //SetImagePreview(historyPageIndex);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
pdfViewer.GoToPage(historyPageIndex);
|
|
|
ChangeBtnGOorBack("GO", btnGOorBack);
|
|
|
- SetImagePreview(pageIndex);
|
|
|
+ //SetImagePreview(pageIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (btnLinkWeb.IsChecked == true)
|
|
|
+ {
|
|
|
+ if (CheckPageWebVaild(PageWebTextContent))
|
|
|
+ {
|
|
|
+ AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.URI);
|
|
|
+ PageWebTextContent = PageWebTextContent.Trim().ToLower();
|
|
|
+ if (!PageWebTextContent.StartsWith("http://") && !PageWebTextContent.StartsWith("https://"))
|
|
|
+ {
|
|
|
+ PageWebTextContent = "http://" + PageWebTextContent;
|
|
|
+ }
|
|
|
+ AnnotAttribEvent?.UpdateAttrib(AnnotAttrib.LinkUri, PageWebTextContent);
|
|
|
+ AnnotAttribEvent?.UpdateAnnot();
|
|
|
+ AnnotArgs?.InvokeLinkSaveCalled(this, EventArgs.Empty);
|
|
|
+
|
|
|
+ if (PageWebTextContent.StartsWith("http://") || PageWebTextContent.StartsWith("https://"))
|
|
|
+ {
|
|
|
+ Process.Start(PageWebTextContent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BtnGOorBackVisibility = Visibility.Collapsed;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 设置前往/返回按钮的文本
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="flag"></param>
|
|
|
+ /// <param name="button"></param>
|
|
|
private void ChangeBtnGOorBack(string flag, Button button)
|
|
|
{
|
|
|
switch (flag)
|
|
@@ -406,12 +552,15 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 页码格式验证
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="pageNum"></param>
|
|
|
+ /// <param name="text"></param>
|
|
|
+ /// <returns></returns>
|
|
|
private bool CheckPageNumVaild(out int pageNum, string text)
|
|
|
{
|
|
|
pageNum = -1;
|
|
|
- //ErrorNumTipsVisibility = Visibility.Collapsed;
|
|
|
- //ErrorRangeTipsVisibility = Visibility.Collapsed;
|
|
|
- //BtnGOorBackVisibility = Visibility.Collapsed;
|
|
|
if (string.IsNullOrEmpty(text))
|
|
|
{
|
|
|
return false;
|
|
@@ -420,10 +569,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
{
|
|
|
if (!int.TryParse(text.Trim(), out pageNum))
|
|
|
{
|
|
|
- //ErrorNumTipsVisibility = Visibility.Visible;
|
|
|
- //ErrorRangeTipsVisibility = Visibility.Collapsed;
|
|
|
- //textBox.IsError = true;
|
|
|
- //PageNumTextIsError = true;
|
|
|
ShowPageNumTip = Visibility.Visible;
|
|
|
PageNumTipText = " Page number error.";
|
|
|
return false;
|
|
@@ -431,24 +576,53 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
if (pageNum < 1 || pageNum > totalPage)
|
|
|
{
|
|
|
- //ErrorNumTipsVisibility = Visibility.Collapsed;
|
|
|
- //ErrorRangeTipsVisibility = Visibility.Visible;
|
|
|
- //textBox.IsError = true;
|
|
|
- //PageNumTextIsError = true;
|
|
|
ShowPageNumTip = Visibility.Visible;
|
|
|
PageNumTipText = " Page number out of range.";
|
|
|
return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //textBox.IsError = false;
|
|
|
- //PageNumTextIsError = false;
|
|
|
ShowPageNumTip = Visibility.Collapsed;
|
|
|
}
|
|
|
BtnGOorBackVisibility = Visibility.Visible;
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ private bool CheckPageWebVaild(string text)
|
|
|
+ {
|
|
|
+ BtnGOorBackVisibility = Visibility.Collapsed;
|
|
|
+ if (string.IsNullOrEmpty(text))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ string checkUrl = text.ToLower().TrimStart("http://".ToCharArray()).TrimStart("https://".ToCharArray());
|
|
|
+ if (!Regex.IsMatch(checkUrl, "([a-zA-Z0-9/\\-%\\?#&=]+[./\\-%\\?#&=]?)+"))
|
|
|
+ {
|
|
|
+ ShowPageWebTip = Visibility.Visible;
|
|
|
+ PageWebTipText = "Invalid link.";
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ string matchText = Regex.Match(checkUrl, "([a-zA-Z0-9/\\-%\\?#&=]+[./\\-%\\?#&=]?)+").Value;
|
|
|
+ if (matchText.Length != checkUrl.Length)
|
|
|
+ {
|
|
|
+ ShowPageWebTip = Visibility.Visible;
|
|
|
+ PageWebTipText = "Invalid link.";
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShowPageWebTip = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+ BtnGOorBackVisibility = Visibility.Visible;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 设置图像
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="pageIndex"></param>
|
|
|
private void SetImagePreview(int pageIndex)
|
|
|
{
|
|
|
ImagePreviewVisibility = Visibility.Visible;
|
|
@@ -479,10 +653,16 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
PreviewImage = WirteBitmap;
|
|
|
}
|
|
|
|
|
|
- private void _annotArgs_LinkDrawFinished(object sender, bool e)
|
|
|
+ /// <summary>
|
|
|
+ /// 链接画框完成时触发事件
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void annotArgs_LinkDrawFinished(object sender, bool e)
|
|
|
{
|
|
|
//linkAnnot.SetTextBoxEnableOrNot(e, totalPage);
|
|
|
SetTextBoxEnableOrNot(e, totalPage);
|
|
|
+
|
|
|
//AnnotArgs = (LinkAnnotArgs)PropertyPanel.annot;
|
|
|
}
|
|
|
|
|
@@ -522,33 +702,31 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
|
|
|
SetTextBoxEnableOrNot(false, totalPage);
|
|
|
|
|
|
- if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkType))
|
|
|
- {
|
|
|
- SetLinkType((LINK_TYPE)AnnotAttribEvent.Attribs[AnnotAttrib.LinkType]);
|
|
|
- }
|
|
|
- if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkDestIndx) && !AnnotAttribEvent.IsAnnotCreateReset)
|
|
|
- {
|
|
|
- SetLinkPageNum((int)AnnotAttribEvent.Attribs[AnnotAttrib.LinkDestIndx] + 1);
|
|
|
- if (AnnotArgs == null)
|
|
|
- {
|
|
|
- backPageIndex = pdfViewer.CurrentIndex;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- AnnotArgs.PageIndex = pdfViewer.CurrentIndex;
|
|
|
- }
|
|
|
- }
|
|
|
+ SetAnnotAttribute();
|
|
|
|
|
|
if (isLoaded)
|
|
|
{
|
|
|
if (pdfViewer != null && pdfViewer.ToolManager != null && pdfViewer.ToolManager.CurrentAnnotArgs?.EventType == AnnotArgsType.AnnotLink)
|
|
|
{
|
|
|
+ if (btnGOorBack != null)
|
|
|
+ {
|
|
|
+ ChangeBtnGOorBack("GO", btnGOorBack);
|
|
|
+ }
|
|
|
if (AnnotAttribEvent.IsAnnotCreateReset)
|
|
|
{
|
|
|
AnnotArgs = pdfViewer.ToolManager.CurrentAnnotArgs as LinkAnnotArgs;
|
|
|
+ if (AnnotArgs == null)
|
|
|
+ {
|
|
|
+ backPageIndex = pdfViewer.CurrentIndex;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ AnnotArgs.PageIndex = pdfViewer.CurrentIndex;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if (AnnotArgs == null)
|
|
|
{
|
|
|
AnnotArgs = (LinkAnnotArgs)PropertyPanel.annot;
|
|
@@ -556,6 +734,70 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void SetAnnotAttribute()
|
|
|
+ {
|
|
|
+ if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkType))
|
|
|
+ {
|
|
|
+ SetLinkType((LINK_TYPE)AnnotAttribEvent.Attribs[AnnotAttrib.LinkType]);
|
|
|
+ }
|
|
|
+ if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkDestIndx) && !AnnotAttribEvent.IsAnnotCreateReset)
|
|
|
+ {
|
|
|
+ SetLinkPageNum((int)AnnotAttribEvent.Attribs[AnnotAttrib.LinkDestIndx] + 1);
|
|
|
+ if (AnnotArgs == null)
|
|
|
+ {
|
|
|
+ backPageIndex = pdfViewer.CurrentIndex;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ AnnotArgs.PageIndex = pdfViewer.CurrentIndex;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (AnnotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkUri))
|
|
|
+ {
|
|
|
+ string linkUrl = (string)AnnotAttribEvent.Attribs[AnnotAttrib.LinkUri];
|
|
|
+ if (!string.IsNullOrEmpty(linkUrl))
|
|
|
+ {
|
|
|
+ if (linkUrl.StartsWith("mailto:", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ SetLinkType(LINK_TYPE.URI, true);
|
|
|
+ if (AnnotAttribEvent.IsAnnotCreateReset)
|
|
|
+ {
|
|
|
+ SetLinkEmail("");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SetLinkEmail(linkUrl.ToLower().TrimStart("mailto:".ToCharArray()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (AnnotAttribEvent.IsAnnotCreateReset)
|
|
|
+ {
|
|
|
+ SetLinkUrl("");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SetLinkUrl(linkUrl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetLinkUrl(string url)
|
|
|
+ {
|
|
|
+ PageWebTextContent = url;
|
|
|
+ PageWebTextIsEnabled = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetLinkEmail(string email)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 设置页码的数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="pageNum"></param>
|
|
|
private void SetLinkPageNum(int pageNum)
|
|
|
{
|
|
|
if (pageNum > 0 && pageNum <= totalPage)
|
|
@@ -564,10 +806,21 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
BtnLocationIsEnabled = true;
|
|
|
PageNumTextIsEnabled = true;
|
|
|
ImagePreviewVisibility = Visibility.Visible;
|
|
|
- SetImagePreview(pageNum - 1);
|
|
|
+
|
|
|
+ //SetImagePreview(pageNum - 1);
|
|
|
+
|
|
|
+ //if (btnGOorBack != null)
|
|
|
+ //{
|
|
|
+ // ChangeBtnGOorBack("GO", btnGOorBack);
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 根据链接类型显示模块
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="linkType"></param>
|
|
|
+ /// <param name="isMail"></param>
|
|
|
public void SetLinkType(LINK_TYPE linkType, bool isMail = false)
|
|
|
{
|
|
|
BtnLinkPageIsChecked = false;
|
|
@@ -580,7 +833,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
break;
|
|
|
|
|
|
case LINK_TYPE.URI:
|
|
|
- if (isMail)
|
|
|
+ if (this.isMail || isMail)
|
|
|
{
|
|
|
BtnLinkMailIsChecked = true;
|
|
|
}
|
|
@@ -601,25 +854,27 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
this.totalPage = totalPage;
|
|
|
|
|
|
PageNumTextContent = string.Empty;
|
|
|
- //PageWebText.Text = string.Empty;
|
|
|
+
|
|
|
+ PageWebTextContent = string.Empty;
|
|
|
//PageMailText.Text = string.Empty;
|
|
|
|
|
|
PageNumTextIsEnabled = enable;
|
|
|
- if (PageNumTextIsEnabled == true)
|
|
|
- {
|
|
|
- //defaultPageNumText.Text = string.Format($"1-{totalPage}页");
|
|
|
- //PageNumText.PlaceholderText = string.Format($"1-{totalPage}页");
|
|
|
- PageNumPlaceHoldText = string.Format($"1-{totalPage}页");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //defaultPageNumText.Text = "Enter target page";
|
|
|
- //PageNumText.PlaceholderText = "Enter target page";
|
|
|
- PageNumPlaceHoldText = "Enter target page";
|
|
|
- }
|
|
|
+ PageWebTextIsEnabled = enable;
|
|
|
+ //if (PageNumTextIsEnabled == true)
|
|
|
+ //{
|
|
|
+ // PageNumPlaceHoldText = string.Format($"1-{totalPage}页");
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // PageNumPlaceHoldText = "输入目标页面";
|
|
|
+ //}
|
|
|
+ PageNumPlaceHoldText = PageNumTextIsEnabled ? string.Format($"1-{totalPage}页") : "输入目标页面";
|
|
|
+ PageWebPlaceHoldText = PageWebTextIsEnabled ? "https://www.pdfreaderpro.com" : "输入您要跳转的链接";
|
|
|
+
|
|
|
ShowPageNumTip = Visibility.Collapsed;
|
|
|
//BorderPageNumText.Background = enable ? Brushes.White : Brushes.LightGray;
|
|
|
|
|
|
+ ShowPageWebTip = Visibility.Collapsed;
|
|
|
//PageWebText.IsEnabled = enable;
|
|
|
//BorderPageWebText.Background = enable ? Brushes.White : Brushes.LightGray;
|
|
|
|
|
@@ -627,6 +882,15 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
//BorderPageMailText.Background = enable ? Brushes.White : Brushes.LightGray;
|
|
|
|
|
|
BtnLocationIsEnabled = enable;
|
|
|
+
|
|
|
+ //if (AnnotArgs.LinkType == LINK_TYPE.URI)
|
|
|
+ //{
|
|
|
+ // BtnGOorBackVisibility = Visibility.Visible;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // BtnGOorBackVisibility = Visibility.Collapsed;
|
|
|
+ //}
|
|
|
//BtnGOorBack.IsEnabled = false;
|
|
|
}
|
|
|
|