|
@@ -39,8 +39,24 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
|
|
|
private IEventAggregator eventor;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 用于筛选多窗体时间的唯一识别码
|
|
|
+ /// </summary>
|
|
|
private string unicode = null;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Undo操作记录栈
|
|
|
+ /// 只有插入、移位、旋转,倒序需要记录
|
|
|
+ /// </summary>
|
|
|
+ private Stack<PageEditItem> UndoStack = new Stack<PageEditItem>();
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Redo操作记录栈
|
|
|
+ /// </summary>
|
|
|
+
|
|
|
+ private Stack<PageEditItem> RedoStack = new Stack<PageEditItem>();
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 项数据集合
|
|
|
/// </summary>
|
|
@@ -103,6 +119,10 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
TbPageRangeVisibility = Visibility.Visible;
|
|
|
TbPageRange = (ListSelectedIndex + 1).ToString();
|
|
|
TxtPageInputVisibility = Visibility.Collapsed;
|
|
|
+ if(IsBOTAThumb==Visibility.Visible&&PDFViewer!=null)
|
|
|
+ {
|
|
|
+ PDFViewer.GoToPage(listSelecedIndex);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -196,6 +216,33 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private string toastText;
|
|
|
+ /// <summary>
|
|
|
+ /// Toast提示
|
|
|
+ /// </summary>
|
|
|
+ public string ToastText
|
|
|
+ {
|
|
|
+ get { return toastText; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref toastText, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private Visibility isBOTAThumb = Visibility.Collapsed;
|
|
|
+ /// <summary>
|
|
|
+ /// 是否是BOTA侧边栏的缩略图
|
|
|
+ /// </summary>
|
|
|
+ public Visibility IsBOTAThumb
|
|
|
+ {
|
|
|
+ get { return isBOTAThumb; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref isBOTAThumb, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region 命令
|
|
@@ -219,7 +266,7 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
/// <summary>
|
|
|
/// 插入文件命令
|
|
|
/// </summary>
|
|
|
- public DelegateCommand<Object> InsertCommand { get; set; }
|
|
|
+ public DelegateCommand<object> InsertCommand { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 拆分文件
|
|
@@ -290,6 +337,7 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
//订阅页面刷新事件
|
|
|
eventAggregator.GetEvent<PageEditRefreshEvent>().Subscribe(OnPageEditRefreshEvent, e => e.Unicode == unicode);
|
|
|
|
|
|
+
|
|
|
RefreshPageRangeItem();
|
|
|
}
|
|
|
|
|
@@ -468,6 +516,11 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
pages.Add(i);
|
|
|
}
|
|
|
}
|
|
|
+ if(pages.Count<=1)
|
|
|
+ {
|
|
|
+ ShowToast("请至少选择两个图片进行倒序操作。");
|
|
|
+ return;
|
|
|
+ }
|
|
|
pages.Sort();
|
|
|
|
|
|
for (int i = 0; i < pages.Count; i++)
|
|
@@ -535,10 +588,7 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
/// </summary>
|
|
|
private void ZoomInCommandEvent()
|
|
|
{
|
|
|
- for (int i = 0; i < PageEditItems.Count; i++)
|
|
|
- {
|
|
|
- PageEditItems[i].ItemSize = new Size(PageEditItems[i].ItemSize.Width * 2, PageEditItems[i].ItemSize.Height * 2);
|
|
|
- }
|
|
|
+ ChangeItemSize(new Size(PageEditItems[0].ItemSize.Width *2, PageEditItems[0].ItemSize.Height *2));
|
|
|
ZoomIndex++;
|
|
|
|
|
|
NotifyUIToRefresh();
|
|
@@ -548,13 +598,22 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
/// 缩小页面
|
|
|
/// </summary>
|
|
|
private void ZoomOutCommandEvent()
|
|
|
+ {
|
|
|
+ ChangeItemSize(new Size(PageEditItems[0].ItemSize.Width / 2, PageEditItems[0].ItemSize.Height / 2));
|
|
|
+ ZoomIndex--;
|
|
|
+ NotifyUIToRefresh();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="newsize"></param>
|
|
|
+ public void ChangeItemSize(Size newsize)
|
|
|
{
|
|
|
for (int i = 0; i < PageEditItems.Count; i++)
|
|
|
{
|
|
|
- PageEditItems[i].ItemSize = new Size(PageEditItems[i].ItemSize.Width / 2, PageEditItems[i].ItemSize.Height / 2);
|
|
|
+ PageEditItems[i].ItemSize = newsize;
|
|
|
}
|
|
|
- ZoomIndex--;
|
|
|
- NotifyUIToRefresh();
|
|
|
}
|
|
|
|
|
|
private bool CanZoomIn()
|
|
@@ -709,14 +768,47 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
#endregion
|
|
|
|
|
|
#region 方法
|
|
|
+ /// <summary>
|
|
|
+ /// 退出页面编辑面试,回到阅读页
|
|
|
+ /// </summary>
|
|
|
+ public void BackToPDFViewer(int PageIndex)
|
|
|
+ {
|
|
|
+ PDFViewer.GoToPage(PageIndex);
|
|
|
+ viewContentViewModel.ExitToolMode();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 显示Toast提示
|
|
|
+ /// </summary>
|
|
|
+ private void ShowToast(string content)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(content))
|
|
|
+ {
|
|
|
+ ToastText = content;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ToastText = "操作失败";
|
|
|
+ }
|
|
|
+ ShowTip = Visibility.Visible;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 通知UI刷新页面范围
|
|
|
+ /// 或通过xaml来设置选中项
|
|
|
/// </summary>vb nmjvcx
|
|
|
- private void NotifyUIToRefresh()
|
|
|
+ private void NotifyUIToRefresh(List<int> pageRange=null)
|
|
|
{
|
|
|
- //通知UI刷新页面范围
|
|
|
- eventor.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs() { Unicode = unicode });
|
|
|
+ if (pageRange == null || pageRange.Count <= 0)
|
|
|
+ {
|
|
|
+ //通知UI刷新页面范围
|
|
|
+ eventor.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs(unicode));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //通知UI刷新页面范围
|
|
|
+ eventor.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs(unicode,NotifyType.SelectItems,pageRange));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -960,7 +1052,7 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
if (pageRange.Item2 - pageRange.Item1 > 30)
|
|
|
{
|
|
|
//范围较大时,通知UI获取更准确的刷新范围
|
|
|
- eventor.GetEvent<PageEditNotifyEvent>().Publish(new PageEditNotifyEventArgs() { Unicode = unicode });
|
|
|
+ NotifyUIToRefresh();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1119,7 +1211,7 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
/// </summary>
|
|
|
private void GetSourceItems(bool isFirstLoad)
|
|
|
{
|
|
|
- if (isFirstLoad)
|
|
|
+ if (isFirstLoad||IsBOTAThumb==Visibility.Visible)
|
|
|
{
|
|
|
PageEditItems.Clear();
|
|
|
for (int i = 0; i < PDFViewer.Document.PageCount; i++)
|
|
@@ -1204,7 +1296,7 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- if (PageEditItems.Count >= pageIndex + 1 && !PageEditItems[pageIndex].IsGetImage)
|
|
|
+ if (PageEditItems.Count >= pageIndex + 1)
|
|
|
{
|
|
|
PixelFormat fmt = PixelFormats.Bgra32;
|
|
|
BitmapSource bps = BitmapSource.Create(w, h, 96.0, 96.0, fmt, null, thumb, (w * fmt.BitsPerPixel + 7) / 8);
|
|
@@ -1240,14 +1332,22 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
{
|
|
|
navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
|
|
|
navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
|
+ bool isBOTA = false;
|
|
|
+ navigationContext.Parameters.TryGetValue<bool>(ParameterNames.BOTAThumb, out isBOTA);
|
|
|
if (PDFViewer != null)
|
|
|
{
|
|
|
if (isFirstLoad)
|
|
|
{
|
|
|
PDFViewer.OnThumbnailGenerated += PDFViewer_OnThumbnailGenerated;
|
|
|
+ PDFViewer.InfoChanged += PDFViewer_InfoChanged;
|
|
|
ZoomIndex = 0;
|
|
|
|
|
|
}
|
|
|
+ //BOTA缩略图时,显示不同的菜单栏
|
|
|
+ if(isBOTA)
|
|
|
+ {
|
|
|
+ IsBOTAThumb = Visibility.Visible;
|
|
|
+ }
|
|
|
|
|
|
GetSourceItems(isFirstLoad);
|
|
|
|
|
@@ -1257,6 +1357,14 @@ namespace PDF_Office.ViewModels.PageEdit
|
|
|
isFirstLoad = false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void PDFViewer_InfoChanged(object sender, KeyValuePair<string, object> e)
|
|
|
+ {
|
|
|
+ if(e.Key== "PageNum")
|
|
|
+ {
|
|
|
+ NotifyUIToRefresh(new List<int> { (int)e.Value});
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
}
|
|
|
}
|