liyijie 1 год назад
Родитель
Сommit
b15ad70827

+ 1 - 1
PDF Office/Helper/ChatGTPAIHelper.cs

@@ -215,7 +215,7 @@ namespace PDF_Master.Helper
         public static async Task<string> fileTranslate(string content, string fromlanguage, string tolanguage, bool isprocess = true)
         {
             string Code = "300";
-            intProcess(isprocess, "Translating", System.Windows.Visibility.Visible);
+            intProcess(isprocess, "Translating...", System.Windows.Visibility.Visible);
             //判断word文档大小
             if (!GetDocumentPagesWord(content))
             {

+ 2 - 2
PDF Office/Views/HomePanel/ChatGPTAI/ChatGPTAITranslationContent.xaml

@@ -33,11 +33,11 @@
                     <VisualBrush>
                         <VisualBrush.Visual>
                             <Grid>
-                                <Rectangle StrokeDashArray="4 2" RadiusX="8" RadiusY="8" Stroke="{StaticResource color.sys.border.neutral.lv1}"
+                                <Rectangle Name="NormalColorBorder" StrokeDashArray="4 2" RadiusX="8" RadiusY="8" Stroke="{StaticResource color.sys.border.neutral.lv1}"
 Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
 Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}" Visibility="{Binding ElementName=DropColorBorder,Path=Visibility,Converter={StaticResource UnvisibleConvert}}">
                                 </Rectangle>
-                                <Rectangle Name="DropColorBorder" StrokeDashArray="4 2" RadiusX="8" RadiusY="8" Stroke="{StaticResource color.btn.brand.bg.hov}"
+                                <Rectangle Name="DropColorBorder"  RadiusX="8" RadiusY="8" Stroke="{StaticResource color.btn.cta.bg.hov}" 
 Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
 Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}" Visibility="Collapsed">
                                 </Rectangle>

+ 2 - 0
PDF Office/Views/HomePanel/ChatGPTAI/ChatGPTAITranslationContent.xaml.cs

@@ -122,6 +122,7 @@ namespace PDF_Master.Views.HomePanel.ChatGPTAI
         private void MainPage_DragEnter(object sender, DragEventArgs e)
         {
             DropColorBorder.Visibility = Visibility.Visible;
+            NormalColorBorder.Visibility = Visibility.Collapsed;
             //BtnBlank.IsEnabled = false;
             //页面编辑和缩略图
             if ((e.OriginalSource as Image) != null)
@@ -162,6 +163,7 @@ namespace PDF_Master.Views.HomePanel.ChatGPTAI
         private void MainPage_DragLeave(object sender, DragEventArgs e)
         {
             DropColorBorder.Visibility = Visibility.Collapsed;
+            NormalColorBorder.Visibility = Visibility.Visible;
             // BtnBlank.IsEnabled = true;
             if ((e.OriginalSource as Image) != null)
                 return;

+ 14 - 3
PDF Office/Views/HomePanel/PDFTools/HomeFilesContent.xaml

@@ -27,14 +27,25 @@
             FontSize="20"
             FontWeight="Bold"
             Foreground="{StaticResource color.sys.text.neutral.lv1}" Height="28"></TextBlock>
-            <Border Margin="0,16,0,0"  Height="264" CornerRadius="8" BorderThickness="1" >
+            <Border Margin="0,16,0,0"  Height="264" CornerRadius="8" BorderThickness="1" 
+                    Background="Transparent"    
+                  Drop="Grid_Drop"
+                  DragEnter="MainPage_DragEnter"
+                  DragOver="MainPage_DragOver"
+                  DragLeave="MainPage_DragLeave">
                 <Border.BorderBrush>
                     <VisualBrush>
                         <VisualBrush.Visual>
-                            <Rectangle StrokeDashArray="4 2" RadiusX="8" RadiusY="8" Stroke="{StaticResource color.sys.border.neutral.lv1}"
+                            <Grid>
+                                <Rectangle Name="NormalColorBorder" StrokeDashArray="4 2" RadiusX="8" RadiusY="8" Stroke="{StaticResource color.sys.border.neutral.lv1}"
 Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
 Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}">
-                            </Rectangle>
+                                </Rectangle>
+                                <Rectangle Name="DropColorBorder"  RadiusX="8" RadiusY="8" Stroke="{StaticResource color.btn.cta.bg.hov}"  
+Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
+Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}" Visibility="Collapsed">
+                                </Rectangle>
+                            </Grid>
                         </VisualBrush.Visual>
                     </VisualBrush>
                 </Border.BorderBrush>

+ 95 - 2
PDF Office/Views/HomePanel/PDFTools/HomeFilesContent.xaml.cs

@@ -1,6 +1,14 @@
-using PDF_Master.ViewModels.HomePanel.PDFTools;
+using ComPDFKit.PDFDocument;
+using PDF_Master.Helper;
+using PDF_Master.Model;
+using PDF_Master.Properties;
+using PDF_Master.ViewModels.HomePanel.PDFTools;
+using System;
 using System.Diagnostics;
+using System.IO;
+using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Interop;
 
 namespace PDF_Master.Views.HomePanel.PDFTools
 {
@@ -12,6 +20,8 @@ namespace PDF_Master.Views.HomePanel.PDFTools
 
         private HomeFilesContentViewModel viewModel;
 
+        private IDropTargetHelper dropHelper;
+
         public HomeFilesContent()
         {
             InitializeComponent();
@@ -20,7 +30,7 @@ namespace PDF_Master.Views.HomePanel.PDFTools
 
         private void StackPanel_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
         {
-            if (Gridroot.ActualWidth<628)
+            if (Gridroot.ActualWidth<638)
             {
                 OpenFileStackPanel.Margin=new System.Windows.Thickness(0,0,0,0);
                 viewModel.CreatGridRowIndex = 1;
@@ -33,5 +43,88 @@ namespace PDF_Master.Views.HomePanel.PDFTools
                 viewModel.CreatGridColumnIndex = 1;
             }
         }
+        private  void Grid_Drop(object sender, DragEventArgs e)
+        {
+
+            try
+            {
+                Point iconPoint = e.GetPosition(this);
+                dropHelper?.Drop((System.Runtime.InteropServices.ComTypes.IDataObject)e.Data, ref iconPoint, e.Effects);
+            }
+            catch
+            {
+
+            }
+            string dropFile = "Drop";
+            if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))
+            {
+                //BtnBlank.IsEnabled = true;
+                int count = ((System.Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).Length;
+                for (int i = 0; i < count; i++)
+                {
+                    dropFile = ((System.Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).GetValue(i).ToString();
+                    
+                }
+            }
+        }
+        private void MainPage_DragEnter(object sender, DragEventArgs e)
+        {
+            DropColorBorder.Visibility = Visibility.Visible;
+            NormalColorBorder.Visibility = Visibility.Collapsed;
+            //BtnBlank.IsEnabled = false;
+            //页面编辑和缩略图
+            if ((e.OriginalSource as Image) != null)
+                return;
+            try
+            {
+                if (dropHelper == null)
+                {
+                    dropHelper = Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("4657278A-411B-11D2-839A-00C04FD918D0"))) as IDropTargetHelper;
+                }
+                Point iconPoint = e.GetPosition(this);
+                dropHelper?.DragEnter(new WindowInteropHelper(Window.GetWindow(this)).Handle, (System.Runtime.InteropServices.ComTypes.IDataObject)e.Data, ref iconPoint, e.Effects);
+            }
+            catch
+            {
+
+            }
+
+        }
+
+        private void MainPage_DragOver(object sender, DragEventArgs e)
+        {
+
+            if ((e.OriginalSource as Image) != null)
+                return;
+            try
+            {
+                Point iconPoint = e.GetPosition(this);
+                dropHelper?.DragOver(ref iconPoint, e.Effects);
+            }
+            catch
+            {
+
+            }
+
+        }
+
+        private void MainPage_DragLeave(object sender, DragEventArgs e)
+        {
+            DropColorBorder.Visibility = Visibility.Collapsed;
+            NormalColorBorder.Visibility = Visibility.Visible;
+            // BtnBlank.IsEnabled = true;
+            if ((e.OriginalSource as Image) != null)
+                return;
+            try
+            {
+                dropHelper?.DragLeave();
+            }
+            catch
+            {
+
+            }
+
+        }
+
     }
 }