|
@@ -75,18 +75,13 @@ namespace PDF_Office.Views.PageEdit
|
|
|
//拖动的Item
|
|
|
private PageEditItem tempItem;
|
|
|
|
|
|
- ///鼠标是否停留在item前半部
|
|
|
- ///显示在前半部时,获取的index为实际索引值
|
|
|
- ///显示在后半部时,获取的index需要+1
|
|
|
- private bool isFrontHalf = false;
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 是否正在拖拽排序中,通过该变量避免单击触发拖动
|
|
|
/// </summary>
|
|
|
private bool isDraging = false;
|
|
|
|
|
|
//是否正在从外部拖入文件
|
|
|
- private bool isDragingEnter = false;
|
|
|
+ public bool isDragingEnter { get; set; } = false;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 是否需要自动滚动
|
|
@@ -105,7 +100,7 @@ namespace PDF_Office.Views.PageEdit
|
|
|
}
|
|
|
|
|
|
|
|
|
- public PageEditContent(IEventAggregator eventAggregator) :this()
|
|
|
+ public PageEditContent(IEventAggregator eventAggregator) : this()
|
|
|
{
|
|
|
eventor = eventAggregator;
|
|
|
unicode = App.mainWindowViewModel.SelectedItem.Unicode;
|
|
@@ -153,15 +148,15 @@ namespace PDF_Office.Views.PageEdit
|
|
|
}
|
|
|
|
|
|
|
|
|
- #region UI事件
|
|
|
- /// <summary>
|
|
|
- /// 每次显示的时候就触发事件,刷新所有图片
|
|
|
- /// </summary>
|
|
|
- /// <param name="sender"></param>
|
|
|
- /// <param name="e"></param>
|
|
|
- private void PageEdit_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
|
|
+ #region UI事件
|
|
|
+ /// <summary>
|
|
|
+ /// 每次显示的时候就触发事件,刷新所有图片
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void PageEdit_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
|
|
{
|
|
|
- if((bool)e.NewValue)
|
|
|
+ if ((bool)e.NewValue)
|
|
|
{
|
|
|
//当前页面没有发生变化时,刷新图片 这种情况下会拿两次图,需要留意
|
|
|
PulishEvent();
|
|
@@ -287,7 +282,7 @@ namespace PDF_Office.Views.PageEdit
|
|
|
/// <param name="e"></param>
|
|
|
private void TextBox_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
|
|
{
|
|
|
- if((bool)e.NewValue)
|
|
|
+ if ((bool)e.NewValue)
|
|
|
{
|
|
|
(sender as Control).Focus();
|
|
|
}
|
|
@@ -320,6 +315,7 @@ namespace PDF_Office.Views.PageEdit
|
|
|
if (pos.Y < 0 || pos.Y > ListPageEdit.ActualHeight)
|
|
|
{
|
|
|
LineInset.Visibility = Visibility.Collapsed;
|
|
|
+ ImgPicture.Visibility = Visibility.Collapsed;
|
|
|
return;
|
|
|
}
|
|
|
HitTestResult result = VisualTreeHelper.HitTest(ListPageEdit, pos);
|
|
@@ -359,7 +355,8 @@ namespace PDF_Office.Views.PageEdit
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
- LineInset.Visibility = Visibility.Collapsed;
|
|
|
+ LineInset.Visibility = Visibility.Collapsed;
|
|
|
+ ImgPicture.Visibility = Visibility.Collapsed;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -425,7 +422,7 @@ namespace PDF_Office.Views.PageEdit
|
|
|
|
|
|
//更改系统默认的选中规则,多选后,鼠标单击抬起后再选中单个
|
|
|
//拖拽框选之后的抬起鼠标不进入处理
|
|
|
- if (!startChoose&&!Keyboard.IsKeyDown(Key.LeftCtrl) && !Keyboard.IsKeyDown(Key.LeftShift))
|
|
|
+ if (!startChoose && !Keyboard.IsKeyDown(Key.LeftCtrl) && !Keyboard.IsKeyDown(Key.LeftShift))
|
|
|
{
|
|
|
ListPageEdit.SelectedItems.Clear();
|
|
|
ListPageEdit.SelectedItem = listBoxItem;
|
|
@@ -488,152 +485,13 @@ namespace PDF_Office.Views.PageEdit
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 计算插入标记线和虚影显示
|
|
|
- /// </summary>
|
|
|
- /// <param name="sender"></param>
|
|
|
- /// <param name="e"></param>
|
|
|
- private void ListPageEdit_DragOver(object sender, DragEventArgs e)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- //ctrl建按下 不显示插入标记和虚影 因为释放不会响应drop事件
|
|
|
- if (e.KeyStates == (DragDropKeyStates.ControlKey | DragDropKeyStates.LeftMouseButton) || e.KeyStates == (DragDropKeyStates.ShiftKey | DragDropKeyStates.LeftMouseButton | DragDropKeyStates.ControlKey))
|
|
|
- return;
|
|
|
-
|
|
|
- //滚动后有 位置不准确 要减去滚动偏移量
|
|
|
- //控制线的位置
|
|
|
- var pos = e.GetPosition(ListPageEdit);
|
|
|
- var result = VisualTreeHelper.HitTest(ListPageEdit, pos);
|
|
|
- if (result == null)
|
|
|
- {
|
|
|
- //MidLane.Visibility = Visibility.Collapsed;
|
|
|
- //return;
|
|
|
- }
|
|
|
-
|
|
|
- //获取当前鼠标指针下的容器
|
|
|
- var listBoxItem = CommonHelper.FindVisualParent<ListBoxItem>(result.VisualHit);
|
|
|
- if (listBoxItem == null)
|
|
|
- {
|
|
|
- //MidLane.Visibility = Visibility.Collapsed;
|
|
|
- //return;
|
|
|
- }
|
|
|
-
|
|
|
- #region 计算虚影位置
|
|
|
- //xaml层 要设置 虚影控件为左上
|
|
|
- double xPos = 0;
|
|
|
- double yPos = 0;
|
|
|
- //内部拖动
|
|
|
- if (!isDragingEnter)
|
|
|
- {
|
|
|
- //Viewbox viewBox = (tempItem.Content as StackPanel).Children[0] as Viewbox;//获取item宽度
|
|
|
-
|
|
|
- ImgPicture.Width = tempItem.ItemSize.Width;
|
|
|
- ImgPicture.Height = tempItem.ItemSize.Height;
|
|
|
- ImgPicture.Source = tempItem.Image;
|
|
|
- xPos = e.GetPosition(ListPageEdit).X - item_x;
|
|
|
- yPos = e.GetPosition(ListPageEdit).Y - item_y;
|
|
|
- }
|
|
|
- //else
|
|
|
- //{
|
|
|
- // //从外部拖入的逻辑
|
|
|
- // //var pic = ToBitmapSource(dragingEnterPath);
|
|
|
- // //ShadowPicture.Width = pic.Width;
|
|
|
- // //ShadowPicture.Height = pic.Height;
|
|
|
- // //ShadowPicture.Source = pic;
|
|
|
- // //xPos = e.GetPosition(ListPageEdit).X - pic.Width / 2;
|
|
|
- // //yPos = e.GetPosition(ListPageEdit).Y - pic.Height / 2;
|
|
|
- //}
|
|
|
-
|
|
|
- ImgPicture.Margin = new Thickness(xPos, yPos, 0, 0);
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region 计算插入标记位置
|
|
|
- var scroll = GetScrollHost(ListPageEdit);
|
|
|
- if (listBoxItem != null)
|
|
|
- {
|
|
|
- //虚拟化影响到该值计算
|
|
|
- var p = VisualTreeHelper.GetOffset(listBoxItem);//计算控件在容器中的偏移(位置)
|
|
|
- LineInset.Visibility = Visibility.Visible;
|
|
|
-
|
|
|
- var panel = GetWrapPanel(ListPageEdit);
|
|
|
- var item = (ListPageEdit.ItemContainerGenerator.ContainerFromIndex(0) as ListBoxItem).DesiredSize.Width;
|
|
|
-
|
|
|
- int count = (int)(panel.ViewportWidth / item);
|
|
|
- var gap = (panel.ViewportWidth - count * item) / (count + 1) * 1.0;
|
|
|
-
|
|
|
- LineInset.X2 = LineInset.X1 = p.X + gap / 2 + listBoxItem.DesiredSize.Width;
|
|
|
-
|
|
|
- if (pos.X < p.X + gap / 2 + listBoxItem.ActualWidth / 2)
|
|
|
- {
|
|
|
- isFrontHalf = true;//前半部 线条出现在位置前
|
|
|
- LineInset.X2 = LineInset.X1 = p.X - gap / 2;
|
|
|
- InsertIndex = ListPageEdit.Items.IndexOf(listBoxItem);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- isFrontHalf = false;
|
|
|
- InsertIndex = ListPageEdit.Items.IndexOf(listBoxItem) + 1;
|
|
|
- }
|
|
|
- //MidLane.Y1 = p.Y - scroll.VerticalOffset;//向下滑动后要减去滑动值
|
|
|
- LineInset.Y1 = p.Y;
|
|
|
- if (LineInset.Y1 < 0)//避免超出上边界
|
|
|
- {
|
|
|
- LineInset.Y1 = 0;
|
|
|
- }
|
|
|
- //MidLane.Y2 = p.Y + listBoxItem.ActualHeight - scroll.VerticalOffset;//仿智能滚动后可能会导致 垂直滚动偏量不准确
|
|
|
- LineInset.Y2 = p.Y + listBoxItem.ActualHeight;
|
|
|
- if (LineInset.Y2 < 0)
|
|
|
- {
|
|
|
- LineInset.Y2 = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- //暂时处理 鼠标移出边框时,虚影的显示问题
|
|
|
- if (pos.Y <= 30 || pos.Y >= ListPageEdit.ActualHeight - 10)
|
|
|
- {
|
|
|
- LineInset.Visibility = Visibility.Collapsed;
|
|
|
- needScroll = false;
|
|
|
- }
|
|
|
-
|
|
|
- if (pos.X <= 40 || pos.X >= scroll.ViewportWidth - 50)
|
|
|
- {
|
|
|
- LineInset.Visibility = Visibility.Collapsed;
|
|
|
- needScroll = false;
|
|
|
- }
|
|
|
-
|
|
|
- #region 靠近上下边界时,自动滚动,离边界越近,滚动速度越快
|
|
|
- //speed = 0;
|
|
|
- //if (pos.Y >= PageEditListBox.ActualHeight - 30)
|
|
|
- //{
|
|
|
- // speed = 30 - (int)(PageEditListBox.ActualHeight - pos.Y);
|
|
|
- // needScroll = true;
|
|
|
- //}
|
|
|
- //else if (pos.Y <= 30)
|
|
|
- //{
|
|
|
- // speed = (int)(pos.Y - 30);
|
|
|
- // needScroll = true;
|
|
|
- //}
|
|
|
- //else
|
|
|
- // needScroll = false;
|
|
|
-
|
|
|
- //var v = scroll.VerticalOffset;
|
|
|
- //scroll.ScrollToVerticalOffset(v + speed);//触发连续滚动
|
|
|
- #endregion
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 退出拖拽模式
|
|
|
/// </summary>
|
|
|
private void ExitDraging()
|
|
|
{
|
|
|
LineInset.Visibility = Visibility.Collapsed;
|
|
|
+ ImgPicture.Visibility = Visibility.Collapsed;
|
|
|
isDraging = false;
|
|
|
}
|
|
|
|
|
@@ -642,13 +500,14 @@ namespace PDF_Office.Views.PageEdit
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
- private void ListPageEdit_Drop(object sender, DragEventArgs e)
|
|
|
+ private async void ListPageEdit_Drop(object sender, DragEventArgs e)
|
|
|
{
|
|
|
needScroll = false;
|
|
|
if (!isDraging)
|
|
|
{
|
|
|
//未拖拽时隐藏插入标记和虚影
|
|
|
LineInset.Visibility = Visibility.Collapsed;
|
|
|
+ ImgPicture.Visibility = Visibility.Collapsed;
|
|
|
return;
|
|
|
}
|
|
|
#region 功能付费锁
|
|
@@ -662,56 +521,27 @@ namespace PDF_Office.Views.PageEdit
|
|
|
#endregion
|
|
|
|
|
|
#region 从外部拖拽插入文件
|
|
|
- //if (isDragingEnter)
|
|
|
- //{
|
|
|
-
|
|
|
-
|
|
|
- // //在当前位置插入整个pdf
|
|
|
- // CPDFDocument dragDoc = CPDFDocument.InitWithFilePath(dragingEnterPath);
|
|
|
- // if (dragDoc.IsLocked)
|
|
|
- // {
|
|
|
- // VerifyPasswordDialog dialog = new VerifyPasswordDialog(dragDoc);
|
|
|
- // dialog.ShowDialog();
|
|
|
- // if (dragDoc.IsLocked)
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // if (dragingEnterPath.Substring(dragingEnterPath.LastIndexOf(".")).ToLower() == ".pdf")
|
|
|
- // {
|
|
|
- // if (dragDoc != null)
|
|
|
- // {
|
|
|
- // int index = InsertIndex == -1 ? 0 : InsertIndex;
|
|
|
- // pdfViewer.Document.ImportPagesAtIndex(dragDoc, "1-" + dragDoc.PageCount, index);
|
|
|
- // PopulateThumbnailList();
|
|
|
- // ItemsInViewHitTest();
|
|
|
-
|
|
|
- // pdfViewer.UndoManager.ClearHistory();
|
|
|
- // pdfViewer.UndoManager.CanSave = true;
|
|
|
- // pdfViewer.ReloadDocument();
|
|
|
- // PageEditListBox.ScrollIntoView(PageEditListBox.SelectedItem as ListBoxItem);
|
|
|
- // PageMoved.Invoke(this, new RoutedEventArgs());
|
|
|
- // PDFViewerCtrl viewerCtrl = ParentPage?.GetCurrentViewer();
|
|
|
- // if (viewerCtrl != null)
|
|
|
- // {
|
|
|
- // viewerCtrl.IsPageEdit = true;
|
|
|
- // }
|
|
|
- // dragDoc.Release();
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // MessageBoxEx.Show(App.MainPageLoader.GetString("Merge_FileCannotOpenedWarningd"));
|
|
|
- // }
|
|
|
- // //提示文档损坏无法打开
|
|
|
- // }
|
|
|
- // else if (!string.IsNullOrEmpty(dragingEnterPath))
|
|
|
- // {
|
|
|
- // //其他文件 则新增一个页签打开
|
|
|
- // // DragAddTab.Invoke(dragingEnterPath, new RoutedEventArgs());//底层库需要加一个 Load(TPDFDocument)的接口
|
|
|
- // }
|
|
|
- // MidLane.Visibility = Visibility.Collapsed;
|
|
|
- // isDragingEnter = false;
|
|
|
- // dragingEnterPath = null;
|
|
|
- // return;
|
|
|
- //}
|
|
|
+ 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;
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
var pos = e.GetPosition(ListPageEdit);
|
|
@@ -851,6 +681,8 @@ namespace PDF_Office.Views.PageEdit
|
|
|
if (e.KeyStates == (DragDropKeyStates.ControlKey | DragDropKeyStates.LeftMouseButton) || e.KeyStates == (DragDropKeyStates.ShiftKey | DragDropKeyStates.LeftMouseButton | DragDropKeyStates.ControlKey))
|
|
|
return;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//滚动后有 位置不准确 要减去滚动偏移量
|
|
|
//控制线的位置
|
|
|
var pos = e.GetPosition(ListPageEdit);
|
|
@@ -876,24 +708,26 @@ namespace PDF_Office.Views.PageEdit
|
|
|
//内部拖动
|
|
|
if (!isDragingEnter)
|
|
|
{
|
|
|
- //Viewbox viewBox = (tempItem.Content as StackPanel).Children[0] as Viewbox;//获取item宽度
|
|
|
-
|
|
|
- ImgPicture.Width = tempItem.ItemSize.Width;
|
|
|
- ImgPicture.Height = tempItem.ItemSize.Height;
|
|
|
- ImgPicture.Source = tempItem.Image;
|
|
|
- xPos = e.GetPosition(ListPageEdit).X - item_x;
|
|
|
- yPos = e.GetPosition(ListPageEdit).Y - item_y;
|
|
|
+ if(tempItem!=null)
|
|
|
+ {
|
|
|
+ ImgPicture.Width = tempItem.ItemSize.Width;
|
|
|
+ ImgPicture.Height = tempItem.ItemSize.Height;
|
|
|
+ ImgPicture.Source = tempItem.Image;
|
|
|
+ xPos = e.GetPosition(ListPageEdit).X - item_x;
|
|
|
+ yPos = e.GetPosition(ListPageEdit).Y - item_y;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DragDropHelper.DragOver(this, e);
|
|
|
+ //从外部拖入的逻辑
|
|
|
+ //var pic = ToBitmapSource(dragingEnterPath);
|
|
|
+ //ShadowPicture.Width = pic.Width;
|
|
|
+ //ShadowPicture.Height = pic.Height;
|
|
|
+ //ShadowPicture.Source = pic;
|
|
|
+ //xPos = e.GetPosition(ListPageEdit).X - pic.Width / 2;
|
|
|
+ //yPos = e.GetPosition(ListPageEdit).Y - pic.Height / 2;
|
|
|
}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // //从外部拖入的逻辑
|
|
|
- // //var pic = ToBitmapSource(dragingEnterPath);
|
|
|
- // //ShadowPicture.Width = pic.Width;
|
|
|
- // //ShadowPicture.Height = pic.Height;
|
|
|
- // //ShadowPicture.Source = pic;
|
|
|
- // //xPos = e.GetPosition(ListPageEdit).X - pic.Width / 2;
|
|
|
- // //yPos = e.GetPosition(ListPageEdit).Y - pic.Height / 2;
|
|
|
- //}
|
|
|
|
|
|
ImgPicture.Margin = new Thickness(xPos, yPos, 0, 0);
|
|
|
#endregion
|
|
@@ -905,6 +739,14 @@ namespace PDF_Office.Views.PageEdit
|
|
|
//虚拟化影响到该值计算
|
|
|
var p = VisualTreeHelper.GetOffset(listBoxItem);//计算控件在容器中的偏移(位置)
|
|
|
LineInset.Visibility = Visibility.Visible;
|
|
|
+ if(!isDragingEnter)
|
|
|
+ {
|
|
|
+ ImgPicture.Visibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ImgPicture.Visibility = Visibility.Collapsed;
|
|
|
+ }
|
|
|
|
|
|
var panel = GetWrapPanel(ListPageEdit);
|
|
|
|
|
@@ -919,15 +761,14 @@ namespace PDF_Office.Views.PageEdit
|
|
|
|
|
|
if (pos.X < p.X + gap / 2 + listBoxItem.ActualWidth / 2)
|
|
|
{
|
|
|
- isFrontHalf = true;//前半部 线条出现在位置前
|
|
|
LineInset.X2 = LineInset.X1 = p.X - gap / 2;
|
|
|
- InsertIndex = ListPageEdit.Items.IndexOf(listBoxItem);
|
|
|
+ InsertIndex = ListPageEdit.Items.IndexOf(listBoxItem.DataContext as PageEditItem);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- isFrontHalf = false;
|
|
|
- InsertIndex = ListPageEdit.Items.IndexOf(listBoxItem) + 1;
|
|
|
+ InsertIndex = ListPageEdit.Items.IndexOf(listBoxItem.DataContext as PageEditItem) + 1;
|
|
|
}
|
|
|
+ Console.WriteLine("InsertIndex:{0}\r\n",InsertIndex);
|
|
|
//MidLane.Y1 = p.Y - scroll.VerticalOffset;//向下滑动后要减去滑动值
|
|
|
LineInset.Y1 = p.Y;
|
|
|
if (LineInset.Y1 < 0)//避免超出上边界
|
|
@@ -947,12 +788,14 @@ namespace PDF_Office.Views.PageEdit
|
|
|
if (pos.Y <= 30 || pos.Y >= ListPageEdit.ActualHeight - 10)
|
|
|
{
|
|
|
LineInset.Visibility = Visibility.Collapsed;
|
|
|
+ ImgPicture.Visibility = Visibility.Collapsed;
|
|
|
needScroll = false;
|
|
|
}
|
|
|
|
|
|
if (pos.X <= 40 || pos.X >= scroll.ViewportWidth - 50)
|
|
|
{
|
|
|
LineInset.Visibility = Visibility.Collapsed;
|
|
|
+ ImgPicture.Visibility = Visibility.Collapsed;
|
|
|
needScroll = false;
|
|
|
}
|
|
|
|
|
@@ -983,14 +826,14 @@ namespace PDF_Office.Views.PageEdit
|
|
|
|
|
|
private void ListBoxItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
//e.Handled = true;
|
|
|
}
|
|
|
|
|
|
private void ListBoxItem_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
- if(e.ChangedButton== MouseButton.Left)
|
|
|
- {
|
|
|
+ if (e.ChangedButton == MouseButton.Left)
|
|
|
+ {
|
|
|
//双击回到PDFViewer界面
|
|
|
var item = sender as ListBoxItem;
|
|
|
if (item != null)
|
|
@@ -1024,7 +867,7 @@ namespace PDF_Office.Views.PageEdit
|
|
|
{
|
|
|
var itemwidth = 0.6 * width;
|
|
|
var itemheight = 294 * itemwidth / 208.0;
|
|
|
- viewModel.ChangeItemSize(new Size(itemwidth,itemheight));
|
|
|
+ viewModel.ChangeItemSize(new Size(itemwidth, itemheight));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1032,5 +875,48 @@ namespace PDF_Office.Views.PageEdit
|
|
|
{
|
|
|
ItemSuitAcutalWidth(this.ActualWidth);
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 用来判断是否有外界拖入的事件
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void Grid_PreviewDragEnter(object sender, DragEventArgs e)
|
|
|
+ {
|
|
|
+ DragDropHelper.DragEnter(this,e);
|
|
|
+
|
|
|
+ var file = (System.Array)e.Data.GetData(DataFormats.FileDrop);
|
|
|
+ if (file == null)//为null 表示内部拖动 触发的
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ isDragingEnter = false;
|
|
|
+ foreach (string f in file)
|
|
|
+ {
|
|
|
+ System.IO.FileInfo info = new System.IO.FileInfo(f);
|
|
|
+ //只要拖拽进来的文件里包含有pdf格式文件,就允许拖入
|
|
|
+ if(System.IO.Path.GetExtension(f).ToLower()==".pdf" &&info.Length>0)
|
|
|
+ {
|
|
|
+ isDragingEnter = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Grid_DragLeave(object sender, DragEventArgs e)
|
|
|
+ {
|
|
|
+ DragDropHelper.DragLeave();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Grid_Drop(object sender, DragEventArgs e)
|
|
|
+ {
|
|
|
+ DragDropHelper.Drop(this,e);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ListBoxItem_DragLeave(object sender, DragEventArgs e)
|
|
|
+ {
|
|
|
+ //增加辅助判断,防止误触发 拖动排序
|
|
|
+ //较大幅度拖动才能触发排序
|
|
|
+ isDraging = true;
|
|
|
+ }
|
|
|
}
|
|
|
}
|