App.xaml.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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.ViewModels.Dialog.ToolsDialogs.SaftyDialogs;
  30. namespace PDF_Office
  31. {
  32. /// <summary>
  33. /// App.xaml 的交互逻辑
  34. /// </summary>
  35. public partial class App : PrismApplication
  36. {
  37. public static MainWindowViewModel mainWindowViewModel;
  38. public static List<string> OpenedFileList = new List<string>();
  39. public static bool IsFirstOpen = true;
  40. public App()
  41. {
  42. #if !DEBUG
  43. //接入Appcenter后台数据检测
  44. string appkey = "b099dccc-1ca5-4ea1-a2fa-afd4a6e1f8bb"
  45. AppCenter.Start(appkey, typeof(Analytics), typeof(Crashes));
  46. var countryCode = RegionInfo.CurrentRegion.TwoLetterISORegionName;//上传国家信息
  47. AppCenter.SetCountryCode(countryCode);
  48. #endif
  49. LicenseVerify();
  50. if (Settings.Default.RecentOpenFiles == null)
  51. Settings.Default.RecentOpenFiles = new RecentOpenFiles();
  52. }
  53. /// <summary>
  54. /// 创建启动窗口
  55. /// </summary>
  56. /// <returns></returns>
  57. protected override Window CreateShell()
  58. {
  59. return Container.Resolve<MainWindow>();
  60. }
  61. protected override void RegisterTypes(IContainerRegistry containerRegistry)
  62. {
  63. //注册内容组件
  64. containerRegistry.RegisterForNavigation<HomeContent>();
  65. containerRegistry.RegisterForNavigation<ViewContent>();
  66. containerRegistry.RegisterForNavigation<MainContent>();
  67. containerRegistry.RegisterForNavigation<HomeCloudContent>("Cloud");
  68. containerRegistry.RegisterForNavigation<HomeToolsContent>("Tools");
  69. containerRegistry.RegisterForNavigation<HomeGuidContent>("Guid");
  70. containerRegistry.RegisterForNavigation<BOTAContent>();
  71. containerRegistry.RegisterForNavigation<PageEditContent>();
  72. containerRegistry.RegisterForNavigation<ToolsBarContent>();
  73. //注册弹窗
  74. containerRegistry.RegisterDialog<VerifyPassWordDialog>(DialogNames.VerifyPassWordDialog);
  75. containerRegistry.RegisterDialog<FullScreenWindow>(DialogNames.FullScreenDialog);
  76. containerRegistry.RegisterDialog<CompressDialog>(DialogNames.CompressDialog);
  77. containerRegistry.RegisterDialog<SetPasswordDialog>(DialogNames.SetPasswordDialog);
  78. containerRegistry.RegisterDialog<CheckPasswordDialog>(DialogNames.CheckPasswordDialog);
  79. containerRegistry.RegisterDialog<DeleteSafetySettingsDialog>(DialogNames.DeleteSafetySettingsDialog);
  80. containerRegistry.RegisterDialog<CompressProgressBarDialog, PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs.CompresProgressBarDialogViewModel>(DialogNames.CompressProgressBarDialog);
  81. }
  82. protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings)
  83. {
  84. var region = new SingleActiveRegion() { Name = RegionNames.MainRegion };
  85. region.Behaviors.Add(DragablzWindowBehavior.BehaviorKey, new DragablzWindowBehavior());
  86. Container.Resolve<IRegionManager>().Regions.Add(region);
  87. base.ConfigureRegionAdapterMappings(regionAdapterMappings);
  88. }
  89. private static bool LicenseVerify()
  90. {
  91. bool result = false;
  92. try
  93. {
  94. result = CPDFSDKVerifier.LoadNativeLibrary();
  95. if (!result)
  96. return false;
  97. }
  98. catch{ }
  99. string devKey = "";
  100. string devSecret = "";
  101. #if DEBUG
  102. devKey = " ehrnKqkWc1XSEAWyPUt6+95GzCoLEyoKrCbsUuJkCqGmxmP5ozX4bS0R6crHItQVNTFvC5mBZ1M7QjJ6Ekdu4Daj7PM+EDLTBKbFJinK4Ri9E5E2X+a9vF5zSj0TkIscQPVnwj9ikxAFOWGIyybMwQQzwc8a4j1cGOqGXQRDMMY=";
  103. devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6ccHhEu996bvBgqf8Sw8OekQKQq13VBewK5AckaDux4W7SGRhCUNWC4MItkr36JnXMD2tiFQYzMG8C66HYmRGSLh";
  104. #endif
  105. string userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs=";
  106. string userSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4ivEHOmPIqbfhpDnKKj+7Ymj2rXQvfZRmke06HMV+3tt064G64WjPW8+EbGCNZaAh1hrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1FKJi6HYB+DuugQyaqI2prfej861QnJrU4s2T/npZK/";
  107. try
  108. {
  109. CPDFSDKVerifier.LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(devKey, devSecret, userKey, userSecret);
  110. if (verifyResult != CPDFSDKVerifier.LicenseErrorCode.LICENSE_ERR_SUCCESS)
  111. return false;
  112. }
  113. catch{ }
  114. string ConverterDevKey = "mDDCTNY5rV2+FUj2JESUBruJ0643Tv7rNuxACu6g3L/0guIw1r8zZB+o3aw3rs4rrOThmxBXpEDcItvyGx096mF/3Ixg7aD6QZk5HvBEScIPerdM3KnhgwMwCjE0DYOSMCRwAhbA2xjXfXgT5VVo7JZroKOGQB5Qmf2kLl5nQuU=";
  115. string ConverterDevSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4g3S5AixMY+3TX1FpQaugG9sTsnCq4QxIEDzyAI3s3dWjNe3wDsMrmFq51HtjPa2tSFAoV6NtcUJC8skonXVk7kMv7C2jvq4o0q6sQtN3jR42k0n/LkN5UfbQ5Lfel4OfZrk7dh2/DUR87Ps4vBX1hrYkwcNWVMyYvggPV2rTFvfawopGIC034QzjthmhwwX90=";
  116. string ConverterUserkey = "WLUHzXhndQKyrTJVzvZ+dvPXDQDZeJpcSvklX3GJwRX4+urd8eQskYgbeCf0NXLZ/qJkS/k10x+qGad34i4v5rI/ASFIx901c/Nw5C0YJMH7X87dib141tdAmSmQhnKLO5TBi4FiAidboyvnLFLrYGMmS2kLQOXFPwPj5zQUv5A=";
  117. string ConverterUserSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iK16EcneqBPRe2eKQLuJXpA79IONX9GVI/Ap3uWzMcNWaitc2UB6gDeexJXFPVaXOFAoV6NtcUJC8skonXVk7k/oKTJGcYKLPGdXenrzHolQ==";
  118. try
  119. {
  120. /*LicenseError licenseerror = CPDFConverter.SDKLicenseVerify(ConverterDevKey, ConverterDevSecret, ConverterUserkey, ConverterUserSecret);
  121. string resPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location) + "\\";
  122. if (licenseerror != LicenseError.ERR_SUCCESS)
  123. {
  124. return false;
  125. }
  126. CPDFConverter.Init(resPath);*/
  127. string resPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location) + "\\";
  128. LicenseError licenseerror = CPDFConverter.LicenseVerify(ConverterDevKey, ConverterDevSecret, ConverterUserkey, ConverterUserSecret);
  129. if (licenseerror != LicenseError.ERR_SUCCESS)
  130. {
  131. //MessageBox.Show("ComPDFKit Conversion SDK Load Failed!");
  132. return false;
  133. }
  134. CPDFConverter.Init(resPath);
  135. }
  136. catch{ }
  137. return result;
  138. }
  139. protected override void OnExit(ExitEventArgs e)
  140. {
  141. Environment.Exit(1);
  142. base.OnExit(e);
  143. }
  144. }
  145. }