|
@@ -2,6 +2,7 @@
|
|
|
using Microsoft.Office.Interop.Excel;
|
|
|
using PDF_Master.CustomControl;
|
|
|
using PDF_Master.Helper;
|
|
|
+using PDF_Master.Model;
|
|
|
using PDF_Master.Properties;
|
|
|
using PDF_Master.Strings.MainPage;
|
|
|
using Prism.Commands;
|
|
@@ -72,7 +73,7 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
|
|
|
T_ProgressBarName = App.MainPageLoader.GetString("OCR_Downloading");
|
|
|
T_tryAgainBtn = App.MainPageLoader.GetString("OCR_DownloadRedownload");
|
|
|
T_ErrorTextBlock = App.MainPageLoader.GetString("OCR_DownloadError");
|
|
|
- T_CancelBtn= App.MainPageLoader.GetString("OCR_CancelDownload");
|
|
|
+ T_CancelBtn = App.MainPageLoader.GetString("OCR_CancelDownload");
|
|
|
|
|
|
}
|
|
|
|
|
@@ -116,11 +117,7 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
|
|
|
|
|
|
private double currentSize;
|
|
|
|
|
|
- //home 是false
|
|
|
- private bool SelectHomeOrmain = false;
|
|
|
-
|
|
|
-
|
|
|
- private string progressBarCurrentSizeValue="0 MB";
|
|
|
+ private string progressBarCurrentSizeValue = "0 MB";
|
|
|
|
|
|
public string ProgressBarCurrentSizeValue
|
|
|
{
|
|
@@ -131,7 +128,7 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private string progressBarFileSize="0 MB";
|
|
|
+ private string progressBarFileSize = "0 MB";
|
|
|
|
|
|
public string ProgressBarFileSize
|
|
|
{
|
|
@@ -163,11 +160,11 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
|
|
|
|
|
|
public OCRDownloadProgressViewModel()
|
|
|
{
|
|
|
- CancelCommand= new DelegateCommand(cancel);
|
|
|
- TryAgainCommnad= new DelegateCommand(tryAgain);
|
|
|
+ CancelCommand = new DelegateCommand(cancel);
|
|
|
+ TryAgainCommnad = new DelegateCommand(tryAgain);
|
|
|
}
|
|
|
|
|
|
- private async void tryAgain()
|
|
|
+ private async void tryAgain()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -200,9 +197,9 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
|
|
|
await Task.Run(() =>
|
|
|
{
|
|
|
|
|
|
- string folder = System.IO.Path.Combine(App.CurrentPath, "modelzip");
|
|
|
+ string folder = System.IO.Path.Combine(App.CurrentPath, "OCREnginezip");
|
|
|
|
|
|
- FileNameComPDFKit = folder + "\\" + "model" + ".zip";
|
|
|
+ FileNameComPDFKit = folder + "\\" + "OCREngine" + ".zip";
|
|
|
long fileSize = 0;
|
|
|
if (!Directory.Exists(folder))
|
|
|
{
|
|
@@ -250,7 +247,7 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
|
|
|
string folderPath = App.CurrentPath;
|
|
|
//解压转档资源文件,intiRes
|
|
|
string folderModelPath = App.CurrentPath;
|
|
|
- if (!Directory.Exists(folderModelPath + "//model"))
|
|
|
+ if (!Directory.Exists(folderModelPath + "//OCREngine"))
|
|
|
{
|
|
|
ExtractWithProgress(FileNameComPDFKit, folderModelPath);
|
|
|
}
|
|
@@ -303,39 +300,21 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
|
|
|
{
|
|
|
ProgressBarCurrentValue = 0;
|
|
|
ProgressBarCurrentSizeValue = (currentSize * (ProgressBarCurrentValue / 100)).ToString("0.00") + " MB";
|
|
|
- string folderzipPath = System.IO.Path.Combine(App.CurrentPath, "modelzip");
|
|
|
+ string folderzipPath = System.IO.Path.Combine(App.CurrentPath, "OCREnginezip");
|
|
|
if (Directory.Exists(folderzipPath))
|
|
|
{
|
|
|
Directory.Delete(folderzipPath, true);
|
|
|
}
|
|
|
- //Close();
|
|
|
+ //Close()
|
|
|
if (FileComparisonHelper.OCRModelItExist())
|
|
|
{
|
|
|
- if (SelectHomeOrmain)
|
|
|
- {
|
|
|
- if (mainPage != null)
|
|
|
- {
|
|
|
- //mainPage.ShowOCRDialog(isItemClieck);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //新OCR弹窗
|
|
|
- //ConvertOCRNewDialog convertOCRNewDialog = new ConvertOCRNewDialog();
|
|
|
- //convertOCRNewDialog.InitBeforeShow(Pdfviewer, password);
|
|
|
- //convertOCRNewDialog.Owner = App.Current.MainWindow;
|
|
|
- //convertOCRNewDialog.ShowDialog();
|
|
|
- //ConvertOCRDialog dialog = new ConvertOCRDialog();
|
|
|
- //dialog.InitBeforeShow(Pdfviewer, password);
|
|
|
- //dialog.StartPosition = FormStartPosition.CenterScreen;
|
|
|
- //dialog.ShowDialog();
|
|
|
-
|
|
|
- }
|
|
|
+ var dialogresult = new DialogResult(ButtonResult.OK);
|
|
|
+ //dialogresult.Parameters.Add(ParameterNames.ConverterType, "Img");
|
|
|
+ RequestClose.Invoke(dialogresult);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- string folderPath = System.IO.Path.Combine(App.CurrentPath, "model");
|
|
|
+ string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
|
|
|
if (Directory.Exists(folderPath))
|
|
|
{
|
|
|
Directory.Delete(folderPath, true);
|
|
@@ -397,30 +376,6 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public bool? ShowDialog(MainPage mainPage, bool isItemClieck)
|
|
|
- {
|
|
|
- this.mainPage = mainPage;
|
|
|
- this.isItemClieck = isItemClieck;
|
|
|
- SelectHomeOrmain = true;
|
|
|
- return false;
|
|
|
- //return base.ShowDialog();
|
|
|
- }
|
|
|
-
|
|
|
- public bool? ShowDialog(CPDFViewer kmpdfviewer, string password)
|
|
|
- {
|
|
|
- Pdfviewer = kmpdfviewer;
|
|
|
- this.password = password;
|
|
|
- SelectHomeOrmain = false;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- private async void Window_Loaded(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
-
|
|
|
- await DownloadOCR();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
public event Action<IDialogResult> RequestClose;
|
|
|
|
|
|
public bool CanCloseDialog()
|
|
@@ -430,11 +385,12 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
|
|
|
|
|
|
public void OnDialogClosed()
|
|
|
{
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- public void OnDialogOpened(IDialogParameters parameters)
|
|
|
+ public async void OnDialogOpened(IDialogParameters parameters)
|
|
|
{
|
|
|
-
|
|
|
+ await DownloadOCR();
|
|
|
}
|
|
|
}
|
|
|
}
|