|
@@ -104,9 +104,12 @@ namespace PDF_Master.Views.PageEdit
|
|
|
|
|
|
private PageEditContentViewModel viewModel;
|
|
|
|
|
|
+ private List<string> dropMoveFiles = null;
|
|
|
+
|
|
|
public PageEditContent()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
+ dropMoveFiles = new List<string>();
|
|
|
}
|
|
|
|
|
|
public PageEditContent(IEventAggregator eventAggregator) : this()
|
|
@@ -360,7 +363,6 @@ namespace PDF_Master.Views.PageEdit
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- Trace.WriteLine("ListPageEdit_PreviewMouseMove 文件拖入App");
|
|
|
if (e.LeftButton == MouseButtonState.Pressed && !isDragingEnter)
|
|
|
{
|
|
|
//鼠标框选逻辑
|
|
@@ -416,16 +418,11 @@ namespace PDF_Master.Views.PageEdit
|
|
|
//files[0] = tempPath;
|
|
|
var scroll = GetScrollHost(ListPageEdit);
|
|
|
|
|
|
- DataObject dataObj = null;
|
|
|
- var position = e.GetPosition(ListPageEdit);
|
|
|
-
|
|
|
- Point pp = Mouse.GetPosition(e.Source as FrameworkElement);//WPF方法
|
|
|
-
|
|
|
//页面 是App内的拖拽 ,还是拖拽 页面 出 App 是一起处理
|
|
|
|
|
|
#region 拖拽 页面 到 桌面/文件夹 ,提取文件
|
|
|
|
|
|
- //string filename = Guid.NewGuid().ToString() + ".pdf";
|
|
|
+ //C:\Users\oyxh\AppData\Local\Temp\
|
|
|
string dir = System.IO.Path.Combine(System.IO.Path.GetTempPath());
|
|
|
if (!System.IO.Directory.Exists(dir))
|
|
|
{
|
|
@@ -445,13 +442,11 @@ namespace PDF_Master.Views.PageEdit
|
|
|
string[] files = new string[pagenums.Count];
|
|
|
for (int i = 0; i < pagenums.Count; i++)
|
|
|
{
|
|
|
- //string filename = Guid.NewGuid().ToString() + ".pdf";
|
|
|
string filename = viewModel.PDFViewer.Document.FileName + " " + pagenums[i] + ".pdf";
|
|
|
-
|
|
|
- string tempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), filename);
|
|
|
- //tempPath = CommonHelper.CreateFilePath(tempPath);
|
|
|
+ string tempPath = System.IO.Path.Combine(dir, filename);
|
|
|
string path = CommonHelper.CreateFilePath(tempPath);
|
|
|
files[i] = path;
|
|
|
+ dropMoveFiles.Add(path);
|
|
|
|
|
|
CPDFDocument savedoc = CPDFDocument.CreateDocument();
|
|
|
bool result2 = savedoc.ImportPages(viewModel.PDFViewer.Document, pagenums[i].ToString());
|
|
@@ -472,7 +467,7 @@ namespace PDF_Master.Views.PageEdit
|
|
|
//string[] files = new string[1];
|
|
|
//files[0] = tempPath;
|
|
|
|
|
|
- dataObj = new DataObject(DataFormats.FileDrop, files);
|
|
|
+ DataObject dataObj = new DataObject(DataFormats.FileDrop, files);
|
|
|
|
|
|
#endregion 拖拽 页面 到 桌面/文件夹 ,提取文件
|
|
|
|
|
@@ -482,7 +477,7 @@ namespace PDF_Master.Views.PageEdit
|
|
|
//如果这里的DragDropEfeects类型有改动,也需要调整ViewContent里UserControl_Drop函数的判断逻辑
|
|
|
DragDrop.DoDragDrop(ListPageEdit, dataObj, DragDropEffects.Copy);
|
|
|
Mouse.Capture(ListPageEdit);
|
|
|
-
|
|
|
+ //CleanDropMoveFiles();
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -545,7 +540,6 @@ namespace PDF_Master.Views.PageEdit
|
|
|
|
|
|
private void ListPageEdit_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
- Trace.WriteLine("ListPageEdit_PreviewMouseLeftButtonUp 文件拖入App");
|
|
|
var pos = e.GetPosition(ListPageEdit);
|
|
|
HitTestResult result = VisualTreeHelper.HitTest(ListPageEdit, pos);
|
|
|
if (result == null)
|
|
@@ -642,7 +636,6 @@ namespace PDF_Master.Views.PageEdit
|
|
|
private async void ListPageEdit_Drop(object sender, DragEventArgs e)
|
|
|
{
|
|
|
//isDragingEnter = false;
|
|
|
- Trace.WriteLine("ListPageEdit_Drop 文件拖入App");
|
|
|
needScroll = false;
|
|
|
if (!isDraging)
|
|
|
{
|
|
@@ -748,6 +741,29 @@ namespace PDF_Master.Views.PageEdit
|
|
|
viewModel.DragToSort(targetindex, pages);
|
|
|
ExitDraging();
|
|
|
isDraging = false;
|
|
|
+
|
|
|
+ CleanDropMoveFiles();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 拖拽完成后,清空临时目录 的文件
|
|
|
+ /// </summary>
|
|
|
+ private void CleanDropMoveFiles()
|
|
|
+ {
|
|
|
+ if (dropMoveFiles != null)
|
|
|
+ {
|
|
|
+ if (dropMoveFiles.Count > 0)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < dropMoveFiles.Count; i++)
|
|
|
+ {
|
|
|
+ if (File.Exists(dropMoveFiles[i]))
|
|
|
+ {
|
|
|
+ File.Delete(dropMoveFiles[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dropMoveFiles.Clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void MidLane_Drop(object sender, DragEventArgs e)
|
|
@@ -769,7 +785,7 @@ namespace PDF_Master.Views.PageEdit
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- Trace.WriteLine("Grid_DragOver 文件拖入App");
|
|
|
+ Trace.WriteLine("Grid_DragOver 文件拖出App");
|
|
|
|
|
|
//将付费锁逻辑提前,避免因弹窗显示后导致虚影无法消失问题
|
|
|
if (!viewModel.viewContentViewModel.IAPBeforeFunction())
|
|
@@ -803,6 +819,9 @@ namespace PDF_Master.Views.PageEdit
|
|
|
var listBoxItem = CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
if (listBoxItem == null)
|
|
|
{
|
|
|
+ //页面 拖出App后隐藏 标记线、缩略图
|
|
|
+ LineInset.Visibility = Visibility.Collapsed;
|
|
|
+ ImgPicture.Visibility = Visibility.Collapsed;
|
|
|
//MidLane.Visibility = Visibility.Collapsed;
|
|
|
//return;
|
|
|
}
|
|
@@ -895,6 +914,7 @@ namespace PDF_Master.Views.PageEdit
|
|
|
#endregion 计算插入标记位置
|
|
|
|
|
|
//暂时处理 鼠标移出边框时,虚影的显示问题
|
|
|
+ //230612 拖拽逻辑,为了更好的效果体现,暂时注释
|
|
|
if (pos.Y <= 30 || pos.Y >= ListPageEdit.ActualHeight - 10)
|
|
|
{
|
|
|
LineInset.Visibility = Visibility.Collapsed;
|
|
@@ -1015,7 +1035,7 @@ namespace PDF_Master.Views.PageEdit
|
|
|
/// <param name="e"></param>
|
|
|
private void Grid_PreviewDragEnter(object sender, DragEventArgs e)
|
|
|
{
|
|
|
- Trace.WriteLine("Grid_PreviewDragEnter 文件拖入App");
|
|
|
+ Trace.WriteLine("Grid_PreviewDragEnter 文件拖出App");
|
|
|
var files = (System.Array)e.Data.GetData(DataFormats.FileDrop);
|
|
|
if (files == null)//为null 表示内部拖动 触发的
|
|
|
{
|
|
@@ -1076,7 +1096,6 @@ namespace PDF_Master.Views.PageEdit
|
|
|
|
|
|
private void Grid_Drop(object sender, DragEventArgs e)
|
|
|
{
|
|
|
- Trace.WriteLine("Grid_Drop 文件拖入App");
|
|
|
|
|
|
DragDropHelper.Drop(this, e);
|
|
|
}
|