App.xaml.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using ComPDFKit.NativeMethod;
  11. using ComPDFKit_Conversion.Converter;
  12. using PDF_Office.CustomControl;
  13. using PDF_Office.CustomControl.SystemControl;
  14. using PDF_Office.ViewModels;
  15. using PDF_Office.Views;
  16. using PDF_Office.Views.BOTA;
  17. using PDF_Office.Views.Dialog;
  18. using PDF_Office.Views.HomePanel;
  19. using Prism.DryIoc;
  20. using Prism.Ioc;
  21. using Prism.Regions;
  22. using PDF_Office.Model;
  23. using PDF_Office.Views.PageEdit;
  24. using PDF_Office.Properties;
  25. using PDFSettings.Settings;
  26. using PDF_Office.Views.Tools;
  27. using PDF_Office.Views.Dialog.ToolsDialogs.SaftyDialogs;
  28. using PDF_Office.Views.Dialog.ToolsDialogs.CompressDialogs;
  29. using PDF_Office.Views.Dialog.PageEditDialogs;
  30. using PDF_Office.Helper;
  31. using PDF_Office.Views.Dialog.HomePageToolsDialogs;
  32. using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePagePrinter;
  33. using PDF_Office.Views.PropertyPanel;
  34. using PDF_Office.Views.Dialog.BOTA;
  35. using PDF_Office.Views.PropertyPanel.AnnotPanel;
  36. using PDF_Office.Views.FillAndSign;
  37. using PDF_Office.Views.FillAndSign.PropertyPanel;
  38. using PDF_Office.Views.PropertyPanel.ViewModular;
  39. using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
  40. using PDF_Office.Views.Dialog.ConverterDialogs;
  41. using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter;
  42. using PDF_Office.Views.EditTools.Watermark;
  43. using PDF_Office.Views.EditTools.Background;
  44. using PDF_Office.Views.EditTools.Bates;
  45. using PDF_Office.Views.EditTools.HeaderFooter;
  46. using PDF_Office.Views.EditTools.Redaction;
  47. using PDF_Office.Views.Form;
  48. using PDF_Office.Views.PropertyPanel.PDFEdit;
  49. using PDF_Office.Views.Dialog.ToolsDialogs;
  50. using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter;
  51. using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates;
  52. using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark;
  53. using PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground;
  54. using ComDocumentAIKit;
  55. using PDF_Office.Views.PropertyPanel.Scan;
  56. using PDF_Office.Views.Dialog.Redaction;
  57. using PDF_Office.Views.Scan;
  58. using PDF_Office.Views.TipContent;
  59. using System.Windows.Threading;
  60. using PDF_Office.Views.Dialog.ServiceDialog;
  61. using System.Diagnostics;
  62. using System.Resources;
  63. using System.Reflection;
  64. using Microsoft.AppCenter;
  65. using System.Globalization;
  66. using Microsoft.AppCenter.Analytics;
  67. using Microsoft.AppCenter.Crashes;
  68. namespace PDF_Office
  69. {
  70. /// <summary>
  71. /// App.xaml 的交互逻辑
  72. /// </summary>
  73. public partial class App : PrismApplication
  74. {
  75. public static string CurrentPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "PDF Office");
  76. /// <summary>
  77. /// 内嵌文档路径
  78. /// </summary>
  79. public static string GuidPDFPath = Path.Combine(Environment.CurrentDirectory, "Resources\\GuidPDF\\Quick Start Guide.pdf");
  80. /// <summary>
  81. /// 是否需要更新内嵌文档
  82. /// </summary>
  83. public static bool IsGuidPDFUpdated = false;
  84. /// <summary>
  85. /// 产品名称
  86. /// </summary>
  87. public static string Name = "PDF Office";
  88. /// <summary>
  89. /// 当前app版本号
  90. /// </summary>
  91. public static string Version = FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).ProductVersion;
  92. public static MainWindowViewModel mainWindowViewModel;
  93. /// <summary>
  94. /// 当前软件已打开的文件路径列表
  95. /// </summary>
  96. public static List<string> OpenedFileList = new List<string>();
  97. public static CacheFilePath CachePath;
  98. /// <summary>
  99. /// OCR数据模型所在目录
  100. /// </summary>
  101. public static string modelFolderPath = null;
  102. /// <summary>
  103. /// 是否是软件的第一个主窗体
  104. /// </summary>
  105. public static bool IsFirstOpen = true;
  106. public static bool IsBookMode = false;
  107. /// <summary>
  108. /// 是否已经登陆
  109. /// </summary>
  110. public static bool IsLogin = true;
  111. //是否需要显示注册弹窗
  112. //app第一次启动时需要弹出注册弹窗
  113. public static bool IsShowRegist = false;
  114. /// <summary>
  115. /// 文案资源管理器 首页
  116. /// </summary>
  117. public static ResourceManager HomePageLoader = new ResourceManager("PDF_Office.Strings.HomePage.HomePage", Assembly.GetExecutingAssembly());
  118. /// <summary>
  119. /// 文案资源管理器 阅读页
  120. /// </summary>
  121. public static ResourceManager MainPageLoader = new ResourceManager("PDF_Office.Strings.MainPage.MainPage", Assembly.GetExecutingAssembly());
  122. /// <summary>
  123. /// 文案资源管理器 注册相关
  124. /// </summary>
  125. public static ResourceManager ServiceLoader = new ResourceManager("PDF_Office.Strings.Service.Service", Assembly.GetExecutingAssembly());
  126. public App()
  127. {
  128. #if !DEBUG
  129. //接入Appcenter后台数据检测 PDF Reader Pro Test
  130. string appkey = "395433ac-97b6-4e28-803e-3d377bdef875";
  131. AppCenter.Start(appkey, typeof(Analytics), typeof(Crashes));
  132. var countryCode = RegionInfo.CurrentRegion.TwoLetterISORegionName;//上传国家信息
  133. AppCenter.SetCountryCode(countryCode);
  134. #endif
  135. }
  136. private void InitSettings()
  137. {
  138. //是否是更新后
  139. if (Settings.Default.UpdateSettings)
  140. {
  141. //内嵌文档更新时 显示文档到最前方
  142. //每次版本更新留意检查IsGuidPDFUpdated 值,如果没有内嵌文档更新,要设为false
  143. if (Settings.Default.IsGuidPDFUpdated && File.Exists(GuidPDFPath))
  144. {
  145. App.IsGuidPDFUpdated = true;
  146. Settings.Default.IsGuidPDFUpdated = false;
  147. }
  148. Settings.Default.Upgrade();
  149. Settings.Default.UpdateSettings = false;
  150. App.IsShowRegist = true;
  151. //重置用于弹窗的记录参数
  152. }
  153. if (Settings.Default.UserDate == null)
  154. {
  155. Settings.Default.UserDate = new PDFSettings.UserDate();
  156. }
  157. if (Settings.Default.RecentOpenFiles == null)
  158. {
  159. Settings.Default.RecentOpenFiles = new RecentOpenFiles();
  160. }
  161. if (Settings.Default.RedactionsSettings == null)
  162. Settings.Default.RedactionsSettings = new PDFSettings.RedactionSettings();
  163. if (Settings.Default.AppProperties == null)
  164. Settings.Default.AppProperties = new PDFSettings.APPSettingProperties();
  165. if (Settings.Default.AllPDFToolsList == null)
  166. Settings.Default.AllPDFToolsList = new PDFSettings.AllPDFToolsList();
  167. if (Settings.Default.QuickPDFToolsList == null)
  168. Settings.Default.QuickPDFToolsList = new PDFSettings.QuickPDFToolsList();
  169. if (App.IsGuidPDFUpdated)
  170. {
  171. SettingHelper.SortRecentOpenFiles(GuidPDFPath);
  172. }
  173. }
  174. protected override void OnStartup(StartupEventArgs e)
  175. {
  176. LicenseVerify();
  177. InitSettings();
  178. CachePath = CacheFilePath.Instance;
  179. //清除临时文件
  180. CacheFilePath.Instance.ClearDeleteFiles();
  181. try
  182. {
  183. DirectoryInfo info = new DirectoryInfo(CurrentPath);
  184. //避免因存在同名文件,导致无法创建文件夹
  185. if (File.Exists(CurrentPath))
  186. {
  187. File.Delete(CurrentPath);
  188. }
  189. if (!info.Exists)
  190. {
  191. info.Create();
  192. }
  193. }
  194. catch (Exception ex)
  195. {
  196. }
  197. //增加全局异常捕获
  198. //UI线程异常
  199. this.DispatcherUnhandledException += App_DispatcherUnhandledException;
  200. //非UI线程异常
  201. AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
  202. //Task线程内
  203. TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
  204. base.OnStartup(e);
  205. }
  206. private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
  207. {
  208. var ex = e.Exception as Exception;
  209. if (ex != null)
  210. {
  211. MessageBox.Show("发生Task未处理异常:" + ex.Message + "\n" + ex.StackTrace, "系统错误", MessageBoxButton.OK, MessageBoxImage.Error);
  212. }
  213. }
  214. private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
  215. {
  216. if (e.ExceptionObject is System.Exception)
  217. {
  218. Exception ex = (System.Exception)e.ExceptionObject;
  219. MessageBox.Show("发生非UI线程异常:" + ex.Message + "\n" + ex.StackTrace, "系统错误", MessageBoxButton.OK, MessageBoxImage.Error);
  220. }
  221. }
  222. private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
  223. {
  224. e.Handled = true;
  225. MessageBox.Show("发生UI线程异常:" + e.Exception.Message + "\n" + e.Exception.StackTrace, "系统错误", MessageBoxButton.OK, MessageBoxImage.Error);
  226. }
  227. /// <summary>
  228. /// 创建启动窗口
  229. /// </summary>
  230. /// <returns></returns>
  231. protected override Window CreateShell()
  232. {
  233. return Container.Resolve<MainWindow>();
  234. }
  235. protected override void RegisterTypes(IContainerRegistry containerRegistry)
  236. {
  237. #region 注册内容组件
  238. containerRegistry.RegisterForNavigation<HomeContent>();
  239. containerRegistry.RegisterForNavigation<ViewContent>();
  240. containerRegistry.RegisterForNavigation<ScanViwer>();
  241. containerRegistry.RegisterForNavigation<MainContent>();
  242. containerRegistry.RegisterForNavigation<HomeCloudContent>("Cloud");
  243. containerRegistry.RegisterForNavigation<HomeToolsContent>("Tools");
  244. containerRegistry.RegisterForNavigation<HomeGuidContent>("Guid");
  245. containerRegistry.RegisterForNavigation<BOTAContent>();
  246. containerRegistry.RegisterForNavigation<PropertyPanelContent>();
  247. containerRegistry.RegisterForNavigation<PageEditContent>();
  248. containerRegistry.RegisterForNavigation<BottomToolContent>();
  249. containerRegistry.RegisterForNavigation<ToolsBarContent>();
  250. containerRegistry.RegisterForNavigation<TextEditToolContent>();
  251. containerRegistry.RegisterForNavigation<AnnotToolContent>();
  252. containerRegistry.RegisterForNavigation<BookmarkContent>();
  253. containerRegistry.RegisterForNavigation<SearchContent>();
  254. containerRegistry.RegisterForNavigation<OutLineControl>();
  255. containerRegistry.RegisterForNavigation<ViewModularContent>();
  256. containerRegistry.RegisterForNavigation<SplitScreenContent>();
  257. containerRegistry.RegisterForNavigation<ThemesContent>();
  258. containerRegistry.RegisterForNavigation<ReadModeContent>();
  259. containerRegistry.RegisterForNavigation<AnnotationContent>();
  260. containerRegistry.RegisterForNavigation<ReadViewContent>();
  261. containerRegistry.RegisterForNavigation<PageContent>();
  262. containerRegistry.RegisterForNavigation<HomePagePrinterDocumentContent>();
  263. containerRegistry.RegisterForNavigation<HomePagePrinterModSizeContent>();
  264. containerRegistry.RegisterForNavigation<HomePagePrinterModPosterContent>();
  265. containerRegistry.RegisterForNavigation<HomePagePrinterModMultipleContent>();
  266. containerRegistry.RegisterForNavigation<HomePagePrinterModBookletContent>();
  267. containerRegistry.RegisterForNavigation<HomePageCompressDialog>();
  268. containerRegistry.RegisterForNavigation<HomePageSetPasswordDialog>();
  269. containerRegistry.RegisterForNavigation<HomePageRemoveDialog>();
  270. containerRegistry.RegisterForNavigation<HomePageHeaderFooterDialog>();
  271. containerRegistry.RegisterForNavigation<HomePageHeaderFooterTemplateListContent>();
  272. containerRegistry.RegisterForNavigation<HomePageHeaderFooterCreateContent>();
  273. containerRegistry.RegisterForNavigation<HomePageBatesDialog>();
  274. containerRegistry.RegisterForNavigation<HomePageBatesTemplateListContent>();
  275. containerRegistry.RegisterForNavigation<HomePageBatesCreateContent>();
  276. containerRegistry.RegisterForNavigation<HomePageBackgroundDialog>();
  277. containerRegistry.RegisterForNavigation<HomePageBackgroundTemplateListBaseContent>();
  278. containerRegistry.RegisterForNavigation<HomePageBackgroundTemplateListColorContent>();
  279. containerRegistry.RegisterForNavigation<HomePageBackgroundTemplateListFileContent>();
  280. containerRegistry.RegisterForNavigation<HomePageBackgroundCreateBaseContent>();
  281. containerRegistry.RegisterForNavigation<HomePageBackgroundCreateColorContent>();
  282. containerRegistry.RegisterForNavigation<HomePageBackgroundCreateFileContent>();
  283. containerRegistry.RegisterForNavigation<HomePageWatermarkDialog>();
  284. containerRegistry.RegisterForNavigation<HomePageWatermarkTemplateListBaseContent>();
  285. containerRegistry.RegisterForNavigation<HomePageWatermarkTemplateListTextContent>();
  286. containerRegistry.RegisterForNavigation<HomePageWatermarkTemplateListFileContent>();
  287. containerRegistry.RegisterForNavigation<HomePageWatermarkCreateBaseContent>();
  288. containerRegistry.RegisterForNavigation<HomePageWatermarkCreateTextContent>();
  289. containerRegistry.RegisterForNavigation<HomePageWatermarkCreateFileContent>();
  290. containerRegistry.RegisterForNavigation<ConverterBarContent>();
  291. containerRegistry.RegisterForNavigation<ScanContent>();
  292. containerRegistry.RegisterForNavigation<HomePageConverterDialog>();
  293. containerRegistry.RegisterForNavigation<HomePageConverterCSV>();
  294. containerRegistry.RegisterForNavigation<HomePageConverterImg>();
  295. containerRegistry.RegisterForNavigation<HomePageConverterWord>();
  296. containerRegistry.RegisterForNavigation<HomePageConverterExcel>();
  297. containerRegistry.RegisterForNavigation<WatermarkContent>();
  298. containerRegistry.RegisterForNavigation<BackgroundContent>();
  299. containerRegistry.RegisterForNavigation<BackgroundTemplateListBaseContent>();
  300. containerRegistry.RegisterForNavigation<BackgroundTemplateListColorContent>();
  301. containerRegistry.RegisterForNavigation<BackgroundTemplateListFileContent>();
  302. containerRegistry.RegisterForNavigation<BackgroundCreateBaseContent>();
  303. containerRegistry.RegisterForNavigation<BackgroundCreateColorContent>();
  304. containerRegistry.RegisterForNavigation<BackgroundCreateFileContent>();
  305. containerRegistry.RegisterForNavigation<BackgroundDocumentContent>();
  306. containerRegistry.RegisterForNavigation<WatermarkTemplateListBaseContent>();
  307. containerRegistry.RegisterForNavigation<WatermarkTemplateListTextContent>();
  308. containerRegistry.RegisterForNavigation<WatermarkTemplateListFileContent>();
  309. containerRegistry.RegisterForNavigation<WatermarkCreateBaseContent>();
  310. containerRegistry.RegisterForNavigation<WatermarkCreateTextContent>();
  311. containerRegistry.RegisterForNavigation<WatermarkCreateFileContent>();
  312. containerRegistry.RegisterForNavigation<WatermarkDocumentContent>();
  313. containerRegistry.RegisterForNavigation<HomePagePrinterModMultipleContent>();
  314. containerRegistry.RegisterForNavigation<FreehandAnnotProperty>();
  315. containerRegistry.RegisterForNavigation<FreetextAnnotProperty>();
  316. containerRegistry.RegisterForNavigation<StickyNoteProperty>();
  317. containerRegistry.RegisterForNavigation<ImageAnnotProperty>();
  318. containerRegistry.RegisterForNavigation<LinkAnnotProperty>();
  319. containerRegistry.RegisterForNavigation<SharpsAnnotProperty>();
  320. containerRegistry.RegisterForNavigation<StampAnnotProperty>();
  321. containerRegistry.RegisterForNavigation<SignatureAnnotProperty>();
  322. containerRegistry.RegisterForNavigation<TextAnnotProperty>();
  323. containerRegistry.RegisterForNavigation<ImageEditProperty>();
  324. containerRegistry.RegisterForNavigation<TextEditProperty>();
  325. containerRegistry.RegisterForNavigation<ImageEditProperty>();
  326. containerRegistry.RegisterForNavigation<ImageTextEditProperty>();
  327. containerRegistry.RegisterForNavigation<ScanPropertyPanel>();
  328. containerRegistry.RegisterForNavigation<BatesContent>();
  329. containerRegistry.RegisterForNavigation<BatesTemplateListContent>();
  330. containerRegistry.RegisterForNavigation<BatesCreateContent>();
  331. containerRegistry.RegisterForNavigation<BatesDocumentContent>();
  332. containerRegistry.RegisterForNavigation<HeaderFooterContent>();
  333. containerRegistry.RegisterForNavigation<HeaderFooterTemplateListContent>();
  334. containerRegistry.RegisterForNavigation<HeaderFooterCreateContent>();
  335. containerRegistry.RegisterForNavigation<HeaderFooterDocumentContent>();
  336. containerRegistry.RegisterForNavigation<RedactionContent>();
  337. //填写与签名
  338. containerRegistry.RegisterForNavigation<FillAndSignContent>();
  339. containerRegistry.RegisterForNavigation<DateFillProperty>();
  340. containerRegistry.RegisterForNavigation<ShapFillProperty>();
  341. containerRegistry.RegisterForNavigation<TextFillProperty>();
  342. //Form表单
  343. containerRegistry.RegisterForNavigation<EmptyFormProperty>();
  344. containerRegistry.RegisterForNavigation<FormsToolContent>();
  345. containerRegistry.RegisterForNavigation<TextFieldProperty>();
  346. containerRegistry.RegisterForNavigation<ButtonProperty>();
  347. containerRegistry.RegisterForNavigation<CheckBoxProperty>();
  348. containerRegistry.RegisterForNavigation<ListBoxProperty>();
  349. containerRegistry.RegisterForNavigation<ComboxProperty>();
  350. containerRegistry.RegisterForNavigation<RadioButtonProperty>();
  351. containerRegistry.RegisterForNavigation<SignProperty>();
  352. //Tip
  353. containerRegistry.RegisterForNavigation<SetPasswordSuccessfullyTip>();
  354. containerRegistry.RegisterForNavigation<FileRestrictedTip>();
  355. containerRegistry.RegisterForNavigation<LinkAnnotTip>();
  356. containerRegistry.RegisterForNavigation<ReadModelTip>();
  357. containerRegistry.RegisterForNavigation<RemoveSecuritySuccessTip>();
  358. containerRegistry.RegisterForNavigation<EnterReadModeTip>();
  359. //轻会员
  360. containerRegistry.RegisterForNavigation<CodeRegion>();
  361. containerRegistry.RegisterForNavigation<LoginRegion>();
  362. containerRegistry.RegisterForNavigation<LoginPasswordRegion>();
  363. containerRegistry.RegisterForNavigation<RegisterRegion>();
  364. containerRegistry.RegisterForNavigation<RegisterOKRegion>();
  365. containerRegistry.RegisterForNavigation<NOInternetRegion>();
  366. containerRegistry.RegisterForNavigation<UserOutCodeRegion>();
  367. containerRegistry.RegisterForNavigation<PasswordUpdataRegion>();
  368. containerRegistry.RegisterForNavigation<StickyNotePopup>();
  369. #endregion 注册内容组件
  370. #region 注册弹窗
  371. containerRegistry.RegisterDialog<VerifyPassWordDialog>(DialogNames.VerifyPassWordDialog);
  372. containerRegistry.RegisterDialog<FullScreenWindow>(DialogNames.FullScreenDialog);
  373. containerRegistry.RegisterDialog<CompressDialog>(DialogNames.CompressDialog);
  374. containerRegistry.RegisterDialog<MergeDialog>(DialogNames.MergeDialog);
  375. containerRegistry.RegisterDialog<SetPasswordDialog>(DialogNames.SetPasswordDialog);
  376. containerRegistry.RegisterDialog<CheckPasswordDialog>(DialogNames.CheckPasswordDialog);
  377. containerRegistry.RegisterDialog<DeleteSafetySettingsDialog>(DialogNames.DeleteSafetySettingsDialog);
  378. containerRegistry.RegisterDialog<CompressProgressBarDialog, PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs.CompresProgressBarDialogViewModel>(DialogNames.CompressProgressBarDialog);
  379. containerRegistry.RegisterDialog<InsertDialog>(DialogNames.InsertDialog);
  380. containerRegistry.RegisterDialog<SplitDialog>(DialogNames.SplitDialog);
  381. containerRegistry.RegisterDialog<ExtractDialog>(DialogNames.ExtractDialog);
  382. containerRegistry.RegisterDialog<HomePageExtractDialog>(DialogNames.HomePageExtractDialog);
  383. containerRegistry.RegisterDialog<HomePageInsertDialog>(DialogNames.HomePageInsertDialog);
  384. containerRegistry.RegisterDialog<HomePageSplitDialog>(DialogNames.HomePageSplitDialog);
  385. containerRegistry.RegisterDialog<HomePagePrinterDialog>(DialogNames.HomePagePrinterDialog);
  386. containerRegistry.RegisterDialog<HomePagePrinterPaperSettingsDialog>(DialogNames.HomePagePrinterPaperSettingsDialog);
  387. containerRegistry.RegisterDialog<HomePagePictureToPDFDialog>(DialogNames.HomePagePictureToPDFDialog);
  388. containerRegistry.RegisterDialog<HomePageBatchProcessingDialog>(DialogNames.HomePageBatchProcessingDialog);
  389. containerRegistry.RegisterDialog<DynamicPropertyDialog>(DialogNames.DynamicPropertyDialog);
  390. containerRegistry.RegisterDialog<CustomCreateDialog>(DialogNames.CustomCreateDialog);
  391. containerRegistry.RegisterDialog<SignatureCreateDialog>(DialogNames.SignatureCreateDialog);
  392. containerRegistry.RegisterDialog<ConverterCSVDialog>(DialogNames.ConverterCSVDialog);
  393. containerRegistry.RegisterDialog<ConverterPPTDialog>(DialogNames.ConverterPPTDialog);
  394. containerRegistry.RegisterDialog<ConverterTextDialog>(DialogNames.ConverterTextDialog);
  395. containerRegistry.RegisterDialog<ConverterWordDialog>(DialogNames.ConverterWordDialog);
  396. containerRegistry.RegisterDialog<ConverterHTMLDialog>(DialogNames.ConverterHTMLDialog);
  397. containerRegistry.RegisterDialog<ConverterImgDialog>(DialogNames.ConverterImgDialog);
  398. containerRegistry.RegisterDialog<ConverterRTFDialog>(DialogNames.ConverterRTFDialog);
  399. containerRegistry.RegisterDialog<ConverterExcelDialog>(DialogNames.ConverterExcelDialog);
  400. containerRegistry.RegisterDialog<ConverterProgressBarDialog>(DialogNames.ConverterProgressBarDialog);
  401. containerRegistry.RegisterDialog<ScreenAnnotationDialog>(DialogNames.ScreenAnnotationDialog);
  402. containerRegistry.RegisterDialog<AddBookmarkDialog>(DialogNames.AddBookmarkDialog);
  403. containerRegistry.RegisterDialog<AddAnnotationDialog>(DialogNames.AddAnnotationDialog);
  404. containerRegistry.RegisterDialog<EditPresetColorsDialog>(DialogNames.EditPresetColorsDialog);
  405. containerRegistry.RegisterDialog<CreateFromHtmlDialog>(DialogNames.CreateFromHtmlDialog);
  406. containerRegistry.RegisterDialog<CreateFromScannerDialogs>(DialogNames.CreateFromScannerDialogs);
  407. //标记密文弹窗
  408. containerRegistry.RegisterDialog<MarkSettingDialog>(DialogNames.MarkSettingDialog);
  409. containerRegistry.RegisterDialog<PageMarkDialog>(DialogNames.PageMarkDialog);
  410. containerRegistry.RegisterDialog<RepeatMarkDialog>(DialogNames.RepeatMarkDialog);
  411. containerRegistry.RegisterDialog<SettingsDialog>(DialogNames.SettingsDialog);
  412. containerRegistry.RegisterDialog<PropertiesDialog>(DialogNames.PropertyDialog);
  413. //轻会员弹窗
  414. containerRegistry.RegisterDialog<RegisterDialog>(DialogNames.RegisterDialog);
  415. containerRegistry.RegisterDialog<LoginDialog>(DialogNames.LoginDialog);
  416. containerRegistry.RegisterDialog<UserDialog>(DialogNames.UserDialog);
  417. containerRegistry.RegisterDialog<UserOutingLogin>(DialogNames.UserOutingLogin);
  418. //新手引导弹窗
  419. containerRegistry.RegisterDialog<NoviceGuidDialog>(DialogNames.GuidDialog);
  420. containerRegistry.RegisterDialog<IAPCompareDialog>(DialogNames.IAPCompareDialog);
  421. #endregion 注册弹窗
  422. }
  423. protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings)
  424. {
  425. var region = new SingleActiveRegion() { Name = RegionNames.MainRegion };
  426. region.Behaviors.Add(DragablzWindowBehavior.BehaviorKey, new DragablzWindowBehavior());
  427. Container.Resolve<IRegionManager>().Regions.Add(region);
  428. base.ConfigureRegionAdapterMappings(regionAdapterMappings);
  429. }
  430. /// <summary>
  431. /// 验证SDK和转档库密钥
  432. /// </summary>
  433. /// <returns></returns>
  434. private static bool LicenseVerify()
  435. {
  436. bool result = false;
  437. try
  438. {
  439. result = CPDFSDKVerifier.LoadNativeLibrary();
  440. if (!result)
  441. return false;
  442. }
  443. catch { }
  444. SDKLisenceHelper sdkhelper = new SDKLisenceHelper();
  445. string devKey = "";
  446. string devSecret = "";
  447. #if DEBUG
  448. devKey = "ehrnKqkWc1XSEAWyPUt6+95GzCoLEyoKrCbsUuJkCqGmxmP5ozX4bS0R6crHItQVNTFvC5mBZ1M7QjJ6Ekdu4Daj7PM+EDLTBKbFJinK4Ri9E5E2X+a9vF5zSj0TkIscQPVnwj9ikxAFOWGIyybMwQQzwc8a4j1cGOqGXQRDMMY=";
  449. devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6ccHhEu996bvBgqf8Sw8OekQKQq13VBewK5AckaDux4W7SGRhCUNWC4MItkr36JnXMD2tiFQYzMG8C66HYmRGSLh";
  450. devKey = sdkhelper.DevKey;
  451. devSecret = sdkhelper.DevSecret;
  452. #endif
  453. string userKey = sdkhelper.UserKey;
  454. string userSecret = sdkhelper.UserSecret;
  455. try
  456. {
  457. LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(devKey, devSecret);
  458. if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
  459. return false;
  460. }
  461. catch { }
  462. string ConverterDevKey = sdkhelper.ConverterDevKey;
  463. string ConverterDevSecret = sdkhelper.ConverterDevSecret;
  464. string ConverterUserkey = sdkhelper.ConverterUserkey;
  465. string ConverterUserSecret = sdkhelper.ConverterUserSecret;
  466. try
  467. {
  468. //加载OCR库
  469. if (!DocumentAIKitLicenseVerify())
  470. {
  471. }
  472. /*LicenseError licenseerror = CPDFConverter.SDKLicenseVerify(ConverterDevKey, ConverterDevSecret, ConverterUserkey, ConverterUserSecret);
  473. string resPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location) + "\\";
  474. if (licenseerror != LicenseError.ERR_SUCCESS)
  475. {
  476. return false;
  477. }
  478. CPDFConverter.Init(resPath);*/
  479. string resPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location) + "\\";
  480. LicenseError licenseerror = CPDFConverter.LicenseVerify(ConverterDevKey, ConverterDevSecret);
  481. if (licenseerror != LicenseError.ERR_SUCCESS)
  482. {
  483. //MessageBox.Show("ComPDFKit Conversion SDK Load Failed!");
  484. return false;
  485. }
  486. CPDFConverter.Init(resPath);
  487. CPDFConverter.SetOCRModelFolder(modelFolderPath);
  488. }
  489. catch { }
  490. return result;
  491. }
  492. /// <summary>
  493. /// 加载,验证DocumentAIKitLicense
  494. /// 目前DocmentAILib暂时移动到X64(原来路径为 string libFolderPath = Path.Combine(exePath, "DocumentAILib");)
  495. /// 含有的库有(ComDocumentAINative.dll,DocumentAI.dll,libiomp5md.dll,mkldnn.dll,mklml.dll,onnxruntime.dll,opencv_world420.dll,opencv_word420d.dll,paddle_inference.dll,paddle2onnx.dll)
  496. /// </summary>
  497. /// <returns></returns>
  498. private static bool DocumentAIKitLicenseVerify()
  499. {
  500. Task.Factory.StartNew(() =>
  501. {
  502. string exePath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location);
  503. exePath = Path.Combine(exePath, "x64");
  504. //string libFolderPath = Path.Combine(exePath, "DocumentAILib");
  505. string libFolderPath = exePath;
  506. modelFolderPath = Path.Combine(exePath, "models");
  507. if (CDocumentAIKit.LoadNativeLibrary(libFolderPath) == false)
  508. return;
  509. CErrorCode error = CDocumentAIKit.LicenseVerify("1F8B0818801DD8F20000636F6D2E636F6D7064666B69742E636F6E76657273696F6E00344136353732364636443635353936313645363700011002EFFDC671954ADECE496F0D96F5C14D82A293CEC71744D0914A388C0FDECA16FC9B6D28694C762AC71F382D9E50B2E9473B431C8FE18D5656A52AB2FF2B06834B7AB87CFB42884BA59110642327D18D77BD13D2AC8EC3A06357000E315956673DC38A02F97AD29B24F421D82D9346A3737BFD806777769DFBA4D50B911E65F4FC674A6DCA1E53FE1F9A4A8DE987B41B143282D2286C22C29F69724A4BCA5C0BD3013DDA2207FFC10A385EF980D4547FD76A4B6EBDE54ACCE68B656621032EC146123B1E8DD9B1EF7F71725917D9CA58431601707A6BB1B41A82049FAF14599B34EAF7D59CD8E6CFEAB24AF5CDDCB2A2236E77710B7E30F10022F2F25EC6586D3B5207378F2CB8B9176EE463B1F2B1D8BD776142E8F9575235BE2A57A63948EDB05DED4649F410CE5941DA5155E6F5A127BFABC5E424F71A1AEB201595ECE8BC8C91DD1C0FF7300A4CB7253B6277CF8B8C5F3CDA5D569E2E27F1609815F9944816AD69550049D94C0FD263D2D3FCF4A3CE685C67F7E27F70E8D9332A45984E7F4D7F5D800BAA58D18715384B98BE310AEDCB4BCF4833E76A5E3860032B3A926DFD247FF426ADA94BA1DA7B11F0451AE506A93DD8B809453E5B51CBE24D572973A55FBD3D25453C3FAD47D30ACAB30500C15FD8714B365AA6F275808C9EB7D5116AC809C91786D6571E2622A5E730D40614061C3B3FC129108AA1360C16151CE38CA03FF3A28FFE7200B4FFA24EF7EDF54B8E9AB207E00810020000");
  510. if (error != CErrorCode.E_DA_SUCCESS)
  511. return;
  512. });
  513. return true;
  514. }
  515. protected override void OnExit(ExitEventArgs e)
  516. {
  517. Environment.Exit(1);
  518. base.OnExit(e);
  519. }
  520. }
  521. }