|
@@ -1,10 +1,14 @@
|
|
-using PDF_Master.EventAggregators;
|
|
|
|
|
|
+using ComPDFKit.PDFDocument;
|
|
|
|
+using ComPDFKitViewer.PdfViewer;
|
|
|
|
+using ImTools;
|
|
|
|
+using PDF_Master.EventAggregators;
|
|
using PDF_Master.Helper;
|
|
using PDF_Master.Helper;
|
|
using PDF_Master.Model.PageEdit;
|
|
using PDF_Master.Model.PageEdit;
|
|
using PDF_Master.ViewModels.PageEdit;
|
|
using PDF_Master.ViewModels.PageEdit;
|
|
using Prism.Events;
|
|
using Prism.Events;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
+using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Text.RegularExpressions;
|
|
@@ -84,6 +88,11 @@ namespace PDF_Master.Views.PageEdit
|
|
//是否正在从外部拖入文件
|
|
//是否正在从外部拖入文件
|
|
public bool isDragingEnter { get; set; } = false;
|
|
public bool isDragingEnter { get; set; } = false;
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 是否正在从 App 拖出文件
|
|
|
|
+ /// </summary>
|
|
|
|
+ public bool isExtractEnter { get; set; } = false;
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 是否需要自动滚动
|
|
/// 是否需要自动滚动
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -95,8 +104,6 @@ namespace PDF_Master.Views.PageEdit
|
|
|
|
|
|
private PageEditContentViewModel viewModel;
|
|
private PageEditContentViewModel viewModel;
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
public PageEditContent()
|
|
public PageEditContent()
|
|
{
|
|
{
|
|
InitializeComponent();
|
|
InitializeComponent();
|
|
@@ -120,7 +127,6 @@ namespace PDF_Master.Views.PageEdit
|
|
eventAggregator.GetEvent<CleanSelectAllEvent>().Subscribe(CleanSelectAll, e => e.Unicode == unicode);
|
|
eventAggregator.GetEvent<CleanSelectAllEvent>().Subscribe(CleanSelectAll, e => e.Unicode == unicode);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
private void Timer_Tick(object sender, EventArgs e)
|
|
private void Timer_Tick(object sender, EventArgs e)
|
|
{
|
|
{
|
|
PulishEvent();
|
|
PulishEvent();
|
|
@@ -148,13 +154,13 @@ namespace PDF_Master.Views.PageEdit
|
|
|
|
|
|
private void OneNotifyEvent(PageEditNotifyEventArgs e)
|
|
private void OneNotifyEvent(PageEditNotifyEventArgs e)
|
|
{
|
|
{
|
|
-
|
|
|
|
switch (e.Type)
|
|
switch (e.Type)
|
|
{
|
|
{
|
|
case NotifyType.RefreshPage:
|
|
case NotifyType.RefreshPage:
|
|
//计算当前区域的页面范围后传递回VM
|
|
//计算当前区域的页面范围后传递回VM
|
|
PulishEvent();
|
|
PulishEvent();
|
|
break;
|
|
break;
|
|
|
|
+
|
|
case NotifyType.SelectItems:
|
|
case NotifyType.SelectItems:
|
|
//根据Vm的参数选中部分页面
|
|
//根据Vm的参数选中部分页面
|
|
if (e.PageRange.Count == 1)
|
|
if (e.PageRange.Count == 1)
|
|
@@ -175,12 +181,14 @@ namespace PDF_Master.Views.PageEdit
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+
|
|
case NotifyType.PageCountChanged:
|
|
case NotifyType.PageCountChanged:
|
|
- if(GridBOTAHeader.Visibility == Visibility.Visible)
|
|
|
|
|
|
+ if (GridBOTAHeader.Visibility == Visibility.Visible)
|
|
{
|
|
{
|
|
viewModel?.GetSourceItems(false);
|
|
viewModel?.GetSourceItems(false);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -192,9 +200,8 @@ namespace PDF_Master.Views.PageEdit
|
|
ListPageEdit.SelectedIndex = viewModel.PDFViewer.CurrentIndex;
|
|
ListPageEdit.SelectedIndex = viewModel.PDFViewer.CurrentIndex;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
#region UI事件
|
|
#region UI事件
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 每次显示的时候就触发事件,刷新所有图片
|
|
/// 每次显示的时候就触发事件,刷新所有图片
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -213,15 +220,9 @@ namespace PDF_Master.Views.PageEdit
|
|
PulishEvent();
|
|
PulishEvent();
|
|
//当前页面发生变化时通过ScrollChanged事件来刷新图片
|
|
//当前页面发生变化时通过ScrollChanged事件来刷新图片
|
|
isFirstScrollChange = true;
|
|
isFirstScrollChange = true;
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 鼠标滚轮滚动时触发的事件
|
|
/// 鼠标滚轮滚动时触发的事件
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -258,13 +259,14 @@ namespace PDF_Master.Views.PageEdit
|
|
PulishEvent();
|
|
PulishEvent();
|
|
}
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
|
|
|
+ #endregion UI事件
|
|
|
|
|
|
#region 方法
|
|
#region 方法
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 发布事件
|
|
/// 发布事件
|
|
/// </summary>
|
|
/// </summary>
|
|
- public void PulishEvent()
|
|
|
|
|
|
+ public void PulishEvent()
|
|
{
|
|
{
|
|
//判空 避免某些乱七八糟的情况下异常
|
|
//判空 避免某些乱七八糟的情况下异常
|
|
if (ListPageEdit != null & ListPageEdit.Items.Count > 0)
|
|
if (ListPageEdit != null & ListPageEdit.Items.Count > 0)
|
|
@@ -280,9 +282,6 @@ namespace PDF_Master.Views.PageEdit
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 获取滑轨的垂直偏移量,结合item总数和Item尺寸以及间隔,来估算实际展示的item范围
|
|
/// 获取滑轨的垂直偏移量,结合item总数和Item尺寸以及间隔,来估算实际展示的item范围
|
|
/// 返回值为页面范围 从1开始
|
|
/// 返回值为页面范围 从1开始
|
|
@@ -342,7 +341,7 @@ namespace PDF_Master.Views.PageEdit
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
|
|
|
+ #endregion 方法
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 输入框显示时,自动获取焦点
|
|
/// 输入框显示时,自动获取焦点
|
|
@@ -361,12 +360,12 @@ namespace PDF_Master.Views.PageEdit
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- if (e.LeftButton == MouseButtonState.Pressed&&!isDragingEnter)
|
|
|
|
|
|
+ if (e.LeftButton == MouseButtonState.Pressed && !isDragingEnter)
|
|
{
|
|
{
|
|
-
|
|
|
|
//鼠标框选逻辑
|
|
//鼠标框选逻辑
|
|
if (startChoose)
|
|
if (startChoose)
|
|
{
|
|
{
|
|
|
|
+ isExtractEnter = false;
|
|
var position = e.GetPosition(ListPageEdit);
|
|
var position = e.GetPosition(ListPageEdit);
|
|
if (position.X < 5 || position.X > ListPageEdit.ActualWidth - 5 || position.Y < 5 || position.Y > ListPageEdit.ActualHeight - 5)
|
|
if (position.X < 5 || position.X > ListPageEdit.ActualWidth - 5 || position.Y < 5 || position.Y > ListPageEdit.ActualHeight - 5)
|
|
{
|
|
{
|
|
@@ -380,47 +379,95 @@ namespace PDF_Master.Views.PageEdit
|
|
DoSelectItems();
|
|
DoSelectItems();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
//拖拽排序的逻辑
|
|
//拖拽排序的逻辑
|
|
- var pos = e.GetPosition(ListPageEdit);
|
|
|
|
- if (pos.Y < 0 || pos.Y > ListPageEdit.ActualHeight)
|
|
|
|
- {
|
|
|
|
- LineInset.Visibility = Visibility.Collapsed;
|
|
|
|
- ImgPicture.Visibility = Visibility.Collapsed;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- HitTestResult result = VisualTreeHelper.HitTest(ListPageEdit, pos);
|
|
|
|
- if (result == null)
|
|
|
|
- {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- var listBoxItem = CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
|
- if (listBoxItem == null)
|
|
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- return;
|
|
|
|
- }
|
|
|
|
- isDragingEnter = false;
|
|
|
|
- tempItem = listBoxItem.DataContext as PageEditItem;
|
|
|
|
|
|
+ var pos = e.GetPosition(ListPageEdit);
|
|
|
|
+ if (pos.Y < 0 || pos.Y > ListPageEdit.ActualHeight)
|
|
|
|
+ {
|
|
|
|
+ LineInset.Visibility = Visibility.Collapsed;
|
|
|
|
+ ImgPicture.Visibility = Visibility.Collapsed;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ HitTestResult result = VisualTreeHelper.HitTest(ListPageEdit, pos);
|
|
|
|
+ if (result == null)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ var listBoxItem = CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
|
+ if (listBoxItem == null)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ isDragingEnter = false;
|
|
|
|
+ tempItem = listBoxItem.DataContext as PageEditItem;
|
|
|
|
|
|
- var item_pos = e.GetPosition(listBoxItem);
|
|
|
|
- if (item_pos != null)
|
|
|
|
- {
|
|
|
|
- item_x = item_pos.X;
|
|
|
|
- item_y = item_pos.Y;
|
|
|
|
|
|
+ var item_pos = e.GetPosition(listBoxItem);
|
|
|
|
+ if (item_pos != null)
|
|
|
|
+ {
|
|
|
|
+ item_x = item_pos.X;
|
|
|
|
+ item_y = item_pos.Y;
|
|
|
|
+ }
|
|
|
|
+ var scroll = GetScrollHost(ListPageEdit);
|
|
|
|
+
|
|
|
|
+ //string filename = Guid.NewGuid().ToString() + ".pdf";
|
|
|
|
+ //string tempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), filename);
|
|
|
|
+ //System.IO.File.Create(tempPath);
|
|
|
|
+ //string[] files = new string[1];
|
|
|
|
+ //files[0] = tempPath;
|
|
|
|
+
|
|
|
|
+ string filename = Guid.NewGuid().ToString() + ".pdf";
|
|
|
|
+ string dir = System.IO.Path.Combine(System.IO.Path.GetTempPath());
|
|
|
|
+ if (!System.IO.Directory.Exists(dir))
|
|
|
|
+ {
|
|
|
|
+ System.IO.Directory.CreateDirectory(dir);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ string tempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), filename);
|
|
|
|
+
|
|
|
|
+ #region 提取文件
|
|
|
|
+
|
|
|
|
+ List<int> pagenums = new List<int>();
|
|
|
|
+ for (int i = 0; i < viewModel.PageEditItems.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ if (viewModel.PageEditItems[i].Selected)
|
|
|
|
+ {
|
|
|
|
+ pagenums.Add(viewModel.PageEditItems[i].PageNumber);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (int i = 0; i < pagenums.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ string path = CommonHelper.CreateFilePath(tempPath);
|
|
|
|
+ CPDFDocument savedoc = CPDFDocument.CreateDocument();
|
|
|
|
+ bool result2 = savedoc.ImportPages(viewModel.PDFViewer.Document, pagenums[i].ToString());
|
|
|
|
+ if (!result2)
|
|
|
|
+ {
|
|
|
|
+ savedoc.Release();
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ result2 = savedoc.WriteToFilePath(path);
|
|
|
|
+ if (!result2)
|
|
|
|
+ {
|
|
|
|
+ savedoc.Release();
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ savedoc.Release();//释放内存
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion 提取文件
|
|
|
|
+
|
|
|
|
+ string[] files = new string[1];
|
|
|
|
+ files[0] = tempPath;
|
|
|
|
+
|
|
|
|
+ DataObject dataObj = new DataObject(DataFormats.FileDrop, files);
|
|
|
|
+
|
|
|
|
+ //禁用从窗体拖拽到桌面的方法
|
|
|
|
+ //DataObject dataObj = new DataObject(listBoxItem);
|
|
|
|
+ isExtractEnter = true;
|
|
|
|
+ DragDrop.DoDragDrop(ListPageEdit, dataObj, DragDropEffects.Move);
|
|
|
|
+ Mouse.Capture(ListPageEdit);
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- var scroll = GetScrollHost(ListPageEdit);
|
|
|
|
-
|
|
|
|
- string filename = Guid.NewGuid().ToString() + ".pdf";
|
|
|
|
- string tempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), filename);
|
|
|
|
- System.IO.File.Create(tempPath);
|
|
|
|
- string[] files = new string[1];
|
|
|
|
- files[0] = tempPath;
|
|
|
|
- //禁用从窗体拖拽到桌面的方法
|
|
|
|
- //DataObject dataObj = new DataObject(DataFormats.FileDrop, files);
|
|
|
|
- DataObject dataObj = new DataObject(listBoxItem);
|
|
|
|
- DragDrop.DoDragDrop(ListPageEdit, dataObj, DragDropEffects.Copy);
|
|
|
|
- Mouse.Capture(ListPageEdit);
|
|
|
|
- return;
|
|
|
|
}
|
|
}
|
|
RectChoose.Visibility = Visibility.Collapsed;
|
|
RectChoose.Visibility = Visibility.Collapsed;
|
|
startChoose = false;
|
|
startChoose = false;
|
|
@@ -469,14 +516,14 @@ namespace PDF_Master.Views.PageEdit
|
|
}
|
|
}
|
|
//选中了item 时,不能框选
|
|
//选中了item 时,不能框选
|
|
startChoose = false;
|
|
startChoose = false;
|
|
|
|
+ isDragingEnter = false;
|
|
|
|
|
|
-
|
|
|
|
//更改系统的选中规则,选中状态下,鼠标松开后取消选中
|
|
//更改系统的选中规则,选中状态下,鼠标松开后取消选中
|
|
//方便实现多选拖拽功能
|
|
//方便实现多选拖拽功能
|
|
if (listBoxItem.IsSelected == true && !Keyboard.IsKeyDown(Key.LeftCtrl))
|
|
if (listBoxItem.IsSelected == true && !Keyboard.IsKeyDown(Key.LeftCtrl))
|
|
{
|
|
{
|
|
e.Handled = true;
|
|
e.Handled = true;
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void ListPageEdit_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
private void ListPageEdit_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
@@ -576,7 +623,7 @@ namespace PDF_Master.Views.PageEdit
|
|
/// <param name="e"></param>
|
|
/// <param name="e"></param>
|
|
private async void ListPageEdit_Drop(object sender, DragEventArgs e)
|
|
private async void ListPageEdit_Drop(object sender, DragEventArgs e)
|
|
{
|
|
{
|
|
- isDragingEnter = false;
|
|
|
|
|
|
+ //isDragingEnter = false;
|
|
needScroll = false;
|
|
needScroll = false;
|
|
if (!isDraging)
|
|
if (!isDraging)
|
|
{
|
|
{
|
|
@@ -590,51 +637,51 @@ namespace PDF_Master.Views.PageEdit
|
|
string[] file = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
string[] file = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
if (file != null)
|
|
if (file != null)
|
|
{
|
|
{
|
|
- return;
|
|
|
|
- }
|
|
|
|
- #region 功能付费锁
|
|
|
|
- #endregion
|
|
|
|
|
|
+ #region 从外部拖拽插入文件
|
|
|
|
|
|
- #region 从外部拖拽插入文件
|
|
|
|
- if (isDragingEnter)
|
|
|
|
- {
|
|
|
|
- //注释从外部拖拽插入文件的功能
|
|
|
|
- //var files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
|
|
- //Array.Reverse(files);
|
|
|
|
- //foreach(string file in files)
|
|
|
|
- //{
|
|
|
|
- // System.IO.FileInfo info = new System.IO.FileInfo(file);
|
|
|
|
- // if(System.IO.Path.GetExtension(file).ToLower()==".pdf"&&info.Length>0)
|
|
|
|
- // {
|
|
|
|
- // int index = InsertIndex == -1 ? 0 : InsertIndex;
|
|
|
|
- // viewModel.InsertFromFile(index, file);
|
|
|
|
- // viewModel.ReloadAfterOption(true,true,new Tuple<int, int>(0,ListPageEdit.Items.Count));
|
|
|
|
- // }
|
|
|
|
- //}
|
|
|
|
- ////其他文件 则新增一个页签打开
|
|
|
|
- //// DragAddTab.Invoke(dragingEnterPath, new RoutedEventArgs());//底层库需要加一个 Load(TPDFDocument)的接口
|
|
|
|
- //LineInset.Visibility = Visibility.Collapsed;
|
|
|
|
- //ImgPicture.Visibility = Visibility.Collapsed;
|
|
|
|
- //isDragingEnter = false;
|
|
|
|
- return;
|
|
|
|
|
|
+ if (isDragingEnter)
|
|
|
|
+ {
|
|
|
|
+ //注释从外部拖拽插入文件的功能
|
|
|
|
+ var files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
|
|
+ Array.Reverse(files);
|
|
|
|
+ foreach (string item in files)
|
|
|
|
+ {
|
|
|
|
+ System.IO.FileInfo info = new System.IO.FileInfo(item);
|
|
|
|
+ if (System.IO.Path.GetExtension(item).ToLower() == ".pdf" && info.Length > 0)
|
|
|
|
+ {
|
|
|
|
+ int index = InsertIndex == -1 ? 0 : InsertIndex;
|
|
|
|
+ await viewModel.InsertFromFile(index, item);
|
|
|
|
+ viewModel.ReloadAfterOption(true, true, new Tuple<int, int>(0, ListPageEdit.Items.Count));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //其他文件 则新增一个页签打开
|
|
|
|
+ // DragAddTab.Invoke(dragingEnterPath, new RoutedEventArgs());//底层库需要加一个 Load(TPDFDocument)的接口
|
|
|
|
+ LineInset.Visibility = Visibility.Collapsed;
|
|
|
|
+ ImgPicture.Visibility = Visibility.Collapsed;
|
|
|
|
+ isDragingEnter = false;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion 从外部拖拽插入文件
|
|
|
|
+
|
|
|
|
+ //return;
|
|
}
|
|
}
|
|
- #endregion
|
|
|
|
|
|
|
|
var pos = e.GetPosition(ListPageEdit);
|
|
var pos = e.GetPosition(ListPageEdit);
|
|
var result = VisualTreeHelper.HitTest(ListPageEdit, pos);
|
|
var result = VisualTreeHelper.HitTest(ListPageEdit, pos);
|
|
- //if (result == null)
|
|
|
|
- //{
|
|
|
|
- // //超出当前可控区域
|
|
|
|
- // ExitDraging();
|
|
|
|
- // return;
|
|
|
|
- //}
|
|
|
|
- ////查找元数据
|
|
|
|
|
|
+ if (result == null)
|
|
|
|
+ {
|
|
|
|
+ //超出当前可控区域
|
|
|
|
+ ExitDraging();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ //查找元数据
|
|
//var sourcePerson = e.Data.GetData(typeof(StackPanel)) as StackPanel;
|
|
//var sourcePerson = e.Data.GetData(typeof(StackPanel)) as StackPanel;
|
|
- //if (sourcePerson == null)
|
|
|
|
- //{
|
|
|
|
- // ExitDraging();
|
|
|
|
- // return;
|
|
|
|
- //}
|
|
|
|
|
|
+ if (tempItem == null)
|
|
|
|
+ {
|
|
|
|
+ ExitDraging();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
//查找目标数据
|
|
//查找目标数据
|
|
int targetindex = 0;//目标插入位置
|
|
int targetindex = 0;//目标插入位置
|
|
if (InsertIndex != -1)
|
|
if (InsertIndex != -1)
|
|
@@ -679,7 +726,7 @@ namespace PDF_Master.Views.PageEdit
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- viewModel.DragToSort(targetindex,pages);
|
|
|
|
|
|
+ viewModel.DragToSort(targetindex, pages);
|
|
ExitDraging();
|
|
ExitDraging();
|
|
isDraging = false;
|
|
isDraging = false;
|
|
}
|
|
}
|
|
@@ -704,7 +751,7 @@ namespace PDF_Master.Views.PageEdit
|
|
try
|
|
try
|
|
{
|
|
{
|
|
//将付费锁逻辑提前,避免因弹窗显示后导致虚影无法消失问题
|
|
//将付费锁逻辑提前,避免因弹窗显示后导致虚影无法消失问题
|
|
- if(!viewModel.viewContentViewModel.IAPBeforeFunction())
|
|
|
|
|
|
+ if (!viewModel.viewContentViewModel.IAPBeforeFunction())
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -715,12 +762,11 @@ namespace PDF_Master.Views.PageEdit
|
|
|
|
|
|
//从外部拖入文件时 返回
|
|
//从外部拖入文件时 返回
|
|
string[] file = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
string[] file = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
- if(file!=null)
|
|
|
|
|
|
+ if (file != null)
|
|
{
|
|
{
|
|
- return;
|
|
|
|
|
|
+ //return;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
//滚动后有 位置不准确 要减去滚动偏移量
|
|
//滚动后有 位置不准确 要减去滚动偏移量
|
|
//控制线的位置
|
|
//控制线的位置
|
|
var pos = e.GetPosition(ListPageEdit);
|
|
var pos = e.GetPosition(ListPageEdit);
|
|
@@ -740,14 +786,15 @@ namespace PDF_Master.Views.PageEdit
|
|
//return;
|
|
//return;
|
|
}
|
|
}
|
|
|
|
|
|
- #region 计算虚影位置
|
|
|
|
|
|
+ #region 计算虚影位置
|
|
|
|
+
|
|
//xaml层 要设置 虚影控件为左上
|
|
//xaml层 要设置 虚影控件为左上
|
|
double xPos = 0;
|
|
double xPos = 0;
|
|
double yPos = 0;
|
|
double yPos = 0;
|
|
//内部拖动
|
|
//内部拖动
|
|
if (!isDragingEnter)
|
|
if (!isDragingEnter)
|
|
{
|
|
{
|
|
- if(tempItem!=null)
|
|
|
|
|
|
+ if (tempItem != null)
|
|
{
|
|
{
|
|
ImgPicture.Width = tempItem.ItemSize.Width;
|
|
ImgPicture.Width = tempItem.ItemSize.Width;
|
|
ImgPicture.Height = tempItem.ItemSize.Height;
|
|
ImgPicture.Height = tempItem.ItemSize.Height;
|
|
@@ -769,16 +816,18 @@ namespace PDF_Master.Views.PageEdit
|
|
}
|
|
}
|
|
|
|
|
|
ImgPicture.Margin = new Thickness(xPos, yPos, 0, 0);
|
|
ImgPicture.Margin = new Thickness(xPos, yPos, 0, 0);
|
|
- #endregion
|
|
|
|
|
|
+
|
|
|
|
+ #endregion 计算虚影位置
|
|
|
|
|
|
#region 计算插入标记位置
|
|
#region 计算插入标记位置
|
|
|
|
+
|
|
var scroll = GetScrollHost(ListPageEdit);
|
|
var scroll = GetScrollHost(ListPageEdit);
|
|
if (listBoxItem != null)
|
|
if (listBoxItem != null)
|
|
{
|
|
{
|
|
//虚拟化影响到该值计算
|
|
//虚拟化影响到该值计算
|
|
var p = VisualTreeHelper.GetOffset(listBoxItem);//计算控件在容器中的偏移(位置)
|
|
var p = VisualTreeHelper.GetOffset(listBoxItem);//计算控件在容器中的偏移(位置)
|
|
LineInset.Visibility = Visibility.Visible;
|
|
LineInset.Visibility = Visibility.Visible;
|
|
- if(!isDragingEnter)
|
|
|
|
|
|
+ if (!isDragingEnter)
|
|
{
|
|
{
|
|
ImgPicture.Visibility = Visibility.Visible;
|
|
ImgPicture.Visibility = Visibility.Visible;
|
|
}
|
|
}
|
|
@@ -807,7 +856,7 @@ namespace PDF_Master.Views.PageEdit
|
|
{
|
|
{
|
|
InsertIndex = ListPageEdit.Items.IndexOf(listBoxItem.DataContext as PageEditItem) + 1;
|
|
InsertIndex = ListPageEdit.Items.IndexOf(listBoxItem.DataContext as PageEditItem) + 1;
|
|
}
|
|
}
|
|
- Console.WriteLine("InsertIndex:{0}\r\n",InsertIndex);
|
|
|
|
|
|
+ Console.WriteLine("InsertIndex:{0}\r\n", InsertIndex);
|
|
//MidLane.Y1 = p.Y - scroll.VerticalOffset;//向下滑动后要减去滑动值
|
|
//MidLane.Y1 = p.Y - scroll.VerticalOffset;//向下滑动后要减去滑动值
|
|
LineInset.Y1 = p.Y;
|
|
LineInset.Y1 = p.Y;
|
|
if (LineInset.Y1 < 0)//避免超出上边界
|
|
if (LineInset.Y1 < 0)//避免超出上边界
|
|
@@ -821,7 +870,8 @@ namespace PDF_Master.Views.PageEdit
|
|
LineInset.Y2 = 0;
|
|
LineInset.Y2 = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- #endregion
|
|
|
|
|
|
+
|
|
|
|
+ #endregion 计算插入标记位置
|
|
|
|
|
|
//暂时处理 鼠标移出边框时,虚影的显示问题
|
|
//暂时处理 鼠标移出边框时,虚影的显示问题
|
|
if (pos.Y <= 30 || pos.Y >= ListPageEdit.ActualHeight - 10)
|
|
if (pos.Y <= 30 || pos.Y >= ListPageEdit.ActualHeight - 10)
|
|
@@ -839,6 +889,7 @@ namespace PDF_Master.Views.PageEdit
|
|
}
|
|
}
|
|
|
|
|
|
#region 靠近上下边界时,自动滚动,离边界越近,滚动速度越快
|
|
#region 靠近上下边界时,自动滚动,离边界越近,滚动速度越快
|
|
|
|
+
|
|
speed = 0;
|
|
speed = 0;
|
|
if (pos.Y >= ListPageEdit.ActualHeight - 30)
|
|
if (pos.Y >= ListPageEdit.ActualHeight - 30)
|
|
{
|
|
{
|
|
@@ -855,26 +906,26 @@ namespace PDF_Master.Views.PageEdit
|
|
|
|
|
|
var v = scroll.VerticalOffset;
|
|
var v = scroll.VerticalOffset;
|
|
scroll.ScrollToVerticalOffset(v + speed);//触发连续滚动
|
|
scroll.ScrollToVerticalOffset(v + speed);//触发连续滚动
|
|
- #endregion
|
|
|
|
|
|
+
|
|
|
|
+ #endregion 靠近上下边界时,自动滚动,离边界越近,滚动速度越快
|
|
}
|
|
}
|
|
catch
|
|
catch
|
|
{
|
|
{
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void ListBoxItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
private void ListBoxItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
{
|
|
- if(GridBOTAHeader.Visibility == Visibility.Visible&&viewModel.PDFViewer!=null)
|
|
|
|
|
|
+ if (GridBOTAHeader.Visibility == Visibility.Visible && viewModel.PDFViewer != null)
|
|
{
|
|
{
|
|
- if(Keyboard.Modifiers == ModifierKeys.Shift||Keyboard.Modifiers== ModifierKeys.Control)
|
|
|
|
|
|
+ if (Keyboard.Modifiers == ModifierKeys.Shift || Keyboard.Modifiers == ModifierKeys.Control)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var item = (sender as ListBoxItem).DataContext as PageEditItem;
|
|
var item = (sender as ListBoxItem).DataContext as PageEditItem;
|
|
- if(item != null)
|
|
|
|
|
|
+ if (item != null)
|
|
{
|
|
{
|
|
- viewModel.PDFViewer.GoToPage(item.PageNumber-1);
|
|
|
|
|
|
+ viewModel.PDFViewer.GoToPage(item.PageNumber - 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -902,7 +953,7 @@ namespace PDF_Master.Views.PageEdit
|
|
ItemSuitAcutalWidth(e.NewSize.Width);
|
|
ItemSuitAcutalWidth(e.NewSize.Width);
|
|
}
|
|
}
|
|
|
|
|
|
- if(e.NewSize.Width>0)
|
|
|
|
|
|
+ if (e.NewSize.Width > 0)
|
|
{
|
|
{
|
|
//宽度变化后刷新一次视图 修复重复点击缩略图后图片不显示的问题
|
|
//宽度变化后刷新一次视图 修复重复点击缩略图后图片不显示的问题
|
|
PulishEvent();
|
|
PulishEvent();
|
|
@@ -915,7 +966,7 @@ namespace PDF_Master.Views.PageEdit
|
|
if ((bool)TbnTwoLine.IsChecked)
|
|
if ((bool)TbnTwoLine.IsChecked)
|
|
{
|
|
{
|
|
var itemwidth = (width - 140) / 2;
|
|
var itemwidth = (width - 140) / 2;
|
|
- if(itemwidth<0)
|
|
|
|
|
|
+ if (itemwidth < 0)
|
|
{
|
|
{
|
|
itemwidth = width / 4;
|
|
itemwidth = width / 4;
|
|
}
|
|
}
|
|
@@ -943,24 +994,39 @@ namespace PDF_Master.Views.PageEdit
|
|
/// <param name="e"></param>
|
|
/// <param name="e"></param>
|
|
private void Grid_PreviewDragEnter(object sender, DragEventArgs e)
|
|
private void Grid_PreviewDragEnter(object sender, DragEventArgs e)
|
|
{
|
|
{
|
|
-
|
|
|
|
- var file = (System.Array)e.Data.GetData(DataFormats.FileDrop);
|
|
|
|
- if (file == null)//为null 表示内部拖动 触发的
|
|
|
|
- {
|
|
|
|
- return;
|
|
|
|
|
|
+ var files = (System.Array)e.Data.GetData(DataFormats.FileDrop);
|
|
|
|
+ if (files == null)//为null 表示内部拖动 触发的
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- isDragingEnter = false;
|
|
|
|
- foreach (string f in file)
|
|
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- System.IO.FileInfo info = new System.IO.FileInfo(f);
|
|
|
|
- //只要拖拽进来的文件里包含有pdf格式文件,就允许拖入
|
|
|
|
- if (System.IO.Path.GetExtension(f).ToLower() == ".pdf" && info.Length > 0)
|
|
|
|
|
|
+ isDragingEnter = false;
|
|
|
|
+
|
|
|
|
+ foreach (string file in files)
|
|
{
|
|
{
|
|
- isDragingEnter = true;
|
|
|
|
|
|
+ if (File.Exists(file))
|
|
|
|
+ {
|
|
|
|
+ if (isExtractEnter)
|
|
|
|
+ {
|
|
|
|
+ isDragingEnter = false;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ System.IO.FileInfo info = new System.IO.FileInfo(file);
|
|
|
|
+ //只要拖拽进来的文件里包含有pdf格式文件,就允许拖入
|
|
|
|
+ if (System.IO.Path.GetExtension(file).ToLower() == ".pdf" && info.Length > 0)
|
|
|
|
+ {
|
|
|
|
+ isDragingEnter = true;
|
|
|
|
+ isExtractEnter = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- DragDropHelper.DragEnter(this, e);
|
|
|
|
|
|
+ DragDropHelper.DragEnter(this, e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void Grid_DragLeave(object sender, DragEventArgs e)
|
|
private void Grid_DragLeave(object sender, DragEventArgs e)
|
|
@@ -970,7 +1036,7 @@ namespace PDF_Master.Views.PageEdit
|
|
|
|
|
|
private void Grid_Drop(object sender, DragEventArgs e)
|
|
private void Grid_Drop(object sender, DragEventArgs e)
|
|
{
|
|
{
|
|
- DragDropHelper.Drop(this,e);
|
|
|
|
|
|
+ DragDropHelper.Drop(this, e);
|
|
}
|
|
}
|
|
|
|
|
|
private void ListBoxItem_DragLeave(object sender, DragEventArgs e)
|
|
private void ListBoxItem_DragLeave(object sender, DragEventArgs e)
|
|
@@ -982,13 +1048,12 @@ namespace PDF_Master.Views.PageEdit
|
|
|
|
|
|
private void Border_Drop(object sender, DragEventArgs e)
|
|
private void Border_Drop(object sender, DragEventArgs e)
|
|
{
|
|
{
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private async void TextBoxEx_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
|
private async void TextBoxEx_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
{
|
|
var text = sender as TextBox;
|
|
var text = sender as TextBox;
|
|
- if(text!=null)
|
|
|
|
|
|
+ if (text != null)
|
|
{
|
|
{
|
|
await Task.Delay(50);
|
|
await Task.Delay(50);
|
|
text.Focus();
|
|
text.Focus();
|
|
@@ -998,7 +1063,7 @@ namespace PDF_Master.Views.PageEdit
|
|
private void TextBoxEx_TextChanged(object sender, TextChangedEventArgs e)
|
|
private void TextBoxEx_TextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
{
|
|
var text = sender as TextBox;
|
|
var text = sender as TextBox;
|
|
- if(text.Visibility==Visibility.Visible&&string.IsNullOrEmpty(text.Text))
|
|
|
|
|
|
+ if (text.Visibility == Visibility.Visible && string.IsNullOrEmpty(text.Text))
|
|
{
|
|
{
|
|
text.Focus();
|
|
text.Focus();
|
|
}
|
|
}
|
|
@@ -1024,33 +1089,32 @@ namespace PDF_Master.Views.PageEdit
|
|
//点击在listbox列表内,具体某一项时,上面的判断调整可能失效,需要补充条件
|
|
//点击在listbox列表内,具体某一项时,上面的判断调整可能失效,需要补充条件
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- var button =CommonHelper.FindVisualParent<Button>(visual.VisualHit);
|
|
|
|
- if(button!=null)
|
|
|
|
|
|
+ var button = CommonHelper.FindVisualParent<Button>(visual.VisualHit);
|
|
|
|
+ if (button != null)
|
|
{
|
|
{
|
|
- //点击在按钮时
|
|
|
|
|
|
+ //点击在按钮时
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var combox = CommonHelper.FindVisualParent<ComboBox>(visual.VisualHit);
|
|
var combox = CommonHelper.FindVisualParent<ComboBox>(visual.VisualHit);
|
|
- if(combox!=null)
|
|
|
|
|
|
+ if (combox != null)
|
|
{
|
|
{
|
|
- //点击在下拉框时
|
|
|
|
|
|
+ //点击在下拉框时
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
viewModel.lostfocus(e);
|
|
viewModel.lostfocus(e);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void Grid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
private void Grid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
{
|
|
var visual = VisualTreeHelper.HitTest(GridHeader, Mouse.GetPosition(GridHeader));
|
|
var visual = VisualTreeHelper.HitTest(GridHeader, Mouse.GetPosition(GridHeader));
|
|
- if(visual==null)
|
|
|
|
|
|
+ if (visual == null)
|
|
{
|
|
{
|
|
//点击区域不是二级菜单区域的Grid时,返回
|
|
//点击区域不是二级菜单区域的Grid时,返回
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var menuItem = CommonHelper.FindVisualParent<ComboBoxItem>(visual.VisualHit);
|
|
var menuItem = CommonHelper.FindVisualParent<ComboBoxItem>(visual.VisualHit);
|
|
- if(menuItem!=null)
|
|
|
|
|
|
+ if (menuItem != null)
|
|
{
|
|
{
|
|
//点击位置为下拉菜单子项时,返回
|
|
//点击位置为下拉菜单子项时,返回
|
|
return;
|
|
return;
|
|
@@ -1066,7 +1130,7 @@ namespace PDF_Master.Views.PageEdit
|
|
{
|
|
{
|
|
//因为需要获取准确的选中页面,因此把入口放在.cs代码里
|
|
//因为需要获取准确的选中页面,因此把入口放在.cs代码里
|
|
List<int> lists = new List<int>();
|
|
List<int> lists = new List<int>();
|
|
- foreach(PageEditItem item in ListPageEdit.SelectedItems)
|
|
|
|
|
|
+ foreach (PageEditItem item in ListPageEdit.SelectedItems)
|
|
{
|
|
{
|
|
lists.Add(item.PageNumber);
|
|
lists.Add(item.PageNumber);
|
|
}
|
|
}
|
|
@@ -1099,4 +1163,4 @@ namespace PDF_Master.Views.PageEdit
|
|
e.Handled = regex.IsMatch(e.Text);
|
|
e.Handled = regex.IsMatch(e.Text);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|