using Microsoft.Win32;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ComPDFKitViewer.PdfViewer;
using Prism.Regions;
using DryIoc;
using System.Diagnostics;
using Prism.Services.Dialogs;
using PDF_Office.CustomControl;
using PDF_Office.Model;
using System.Windows;
using System.Windows.Controls;
using System.IO;
using PDFSettings;
using ComPDFKitViewer.AnnotEvent;
using PDF_Office.ViewModels.Tools;
using PDF_Office.Views;
using Prism.Events;
using PDF_Office.EventAggregators;
using PDF_Office.Views.EditTools.Background;
namespace PDF_Office.ViewModels
{
public class ViewContentViewModel : BindableBase, INavigationAware
{
#region 属性、变量
public CPDFViewer PDFViewer { get; set; }
private MainContentViewModel mainViewModel { get; set; }
public IRegionManager region;
public IDialogService dialogs;
public string ViwerRegionName { get; set; }
public string BOTARegionName { get; set; }
public string PropertyRegionName { get; set; }
public string ToolContentRegionName { get; set; }
public string ToolsBarContentRegionName { get; set; }
public string ReadModeRegionName { get; set; }
public string ConverterBarContentRegionName { get; set; }
public string TextEditContentRegionName { get; set; }
public string BackgroundContentRegionName { get; set; }
///
/// 底部工具栏 RegionName
///
public string BottomToolRegionName { get; set; }
private bool _isInPageEdit = false;
///
/// 是否处于页面编辑模式,用于执行undo redo 的具体操作
///
public bool isInPageEdit
{
get { return _isInPageEdit; }
set
{
_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;
///
/// 是否正在加载中
///
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
{
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
{
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
{
openBOTA = value;
if (openBOTA && BOTAWidth.Value <= 48)
{
BOTAWidth = new GridLength(256);
}
}
}
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 };
#endregion 属性、变量
#region 命令
public DelegateCommand LoadFile { get; set; }
public DelegateCommand Load { get; set; }
public DelegateCommand