Selaa lähdekoodia

Merge branch 'dev' of http://git.kdan.cc:8865/Windows/PDFOffice_Windows_exe into dev

OYXH\oyxh 2 vuotta sitten
vanhempi
commit
ddbbaa9bc4
2 muutettua tiedostoa jossa 51 lisäystä ja 2 poistoa
  1. 5 0
      PDF Office/App.xaml.cs
  2. 46 2
      PDF Office/Views/BOTA/OutLineControl.xaml.cs

+ 5 - 0
PDF Office/App.xaml.cs

@@ -129,6 +129,11 @@ namespace PDF_Master
         //app第一次启动时需要弹出注册弹窗
         public static bool IsShowRegist = false;
 
+        /// <summary>
+        /// 记录开始拖拽的窗口句柄,用于判断是否为跨窗口拖拽
+        /// </summary>
+        public static MainWindow DropStartWindow = null;
+
         /// <summary>
         /// 双击打开文件通知ID
         /// </summary>

+ 46 - 2
PDF Office/Views/BOTA/OutLineControl.xaml.cs

@@ -53,6 +53,24 @@ namespace PDF_Master.Views.BOTA
 
         public bool IsReName = false;
 
+        /// <summary>
+        /// 判断是否拖拽到了新窗口
+        /// </summary>
+        /// <returns></returns>
+        private bool IsInNowWindow()
+        {
+            if (App.DropStartWindow != null)
+            {
+                Window frm = Window.GetWindow(OutlineView);
+                if (frm != App.DropStartWindow)
+                {
+                    return true;
+                }
+                return false;
+            }
+            return false;
+        }
+
         public OutLineControl()
         {
 
@@ -68,6 +86,10 @@ namespace PDF_Master.Views.BOTA
 
         private void OutlineView_PreviewMouseMove(object sender, MouseEventArgs e)
         {
+            if (IsInNowWindow())
+            {
+                return;
+            }
             if (e.LeftButton == MouseButtonState.Pressed && !IsReName)
             {
                 var pos = e.GetPosition(OutlineView);
@@ -96,7 +118,14 @@ namespace PDF_Master.Views.BOTA
         /// <param name="e"></param>
         private void Grid_DragOver(object sender, DragEventArgs e)
         {
-            (DataContext as OutLineControlViewModel).IsOnDrop = true;
+            if (IsInNowWindow())
+            {
+                e.Effects = DragDropEffects.None;
+                e.Handled = true;
+                return;
+            }
+
+              (DataContext as OutLineControlViewModel).IsOnDrop = true;
             TreeViewItem sourceitem = e.Data.GetData(typeof(TreeViewItem)) as TreeViewItem;
             if (sourceitem == null)
             {
@@ -189,6 +218,7 @@ namespace PDF_Master.Views.BOTA
 
         private void OutlineView_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
         {
+
             (DataContext as OutLineControlViewModel).IsInsertHead = false;
             if (Treeviewitem != null)
             {
@@ -200,6 +230,12 @@ namespace PDF_Master.Views.BOTA
 
         private void OutlineView_Drop(object sender, DragEventArgs e)
         {
+            if (IsInNowWindow())
+            {
+                e.Effects = DragDropEffects.None;
+                e.Handled = true;
+                return;
+            }
             onDrop = false;
             TreeViewItem souredata = e.Data.GetData(typeof(TreeViewItem)) as TreeViewItem;
             if (souredata == null)
@@ -330,6 +366,14 @@ namespace PDF_Master.Views.BOTA
 
         private void TreeViewItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         {
+            //每次鼠标按下,更新开始拖拽的窗口对象
+            MainWindow frm = Window.GetWindow(this) as MainWindow;
+
+            if (frm != null)
+            {
+                App.DropStartWindow = frm;
+            }
+
             if (e.ClickCount == 1)
             {
                 TreeViewItem content = sender as TreeViewItem;
@@ -486,7 +530,7 @@ namespace PDF_Master.Views.BOTA
                 OutlineNode outlineNode = OutlineView.SelectedItem as OutlineNode;
                 if (outlineNode != null)
                 {
-                    outlineNode.IsSelected = false; 
+                    outlineNode.IsSelected = false;
                     e.Handled = true;
                 }
             }