123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577 |
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using ComPDFKit.NativeMethod;
- using ComPDFKit_Conversion.Converter;
- using PDF_Office.CustomControl;
- using PDF_Office.CustomControl.SystemControl;
- using PDF_Office.ViewModels;
- using PDF_Office.Views;
- using PDF_Office.Views.BOTA;
- using PDF_Office.Views.Dialog;
- using PDF_Office.Views.HomePanel;
- using Prism.DryIoc;
- using Prism.Ioc;
- using Prism.Regions;
- using PDF_Office.Model;
- using PDF_Office.Views.PageEdit;
- using PDF_Office.Properties;
- using PDFSettings.Settings;
- using PDF_Office.Views.Tools;
- using PDF_Office.Views.Dialog.ToolsDialogs.SaftyDialogs;
- using PDF_Office.Views.Dialog.ToolsDialogs.CompressDialogs;
- using PDF_Office.Views.Dialog.PageEditDialogs;
- using PDF_Office.Helper;
- using PDF_Office.Views.Dialog.HomePageToolsDialogs;
- using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePagePrinter;
- using PDF_Office.Views.PropertyPanel;
- using PDF_Office.Views.Dialog.BOTA;
- using PDF_Office.Views.PropertyPanel.AnnotPanel;
- using PDF_Office.Views.FillAndSign;
- using PDF_Office.Views.FillAndSign.PropertyPanel;
- using PDF_Office.Views.PropertyPanel.ViewModular;
- using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
- using PDF_Office.Views.Dialog.ConverterDialogs;
- using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter;
- using PDF_Office.Views.EditTools.Watermark;
- using PDF_Office.Views.EditTools.Background;
- using PDF_Office.Views.EditTools.Bates;
- using PDF_Office.Views.EditTools.HeaderFooter;
- using PDF_Office.Views.EditTools.Redaction;
- using PDF_Office.Views.Form;
- using PDF_Office.Views.PropertyPanel.PDFEdit;
- using PDF_Office.Views.Dialog.ToolsDialogs;
- using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter;
- using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates;
- using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark;
- using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground;
- using ComDocumentAIKit;
- using PDF_Office.Views.PropertyPanel.Scan;
- using PDF_Office.Views.Dialog.Redaction;
- using PDF_Office.Views.Scan;
- using PDF_Office.Views.TipContent;
- using System.Windows.Threading;
- using PDF_Office.Views.Dialog.ServiceDialog;
- using System.Diagnostics;
- using System.Resources;
- using System.Reflection;
- using Microsoft.AppCenter;
- using System.Globalization;
- using Microsoft.AppCenter.Analytics;
- using Microsoft.AppCenter.Crashes;
- namespace PDF_Office
- {
- /// <summary>
- /// App.xaml 的交互逻辑
- /// </summary>
- public partial class App : PrismApplication
- {
- public static string CurrentPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "PDF Office");
- /// <summary>
- /// 内嵌文档路径
- /// </summary>
- public static string GuidPDFPath = Path.Combine(Environment.CurrentDirectory, "Resources\\GuidPDF\\Quick Start Guide.pdf");
- /// <summary>
- /// 是否需要更新内嵌文档
- /// </summary>
- public static bool IsGuidPDFUpdated = false;
- /// <summary>
- /// 产品名称
- /// </summary>
- public static string Name = "PDF Office";
- /// <summary>
- /// 当前app版本号
- /// </summary>
- public static string Version = FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).ProductVersion;
- public static MainWindowViewModel mainWindowViewModel;
- /// <summary>
- /// 当前软件已打开的文件路径列表
- /// </summary>
- public static List<string> OpenedFileList = new List<string>();
- public static CacheFilePath CachePath;
- /// <summary>
- /// OCR数据模型所在目录
- /// </summary>
- public static string modelFolderPath = null;
- /// <summary>
- /// 是否是软件的第一个主窗体
- /// </summary>
- public static bool IsFirstOpen = true;
- public static bool IsBookMode = false;
- /// <summary>
- /// 是否已经登陆
- /// </summary>
- public static bool IsLogin = true;
- //是否需要显示注册弹窗
- //app第一次启动时需要弹出注册弹窗
- public static bool IsShowRegist = false;
- /// <summary>
- /// 文案资源管理器 首页
- /// </summary>
- public static ResourceManager HomePageLoader = new ResourceManager("PDF_Office.Strings.HomePage.HomePage", Assembly.GetExecutingAssembly());
- /// <summary>
- /// 文案资源管理器 阅读页
- /// </summary>
- public static ResourceManager MainPageLoader = new ResourceManager("PDF_Office.Strings.MainPage.MainPage", Assembly.GetExecutingAssembly());
- /// <summary>
- /// 文案资源管理器 注册相关
- /// </summary>
- public static ResourceManager ServiceLoader = new ResourceManager("PDF_Office.Strings.Service.Service", Assembly.GetExecutingAssembly());
- public App()
- {
- #if !DEBUG
- //接入Appcenter后台数据检测 PDF Reader Pro Test
- string appkey = "395433ac-97b6-4e28-803e-3d377bdef875";
- AppCenter.Start(appkey, typeof(Analytics), typeof(Crashes));
- var countryCode = RegionInfo.CurrentRegion.TwoLetterISORegionName;//上传国家信息
- AppCenter.SetCountryCode(countryCode);
- #endif
- }
- private void InitSettings()
- {
- //是否是更新后
- if (Settings.Default.UpdateSettings)
- {
- //内嵌文档更新时 显示文档到最前方
- //每次版本更新留意检查IsGuidPDFUpdated 值,如果没有内嵌文档更新,要设为false
- if (Settings.Default.IsGuidPDFUpdated && File.Exists(GuidPDFPath))
- {
- App.IsGuidPDFUpdated = true;
- Settings.Default.IsGuidPDFUpdated = false;
- }
- Settings.Default.Upgrade();
- Settings.Default.UpdateSettings = false;
- App.IsShowRegist = true;
- //重置用于弹窗的记录参数
- }
- if (Settings.Default.RecentOpenFiles == null)
- {
- Settings.Default.RecentOpenFiles = new RecentOpenFiles();
- }
- if (Settings.Default.RedactionsSettings == null)
- Settings.Default.RedactionsSettings = new PDFSettings.RedactionSettings();
- if (Settings.Default.AppProperties == null)
- Settings.Default.AppProperties = new PDFSettings.APPSettingProperties();
- if (Settings.Default.AllPDFToolsList == null)
- Settings.Default.AllPDFToolsList = new PDFSettings.AllPDFToolsList();
- if (Settings.Default.QuickPDFToolsList == null)
- Settings.Default.QuickPDFToolsList = new PDFSettings.QuickPDFToolsList();
- if (App.IsGuidPDFUpdated)
- {
- SettingHelper.SortRecentOpenFiles(GuidPDFPath);
- }
- }
- protected override void OnStartup(StartupEventArgs e)
- {
- LicenseVerify();
- InitSettings();
- CachePath = CacheFilePath.Instance;
- //清除临时文件
- CacheFilePath.Instance.ClearDeleteFiles();
- try
- {
- DirectoryInfo info = new DirectoryInfo(CurrentPath);
- //避免因存在同名文件,导致无法创建文件夹
- if (File.Exists(CurrentPath))
- {
- File.Delete(CurrentPath);
- }
- if (!info.Exists)
- {
- info.Create();
- }
- }
- catch (Exception ex)
- {
- }
- //增加全局异常捕获
- //UI线程异常
- this.DispatcherUnhandledException += App_DispatcherUnhandledException;
- //非UI线程异常
- AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
- //Task线程内
- TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
- base.OnStartup(e);
- }
- private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
- {
- var ex = e.Exception as Exception;
- if (ex != null)
- {
- MessageBox.Show("发生Task未处理异常:" + ex.Message + "\n" + ex.StackTrace, "系统错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
- private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
- {
- if (e.ExceptionObject is System.Exception)
- {
- Exception ex = (System.Exception)e.ExceptionObject;
- MessageBox.Show("发生非UI线程异常:" + ex.Message + "\n" + ex.StackTrace, "系统错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
- private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
- {
- e.Handled = true;
- MessageBox.Show("发生UI线程异常:" + e.Exception.Message + "\n" + e.Exception.StackTrace, "系统错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- /// <summary>
- /// 创建启动窗口
- /// </summary>
- /// <returns></returns>
- protected override Window CreateShell()
- {
- return Container.Resolve<MainWindow>();
- }
- protected override void RegisterTypes(IContainerRegistry containerRegistry)
- {
- #region 注册内容组件
- containerRegistry.RegisterForNavigation<HomeContent>();
- containerRegistry.RegisterForNavigation<ViewContent>();
- containerRegistry.RegisterForNavigation<ScanViwer>();
- containerRegistry.RegisterForNavigation<MainContent>();
- containerRegistry.RegisterForNavigation<HomeCloudContent>("Cloud");
- containerRegistry.RegisterForNavigation<HomeToolsContent>("Tools");
- containerRegistry.RegisterForNavigation<HomeGuidContent>("Guid");
- containerRegistry.RegisterForNavigation<BOTAContent>();
- containerRegistry.RegisterForNavigation<PropertyPanelContent>();
- containerRegistry.RegisterForNavigation<PageEditContent>();
- containerRegistry.RegisterForNavigation<BottomToolContent>();
- containerRegistry.RegisterForNavigation<ToolsBarContent>();
- containerRegistry.RegisterForNavigation<TextEditToolContent>();
- containerRegistry.RegisterForNavigation<AnnotToolContent>();
- containerRegistry.RegisterForNavigation<BookmarkContent>();
- containerRegistry.RegisterForNavigation<SearchContent>();
- containerRegistry.RegisterForNavigation<OutLineControl>();
- containerRegistry.RegisterForNavigation<ViewModularContent>();
- containerRegistry.RegisterForNavigation<SplitScreenContent>();
- containerRegistry.RegisterForNavigation<ThemesContent>();
- containerRegistry.RegisterForNavigation<ReadModeContent>();
- containerRegistry.RegisterForNavigation<AnnotationContent>();
- containerRegistry.RegisterForNavigation<ReadViewContent>();
- containerRegistry.RegisterForNavigation<PageContent>();
- containerRegistry.RegisterForNavigation<HomePagePrinterDocumentContent>();
- containerRegistry.RegisterForNavigation<HomePagePrinterModSizeContent>();
- containerRegistry.RegisterForNavigation<HomePagePrinterModPosterContent>();
- containerRegistry.RegisterForNavigation<HomePagePrinterModMultipleContent>();
- containerRegistry.RegisterForNavigation<HomePagePrinterModBookletContent>();
- containerRegistry.RegisterForNavigation<HomePageCompressDialog>();
- containerRegistry.RegisterForNavigation<HomePageSetPasswordDialog>();
- containerRegistry.RegisterForNavigation<HomePageRemoveDialog>();
- containerRegistry.RegisterForNavigation<HomePageHeaderFooterDialog>();
- containerRegistry.RegisterForNavigation<HomePageHeaderFooterTemplateListContent>();
- containerRegistry.RegisterForNavigation<HomePageHeaderFooterCreateContent>();
- containerRegistry.RegisterForNavigation<HomePageBatesDialog>();
- containerRegistry.RegisterForNavigation<HomePageBatesTemplateListContent>();
- containerRegistry.RegisterForNavigation<HomePageBatesCreateContent>();
- containerRegistry.RegisterForNavigation<HomePageBackgroundDialog>();
- containerRegistry.RegisterForNavigation<HomePageBackgroundTemplateListBaseContent>();
- containerRegistry.RegisterForNavigation<HomePageBackgroundTemplateListColorContent>();
- containerRegistry.RegisterForNavigation<HomePageBackgroundTemplateListFileContent>();
- containerRegistry.RegisterForNavigation<HomePageBackgroundCreateBaseContent>();
- containerRegistry.RegisterForNavigation<HomePageBackgroundCreateColorContent>();
- containerRegistry.RegisterForNavigation<HomePageBackgroundCreateFileContent>();
- containerRegistry.RegisterForNavigation<HomePageWatermarkDialog>();
- containerRegistry.RegisterForNavigation<HomePageWatermarkTemplateListBaseContent>();
- containerRegistry.RegisterForNavigation<HomePageWatermarkTemplateListTextContent>();
- containerRegistry.RegisterForNavigation<HomePageWatermarkTemplateListFileContent>();
- containerRegistry.RegisterForNavigation<HomePageWatermarkCreateBaseContent>();
- containerRegistry.RegisterForNavigation<HomePageWatermarkCreateTextContent>();
- containerRegistry.RegisterForNavigation<HomePageWatermarkCreateFileContent>();
- containerRegistry.RegisterForNavigation<ConverterBarContent>();
- containerRegistry.RegisterForNavigation<ScanContent>();
- containerRegistry.RegisterForNavigation<HomePageConverterDialog>();
- containerRegistry.RegisterForNavigation<HomePageConverterCSV>();
- containerRegistry.RegisterForNavigation<HomePageConverterImg>();
- containerRegistry.RegisterForNavigation<HomePageConverterWord>();
- containerRegistry.RegisterForNavigation<HomePageConverterExcel>();
- containerRegistry.RegisterForNavigation<WatermarkContent>();
- containerRegistry.RegisterForNavigation<BackgroundContent>();
- containerRegistry.RegisterForNavigation<BackgroundTemplateListBaseContent>();
- containerRegistry.RegisterForNavigation<BackgroundTemplateListColorContent>();
- containerRegistry.RegisterForNavigation<BackgroundTemplateListFileContent>();
- containerRegistry.RegisterForNavigation<BackgroundCreateBaseContent>();
- containerRegistry.RegisterForNavigation<BackgroundCreateColorContent>();
- containerRegistry.RegisterForNavigation<BackgroundCreateFileContent>();
- containerRegistry.RegisterForNavigation<BackgroundDocumentContent>();
- containerRegistry.RegisterForNavigation<WatermarkTemplateListBaseContent>();
- containerRegistry.RegisterForNavigation<WatermarkTemplateListTextContent>();
- containerRegistry.RegisterForNavigation<WatermarkTemplateListFileContent>();
- containerRegistry.RegisterForNavigation<WatermarkCreateBaseContent>();
- containerRegistry.RegisterForNavigation<WatermarkCreateTextContent>();
- containerRegistry.RegisterForNavigation<WatermarkCreateFileContent>();
- containerRegistry.RegisterForNavigation<WatermarkDocumentContent>();
- containerRegistry.RegisterForNavigation<HomePagePrinterModMultipleContent>();
- containerRegistry.RegisterForNavigation<FreehandAnnotProperty>();
- containerRegistry.RegisterForNavigation<FreetextAnnotProperty>();
- containerRegistry.RegisterForNavigation<StickyNoteProperty>();
- containerRegistry.RegisterForNavigation<ImageAnnotProperty>();
- containerRegistry.RegisterForNavigation<LinkAnnotProperty>();
- containerRegistry.RegisterForNavigation<SharpsAnnotProperty>();
- containerRegistry.RegisterForNavigation<StampAnnotProperty>();
- containerRegistry.RegisterForNavigation<SignatureAnnotProperty>();
- containerRegistry.RegisterForNavigation<TextAnnotProperty>();
- containerRegistry.RegisterForNavigation<ImageEditProperty>();
- containerRegistry.RegisterForNavigation<TextEditProperty>();
- containerRegistry.RegisterForNavigation<ImageEditProperty>();
- containerRegistry.RegisterForNavigation<ImageTextEditProperty>();
- containerRegistry.RegisterForNavigation<ScanPropertyPanel>();
- containerRegistry.RegisterForNavigation<BatesContent>();
- containerRegistry.RegisterForNavigation<BatesTemplateListContent>();
- containerRegistry.RegisterForNavigation<BatesCreateContent>();
- containerRegistry.RegisterForNavigation<BatesDocumentContent>();
- containerRegistry.RegisterForNavigation<HeaderFooterContent>();
- containerRegistry.RegisterForNavigation<HeaderFooterTemplateListContent>();
- containerRegistry.RegisterForNavigation<HeaderFooterCreateContent>();
- containerRegistry.RegisterForNavigation<HeaderFooterDocumentContent>();
- containerRegistry.RegisterForNavigation<RedactionContent>();
- //填写与签名
- containerRegistry.RegisterForNavigation<FillAndSignContent>();
- containerRegistry.RegisterForNavigation<DateFillProperty>();
- containerRegistry.RegisterForNavigation<ShapFillProperty>();
- containerRegistry.RegisterForNavigation<TextFillProperty>();
- //Form表单
- containerRegistry.RegisterForNavigation<EmptyFormProperty>();
- containerRegistry.RegisterForNavigation<FormsToolContent>();
- containerRegistry.RegisterForNavigation<TextFieldProperty>();
- containerRegistry.RegisterForNavigation<ButtonProperty>();
- containerRegistry.RegisterForNavigation<CheckBoxProperty>();
- containerRegistry.RegisterForNavigation<ListBoxProperty>();
- containerRegistry.RegisterForNavigation<ComboxProperty>();
- containerRegistry.RegisterForNavigation<RadioButtonProperty>();
- containerRegistry.RegisterForNavigation<SignProperty>();
- //Tip
- containerRegistry.RegisterForNavigation<SetPasswordSuccessfullyTip>();
- containerRegistry.RegisterForNavigation<FileRestrictedTip>();
- containerRegistry.RegisterForNavigation<LinkAnnotTip>();
- containerRegistry.RegisterForNavigation<ReadModelTip>();
- containerRegistry.RegisterForNavigation<RemoveSecuritySuccessTip>();
- containerRegistry.RegisterForNavigation<EnterReadModeTip>();
- //轻会员
- containerRegistry.RegisterForNavigation<CodeRegion>();
- containerRegistry.RegisterForNavigation<LoginRegion>();
- containerRegistry.RegisterForNavigation<LoginPasswordRegion>();
- containerRegistry.RegisterForNavigation<RegisterRegion>();
- containerRegistry.RegisterForNavigation<RegisterOKRegion>();
- containerRegistry.RegisterForNavigation<NOInternetRegion>();
- containerRegistry.RegisterForNavigation<UserOutCodeRegion>();
- containerRegistry.RegisterForNavigation<PasswordUpdataRegion>();
- containerRegistry.RegisterForNavigation<StickyNotePopup>();
- #endregion 注册内容组件
- #region 注册弹窗
- containerRegistry.RegisterDialog<VerifyPassWordDialog>(DialogNames.VerifyPassWordDialog);
- containerRegistry.RegisterDialog<FullScreenWindow>(DialogNames.FullScreenDialog);
- containerRegistry.RegisterDialog<CompressDialog>(DialogNames.CompressDialog);
- containerRegistry.RegisterDialog<MergeDialog>(DialogNames.MergeDialog);
- containerRegistry.RegisterDialog<SetPasswordDialog>(DialogNames.SetPasswordDialog);
- containerRegistry.RegisterDialog<CheckPasswordDialog>(DialogNames.CheckPasswordDialog);
- containerRegistry.RegisterDialog<DeleteSafetySettingsDialog>(DialogNames.DeleteSafetySettingsDialog);
- containerRegistry.RegisterDialog<CompressProgressBarDialog, PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs.CompresProgressBarDialogViewModel>(DialogNames.CompressProgressBarDialog);
- containerRegistry.RegisterDialog<InsertDialog>(DialogNames.InsertDialog);
- containerRegistry.RegisterDialog<SplitDialog>(DialogNames.SplitDialog);
- containerRegistry.RegisterDialog<ExtractDialog>(DialogNames.ExtractDialog);
- containerRegistry.RegisterDialog<HomePageExtractDialog>(DialogNames.HomePageExtractDialog);
- containerRegistry.RegisterDialog<HomePageInsertDialog>(DialogNames.HomePageInsertDialog);
- containerRegistry.RegisterDialog<HomePageSplitDialog>(DialogNames.HomePageSplitDialog);
- containerRegistry.RegisterDialog<HomePagePrinterDialog>(DialogNames.HomePagePrinterDialog);
- containerRegistry.RegisterDialog<HomePagePrinterPaperSettingsDialog>(DialogNames.HomePagePrinterPaperSettingsDialog);
- containerRegistry.RegisterDialog<HomePagePictureToPDFDialog>(DialogNames.HomePagePictureToPDFDialog);
- containerRegistry.RegisterDialog<HomePageBatchProcessingDialog>(DialogNames.HomePageBatchProcessingDialog);
- containerRegistry.RegisterDialog<DynamicPropertyDialog>(DialogNames.DynamicPropertyDialog);
- containerRegistry.RegisterDialog<CustomCreateDialog>(DialogNames.CustomCreateDialog);
- containerRegistry.RegisterDialog<SignatureCreateDialog>(DialogNames.SignatureCreateDialog);
- containerRegistry.RegisterDialog<ConverterCSVDialog>(DialogNames.ConverterCSVDialog);
- containerRegistry.RegisterDialog<ConverterPPTDialog>(DialogNames.ConverterPPTDialog);
- containerRegistry.RegisterDialog<ConverterTextDialog>(DialogNames.ConverterTextDialog);
- containerRegistry.RegisterDialog<ConverterWordDialog>(DialogNames.ConverterWordDialog);
- containerRegistry.RegisterDialog<ConverterHTMLDialog>(DialogNames.ConverterHTMLDialog);
- containerRegistry.RegisterDialog<ConverterImgDialog>(DialogNames.ConverterImgDialog);
- containerRegistry.RegisterDialog<ConverterRTFDialog>(DialogNames.ConverterRTFDialog);
- containerRegistry.RegisterDialog<ConverterExcelDialog>(DialogNames.ConverterExcelDialog);
- containerRegistry.RegisterDialog<ConverterProgressBarDialog>(DialogNames.ConverterProgressBarDialog);
- containerRegistry.RegisterDialog<ScreenAnnotationDialog>(DialogNames.ScreenAnnotationDialog);
- containerRegistry.RegisterDialog<AddBookmarkDialog>(DialogNames.AddBookmarkDialog);
- containerRegistry.RegisterDialog<AddAnnotationDialog>(DialogNames.AddAnnotationDialog);
- containerRegistry.RegisterDialog<EditPresetColorsDialog>(DialogNames.EditPresetColorsDialog);
- containerRegistry.RegisterDialog<CreateFromHtmlDialog>(DialogNames.CreateFromHtmlDialog);
- containerRegistry.RegisterDialog<CreateFromScannerDialogs>(DialogNames.CreateFromScannerDialogs);
- //标记密文弹窗
- containerRegistry.RegisterDialog<MarkSettingDialog>(DialogNames.MarkSettingDialog);
- containerRegistry.RegisterDialog<PageMarkDialog>(DialogNames.PageMarkDialog);
- containerRegistry.RegisterDialog<RepeatMarkDialog>(DialogNames.RepeatMarkDialog);
- containerRegistry.RegisterDialog<SettingsDialog>(DialogNames.SettingsDialog);
- containerRegistry.RegisterDialog<PropertiesDialog>(DialogNames.PropertyDialog);
- //轻会员弹窗
- containerRegistry.RegisterDialog<RegisterDialog>(DialogNames.RegisterDialog);
- containerRegistry.RegisterDialog<LoginDialog>(DialogNames.LoginDialog);
- containerRegistry.RegisterDialog<UserDialog>(DialogNames.UserDialog);
- //新手引导弹窗
- containerRegistry.RegisterDialog<NoviceGuidDialog>(DialogNames.GuidDialog);
- containerRegistry.RegisterDialog<IAPCompareDialog>(DialogNames.IAPCompareDialog);
- #endregion 注册弹窗
- }
- protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings)
- {
- var region = new SingleActiveRegion() { Name = RegionNames.MainRegion };
- region.Behaviors.Add(DragablzWindowBehavior.BehaviorKey, new DragablzWindowBehavior());
- Container.Resolve<IRegionManager>().Regions.Add(region);
- base.ConfigureRegionAdapterMappings(regionAdapterMappings);
- }
- /// <summary>
- /// 验证SDK和转档库密钥
- /// </summary>
- /// <returns></returns>
- private static bool LicenseVerify()
- {
- bool result = false;
- try
- {
- result = CPDFSDKVerifier.LoadNativeLibrary();
- if (!result)
- return false;
- }
- catch { }
- SDKLisenceHelper sdkhelper = new SDKLisenceHelper();
- string devKey = "";
- string devSecret = "";
- #if DEBUG
- devKey = "ehrnKqkWc1XSEAWyPUt6+95GzCoLEyoKrCbsUuJkCqGmxmP5ozX4bS0R6crHItQVNTFvC5mBZ1M7QjJ6Ekdu4Daj7PM+EDLTBKbFJinK4Ri9E5E2X+a9vF5zSj0TkIscQPVnwj9ikxAFOWGIyybMwQQzwc8a4j1cGOqGXQRDMMY=";
- devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6ccHhEu996bvBgqf8Sw8OekQKQq13VBewK5AckaDux4W7SGRhCUNWC4MItkr36JnXMD2tiFQYzMG8C66HYmRGSLh";
- devKey = sdkhelper.DevKey;
- devSecret = sdkhelper.DevSecret;
- #endif
- string userKey = sdkhelper.UserKey;
- string userSecret = sdkhelper.UserSecret;
- try
- {
- LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(devKey, devSecret);
- if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
- return false;
- }
- catch { }
- string ConverterDevKey = sdkhelper.ConverterDevKey;
- string ConverterDevSecret = sdkhelper.ConverterDevSecret;
- string ConverterUserkey = sdkhelper.ConverterUserkey;
- string ConverterUserSecret = sdkhelper.ConverterUserSecret;
- try
- {
- //加载OCR库
- if (!DocumentAIKitLicenseVerify())
- {
- }
- /*LicenseError licenseerror = CPDFConverter.SDKLicenseVerify(ConverterDevKey, ConverterDevSecret, ConverterUserkey, ConverterUserSecret);
- string resPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location) + "\\";
- if (licenseerror != LicenseError.ERR_SUCCESS)
- {
- return false;
- }
- CPDFConverter.Init(resPath);*/
- string resPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location) + "\\";
- LicenseError licenseerror = CPDFConverter.LicenseVerify(ConverterDevKey, ConverterDevSecret);
- if (licenseerror != LicenseError.ERR_SUCCESS)
- {
- //MessageBox.Show("ComPDFKit Conversion SDK Load Failed!");
- return false;
- }
- CPDFConverter.Init(resPath);
- CPDFConverter.SetOCRModelFolder(modelFolderPath);
- }
- catch { }
- return result;
- }
- /// <summary>
- /// 加载,验证DocumentAIKitLicense
- /// 目前DocmentAILib暂时移动到X64(原来路径为 string libFolderPath = Path.Combine(exePath, "DocumentAILib");)
- /// 含有的库有(ComDocumentAINative.dll,DocumentAI.dll,libiomp5md.dll,mkldnn.dll,mklml.dll,onnxruntime.dll,opencv_world420.dll,opencv_word420d.dll,paddle_inference.dll,paddle2onnx.dll)
- /// </summary>
- /// <returns></returns>
- private static bool DocumentAIKitLicenseVerify()
- {
- Task.Factory.StartNew(() =>
- {
- string exePath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location);
- exePath = Path.Combine(exePath, "x64");
- //string libFolderPath = Path.Combine(exePath, "DocumentAILib");
- string libFolderPath = exePath;
- modelFolderPath = Path.Combine(exePath, "models");
- if (CDocumentAIKit.LoadNativeLibrary(libFolderPath) == false)
- return;
- CErrorCode error = CDocumentAIKit.LicenseVerify("1F8B0818801DD8F20000636F6D2E636F6D7064666B69742E636F6E76657273696F6E00344136353732364636443635353936313645363700011002EFFDC671954ADECE496F0D96F5C14D82A293CEC71744D0914A388C0FDECA16FC9B6D28694C762AC71F382D9E50B2E9473B431C8FE18D5656A52AB2FF2B06834B7AB87CFB42884BA59110642327D18D77BD13D2AC8EC3A06357000E315956673DC38A02F97AD29B24F421D82D9346A3737BFD806777769DFBA4D50B911E65F4FC674A6DCA1E53FE1F9A4A8DE987B41B143282D2286C22C29F69724A4BCA5C0BD3013DDA2207FFC10A385EF980D4547FD76A4B6EBDE54ACCE68B656621032EC146123B1E8DD9B1EF7F71725917D9CA58431601707A6BB1B41A82049FAF14599B34EAF7D59CD8E6CFEAB24AF5CDDCB2A2236E77710B7E30F10022F2F25EC6586D3B5207378F2CB8B9176EE463B1F2B1D8BD776142E8F9575235BE2A57A63948EDB05DED4649F410CE5941DA5155E6F5A127BFABC5E424F71A1AEB201595ECE8BC8C91DD1C0FF7300A4CB7253B6277CF8B8C5F3CDA5D569E2E27F1609815F9944816AD69550049D94C0FD263D2D3FCF4A3CE685C67F7E27F70E8D9332A45984E7F4D7F5D800BAA58D18715384B98BE310AEDCB4BCF4833E76A5E3860032B3A926DFD247FF426ADA94BA1DA7B11F0451AE506A93DD8B809453E5B51CBE24D572973A55FBD3D25453C3FAD47D30ACAB30500C15FD8714B365AA6F275808C9EB7D5116AC809C91786D6571E2622A5E730D40614061C3B3FC129108AA1360C16151CE38CA03FF3A28FFE7200B4FFA24EF7EDF54B8E9AB207E00810020000");
- if (error != CErrorCode.E_DA_SUCCESS)
- return;
- });
- return true;
- }
- protected override void OnExit(ExitEventArgs e)
- {
- Environment.Exit(1);
- base.OnExit(e);
- }
- }
- }
|