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_Office.CustomControl;
using PDF_Office.Model;
using System.Windows;
using System.Windows.Controls;
using System.IO;
using ComPDFKitViewer.AnnotEvent;
using PDF_Office.ViewModels.Tools;
using Prism.Events;
using PDF_Office.EventAggregators;
using PDF_Office.Helper;
using ComPDFKit.PDFDocument;
using PDFSettings.Settings;
using PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs;
using static PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs.SetPasswordDialogModel;
using PDF_Office.Model.Dialog.ToolsDialogs;
using DryIoc;
using PDF_Office.Model.Dialog.ConverterDialogs;
using static PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySettintgsModel;
using PDF_Office.Views.PropertyPanel.AnnotPanel;
using System.Linq;
using System.Text;
using PDF_Office.Views.Tools;
using System.Windows.Input;
using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
using ImTools;
using PDF_Office.Properties;
using PDF_Office.ViewModels.BOTA;
using PDF_Office.Views.BOTA;
using System.Drawing;
using PDF_Office.ViewModels.Tools.AnnotManager;
namespace PDF_Office.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 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_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 OpenFileInfo OpenFileInfo = null;
public CPDFViewer PDFViewer { get; set; }
public MainContentViewModel mainViewModel { get; set; }
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 ConverterBarContentRegionName { get; set; }
public string TextEditContentRegionName { get; set; }
public string BackgroundContentRegionName { get; set; }
//若point不赋值或从列表中找不到point,系统会提供默认值为(0,0)的新point,所以改用Tuple
public List> FillAndSign = new List>();
///
/// 文档的密码
///
public string PassWord { get; set; }
private Visibility tipVisible = Visibility.Collapsed;
///
/// 顶部提示栏的显示状态
///
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);
if (!value)
{
CanRedo = PDFViewer.UndoManager.CanRedo;
CanUndo = PDFViewer.UndoManager.CanUndo;
}
}
}
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);
}
}
///
/// 水印,背景侧边栏宽度
/// 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);
}
}
private Visibility converterBarContentVisible = Visibility.Collapsed;
private Visibility toolsbarContentVisible = Visibility.Collapsed;
///
/// 控制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)
{
if (mainViewModel.IsBookMode)
{
this.events.GetEvent().Publish(new ReadModePropertyOpenArgs() { Unicode = unicode });
}
SetProperty(ref isPorpertyOpen, value);
}
}
}
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 { Unicode = "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);
}
}
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(260);
}
//关闭BOTA的逻辑在xaml.cs代码里控制,无法绑定后台
}
}
public SecurityInfo SecurityInfo = new SecurityInfo();
private Dictionary regionNameByTabItem;
private Dictionary barContentByTabItem;
private string previousBar = "";
public string CurrentBar = "";
public string unicode = null;
///
/// 用来避免重复触发导航事件的标志符
///
private bool isOpenFile = false;
///
/// 鼠标滚轮缩放的缩放值
///
private double[] zoomLevel = { 1.00f, 10, 25, 50, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
///
/// 注释-链接,提示语
///
private Visibility linkAnnotTipVisibility = Visibility.Collapsed;
public Visibility LinkAnnotTipVisibility
{
get { return linkAnnotTipVisibility; }
set
{
SetProperty(ref linkAnnotTipVisibility, value);
}
}
private string linkAnnotTipText = "Please use the scroll bar, thumbnail tool to locate the target page, click or box the area to select the target range";
private bool isCreateLink = false;
public string LinkAnnotTipText
{
get { return linkAnnotTipText; }
set
{
SetProperty(ref linkAnnotTipText, value);
}
}
#endregion 属性、变量
#region 命令
public DelegateCommand LoadFile { get; set; }
public DelegateCommand Load { get; set; }
public DelegateCommand MouseDown { get; set; }
public DelegateCommand