using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using ComPDFKitViewer.PdfViewer;
using PDF_Master.Model;
using System.Collections.ObjectModel;
using PDF_Master.Model.PageEdit;
using Prism.Commands;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Controls.Primitives;
using System.Diagnostics;
using System.Windows.Controls;
using System.Windows.Threading;
using Prism.Events;
using PDF_Master.EventAggregators;
using System.Windows.Input;
using PDF_Master.Helper;
using Microsoft.Win32;
using ComPDFKit.PDFDocument;
using PDF_Master.CustomControl;
using PDF_Master.Model.HomePageToolsDialogs;
using System.IO;
using System.Text.RegularExpressions;
namespace PDF_Master.ViewModels.PageEdit
{
public class PageEditContentViewModel : BindableBase, INavigationAware
{
#region 文案
private string T_title;
public string T_Title
{
get { return T_title; }
set
{
SetProperty(ref T_title, value);
}
}
private void InitString()
{
T_Title = App.MainPageLoader.GetString("Thumbnails_Title");
}
#endregion
private CPDFViewer PDFViewer;
private ViewContentViewModel viewContentViewModel;
private IDialogService dialogs;
private IEventAggregator eventor;
///
/// 用于筛选多窗体时间的唯一识别码
///
private string unicode = null;
///
/// Undo操作记录栈
/// 只有插入、移位、旋转,倒序需要记录
///
private Stack UndoStack = new Stack();
///
/// Redo操作记录栈
///
private Stack RedoStack = new Stack();
///
/// 项数据集合
///
public ObservableCollection PageEditItems { get; set; }
///
/// 页面范围的项集合
///
public ObservableCollection PageRangeItems { get; set; }
#region 属性
///
/// 是否是第一次加载
///
private bool isFirstLoad = true;
///
/// 记录多选项中最后一项的索引
///
private int maxSelectedIndex = 0;
private Visibility showTip = Visibility.Collapsed;
///
/// 是否显示渐隐提示
///
public Visibility ShowTip
{
get { return showTip; }
set
{
SetProperty(ref showTip, value);
}
}
private Visibility isLoading = Visibility.Collapsed;
///
/// 是否正在处理中
///
public Visibility IsLoading
{
get { return isLoading; }
set
{
SetProperty(ref isLoading, value);
}
}
private int listSelecedIndex;
///
/// 缩略图选中项的索引
///
public int ListSelectedIndex
{
get { return listSelecedIndex; }
set
{
SetProperty(ref listSelecedIndex, value);
//显示页面范围选择控件
TbPageRangeVisibility = Visibility.Visible;
TbPageRange = (ListSelectedIndex + 1).ToString();
TxtPageInputVisibility = Visibility.Collapsed;
if(IsBOTAThumb==Visibility.Visible&&PDFViewer!=null)
{
PDFViewer.GoToPage(listSelecedIndex);
}
}
}
private bool isMultiSelected;
///
/// 是否有多选 用于判断倒序和替换功能
///
public bool IsMultiSelected
{
get { return isMultiSelected; }
set
{
SetProperty(ref isMultiSelected, value);
}
}
private int comboxSelectIndex;
///
/// 下拉框选项集合
///
public int ComboxSelectIndex
{
get { return comboxSelectIndex; }
set
{
SetProperty(ref comboxSelectIndex, value);
//选中指定的页面范围
SuitPageRange(comboxSelectIndex);
//隐藏tb页面范围显示控件
TbPageRangeVisibility = Visibility.Collapsed;
}
}
private Visibility tbPageRangeVisibility = Visibility.Visible;
///
/// 页面范围的文本显示
///
public Visibility TbPageRangeVisibility
{
get { return tbPageRangeVisibility; }
set
{
SetProperty(ref tbPageRangeVisibility, value);
if (value == Visibility.Visible)
{
comboxSelectIndex = -1;
}
}
}
private string tbPageRange;
///
/// 页面范围显示的内容
///
public string TbPageRange
{
get { return tbPageRange; }
set
{
SetProperty(ref tbPageRange, value);
if(string.IsNullOrEmpty(TbPageRange))
{
TbPageRange = "请输入范围";
}
}
}
private Visibility txtPageInputVisibility = Visibility.Collapsed;
///
/// 页面自定义输入框的显示
///
public Visibility TxtPageInputVisibility
{
get { return txtPageInputVisibility; }
set
{
SetProperty(ref txtPageInputVisibility, value);
}
}
///
/// 页面缩放状态,-1 为最小值,1为最大值
///
private int zoomIndex = 0;
public int ZoomIndex
{
get { return zoomIndex; }
set
{
SetProperty(ref zoomIndex, value);
}
}
private string toastText = App.MainPageLoader.GetString("PageEdit_Failed");
///
/// Toast提示
///
public string ToastText
{
get { return toastText; }
set
{
SetProperty(ref toastText, value);
}
}
private Visibility isBOTAThumb = Visibility.Collapsed;
///
/// 是否是BOTA侧边栏的缩略图
///
public Visibility IsBOTAThumb
{
get { return isBOTAThumb; }
set
{
SetProperty(ref isBOTAThumb, value);
}
}
private Visibility hasShowPageSize = Visibility.Collapsed;
///
/// 是否显示页面尺寸
///
public Visibility HasShowPageSize
{
get { return hasShowPageSize; }
set
{
SetProperty(ref hasShowPageSize, value);
}
}
private bool canUndo;
///
/// 是否可以进行Undo操作
///
public bool CanUndo
{
get { return canUndo; }
set
{
SetProperty(ref canUndo, value);
if (viewContentViewModel != null)
{
viewContentViewModel.CanUndo = this.CanUndo;
}
}
}
private bool canRedo;
///
/// 是否可以进行Redo操作
///
public bool CanRedo
{
get { return canRedo; }
set
{
SetProperty(ref canRedo, value);
if(viewContentViewModel!=null)
{
viewContentViewModel.CanRedo = this.CanRedo;
}
}
}
private bool canPaste = false;
///
/// 是否可以粘贴
///
public bool CanPaste
{
get { return canPaste; }
set
{
SetProperty(ref canPaste, value);
}
}
///
/// 页面缩放的范围
///
private List ItemSizes = new List() {
new Size(104,142),
new Size(208, 294),
new Size(312,441)
};
//选中的页面集合
private List selectedPageList = new List();
#endregion
#region 命令
public DelegateCommand