App.xaml.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  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_Master.CustomControl;
  13. using PDF_Master.CustomControl.SystemControl;
  14. using PDF_Master.ViewModels;
  15. using PDF_Master.Views;
  16. using PDF_Master.Views.BOTA;
  17. using PDF_Master.Views.Dialog;
  18. using PDF_Master.Views.HomePanel;
  19. using Prism.DryIoc;
  20. using Prism.Ioc;
  21. using Prism.Regions;
  22. using PDF_Master.Model;
  23. using PDF_Master.Views.PageEdit;
  24. using PDF_Master.Properties;
  25. using PDFSettings;
  26. using PDF_Master.Views.Tools;
  27. using PDF_Master.Views.Dialog.ToolsDialogs.SaftyDialogs;
  28. using PDF_Master.Views.Dialog.ToolsDialogs.CompressDialogs;
  29. using PDF_Master.Views.Dialog.PageEditDialogs;
  30. using PDF_Master.Helper;
  31. using PDF_Master.Views.Dialog.HomePageToolsDialogs;
  32. using PDF_Master.Views.Dialog.HomePageToolsDialogs.HomePagePrinter;
  33. using PDF_Master.Views.PropertyPanel;
  34. using PDF_Master.Views.Dialog.BOTA;
  35. using PDF_Master.Views.PropertyPanel.AnnotPanel;
  36. using PDF_Master.Views.FillAndSign;
  37. using PDF_Master.Views.FillAndSign.PropertyPanel;
  38. using PDF_Master.Views.PropertyPanel.ViewModular;
  39. using PDF_Master.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
  40. using PDF_Master.Views.Dialog.ConverterDialogs;
  41. using PDF_Master.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter;
  42. using PDF_Master.Views.EditTools.Watermark;
  43. using PDF_Master.Views.EditTools.Background;
  44. using PDF_Master.Views.EditTools.Bates;
  45. using PDF_Master.Views.EditTools.HeaderFooter;
  46. using PDF_Master.Views.EditTools.Redaction;
  47. using PDF_Master.Views.Form;
  48. using PDF_Master.Views.PropertyPanel.PDFEdit;
  49. using PDF_Master.Views.Dialog.ToolsDialogs;
  50. using PDF_Master.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter;
  51. using PDF_Master.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates;
  52. using PDF_Master.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark;
  53. using PDF_Master.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground;
  54. using ComDocumentAIKit;
  55. using PDF_Master.Views.PropertyPanel.Scan;
  56. using PDF_Master.Views.Dialog.Redaction;
  57. using PDF_Master.Views.Scan;
  58. using PDF_Master.Views.TipContent;
  59. using System.Windows.Threading;
  60. using PDF_Master.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. using System.Runtime.InteropServices;
  69. using System.Security.Cryptography;
  70. using System.Text;
  71. using Prism.Services.Dialogs;
  72. using NetSparkleUpdater;
  73. using NetSparkleUpdater.SignatureVerifiers;
  74. using System.Threading;
  75. using PDF_Master.Views.HomePanel.PDFTools;
  76. using PDF_Master.Views.HomePanel.ChatGPTAI;
  77. using PDF_Master.Views.Dialog.ChatGPTAIDialogs;
  78. namespace PDF_Master
  79. {
  80. /// <summary>
  81. /// App.xaml 的交互逻辑
  82. /// </summary>
  83. public partial class App : PrismApplication
  84. {
  85. /// <summary>
  86. /// 产品名称
  87. /// </summary>
  88. public static string Name = "PDF Master";
  89. /// <summary>
  90. /// 新建文档未保存时,文档的临时命名
  91. /// </summary>
  92. public static string UntitledFileNmae = "Document.pdf";
  93. public static string CurrentPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), Name);
  94. public static List<string> NeedOpenFilePathList = new List<string>();
  95. /// <summary>
  96. /// 项目内嵌文档路径 实际打开文档时,会将改文档复制到Document 文件夹下,避免C盘文件无法写入的情况
  97. /// </summary>
  98. public static string GuidPDFPath;
  99. /// <summary>
  100. /// 是否需要更新内嵌文档
  101. /// </summary>
  102. public static bool IsGuidPDFUpdated = false;
  103. /// <summary>
  104. /// 当前app版本号
  105. /// </summary>
  106. public static string Version = FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).ProductVersion;
  107. public static MainWindowViewModel mainWindowViewModel;
  108. /// <summary>
  109. /// 当前软件已打开的文件路径列表
  110. /// </summary>
  111. public static List<string> OpenedFileList = new List<string>();
  112. public static CacheFilePath CachePath;
  113. /// <summary>
  114. /// OCR数据模型所在目录
  115. /// </summary>
  116. public static string modelFolderPath = null;
  117. public static SparkleUpdater SparkleUpdateDetector;
  118. /// <summary>
  119. /// 是否是软件的第一个主窗体
  120. /// </summary>
  121. public static bool IsFirstOpen = true;
  122. /// <summary>
  123. /// 是否获取了SDK支持的系统字体
  124. /// </summary>
  125. public static bool IsGetTextFamily = false;
  126. /// <summary>
  127. /// 激活窗体的原因
  128. /// </summary>
  129. public static string WebOpencase = "";
  130. public static bool IsBookMode = false;
  131. public static bool UserOpen = false;
  132. public static bool LoginOpen = false;
  133. /// <summary>
  134. /// 是否使用过高级功能
  135. /// </summary>
  136. public static bool IsUsedVIP = false;
  137. /// <summary>
  138. /// 是否已经登陆
  139. /// </summary>
  140. public static bool IsLogin = false;
  141. /// <summary>
  142. /// 记录开始拖拽的窗口句柄,用于判断是否为跨窗口拖拽
  143. /// </summary>
  144. public static MainWindow DropStartWindow = null;
  145. /// <summary>
  146. /// 双击打开文件通知ID
  147. /// </summary>
  148. public static uint MsgId;
  149. /// <summary>
  150. /// 将应用前置通知ID
  151. /// </summary>
  152. public static uint WakeId;
  153. /// <summary>
  154. /// 网页查看账单信息token失效唤起
  155. /// </summary>
  156. public static uint WebopenexpiredId;
  157. //App当前系统语言
  158. public static string CultureLanguage;
  159. /// <summary>
  160. /// 文案资源管理器 首页
  161. /// </summary>
  162. public static ResourceManager HomePageLoader = new ResourceManager("PDF_Master.Strings.HomePage.HomePage", Assembly.GetExecutingAssembly());
  163. /// <summary>
  164. /// 文案资源管理器 阅读页
  165. /// </summary>
  166. public static ResourceManager MainPageLoader = new ResourceManager("PDF_Master.Strings.MainPage.MainPage", Assembly.GetExecutingAssembly());
  167. /// <summary>
  168. /// 文案资源管理器 注册相关
  169. /// </summary>
  170. public static ResourceManager ServiceLoader = new ResourceManager("PDF_Master.Strings.Service.Service", Assembly.GetExecutingAssembly());
  171. public App()
  172. {
  173. #if !DEBUG
  174. //接入Appcenter后台数据检测 PDF Reader Pro Test
  175. string appkey = "260c4a7f-6986-4d5c-b201-cd50a46cc243";
  176. AppCenter.Start(appkey, typeof(Analytics), typeof(Crashes));
  177. var countryCode = RegionInfo.CurrentRegion.TwoLetterISORegionName;//上传国家信息
  178. AppCenter.SetCountryCode(countryCode);
  179. #endif
  180. //增加全局异常捕获
  181. //UI线程异常
  182. this.DispatcherUnhandledException += App_DispatcherUnhandledException;
  183. //非UI线程异常
  184. AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
  185. //Task线程内
  186. TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
  187. CultureLanguage = System.Globalization.CultureInfo.CurrentUICulture.ToString();
  188. }
  189. private void InitSettings()
  190. {
  191. try
  192. {
  193. //是否是更新后
  194. if (Settings.Default.UpdateSettings)
  195. {
  196. //内嵌文档更新时 显示文档到最前方
  197. //每次版本更新留意检查IsGuidPDFUpdated 值,如果没有内嵌文档更新,要设为false
  198. if (Settings.Default.IsGuidPDFUpdated)
  199. {
  200. App.IsGuidPDFUpdated = true;
  201. Settings.Default.IsGuidPDFUpdated = false;
  202. }
  203. Settings.Default.Upgrade();
  204. Settings.Default.UpdateSettings = false;
  205. //清除OCR下载内容
  206. if (Settings.Default.AppProperties == null)
  207. {
  208. Settings.Default.AppProperties = new PDFSettings.APPSettingProperties();
  209. }
  210. Settings.Default.AppProperties.OCRFile_Url = "";
  211. Settings.Default.AppProperties.OCRmodelMD5 = "";
  212. //重置用于弹窗的记录参数
  213. }
  214. if (Settings.Default.ADDate == null)
  215. {
  216. Settings.Default.ADDate = new PDFSettings.ADDate();
  217. }
  218. if (Settings.Default.PDFEditList == null)
  219. {
  220. Settings.Default.PDFEditList = new PDFSettings.PDFEditList();
  221. }
  222. if (Settings.Default.UserDate == null)
  223. {
  224. Settings.Default.UserDate = new PDFSettings.UserDate();
  225. }
  226. if (Settings.Default.AppProperties == null)
  227. {
  228. Settings.Default.AppProperties = new PDFSettings.APPSettingProperties();
  229. }
  230. if (Settings.Default.RecentOpenFiles == null)
  231. {
  232. Settings.Default.RecentOpenFiles = new RecentOpenFiles();
  233. }
  234. if (Settings.Default.RedactionsSettings == null)
  235. Settings.Default.RedactionsSettings = new PDFSettings.RedactionSettings();
  236. if (Settings.Default.AppProperties == null)
  237. Settings.Default.AppProperties = new PDFSettings.APPSettingProperties();
  238. if (Settings.Default.AllPDFToolsList == null)
  239. Settings.Default.AllPDFToolsList = new PDFSettings.AllPDFToolsList();
  240. if (Settings.Default.QuickPDFToolsList == null)
  241. Settings.Default.QuickPDFToolsList = new PDFSettings.QuickPDFToolsList();
  242. if (Settings.Default.PresetFontList == null)
  243. Settings.Default.PresetFontList = new PDFSettings.PresetFontList();
  244. }
  245. catch
  246. {
  247. }
  248. }
  249. protected override void OnStartup(StartupEventArgs e)
  250. {
  251. MsgId = Win32Helper.RegisterWindowMessage("msgNotify_PDFMaster");
  252. WakeId = Win32Helper.RegisterWindowMessage("msgWake_PDFMaster");
  253. WakeId = Win32Helper.RegisterWindowMessage("webopenexpired_PDFMaster");
  254. Process[] pros = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);
  255. //禁止多开程序
  256. if (pros.Length > 1)
  257. {
  258. if (e != null && e.Args != null && e.Args.Length > 0)
  259. {
  260. if (Webgoapp(e.Args) == true)
  261. {
  262. if (WebOpencase == "expired")
  263. {
  264. Win32Helper.PostMessage((IntPtr)0xffff, WebopenexpiredId, IntPtr.Zero, IntPtr.Zero);
  265. IntPtr waitPtr = Win32Helper.CreateEvent(IntPtr.Zero, true, false, "Global\\shareWaitNotify" + Guid.NewGuid());
  266. Win32Helper.WaitForSingleObject(waitPtr, 5000);
  267. Win32Helper.CloseHandle(waitPtr);
  268. }
  269. else
  270. {
  271. Win32Helper.PostMessage((IntPtr)0xffff, WakeId, IntPtr.Zero, IntPtr.Zero);
  272. IntPtr waitPtr = Win32Helper.CreateEvent(IntPtr.Zero, true, false, "Global\\shareWaitNotify" + Guid.NewGuid());
  273. Win32Helper.WaitForSingleObject(waitPtr, 5000);
  274. Win32Helper.CloseHandle(waitPtr);
  275. }
  276. }
  277. else
  278. {
  279. foreach (var filePath in e.Args)
  280. {
  281. if (filePath.ToLower().Contains(".pdf") && Path.GetExtension(filePath).ToLower() == ".pdf")
  282. {
  283. try
  284. {
  285. uint mapSize = 1024;
  286. IntPtr mapHandle = Win32Helper.CreateFileMapping(IntPtr.Zero, IntPtr.Zero, Win32Helper.FileMapProtection.PageReadWrite, 0, mapSize, "Global\\sharePathNotify");
  287. if (mapHandle != IntPtr.Zero)
  288. {
  289. IntPtr writePtr = Win32Helper.MapViewOfFileEx(mapHandle, Win32Helper.FileMapAccessType.Read | Win32Helper.FileMapAccessType.Write, 0, 0, UIntPtr.Zero, IntPtr.Zero);
  290. Marshal.Copy(filePath.ToCharArray(), 0, writePtr, filePath.Length);
  291. MD5 currMd5 = MD5.Create();
  292. byte[] hashArray = currMd5.ComputeHash(Encoding.Default.GetBytes(filePath));
  293. StringBuilder hexBuilder = new StringBuilder();
  294. foreach (byte code in hashArray)
  295. {
  296. hexBuilder.AppendFormat("{0:X2}", code);
  297. }
  298. IntPtr waitPtr = Win32Helper.CreateEvent(IntPtr.Zero, true, false, "Global\\shareWaitNotify" + hexBuilder.ToString());
  299. if (waitPtr != IntPtr.Zero)
  300. {
  301. Win32Helper.PostMessage((IntPtr)0xffff, MsgId, IntPtr.Zero, (IntPtr)filePath.Length);
  302. Win32Helper.WaitForSingleObject(waitPtr, 5000);
  303. Win32Helper.CloseHandle(waitPtr);
  304. }
  305. Win32Helper.UnmapViewOfFile(writePtr);
  306. Win32Helper.CloseHandle(mapHandle);
  307. }
  308. }
  309. catch
  310. {
  311. }
  312. }
  313. }
  314. }
  315. }
  316. else
  317. {
  318. //进程置于前台
  319. Win32Helper.PostMessage((IntPtr)0xffff, WakeId, IntPtr.Zero, IntPtr.Zero);
  320. IntPtr waitPtr = Win32Helper.CreateEvent(IntPtr.Zero, true, false, "Global\\shareWaitNotify" + Guid.NewGuid());
  321. Win32Helper.WaitForSingleObject(waitPtr, 5000);
  322. Win32Helper.CloseHandle(waitPtr);
  323. }
  324. Environment.Exit(1);
  325. return;
  326. }
  327. if (!LicenseVerify())
  328. {
  329. #if !DEBUG
  330. //部分人员没有转档库密钥,为避免弹窗影响正常的功能开发、调试。本弹窗仅在Release模式下弹出,用于正式包
  331. System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
  332. {
  333. AlertsMessage alertsMessage = new AlertsMessage();
  334. alertsMessage.ShowDialog("",App.MainPageLoader.GetString("SDKLoadingFailed"), App.ServiceLoader.GetString("Text_ok"));
  335. Environment.Exit(1);
  336. return;
  337. }));
  338. #endif
  339. }
  340. InitSettings();
  341. #if DEBUG
  342. IsLogin = false;
  343. #endif
  344. CachePath = CacheFilePath.Instance;
  345. //清除临时文件
  346. CacheFilePath.Instance.ClearDeleteFiles();
  347. try
  348. {
  349. DirectoryInfo info = new DirectoryInfo(CurrentPath);
  350. //避免因存在同名文件,导致无法创建文件夹
  351. if (File.Exists(CurrentPath))
  352. {
  353. File.Delete(CurrentPath);
  354. }
  355. if (!info.Exists)
  356. {
  357. info.Create();
  358. }
  359. //复制项目的新手引导文档到Document 目录
  360. string guidfilePath = Path.Combine(CachePath.GuidPDFPath, "Quick Start Guide.pdf");
  361. if (!File.Exists(guidfilePath) || App.IsGuidPDFUpdated)
  362. {
  363. //Document 路径下没有内嵌文档或者内嵌文档版本更新时
  364. File.Copy(Path.Combine(Environment.CurrentDirectory, "Resources\\GuidPDF\\Quick Start Guide.pdf"), guidfilePath, true);
  365. GuidPDFPath = guidfilePath;
  366. }
  367. //如果内嵌文档更新了,记录置顶
  368. if (App.IsGuidPDFUpdated)
  369. {
  370. SettingHelper.SortRecentOpenFiles(GuidPDFPath);
  371. }
  372. //如果如果缓存被清空,但是缓存文档还在时,更新变量
  373. if (string.IsNullOrEmpty(GuidPDFPath))
  374. {
  375. GuidPDFPath = Path.Combine(CachePath.GuidPDFPath, "Quick Start Guide.pdf");
  376. }
  377. }
  378. catch
  379. {
  380. }
  381. #region 设置软件语系
  382. List<string> lang = new List<string>() { "zh-CN", "zh-TW", "en-US" };
  383. CultureInfo cultureInfo = new CultureInfo("en-US");
  384. //if (lang.Contains(Settings.Default.AppProperties.culture))
  385. //{
  386. // cultureInfo = new CultureInfo(Settings.Default.AppProperties.culture);
  387. //}
  388. //以防万一 极少数机器可能报错
  389. try
  390. {
  391. Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureInfo.Name);
  392. Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureInfo.Name);
  393. }
  394. catch { }
  395. #endregion 设置软件语系
  396. //启动循环检查更新线程
  397. CheckUpdate();
  398. //双击文件 打开软件时
  399. foreach (var filePath in e.Args)
  400. {
  401. if (filePath.ToLower().Contains(".pdf"))
  402. {
  403. if (filePath.Substring(filePath.LastIndexOf(".")).ToLower() == ".pdf")
  404. {
  405. NeedOpenFilePathList.Add(filePath);
  406. }
  407. }
  408. }
  409. base.OnStartup(e);
  410. }
  411. /// <summary>
  412. /// 解析是否带参数启动
  413. /// </summary>
  414. /// <param name="args"></param>
  415. /// <returns></returns>
  416. public static bool Webgoapp(string[] args)
  417. {
  418. bool flg = false;
  419. if (args.Length > 0)
  420. {
  421. string url = args[0];
  422. string[] urlParts = url.Split(new char[] { '?', '&' });
  423. Dictionary<string, string> parameters = new Dictionary<string, string>();
  424. foreach (string part in urlParts.Skip(1))
  425. {
  426. string[] keyValue = part.Split('=');
  427. if (keyValue.Length > 0)
  428. {
  429. flg = true;
  430. string key = keyValue[0];
  431. string value = Uri.UnescapeDataString(keyValue[1]); // 对参数值进行URL解码
  432. WebOpencase = value;
  433. }
  434. }
  435. }
  436. return flg;
  437. }
  438. private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
  439. {
  440. #if DEBUG
  441. var ex = e.Exception as Exception;
  442. if (ex != null)
  443. {
  444. MessageBox.Show("发生Task未处理异常:" + ex.Message + "\n" + ex.StackTrace, "系统错误", MessageBoxButton.OK, MessageBoxImage.Error);
  445. }
  446. #else
  447. if (e.Exception is System.Exception)
  448. {
  449. Crashes.TrackError(e.Exception as Exception);
  450. }
  451. #endif
  452. }
  453. private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
  454. {
  455. #if DEBUG
  456. if (e.ExceptionObject is System.Exception)
  457. {
  458. Exception ex = (System.Exception)e.ExceptionObject;
  459. MessageBox.Show("发生非UI线程异常:" + ex.Message + "\n" + ex.StackTrace, "系统错误", MessageBoxButton.OK, MessageBoxImage.Error);
  460. }
  461. #else
  462. if (e.ExceptionObject is System.Exception)
  463. {
  464. Crashes.TrackError(e.ExceptionObject as Exception);
  465. }
  466. #endif
  467. }
  468. private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
  469. {
  470. #if DEBUG
  471. e.Handled = true;
  472. MessageBox.Show("发生UI线程异常:" + e.Exception.Message + "\n" + e.Exception.StackTrace, "系统错误", MessageBoxButton.OK, MessageBoxImage.Error);
  473. #else
  474. e.Handled = true;
  475. Crashes.TrackError(e.Exception);
  476. #endif
  477. }
  478. /// <summary>
  479. /// 创建启动窗口
  480. /// </summary>
  481. /// <returns></returns>
  482. protected override Window CreateShell()
  483. {
  484. return Container.Resolve<MainWindow>();
  485. }
  486. protected override void RegisterTypes(IContainerRegistry containerRegistry)
  487. {
  488. #region 注册内容组件
  489. containerRegistry.RegisterForNavigation<HomeContent>();
  490. containerRegistry.RegisterForNavigation<ViewContent>();
  491. containerRegistry.RegisterForNavigation<ScanViwer>();
  492. containerRegistry.RegisterForNavigation<MainContent>();
  493. containerRegistry.RegisterForNavigation<HomeCloudContent>("Cloud");
  494. containerRegistry.RegisterForNavigation<HomeToolsContent>("Tools");
  495. containerRegistry.RegisterForNavigation<HomeGuidContent>("Guid");
  496. containerRegistry.RegisterForNavigation<HomeFilesContent>();
  497. containerRegistry.RegisterForNavigation<HomeChatGPTAIContent>();
  498. containerRegistry.RegisterForNavigation<ChatGPTAITranslationContent>();
  499. containerRegistry.RegisterForNavigation<ChatGPTAIRewritingContent>();
  500. containerRegistry.RegisterForNavigation<ChatGPTAIErrorCorrectionContent>();
  501. containerRegistry.RegisterForNavigation<BOTAContent>();
  502. containerRegistry.RegisterForNavigation<PropertyPanelContent>();
  503. containerRegistry.RegisterForNavigation<PropertyPanelContentEdit>();
  504. containerRegistry.RegisterForNavigation<PageEditContent>();
  505. containerRegistry.RegisterForNavigation<BottomToolContent>();
  506. containerRegistry.RegisterForNavigation<ToolsBarContent>();
  507. containerRegistry.RegisterForNavigation<TextEditToolContent>();
  508. containerRegistry.RegisterForNavigation<AnnotToolContent>();
  509. containerRegistry.RegisterForNavigation<BookmarkContent>();
  510. containerRegistry.RegisterForNavigation<SearchContent>();
  511. containerRegistry.RegisterForNavigation<OutLineControl>();
  512. containerRegistry.RegisterForNavigation<ViewModularContent>();
  513. containerRegistry.RegisterForNavigation<SplitScreenContent>();
  514. containerRegistry.RegisterForNavigation<ThemesContent>();
  515. containerRegistry.RegisterForNavigation<ReadModeContent>();
  516. containerRegistry.RegisterForNavigation<AnnotationContent>();
  517. containerRegistry.RegisterForNavigation<ReadViewContent>();
  518. containerRegistry.RegisterForNavigation<PageContent>();
  519. containerRegistry.RegisterForNavigation<HomePagePrinterDocumentContent>();
  520. containerRegistry.RegisterForNavigation<HomePagePrinterModSizeContent>();
  521. containerRegistry.RegisterForNavigation<HomePagePrinterModPosterContent>();
  522. containerRegistry.RegisterForNavigation<HomePagePrinterModMultipleContent>();
  523. containerRegistry.RegisterForNavigation<HomePagePrinterModBookletContent>();
  524. containerRegistry.RegisterForNavigation<HomePageCompressDialog>();
  525. containerRegistry.RegisterForNavigation<HomePageSetPasswordDialog>();
  526. containerRegistry.RegisterForNavigation<HomePageRemoveDialog>();
  527. containerRegistry.RegisterForNavigation<HomePageHeaderFooterDialog>();
  528. containerRegistry.RegisterForNavigation<HomePageHeaderFooterTemplateListContent>();
  529. containerRegistry.RegisterForNavigation<HomePageHeaderFooterCreateContent>();
  530. containerRegistry.RegisterForNavigation<HomePageBatesDialog>();
  531. containerRegistry.RegisterForNavigation<HomePageBatesTemplateListContent>();
  532. containerRegistry.RegisterForNavigation<HomePageBatesCreateContent>();
  533. containerRegistry.RegisterForNavigation<HomePageBackgroundDialog>();
  534. containerRegistry.RegisterForNavigation<HomePageBackgroundTemplateListBaseContent>();
  535. containerRegistry.RegisterForNavigation<HomePageBackgroundTemplateListColorContent>();
  536. containerRegistry.RegisterForNavigation<HomePageBackgroundTemplateListFileContent>();
  537. containerRegistry.RegisterForNavigation<HomePageBackgroundCreateBaseContent>();
  538. containerRegistry.RegisterForNavigation<HomePageBackgroundCreateColorContent>();
  539. containerRegistry.RegisterForNavigation<HomePageBackgroundCreateFileContent>();
  540. containerRegistry.RegisterForNavigation<HomePageWatermarkDialog>();
  541. containerRegistry.RegisterForNavigation<HomePageWatermarkTemplateListBaseContent>();
  542. containerRegistry.RegisterForNavigation<HomePageWatermarkTemplateListTextContent>();
  543. containerRegistry.RegisterForNavigation<HomePageWatermarkTemplateListFileContent>();
  544. containerRegistry.RegisterForNavigation<HomePageWatermarkCreateBaseContent>();
  545. containerRegistry.RegisterForNavigation<HomePageWatermarkCreateTextContent>();
  546. containerRegistry.RegisterForNavigation<HomePageWatermarkCreateFileContent>();
  547. containerRegistry.RegisterForNavigation<ConverterBarContent>();
  548. containerRegistry.RegisterForNavigation<ScanContent>();
  549. containerRegistry.RegisterForNavigation<HomePageConverterDialog>();
  550. containerRegistry.RegisterForNavigation<HomePageConverterCSV>();
  551. containerRegistry.RegisterForNavigation<HomePageConverterImg>();
  552. containerRegistry.RegisterForNavigation<HomePageConverterWord>();
  553. containerRegistry.RegisterForNavigation<HomePageConverterExcel>();
  554. containerRegistry.RegisterForNavigation<WatermarkContent>();
  555. containerRegistry.RegisterForNavigation<BackgroundContent>();
  556. containerRegistry.RegisterForNavigation<BackgroundTemplateListBaseContent>();
  557. containerRegistry.RegisterForNavigation<BackgroundTemplateListColorContent>();
  558. containerRegistry.RegisterForNavigation<BackgroundTemplateListFileContent>();
  559. containerRegistry.RegisterForNavigation<BackgroundCreateBaseContent>();
  560. containerRegistry.RegisterForNavigation<BackgroundCreateColorContent>();
  561. containerRegistry.RegisterForNavigation<BackgroundCreateFileContent>();
  562. containerRegistry.RegisterForNavigation<BackgroundDocumentContent>();
  563. containerRegistry.RegisterForNavigation<WatermarkTemplateListBaseContent>();
  564. containerRegistry.RegisterForNavigation<WatermarkTemplateListTextContent>();
  565. containerRegistry.RegisterForNavigation<WatermarkTemplateListFileContent>();
  566. containerRegistry.RegisterForNavigation<WatermarkCreateBaseContent>();
  567. containerRegistry.RegisterForNavigation<WatermarkCreateTextContent>();
  568. containerRegistry.RegisterForNavigation<WatermarkCreateFileContent>();
  569. containerRegistry.RegisterForNavigation<WatermarkDocumentContent>();
  570. containerRegistry.RegisterForNavigation<HomePagePrinterModMultipleContent>();
  571. containerRegistry.RegisterForNavigation<FreehandAnnotProperty>();
  572. containerRegistry.RegisterForNavigation<FreetextAnnotProperty>();
  573. containerRegistry.RegisterForNavigation<StickyNoteProperty>();
  574. containerRegistry.RegisterForNavigation<ImageAnnotProperty>();
  575. containerRegistry.RegisterForNavigation<LinkAnnotProperty>();
  576. containerRegistry.RegisterForNavigation<SharpsAnnotProperty>();
  577. containerRegistry.RegisterForNavigation<StampAnnotProperty>();
  578. containerRegistry.RegisterForNavigation<SignatureAnnotProperty>();
  579. containerRegistry.RegisterForNavigation<TextAnnotProperty>();
  580. containerRegistry.RegisterForNavigation<ImageEditProperty>();
  581. containerRegistry.RegisterForNavigation<TextEditProperty>();
  582. containerRegistry.RegisterForNavigation<ImageTextEditProperty>();
  583. containerRegistry.RegisterForNavigation<ScanPropertyPanel>();
  584. containerRegistry.RegisterForNavigation<BatesContent>();
  585. containerRegistry.RegisterForNavigation<BatesTemplateListContent>();
  586. containerRegistry.RegisterForNavigation<BatesCreateContent>();
  587. containerRegistry.RegisterForNavigation<BatesDocumentContent>();
  588. containerRegistry.RegisterForNavigation<HeaderFooterContent>();
  589. containerRegistry.RegisterForNavigation<HeaderFooterTemplateListContent>();
  590. containerRegistry.RegisterForNavigation<HeaderFooterCreateContent>();
  591. containerRegistry.RegisterForNavigation<HeaderFooterDocumentContent>();
  592. containerRegistry.RegisterForNavigation<RedactionContent>();
  593. //填写与签名
  594. containerRegistry.RegisterForNavigation<FillAndSignContent>();
  595. containerRegistry.RegisterForNavigation<DateFillProperty>();
  596. containerRegistry.RegisterForNavigation<ShapFillProperty>();
  597. containerRegistry.RegisterForNavigation<TextFillProperty>();
  598. //Form表单
  599. containerRegistry.RegisterForNavigation<EmptyFormProperty>();
  600. containerRegistry.RegisterForNavigation<FormsToolContent>();
  601. containerRegistry.RegisterForNavigation<TextFieldProperty>();
  602. containerRegistry.RegisterForNavigation<ButtonProperty>();
  603. containerRegistry.RegisterForNavigation<CheckBoxProperty>();
  604. containerRegistry.RegisterForNavigation<ListBoxProperty>();
  605. containerRegistry.RegisterForNavigation<ComboxProperty>();
  606. containerRegistry.RegisterForNavigation<RadioButtonProperty>();
  607. containerRegistry.RegisterForNavigation<SignProperty>();
  608. //Tip
  609. containerRegistry.RegisterForNavigation<SetPasswordSuccessfullyTip>();
  610. containerRegistry.RegisterForNavigation<FileRestrictedTip>();
  611. containerRegistry.RegisterForNavigation<LinkAnnotTip>();
  612. containerRegistry.RegisterForNavigation<ReadModelTip>();
  613. containerRegistry.RegisterForNavigation<RemoveSecuritySuccessTip>();
  614. containerRegistry.RegisterForNavigation<EnterReadModeTip>();
  615. //轻会员
  616. containerRegistry.RegisterForNavigation<UserOutOKRegion>();
  617. containerRegistry.RegisterForNavigation<CodeRegion>();
  618. containerRegistry.RegisterForNavigation<LoginRegion>();
  619. containerRegistry.RegisterForNavigation<LoginPasswordRegion>();
  620. containerRegistry.RegisterForNavigation<RegisterRegion>();
  621. containerRegistry.RegisterForNavigation<NOInternetRegion>();
  622. containerRegistry.RegisterForNavigation<UserOutCodeRegion>();
  623. containerRegistry.RegisterForNavigation<PasswordUpdataRegion>();
  624. containerRegistry.RegisterForNavigation<StickyNotePopup>();
  625. #endregion 注册内容组件
  626. #region 注册弹窗
  627. containerRegistry.RegisterDialog<VerifyPassWordDialog>(DialogNames.VerifyPassWordDialog);
  628. containerRegistry.RegisterDialog<FullScreenWindow>(DialogNames.FullScreenDialog);
  629. containerRegistry.RegisterDialog<CompressDialog>(DialogNames.CompressDialog);
  630. containerRegistry.RegisterDialog<MergeDialog>(DialogNames.MergeDialog);
  631. containerRegistry.RegisterDialog<SetPasswordDialog>(DialogNames.SetPasswordDialog);
  632. containerRegistry.RegisterDialog<CheckPasswordDialog>(DialogNames.CheckPasswordDialog);
  633. containerRegistry.RegisterDialog<DeleteSafetySettingsDialog>(DialogNames.DeleteSafetySettingsDialog);
  634. containerRegistry.RegisterDialog<CompressProgressBarDialog, PDF_Master.ViewModels.Dialog.ToolsDialogs.CompressDialogs.CompresProgressBarDialogViewModel>(DialogNames.CompressProgressBarDialog);
  635. containerRegistry.RegisterDialog<InsertDialog>(DialogNames.InsertDialog);
  636. containerRegistry.RegisterDialog<SplitDialog>(DialogNames.SplitDialog);
  637. containerRegistry.RegisterDialog<ExtractDialog>(DialogNames.ExtractDialog);
  638. containerRegistry.RegisterDialog<HomePageExtractDialog>(DialogNames.HomePageExtractDialog);
  639. containerRegistry.RegisterDialog<HomePageInsertDialog>(DialogNames.HomePageInsertDialog);
  640. containerRegistry.RegisterDialog<HomePageSplitDialog>(DialogNames.HomePageSplitDialog);
  641. containerRegistry.RegisterDialog<HomePagePrinterDialog>(DialogNames.HomePagePrinterDialog);
  642. containerRegistry.RegisterDialog<HomePagePrinterPaperSettingsDialog>(DialogNames.HomePagePrinterPaperSettingsDialog);
  643. containerRegistry.RegisterDialog<HomePagePictureToPDFDialog>(DialogNames.HomePagePictureToPDFDialog);
  644. containerRegistry.RegisterDialog<HomePageBatchProcessingDialog>(DialogNames.HomePageBatchProcessingDialog);
  645. containerRegistry.RegisterDialog<DynamicPropertyDialog>(DialogNames.DynamicPropertyDialog);
  646. containerRegistry.RegisterDialog<CustomCreateDialog>(DialogNames.CustomCreateDialog);
  647. containerRegistry.RegisterDialog<SignatureCreateDialog>(DialogNames.SignatureCreateDialog);
  648. containerRegistry.RegisterDialog<ConverterCSVDialog>(DialogNames.ConverterCSVDialog);
  649. containerRegistry.RegisterDialog<ConverterPPTDialog>(DialogNames.ConverterPPTDialog);
  650. containerRegistry.RegisterDialog<ConverterTextDialog>(DialogNames.ConverterTextDialog);
  651. containerRegistry.RegisterDialog<ConverterWordDialog>(DialogNames.ConverterWordDialog);
  652. containerRegistry.RegisterDialog<ConverterHTMLDialog>(DialogNames.ConverterHTMLDialog);
  653. containerRegistry.RegisterDialog<ConverterImgDialog>(DialogNames.ConverterImgDialog);
  654. containerRegistry.RegisterDialog<ConverterRTFDialog>(DialogNames.ConverterRTFDialog);
  655. containerRegistry.RegisterDialog<ConverterExcelDialog>(DialogNames.ConverterExcelDialog);
  656. containerRegistry.RegisterDialog<ConverterProgressBarDialog>(DialogNames.ConverterProgressBarDialog);
  657. containerRegistry.RegisterDialog<ScreenAnnotationDialog>(DialogNames.ScreenAnnotationDialog);
  658. containerRegistry.RegisterDialog<AddBookmarkDialog>(DialogNames.AddBookmarkDialog);
  659. containerRegistry.RegisterDialog<AddAnnotationDialog>(DialogNames.AddAnnotationDialog);
  660. containerRegistry.RegisterDialog<EditPresetColorsDialog>(DialogNames.EditPresetColorsDialog);
  661. containerRegistry.RegisterDialog<CreateFromHtmlDialog>(DialogNames.CreateFromHtmlDialog);
  662. containerRegistry.RegisterDialog<CreateFromScannerDialogs>(DialogNames.CreateFromScannerDialogs);
  663. //标记密文弹窗
  664. containerRegistry.RegisterDialog<MarkSettingDialog>(DialogNames.MarkSettingDialog);
  665. containerRegistry.RegisterDialog<PageMarkDialog>(DialogNames.PageMarkDialog);
  666. containerRegistry.RegisterDialog<RepeatMarkDialog>(DialogNames.RepeatMarkDialog);
  667. containerRegistry.RegisterDialog<SettingsDialog>(DialogNames.SettingsDialog);
  668. containerRegistry.RegisterDialog<PropertiesDialog>(DialogNames.PropertyDialog);
  669. //轻会员弹窗
  670. containerRegistry.RegisterDialog<RegisterDialog>(DialogNames.RegisterDialog);
  671. containerRegistry.RegisterDialog<LoginDialog>(DialogNames.LoginDialog);
  672. containerRegistry.RegisterDialog<UserDialog>(DialogNames.UserDialog);
  673. containerRegistry.RegisterDialog<UserOutingLogin>(DialogNames.UserOutingLogin);
  674. containerRegistry.RegisterDialog<RegisterOKRegion>(DialogNames.RegisterOKRegion);
  675. containerRegistry.RegisterDialog<SubscriptionDialog>(DialogNames.SubscriptionDialog);
  676. containerRegistry.RegisterDialog<SubscriptionOKDialog>(DialogNames.SubscriptionOKDialog);
  677. containerRegistry.RegisterDialog<LoginoffDialog>(DialogNames.LoginoffDialog);
  678. //新手引导弹窗
  679. containerRegistry.RegisterDialog<NoviceGuidDialog>(DialogNames.GuidDialog);
  680. containerRegistry.RegisterDialog<IAPCompareDialog>(DialogNames.IAPCompareDialog);
  681. //关于弹窗
  682. containerRegistry.RegisterDialog<AboutDialog>(DialogNames.AboutDialog);
  683. containerRegistry.Register<IDialogWindow, CustomControl.DialogWindow>();
  684. //chatgtp
  685. containerRegistry.RegisterDialog<DocumentaryTranslationDialog>(DialogNames.DocumentaryTranslation);
  686. containerRegistry.RegisterDialog<SelectedTranslationDialog>(DialogNames.SelectedTranslation);
  687. //OCR下载弹窗
  688. containerRegistry.RegisterDialog<OCRDownloadProgress>(DialogNames.OCRDownloadProgress);
  689. containerRegistry.RegisterDialog<ChangeEmailDialog>(DialogNames.ChangeEmailDialog);
  690. #endregion 注册弹窗
  691. }
  692. protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings)
  693. {
  694. var region = new SingleActiveRegion() { Name = RegionNames.MainRegion };
  695. region.Behaviors.Add(DragablzWindowBehavior.BehaviorKey, new DragablzWindowBehavior());
  696. Container.Resolve<IRegionManager>().Regions.Add(region);
  697. base.ConfigureRegionAdapterMappings(regionAdapterMappings);
  698. }
  699. /// <summary>
  700. /// 验证SDK和转档库密钥
  701. /// </summary>
  702. /// <returns></returns>
  703. private static bool LicenseVerify()
  704. {
  705. bool result = false;
  706. try
  707. {
  708. result = CPDFSDKVerifier.LoadNativeLibrary();
  709. if (!result)
  710. {
  711. Trace.WriteLine("CPDFSDK Load Failed.\n");
  712. return false;
  713. }
  714. Trace.WriteLine("CPDFSDK Load Success.\n");
  715. }
  716. catch { Trace.WriteLine("CPDFSDK Load Error.\n"); }
  717. SDKLisenceHelper sdkhelper = new SDKLisenceHelper();
  718. string devKey = "";
  719. string devSecret = "";
  720. #if DEBUG
  721. devKey = "ehrnKqkWc1XSEAWyPUt6+95GzCoLEyoKrCbsUuJkCqGmxmP5ozX4bS0R6crHItQVNTFvC5mBZ1M7QjJ6Ekdu4Daj7PM+EDLTBKbFJinK4Ri9E5E2X+a9vF5zSj0TkIscQPVnwj9ikxAFOWGIyybMwQQzwc8a4j1cGOqGXQRDMMY=";
  722. devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6ccHhEu996bvBgqf8Sw8OekQKQq13VBewK5AckaDux4W7SGRhCUNWC4MItkr36JnXMD2tiFQYzMG8C66HYmRGSLh";
  723. #endif
  724. devKey = sdkhelper.DevKey;
  725. devSecret = sdkhelper.DevSecret;
  726. string userKey = sdkhelper.UserKey;
  727. string userSecret = sdkhelper.UserSecret;
  728. try
  729. {
  730. LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(devKey, devSecret);
  731. Trace.WriteLine("CPDFSDK License Code." + verifyResult + "\n");
  732. if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
  733. return false;
  734. }
  735. catch { Trace.WriteLine("CPDFSDK License Code Error \n"); }
  736. string ConverterDevKey = sdkhelper.ConverterDevKey;
  737. string ConverterDevSecret = sdkhelper.ConverterDevSecret;
  738. string ConverterUserkey = sdkhelper.ConverterUserkey;
  739. string ConverterUserSecret = sdkhelper.ConverterUserSecret;
  740. try
  741. {
  742. ////加载OCR库
  743. //if (!DocumentAIKitLicenseVerify())
  744. //{
  745. //}
  746. /*LicenseError licenseerror = CPDFConverter.SDKLicenseVerify(ConverterDevKey, ConverterDevSecret, ConverterUserkey, ConverterUserSecret);
  747. string resPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location) + "\\";
  748. if (licenseerror != LicenseError.ERR_SUCCESS)
  749. {
  750. return false;
  751. }
  752. CPDFConverter.Init(resPath);*/
  753. string resPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location) + "\\";
  754. CPDFConverter.Init(resPath);
  755. LicenseError licenseerror = CPDFConverter.LicenseVerify(ConverterDevKey, ConverterDevSecret);
  756. //初始化ocr库
  757. CPDFConverter.InitOCRLibrary(Path.Combine(resPath, "x64"));
  758. //初始化资源
  759. CPDFConverter.SetOCRModelPath(Path.Combine(resPath, "source"));
  760. if (licenseerror != LicenseError.ERR_SUCCESS)
  761. {
  762. //MessageBox.Show("ComPDFKit Conversion SDK Load Failed!");
  763. Console.WriteLine("CPDFConvert Load Failed.\n");
  764. return false;
  765. }
  766. //之前1.7.0逻辑
  767. //CPDFConverter.Init(resPath);
  768. //CPDFConverter.SetOCRModelFolder(modelFolderPath);
  769. }
  770. catch { }
  771. return result;
  772. }
  773. /// <summary>
  774. /// 加载,验证DocumentAIKitLicense
  775. /// 目前DocmentAILib暂时移动到X64(原来路径为 string libFolderPath = Path.Combine(exePath, "DocumentAILib");)
  776. /// 含有的库有(ComDocumentAINative.dll,DocumentAI.dll,libiomp5md.dll,mkldnn.dll,mklml.dll,onnxruntime.dll,opencv_world420.dll,opencv_word420d.dll,paddle_inference.dll,paddle2onnx.dll)
  777. /// </summary>
  778. /// <returns></returns>
  779. private static bool DocumentAIKitLicenseVerify()
  780. {
  781. Task.Factory.StartNew(() =>
  782. {
  783. string exePath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location);
  784. exePath = Path.Combine(exePath, "x64");
  785. //string libFolderPath = Path.Combine(exePath, "DocumentAILib");
  786. string libFolderPath = exePath;
  787. modelFolderPath = Path.Combine(exePath, "models");
  788. if (CDocumentAIKit.LoadNativeLibrary(libFolderPath) == false)
  789. return;
  790. CErrorCode error = CDocumentAIKit.LicenseVerify("1F8B0818801DD8F20000636F6D2E636F6D7064666B69742E636F6E76657273696F6E00344136353732364636443635353936313645363700011002EFFDC671954ADECE496F0D96F5C14D82A293CEC71744D0914A388C0FDECA16FC9B6D28694C762AC71F382D9E50B2E9473B431C8FE18D5656A52AB2FF2B06834B7AB87CFB42884BA59110642327D18D77BD13D2AC8EC3A06357000E315956673DC38A02F97AD29B24F421D82D9346A3737BFD806777769DFBA4D50B911E65F4FC674A6DCA1E53FE1F9A4A8DE987B41B143282D2286C22C29F69724A4BCA5C0BD3013DDA2207FFC10A385EF980D4547FD76A4B6EBDE54ACCE68B656621032EC146123B1E8DD9B1EF7F71725917D9CA58431601707A6BB1B41A82049FAF14599B34EAF7D59CD8E6CFEAB24AF5CDDCB2A2236E77710B7E30F10022F2F25EC6586D3B5207378F2CB8B9176EE463B1F2B1D8BD776142E8F9575235BE2A57A63948EDB05DED4649F410CE5941DA5155E6F5A127BFABC5E424F71A1AEB201595ECE8BC8C91DD1C0FF7300A4CB7253B6277CF8B8C5F3CDA5D569E2E27F1609815F9944816AD69550049D94C0FD263D2D3FCF4A3CE685C67F7E27F70E8D9332A45984E7F4D7F5D800BAA58D18715384B98BE310AEDCB4BCF4833E76A5E3860032B3A926DFD247FF426ADA94BA1DA7B11F0451AE506A93DD8B809453E5B51CBE24D572973A55FBD3D25453C3FAD47D30ACAB30500C15FD8714B365AA6F275808C9EB7D5116AC809C91786D6571E2622A5E730D40614061C3B3FC129108AA1360C16151CE38CA03FF3A28FFE7200B4FFA24EF7EDF54B8E9AB207E00810020000");
  791. if (error != CErrorCode.E_DA_SUCCESS)
  792. return;
  793. });
  794. return true;
  795. }
  796. private static void CheckUpdate()
  797. {
  798. try
  799. {
  800. string lang = "en_Us";
  801. //暂时没有多语,固定检测英文环境更新
  802. //lang = Settings.Default.AppProperties.culture;
  803. switch (lang)
  804. {
  805. case "zh-CN":
  806. lang = "zh_Hans";
  807. break;
  808. case "zh-TW":
  809. lang = "zh_Hant";
  810. break;
  811. default:
  812. lang = "en_Us";
  813. break;
  814. }
  815. #if DEBUG
  816. var appcastUrl = string.Format("http://test-pdf-pro.kdan.cn:3021/downloads/pdfmaster_win_{0}.xml", lang);
  817. #else
  818. var appcastUrl = string.Format("https://www.pdfreaderpro.com/downloads/pdfmaster_win_{0}.xml",lang);
  819. #endif
  820. // set icon in project properties!
  821. string manifestModuleName = System.Reflection.Assembly.GetEntryAssembly().ManifestModule.FullyQualifiedName;
  822. var icon = System.Drawing.Icon.ExtractAssociatedIcon(manifestModuleName);
  823. //设为false 则显示立即购买按钮,设为true则不显示立即购买按钮
  824. bool ispurchased = true;
  825. SparkleUpdateDetector = new SparkleUpdater(appcastUrl, new DSAChecker(NetSparkleUpdater.Enums.SecurityMode.Unsafe), ispurchased)
  826. {
  827. UIFactory = new NetSparkleUpdater.UI.WinForms.UIFactory(icon, "PDF Master"),
  828. //RelaunchAfterUpdate = true,
  829. //ShowsUIOnMainThread = true,
  830. //UseNotificationToast = true
  831. };
  832. SparkleUpdateDetector.SecurityProtocolType = System.Net.SecurityProtocolType.Tls12;
  833. SparkleUpdateDetector.CloseApplication += SparkleUpdateDetector_CloseApplication;
  834. SparkleUpdateDetector.StartLoop(true);
  835. }
  836. catch { }
  837. }
  838. private static void SparkleUpdateDetector_CloseApplication()
  839. {
  840. try
  841. {
  842. SparkleUpdateDetector.Dispose();
  843. Current.Dispatcher.Invoke(() =>
  844. {
  845. Current.Shutdown();
  846. });
  847. }
  848. catch
  849. {
  850. }
  851. }
  852. protected override void OnExit(ExitEventArgs e)
  853. {
  854. Environment.Exit(1);
  855. base.OnExit(e);
  856. }
  857. }
  858. }