using ComPDFKit.PDFDocument;
using ComPDFKit_Conversion.Converter;
using ComPDFKitViewer.PdfViewer;
using Dropbox.Api.Team;
using Microsoft.Win32;
using PDF_Master.CustomControl;
using PDF_Master.EventAggregators;
using PDF_Master.Helper;
using PDF_Master.Model;
using PDF_Master.Model.HomePageToolsDialogs;
using PDF_Master.Model.PageEdit;
using PDF_Master.Properties;
using PDFReader_WPF.Helper;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using WIA;
using static PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySettintgsModel;
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 string T_rotateLeftToolTip;
public string T_RotateLeftToolTip
{
get { return T_rotateLeftToolTip; }
set
{
SetProperty(ref T_rotateLeftToolTip, value);
}
}
private string T_rotateRightToolTip;
public string T_RotateRightToolTip
{
get { return T_rotateRightToolTip; }
set
{
SetProperty(ref T_rotateRightToolTip, value);
}
}
private string T_deleteToolTip;
public string T_DeleteToolTip
{
get { return T_deleteToolTip; }
set
{
SetProperty(ref T_deleteToolTip, value);
}
}
private string T_deleteLook = "";
public string T_DeleteLook
{
get { return T_deleteLook; }
set
{
SetProperty(ref T_deleteLook, value);
}
}
private string t_Insert;
public string T_Insert
{
get { return t_Insert; }
set
{
SetProperty(ref t_Insert, value);
}
}
private string t_InsertFile;
public string T_InsertFile
{
get { return t_InsertFile; }
set
{
SetProperty(ref t_InsertFile, value);
}
}
private string t_InsertaBlankPage;
public string T_InsertaBlankPage
{
get { return t_InsertaBlankPage; }
set
{
SetProperty(ref t_InsertaBlankPage, value);
}
}
private string t_InsertaCustomPage;
public string T_InsertaCustomPage
{
get { return t_InsertaCustomPage; }
set
{
SetProperty(ref t_InsertaCustomPage, value);
}
}
private string t_Extract;
public string T_Extract
{
get { return t_Extract; }
set
{
SetProperty(ref t_Extract, value);
}
}
private string t_Replace;
public string T_Replace
{
get { return t_Replace; }
set
{
SetProperty(ref t_Replace, value);
}
}
private string t_Split;
public string T_Split
{
get { return t_Split; }
set
{
SetProperty(ref t_Split, value);
}
}
private string t_InsertPage;
public string T_InsertPage
{
get { return t_InsertPage; }
set
{
SetProperty(ref t_InsertPage, value);
}
}
private string t_Reverse;
public string T_Reverse
{
get { return t_Reverse; }
set
{
SetProperty(ref t_Reverse, value);
}
}
private string t_ExtractPage;
public string T_ExtractPage
{
get { return t_ExtractPage; }
set
{
SetProperty(ref t_ExtractPage, value);
}
}
private string t_ReplacePage;
public string T_ReplacePage
{
get { return t_ReplacePage; }
set
{
SetProperty(ref t_ReplacePage, value);
}
}
private void InitString()
{
T_InsertFile = App.MainPageLoader.GetString("PageEdit_Insert");
T_Insert = App.MainPageLoader.GetString("PageEdit_InsertFile");
T_InsertaBlankPage = App.MainPageLoader.GetString("PageEdit_InsertaBlankPage");
T_InsertaCustomPage = App.MainPageLoader.GetString("PageEdit_InsertaCustomPage");
T_Extract = App.MainPageLoader.GetString("PageEdit_Extract");
T_Replace = App.MainPageLoader.GetString("PageEdit_Replace");
T_Split = App.MainPageLoader.GetString("PageEdit_Split");
T_InsertPage = App.MainPageLoader.GetString("PageEdit_InsertPage");
T_Reverse = App.MainPageLoader.GetString("PageEdit_Reverse");
T_ExtractPage = App.MainPageLoader.GetString("PageEdit_ExtractPage");
T_ReplacePage = App.MainPageLoader.GetString("PageEdit_ReplacePage");
T_Title = App.MainPageLoader.GetString("Thumbnails_Title");
T_DeleteToolTip = App.MainPageLoader.GetString("ToolTipsPageEdit_Delete");
T_DeleteLook = App.MainPageLoader.GetString("T_DeleteLook");
T_RotateRightToolTip = App.MainPageLoader.GetString("ToolTipsPageEdit_RotateRight");
T_RotateLeftToolTip = App.MainPageLoader.GetString("ToolTipsPageEdit_RotateLeft");
}
#endregion 文案
public CPDFViewer PDFViewer;
public PageEditItem CurrentPageEditItem = null;
public ViewContentViewModel viewContentViewModel;
private IDialogService dialogs;
private IEventAggregator eventor;
///
/// 用于筛选多窗体时间的唯一识别码
///
private string unicode = null;
///
/// 项数据集合
///
public ObservableCollection PageEditItems { get; set; }
///
/// 页面范围的项集合
///
public ObservableCollection PageRangeItems { get; set; }
#region 属性
///
/// 判断是否是添加页面
///
public bool IsAddPages { get; set; } = false;
///
/// 增加两个变量,用于记录当前控件内已经刷新图片的索引值,用于显示页面尺寸大小时,先显示当前范围可见Item的页面尺寸
///
private int startRefreshedIndex = 0;
private int endRefreshedIndex = 0;
///
/// 正在初始化(正在初始化过程中 不发布通知BOTA刷新的事件)
///
public bool Initializing = false;
///
/// 是否是第一次加载
///
private bool isFirstLoad = true;
///
/// 记录多选项中最后一项的索引
///
public int maxSelectedIndex = -1;
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);
if (!IsSelectFormSelf && value >= 0)
{
//显示页面范围选择控件
TxtPageInputVisibility = Visibility.Visible;
TbPageRange = (ListSelectedIndex + 1).ToString();
}
}
}
///
///右键不会选中页面, 不要跳转
///
/// 判断是否是右键选择
private bool isMouseRightButtonDown = false;
public bool IsMouseRightButtonDown
{
get { return isMouseRightButtonDown; }
set { SetProperty(ref isMouseRightButtonDown, value); }
}
///
/// 右键选择索引
///
public int RightSelectedIndex = 0;
///
/// 右键选择 集合
///
public List RightSelectedIndexs = new List();
///
/// 多选
///
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);
//隐藏tb页面范围显示控件
TxtPageInputVisibility = Visibility.Collapsed;
//选中指定的页面范围
SuitPageRange(comboxSelectIndex);
}
}
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);
}
}
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 showedPageSize = Visibility.Collapsed;
///
/// 显示页面尺寸
///
public Visibility ShowedPageSize
{
get { return showedPageSize; }
set
{
SetProperty(ref showedPageSize, value);
//if (IsBOTAThumb != Visibility.Visible)
//{
// if (value == Visibility.Visible)
// {
// HidePageSize = Visibility.Collapsed;
// }
// else
// {
// HidePageSize = Visibility.Visible;
// }
//}
}
}
private Visibility hidePageSize = Visibility.Collapsed;
///
/// 隐藏页面尺寸
///
public Visibility HidePageSize
{
get { return hidePageSize; }
set
{
SetProperty(ref hidePageSize, value);
}
}
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();
///
/// 是否是下拉框选项改变引起的选项变更事件
///
private bool IsSelectFormSelf = false;
public bool IsShowPageSize = false;
public string Txt = Properties.Resources.txtex;
public string Word = Properties.Resources.wordex;
public string Ppt = Properties.Resources.pptex;
public string Excel = Properties.Resources.excelex;
public string Html = Properties.Resources.htmlex;
public string Image = Properties.Resources.imageex;
public string Pdf = Properties.Resources.pdf;
#endregion 属性
#region 命令
public DelegateCommand