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;
using static PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySettintgsModel;
using PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs;
using PDF_Master.Properties;
using PDF_Master.Views.PageEdit;
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 void InitString()
{
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 ViewContentViewModel viewContentViewModel;
private IDialogService dialogs;
private IEventAggregator eventor;
///
/// 用于筛选多窗体时间的唯一识别码
///
private string unicode = null;
///
/// 项数据集合
///
public ObservableCollection PageEditItems { get; set; }
///
/// 页面范围的项集合
///
public ObservableCollection PageRangeItems { get; set; }
#region 属性
///
/// 是否是第一次加载
///
private bool isFirstLoad = true;
///
/// 是否正在拖拽排序中
///
private bool DragSorting = false;
///
/// 记录多选项中最后一项的索引
///
private 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 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;
///
/// 隐藏页面尺寸
///
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;
#endregion 属性
#region 命令
public DelegateCommand