|
@@ -1,4 +1,18 @@
|
|
|
-using System.Windows.Controls;
|
|
|
+using ComPDFKitViewer;
|
|
|
+using PDF_Master.Helper;
|
|
|
+using System.Data;
|
|
|
+using System.Windows;
|
|
|
+using System;
|
|
|
+using System.Windows.Controls;
|
|
|
+using System.Windows.Interop;
|
|
|
+using PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
|
|
|
+using PDF_Master.ViewModels.HomePanel.ChatGPTAI;
|
|
|
+using Microsoft.Office.Core;
|
|
|
+using PDF_Master.ViewModels;
|
|
|
+using Microsoft.Office.Interop.Word;
|
|
|
+using System.IO;
|
|
|
+using Point = System.Windows.Point;
|
|
|
+using Window = System.Windows.Window;
|
|
|
|
|
|
namespace PDF_Master.Views.HomePanel.ChatGPTAI
|
|
|
{
|
|
@@ -7,9 +21,107 @@ namespace PDF_Master.Views.HomePanel.ChatGPTAI
|
|
|
/// </summary>
|
|
|
public partial class ChatGPTAITranslationContent : UserControl
|
|
|
{
|
|
|
+ private ChatGPTAITranslationContentViewModel viewModel;
|
|
|
+ private IDropTargetHelper dropHelper;
|
|
|
public ChatGPTAITranslationContent()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
+ viewModel = this.DataContext as ChatGPTAITranslationContentViewModel;
|
|
|
}
|
|
|
+
|
|
|
+ private async 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 (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ 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();
|
|
|
+ if (dropFile.ToLower().EndsWith("pdf")|| dropFile.ToLower().EndsWith(".doc") || dropFile.ToLower().EndsWith(".docx")|| dropFile.ToLower().EndsWith(".docm")|| dropFile.ToLower().EndsWith(".dot")|| dropFile.ToLower().EndsWith(".dotx") || dropFile.ToLower().EndsWith(".dotm"))
|
|
|
+ {
|
|
|
+ string newfile = await ChatGTPAIHelper.fileTranslate(dropFile, viewModel.fromlanguage, viewModel.tolanguage);
|
|
|
+ if (!string.IsNullOrEmpty(newfile))
|
|
|
+ {
|
|
|
+ if (File.Exists(newfile))
|
|
|
+ {
|
|
|
+ if (viewModel.homeContentViewModel != null)
|
|
|
+ {
|
|
|
+ viewModel.homeContentViewModel.OpenFile(new string[] { newfile });
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void MainPage_DragEnter(object sender, DragEventArgs e)
|
|
|
+ {
|
|
|
+ //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 (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void MainPage_DragLeave(object sender, DragEventArgs e)
|
|
|
+ {
|
|
|
+ // BtnBlank.IsEnabled = true;
|
|
|
+ if ((e.OriginalSource as Image) != null)
|
|
|
+ return;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ dropHelper?.DragLeave();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|