using ComPDFKit.PDFDocument;
using ComPDFKit.PDFPage;
using ComPDFKitViewer.AnnotEvent;
using ComPDFKitViewer.PdfViewer;
using PDF_Master.Model;
using PDF_Master.ViewModels.Tools;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows;
using System.Windows.Media.Imaging;
using Prism.Commands;
using PDF_Master.Helper;
using Microsoft.Office.Interop.Word;
using static Dropbox.Api.Files.FileCategory;
using PDF_Master.Views.PropertyPanel.AnnotPanel;
using System.Windows.Controls;
using PDF_Master.CustomControl;
using System.Windows.Markup;
using ComPDFKitViewer;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Net;
using System.Diagnostics;
using static Dropbox.Api.TeamLog.TrustedTeamsRequestState;
using System.Windows.Input;
using Prism.Events;
using Prism.Services.Dialogs;
using PDF_Master.Views.BOTA;
using ImTools;
using PDF_Master.ViewModels.Tools.AnnotManager;
namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
{
internal class LinkAnnotPropertyViewModel : BindableBase, INavigationAware
{
#region 文案
private string T_title;
public string T_Title
{
get { return T_title; }
set
{
SetProperty(ref T_title, value);
}
}
private string T_page;
public string T_Page
{
get { return T_page; }
set
{
SetProperty(ref T_page, value);
}
}
private void InitString()
{
T_Title = App.MainPageLoader.GetString("Link_Title");
T_Page = App.MainPageLoader.GetString("Link_Page");
}
#endregion 文案
public AnnotAttribEvent AnnotAttribEvent { get; set; }
private LinkAnnotArgs linkAnnotArgs;
public LinkAnnotArgs LinkAnnotArgs
{
get
{
return linkAnnotArgs;
}
set
{
if (linkAnnotArgs != null)
{
linkAnnotArgs.LinkDrawFinished -= linkAnnotArgs_LinkDrawFinished;
}
linkAnnotArgs = value;
if (linkAnnotArgs != null)
{
linkAnnotArgs.LinkDrawFinished += linkAnnotArgs_LinkDrawFinished;
}
}
}
private AnnotArgsType annotType;
public AnnotArgsType AnnotType
{
get { return annotType; }
set
{
SetProperty(ref annotType, value);
}
}
#region 输入框的验证、设置
private string pageNumTextContent;
public string PageNumTextContent
{
get
{
if (CheckPageNumVaild(out int pageNum, pageNumTextContent))
{
if (LinkAnnotArgs != null)
{
LinkAnnotArgs.DestIndex = pageNum - 1;
LinkAnnotArgs.Content = string.Format($"To Page {LinkAnnotArgs.DestIndex}");
//isTextChanged = (int)AnnotAttribEvent.Attribs[AnnotAttrib.LinkDestIndx] != AnnotArgs.DestIndex ? true : false;
SetImagePreview(LinkAnnotArgs.DestIndex);
}
}
else
{
ImagePreviewVisibility = Visibility.Collapsed;
BtnGOorBackVisibility = Visibility.Collapsed;
BtnLocationIsEnabled = false;
}
return pageNumTextContent;
}
set
{
SetProperty(ref pageNumTextContent, 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 (LinkAnnotArgs != null)
{
LinkAnnotArgs.URI = pageWebTextContent;
LinkAnnotArgs.Content = LinkAnnotArgs.URI;
//isTextChanged = (string)AnnotAttribEvent.Attribs[AnnotAttrib.LinkUri] != AnnotArgs.URI ? true : false;
}
}
return pageWebTextContent;
}
set
{
SetProperty(ref pageWebTextContent, value);
}
}
private string pageMailTextContent;
public string PageMailTextContent
{
get
{
if (CheckPageMailVaild(pageMailTextContent))
{
if (!string.IsNullOrEmpty(pageMailTextContent) && LinkAnnotArgs != null)
{
LinkAnnotArgs.URI = "mailto:" + pageMailTextContent.Trim();
LinkAnnotArgs.Content = LinkAnnotArgs.URI;
//isTextChanged = (string)AnnotAttribEvent.Attribs[AnnotAttrib.LinkUri] != AnnotArgs.URI ? true : false;
}
}
return pageMailTextContent;
}
set
{
SetProperty(ref pageMailTextContent, value);
}
}
///
/// 设置预文本内容
///
private string pageNumPlaceHoldText = "输入目标页面";
public string PageNumPlaceHoldText
{
get { return pageNumPlaceHoldText; }
set
{
SetProperty(ref pageNumPlaceHoldText, value);
}
}
///
/// 是否显示输入框下方提示文案
///
private Visibility showPageNumTip = Visibility.Collapsed;
public Visibility ShowPageNumTip
{
get { return showPageNumTip; }
set
{
SetProperty(ref showPageNumTip, value);
}
}
///
/// 输入框下方提示文案
///
private string pageNumTipText = "Page number error.";
public string PageNumTipText
{
get { return pageNumTipText; }
set
{
SetProperty(ref pageNumTipText, value);
}
}
private bool pageNumTextIsEnabled = false;
public bool PageNumTextIsEnabled
{
get { return pageNumTextIsEnabled; }
set
{
SetProperty(ref pageNumTextIsEnabled, value);
}
}
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 pageWebTipText = "Invalid link.";
public string PageWebTipText
{
get { return pageWebTipText; }
set
{
SetProperty(ref pageWebTipText, value);
}
}
private bool pageMailTextIsEnabled = false;
public bool PageMailTextIsEnabled
{
get { return pageMailTextIsEnabled; }
set
{
SetProperty(ref pageMailTextIsEnabled, value);
}
}
private string pageMailPlaceHoldText = "输入您要跳转邮件地址";
public string PageMailPlaceHoldText
{
get { return pageMailPlaceHoldText; }
set
{
SetProperty(ref pageMailPlaceHoldText, value);
}
}
private Visibility showPageMailTip = Visibility.Collapsed;
public Visibility ShowPageMailTip
{
get { return showPageMailTip; }
set
{
SetProperty(ref showPageMailTip, value);
}
}
private string pageMailTipText = "The email is invalid.Please enter a valid email address.";
public string PageMailTipText
{
get { return pageMailTipText; }
set
{
SetProperty(ref pageMailTipText, value);
}
}
#endregion 输入框的验证、设置
#region 按钮、图片的设置
private bool btnLocationIsEnabled = false;
public bool BtnLocationIsEnabled
{
get { return btnLocationIsEnabled; }
set
{
SetProperty(ref btnLocationIsEnabled, value);
}
}
private bool btnLocationIsChecked = false;
public bool BtnLocationIsChecked
{
get { return btnLocationIsChecked; }
set
{
SetProperty(ref btnLocationIsChecked, value);
}
}
private WriteableBitmap previewImage;
public WriteableBitmap PreviewImage
{
get { return previewImage; }
set
{
SetProperty(ref previewImage, value);
}
}
private int imagePreviewWidth = 196;
public int ImagePreviewWidth
{
get { return imagePreviewWidth; }
set
{
SetProperty(ref imagePreviewWidth, value);
}
}
private int imagePreviewHeight = 256;
public int ImagePreviewHeight
{
get { return imagePreviewHeight; }
set
{
SetProperty(ref imagePreviewHeight, value);
}
}
private Visibility imagePreviewVisibility = Visibility.Collapsed;
public Visibility ImagePreviewVisibility
{
get { return imagePreviewVisibility; }
set
{
SetProperty(ref imagePreviewVisibility, value);
}
}
private Visibility btnGOorBackVisibility = Visibility.Collapsed;
public Visibility BtnGOorBackVisibility
{
get { return btnGOorBackVisibility; }
set
{
SetProperty(ref btnGOorBackVisibility, value);
}
}
private string btnGOorBackContent = "GO";
public string BtnGOorBackContent
{
get { return btnGOorBackContent; }
set
{
SetProperty(ref btnGOorBackContent, value);
}
}
private bool btnLinkPageIsChecked = true;
public bool BtnLinkPageIsChecked
{
get { return btnLinkPageIsChecked; }
set
{
SetProperty(ref btnLinkPageIsChecked, value);
}
}
private bool btnLinkWebIsChecked = false;
public bool BtnLinkWebIsChecked
{
get { return btnLinkWebIsChecked; }
set
{
SetProperty(ref btnLinkWebIsChecked, value);
}
}
private bool btnLinkMailIsChecked = false;
public bool BtnLinkMailIsChecked
{
get { return btnLinkMailIsChecked; }
set
{
SetProperty(ref btnLinkMailIsChecked, value);
}
}
#endregion 按钮、图片的设置
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;
private int historyPageIndex = 0;
private CPDFViewer pdfViewer;
private CPDFDocument document;
private Button btnGOorBack = null;
private LinkAnnotProperty linkAnnot;
private AnnotTransfer propertyPanel;
private ViewContentViewModel viewContentViewModel;
public IRegionManager region;
public IDialogService dialogs;
public IEventAggregator events;
#region 命令
public DelegateCommand