using Microsoft.Win32;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ComPDFKitViewer.PdfViewer;
using Prism.Regions;
using Prism.Services.Dialogs;
using PDF_Master.CustomControl;
using PDF_Master.Model;
using System.Windows;
using System.Windows.Controls;
using System.IO;
using ComPDFKitViewer.AnnotEvent;
using PDF_Master.ViewModels.Tools;
using Prism.Events;
using PDF_Master.EventAggregators;
using PDF_Master.Helper;
using ComPDFKit.PDFDocument;
using PDFSettings;
using PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs;
using static PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs.SetPasswordDialogModel;
using PDF_Master.Model.Dialog.ToolsDialogs;
using DryIoc;
using PDF_Master.Model.Dialog.ConverterDialogs;
using static PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySettintgsModel;
using PDF_Master.Views.PropertyPanel.AnnotPanel;
using System.Linq;
using System.Text;
using PDF_Master.Views.Tools;
using System.Windows.Input;
using PDF_Master.ViewModels.PropertyPanel.AnnotPanel;
using ImTools;
using PDF_Master.Properties;
using PDF_Master.ViewModels.BOTA;
using PDF_Master.Views.BOTA;
using System.Drawing;
using PDF_Master.ViewModels.Tools.AnnotManager;
using PDF_Master.Model.FillAndSign;
using PDF_Master.Views.PropertyPanel.ViewModular;
using PDF_Master.Views.PropertyPanel;
using System.Windows.Threading;
using Dropbox.Api.Files;
using System.Windows.Media;
using Color = System.Windows.Media.Color;
using PDF_Master.Views;
using System.Windows.Documents;
using ComPDFKit.PDFPage;
using ComPDFKitViewer;
using SplitMode = PDF_Master.EventAggregators.SplitMode;
using System.Windows.Resources;
using System.Windows.Media.Imaging;
using ComPDFKit.PDFWatermark;
using PDF_Master.ViewModels.PageEdit;
using System.Windows.Annotations;
using PDFReader_WPF.Helper;
namespace PDF_Master.ViewModels
{
public class ViewContentViewModel : BindableBase, INavigationAware
{
#region 文案
private string T_file;
public string T_File
{
get { return T_file; }
set
{
SetProperty(ref T_file, value);
}
}
private string T_save;
public string T_Save
{
get { return T_save; }
set
{
SetProperty(ref T_save, value);
}
}
private string T_undo;
public string T_Undo
{
get { return T_undo; }
set
{
SetProperty(ref T_undo, value);
}
}
private string T_redo;
public string T_Redo
{
get { return T_redo; }
set
{
SetProperty(ref T_redo, value);
}
}
private string T_annotation;
public string T_Annotation
{
get { return T_annotation; }
set
{
SetProperty(ref T_annotation, value);
}
}
private string T_pageEdit;
public string T_PageEdit
{
get { return T_pageEdit; }
set
{
SetProperty(ref T_pageEdit, value);
}
}
private string T_converter;
public string T_Converter
{
get { return T_converter; }
set
{
SetProperty(ref T_converter, value);
}
}
private string T_fillSign;
public string T_FillSign
{
get { return T_fillSign; }
set
{
SetProperty(ref T_fillSign, value);
}
}
private string T_tools;
public string T_Tools
{
get { return T_tools; }
set
{
SetProperty(ref T_tools, value);
}
}
private string T_print;
public string T_Print
{
get { return T_print; }
set
{
SetProperty(ref T_print, value);
}
}
private string T_share;
public string T_Share
{
get { return T_share; }
set
{
SetProperty(ref T_share, value);
}
}
private string T_properties;
public string T_Properties
{
get { return T_properties; }
set
{
SetProperty(ref T_properties, value);
}
}
private string _T_EditPDF;
public string T_EditPDF
{
get { return _T_EditPDF; }
set
{
SetProperty(ref _T_EditPDF, value);
}
}
private void InitStirng()
{
T_File = App.MainPageLoader.GetString("ViewTopToolbar_File");
T_Save = App.MainPageLoader.GetString("ViewTopToolbar_Save");
T_Undo = App.MainPageLoader.GetString("ViewTopToolbar_Undo");
T_Redo = App.MainPageLoader.GetString("ViewTopToolbar_Redo");
T_Annotation = App.MainPageLoader.GetString("ViewTopToolbar_Annotation");
T_PageEdit = App.MainPageLoader.GetString("ViewTopToolbar_PageEdit");
T_EditPDF = App.MainPageLoader.GetString("ViewTopToolbar_T_EditPDF");
T_Converter = App.MainPageLoader.GetString("ViewTopToolbar_Converter");
T_FillSign = App.MainPageLoader.GetString("ViewTopToolbar_Fill&Sign");
T_Tools = App.MainPageLoader.GetString("ViewTopToolbar_Tools");
T_Print = App.MainPageLoader.GetString("ViewTopToolbar_Print");
T_Share = App.MainPageLoader.GetString("ViewTopToolbar_Share");
T_Properties = App.MainPageLoader.GetString("ViewTopToolbar_Properties");
}
#endregion 文案
#region 属性、变量
///
/// 显示 隐藏注释
///
public bool IsHiddenAnnot = false;
public bool IsMultiSelected { get; set; } = false;
public OpenFileInfo OpenFileInfo = null;
public CPDFViewer PDFViewer { get; set; }
public bool ReadModeIsShowProperty { get; set; } = false;
public MainContentViewModel mainViewModel { get; set; }
public BottomToolContentViewModel bottom { get; set; }
public BOTAContentViewModel botaViewModel { get; set; }
private CPDFWatermark watermark;
public bool IsSettingOut = false;
public IRegionManager region;
public IDialogService dialogs;
public IEventAggregator events;
public bool IsRightMenuCreateLink { get => isCreateLink; set => isCreateLink = value; }
public string ViwerRegionName { get; set; }
///
/// 分屏视图的region名称
///
public string SplitViewerRegionName { get; set; }
///
/// OCR视图名称
///
public string OCRViewerRegionName { get; set; }
public string BOTARegionName { get; set; }
public string PropertyRegionName { get; set; }
public string ToolContentRegionName { get; set; }
public string ToolsBarContentRegionName { get; set; }
///
/// 顶部提示的Content
///
public string TipContentRegionName { get; set; }
public string LeftTipContentRegionName { get; set; }
//便签弹窗
public string NotePopupRegionName { get; set; }
public string ReadModeRegionName { get; set; }
public string TextEditContentRegionName { get; set; }
public string BackgroundContentRegionName { get; set; }
public PasswordInfo PasswordInfo = new PasswordInfo();
//若point不赋值或从列表中找不到point,系统会提供默认值为(0,0)的新point,所以改用Tuple
public List FillAndSign = new List();
///
/// 签名列表
///
public List> AnnotSignatures = new List>();
///
/// 文档的密码
///
public string PassWord { get; set; }
public PasswordInfo passwordInfo = new PasswordInfo();
private Visibility tipVisible = Visibility.Collapsed;
///
/// 顶部提示栏的显示状态
///
public bool IsFileLocked = false;
public Visibility TipVisible
{
get { return tipVisible; }
set
{
SetProperty(ref tipVisible, value);
}
}
private Visibility leftTipVisible = Visibility.Collapsed;
public Visibility LeftTipVisible
{
get { return leftTipVisible; }
set
{
SetProperty(ref leftTipVisible, value);
}
}
private Visibility notePopupVisible = Visibility.Collapsed;
public Visibility NotePopupVisible
{
get { return notePopupVisible; }
set
{
SetProperty(ref notePopupVisible, value);
}
}
public bool IsNoteAdd = false;
private double canvasNoteLeft;
public double CanvasNoteLeft
{
get { return canvasNoteLeft; }
set
{
SetProperty(ref canvasNoteLeft, value);
}
}
private double canvasNoteBottom;
public double CanvasNoteBottom
{
get { return canvasNoteBottom; }
set
{
SetProperty(ref canvasNoteBottom, value);
}
}
///
/// 底部工具栏 RegionName
///
public string BottomToolRegionName { get; set; }
private bool _isInPageEdit = false;
///
/// 是否处于页面编辑模式,用于执行undo redo 的具体操作
///
public bool isInPageEdit
{
get { return _isInPageEdit; }
set
{
SetProperty(ref _isInPageEdit, value);
}
}
public Action PageEditUndo { get; set; }
public Action PageEditRedo { get; set; }
///
///工具条
///0:收起
///40:显示
///
private int toolRowHeight = 40;
public int ToolRowHeight
{
get { return toolRowHeight; }
set
{
SetProperty(ref toolRowHeight, value);
}
}
private GridLength _ToolTooRow = new GridLength(40);
public GridLength ToolTooRow
{
get { return _ToolTooRow; }
set
{
SetProperty(ref _ToolTooRow, value);
}
}
///
/// 水印,背景侧边栏宽度
/// 0:收起
/// 260:显示
///
private int propertyColumnWidth = 0;
public int PropertyColumnWidth
{
get { return propertyColumnWidth; }
set
{
SetProperty(ref propertyColumnWidth, value);
}
}
private int gridToolRow = 1;
///
/// 控制ToolContent的Row
///
public int GridToolRow
{
get { return gridToolRow; }
set
{
SetProperty(ref gridToolRow, value);
}
}
private int gridToolRowSpan = 3;
///
/// 控制ToolContent的RowSpan
///
public int GridToolRowSpan
{
get { return gridToolRowSpan; }
set
{
SetProperty(ref gridToolRowSpan, value);
}
}
private Visibility toolContentVisible = Visibility.Collapsed;
///
/// 控制Content的显示 用于显示水印、贝茨码、密文等功能模块
/// 留意:显示前需要先注入内容、设置好行和跨行数
///
public Visibility ToolContentVisible
{
get { return toolContentVisible; }
set
{
SetProperty(ref toolContentVisible, value);
}
}
private Visibility gridVisibility = Visibility.Visible;
///
/// 是否正在加载中
///
public Visibility GridVisibility
{
get { return gridVisibility; }
set
{
SetProperty(ref gridVisibility, value);
}
}
private Visibility isLoading = Visibility.Collapsed;
private Visibility ocrContentVisible = Visibility.Collapsed;
public Visibility OCRContentVisible
{
get { return ocrContentVisible; }
set
{
SetProperty(ref ocrContentVisible, value);
}
}
///
/// 是否正在加载中
///
public Visibility IsLoading
{
get { return isLoading; }
set
{
SetProperty(ref isLoading, value);
}
}
/////
///// 控制ToolsBarContent的显示
///// 留意:显示前需要先注入内容、设置好行和跨行数
/////
//public Visibility ConverterBarContentVisible
//{
// get { return converterBarContentVisible; }
// set
// {
// SetProperty(ref converterBarContentVisible, value);
// }
//}
private Visibility toolsBarContentVisible = Visibility.Collapsed;
///
/// 控制ToolsBarContent的显示
/// 留意:显示前需要先注入内容、设置好行和跨行数
///
public Visibility ToolsBarContentVisible
{
get { return toolsBarContentVisible; }
set
{
SetProperty(ref toolsBarContentVisible, value);
}
}
private Visibility textEditToolContentVisible = Visibility.Collapsed;
///
/// 控制ToolsBarContent的显示
/// 留意:显示前需要先注入内容、设置好行和跨行数
///
public Visibility TextEditToolContentVisible
{
get { return textEditToolContentVisible; }
set
{
SetProperty(ref textEditToolContentVisible, value);
}
}
private bool isPorpertyOpen = false;
///
/// 属性栏是否展开
///
public bool IsPropertyOpen
{
get { return isPorpertyOpen; }
set
{
//如果设置为手动展开属性面板时,则不响应代码控制的展开
//或者手动点击按钮时 也展开
if (Settings.Default.AppProperties.InitialVIew.AutoExpandProperty || FromClick)
{
//阅读模式 不显示属性面板
//if (mainViewModel.IsBookMode)
//{
// this.events.GetEvent().Publish(new ReadModePropertyOpenArgs() { Unicode = unicode });
//}
SetProperty(ref isPorpertyOpen, value);
}
}
}
///
/// 是否是点击属性面板按钮
///
private bool FromClick = false;
private Visibility isReadMode = Visibility.Visible;
///
///是否为阅读模式
///
public Visibility IsReadMode
{
get { return isReadMode; }
set
{
SetProperty(ref isReadMode, value);
}
}
private bool canSave;
///
/// 是否可以保存
///
public bool CanSave
{
get { return canSave; }
set
{
if (events != null && canSave == false)
this.events.GetEvent().Publish(new FillAndSigntEventArgs { Action = "Clear", AppUnicode = unicode });
SetProperty(ref canSave, value);
}
}
private bool canUndo;
///
/// 是否可以进行Undo
///
public bool CanUndo
{
get { return canUndo; }
set
{
SetProperty(ref canUndo, value);
}
}
private bool canRedo;
///
/// 是否可以进行Redo
///
public bool CanRedo
{
get { return canRedo; }
set
{
SetProperty(ref canRedo, value);
}
}
///
/// 定义BOTA展开后的最小宽度,小于等于该宽度时无法再缩小宽度,再往左边拖动便是收起BOTA
///
public double BOTAMiniWidth = 260;
private GridLength botaWidth = new GridLength(48);
///
/// BOTA栏的宽度
///
public GridLength BOTAWidth
{
get { return botaWidth; }
set
{
SetProperty(ref botaWidth, value);
if (botaWidth.Value <= 48)
{
OpenBOTA = false;
}
}
}
private int selectedIndex;
///
/// 工具栏选中项的索引
///
public int TabSelectedIndex
{
get { return selectedIndex; }
set
{
SetProperty(ref selectedIndex, value);
}
}
private bool openBOTA = false;
///
/// 是否展开BOTA
///
public bool OpenBOTA
{
get { return openBOTA; }
set
{
SetProperty(ref openBOTA, value);
if (openBOTA && BOTAWidth.Value <= 48)
{
BOTAWidth = new GridLength(BOTAMiniWidth);
}
Settings.Default.AppProperties.InitialVIew.RememberBOTA = openBOTA;
//关闭BOTA的逻辑在xaml.cs代码里控制,无法绑定后台
}
}
///
/// 防止自动保存异步导致弹窗出现两次
///
private bool _isPopupInProgress;
public bool IsPopupInProgress
{
get { return _isPopupInProgress; }
set { SetProperty(ref _isPopupInProgress, value); }
}
public SecurityInfo SecurityInfo = new SecurityInfo();
private Dictionary regionNameByTabItem;
private Dictionary barContentByTabItem;
private string previousBar = "";
public string CurrentBar = "";
public string unicode = null;
///
/// 自动保存的定时器
///
private DispatcherTimer autoSaveTimer = new DispatcherTimer();
///
/// 鼠标滚轮缩放的缩放值
///
private double[] zoomLevel = { 1.00f, 10, 25, 50, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000, 2000, 4000, 10000 };
///
/// 注释-链接,提示语
///
private Visibility linkAnnotTipVisibility = Visibility.Collapsed;
public Visibility LinkAnnotTipVisibility
{
get { return linkAnnotTipVisibility; }
set
{
SetProperty(ref linkAnnotTipVisibility, value);
}
}
private string linkAnnotTipText = "Turn to the target page, then click or box area on the page to select the target page where the link will jump.";
private bool isCreateLink = false;
internal bool IsRightMenuSelectedTextAddLink = false;
internal bool IsSelectedTextAddLink = false;
///
/// 上下左右滑动的距离
///
private double scrolloffset = 50;
public string LinkAnnotTipText
{
get { return linkAnnotTipText; }
set
{
SetProperty(ref linkAnnotTipText, value);
}
}
private bool botaState = false;
private bool propertyOpenState = false;
public bool _IsCrop = false;
public bool IsCrop
{
get { return _IsCrop; }
set
{
SetProperty(ref _IsCrop, value);
}
}
#endregion 属性、变量
#region 命令
public DelegateCommand Load { get; set; }
public DelegateCommand MouseDown { get; set; }
public DelegateCommand