|
@@ -2,15 +2,18 @@
|
|
|
using Microsoft.Win32;
|
|
|
using PDF_Master.Helper;
|
|
|
using PDF_Master.Model;
|
|
|
+using PDF_Master.Properties;
|
|
|
using Prism.Commands;
|
|
|
using Prism.Mvvm;
|
|
|
using Prism.Regions;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Diagnostics;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
+using System.Windows.Threading;
|
|
|
|
|
|
namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
|
|
|
{
|
|
@@ -55,6 +58,9 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
|
|
|
set
|
|
|
{
|
|
|
SetProperty(ref errorTipVisible, value);
|
|
|
+ if (value == Visibility.Visible) {
|
|
|
+ dispatcherTimer.Start();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -78,6 +84,8 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
|
|
|
}
|
|
|
public List<string> TolanguageFamily { set; get; } = new List<string>();
|
|
|
|
|
|
+ private DispatcherTimer dispatcherTimer = new DispatcherTimer();
|
|
|
+
|
|
|
private void GetTolanguageOrigin()
|
|
|
{
|
|
|
TolanguageFamily.Clear();
|
|
@@ -87,6 +95,9 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
|
|
|
public ChatGPTAITranslationContentViewModel()
|
|
|
{
|
|
|
SelectFilesCommand = new DelegateCommand(selectFiles);
|
|
|
+
|
|
|
+ dispatcherTimer.Interval = TimeSpan.FromSeconds(5);
|
|
|
+ dispatcherTimer.Tick += Dispatchertimer_Tick;
|
|
|
init();
|
|
|
}
|
|
|
|
|
@@ -96,6 +107,12 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
|
|
|
GetTolanguageOrigin();
|
|
|
}
|
|
|
|
|
|
+ private void Dispatchertimer_Tick(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ ErrorTipVisible = Visibility.Collapsed;
|
|
|
+ dispatcherTimer.Stop();
|
|
|
+ }
|
|
|
+
|
|
|
public async void selectFiles()
|
|
|
{
|
|
|
string word = Properties.Resources.wordex;
|
|
@@ -108,6 +125,11 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
|
|
|
$"Microsoft Office Word({word})|{word}");
|
|
|
if ((bool)dialog.ShowDialog())
|
|
|
{
|
|
|
+ FileInfo fileInfo = new FileInfo(dialog.FileName);
|
|
|
+ if ((((float)fileInfo.Length) / 1024 / 1024) > 30) {
|
|
|
+ ErrorTipVisible = Visibility.Visible;
|
|
|
+ return;
|
|
|
+ }
|
|
|
string newfile = "";
|
|
|
await Task.Run(async delegate
|
|
|
{
|
|
@@ -121,11 +143,12 @@ namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
|
|
|
if (homeContentViewModel != null)
|
|
|
{
|
|
|
homeContentViewModel.OpenFile(new string[] { newfile });
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ ErrorTipVisible=Visibility.Visible;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|