App.xaml.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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.ViewModels.Dialog.ToolsDialogs;
  28. using PDF_Office.Views.Dialog.ToolsDialogs;
  29. using PDF_Office.Views.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<CancelPasswordDialog>(DialogNames.CancelPasswordDialog);
  80. }
  81. protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings)
  82. {
  83. var region = new SingleActiveRegion() { Name = RegionNames.MainRegion };
  84. region.Behaviors.Add(DragablzWindowBehavior.BehaviorKey, new DragablzWindowBehavior());
  85. Container.Resolve<IRegionManager>().Regions.Add(region);
  86. base.ConfigureRegionAdapterMappings(regionAdapterMappings);
  87. }
  88. private static bool LicenseVerify()
  89. {
  90. bool result = false;
  91. try
  92. {
  93. result = CPDFSDKVerifier.LoadNativeLibrary();
  94. if (!result)
  95. return false;
  96. }
  97. catch{ }
  98. string devKey = "";
  99. string devSecret = "";
  100. #if DEBUG
  101. devKey = "sTHSivIW4YnZQavIYDLVw4vaFcN5DQTUtRGrVyv5p9aeaHX3GirG/MBxl6Wy9TJbNOwR4CU6LPjHmGe3Po3OtBCPqIRheam9+LomScw3AvoUTHFlG1134e2J4enF43WJQ6PyOnjwZqsG1kUdlBPNztkoPzDAE2pQKgZWf6V2i34=";
  102. devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6cfaiHpW8pgW2aur3AxuQIBBLuJD5gcmNxTYW3KA32JLG8alfyXjKFVS3gka9bngvwfZ7GuNXybjKlmz1tnN6iVHpnbSj+xOHhWEperY4HHrSg==";
  103. #endif
  104. string userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs=";
  105. string userSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4ivEHOmPIqbfhpDnKKj+7Ymj2rXQvfZRmke06HMV+3tt064G64WjPW8+EbGCNZaAh1hrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1FKJi6HYB+DuugQyaqI2prfej861QnJrU4s2T/npZK/";
  106. try
  107. {
  108. CPDFSDKVerifier.LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(devKey, devSecret, userKey, userSecret);
  109. if (verifyResult != CPDFSDKVerifier.LicenseErrorCode.LICENSE_ERR_SUCCESS)
  110. return false;
  111. }
  112. catch{ }
  113. string ConverterDevKey = "mDDCTNY5rV2+FUj2JESUBruJ0643Tv7rNuxACu6g3L/0guIw1r8zZB+o3aw3rs4rrOThmxBXpEDcItvyGx096mF/3Ixg7aD6QZk5HvBEScIPerdM3KnhgwMwCjE0DYOSMCRwAhbA2xjXfXgT5VVo7JZroKOGQB5Qmf2kLl5nQuU=";
  114. string ConverterDevSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4g3S5AixMY+3TX1FpQaugG9sTsnCq4QxIEDzyAI3s3dWjNe3wDsMrmFq51HtjPa2tSFAoV6NtcUJC8skonXVk7kMv7C2jvq4o0q6sQtN3jR42k0n/LkN5UfbQ5Lfel4OfZrk7dh2/DUR87Ps4vBX1hrYkwcNWVMyYvggPV2rTFvfawopGIC034QzjthmhwwX90=";
  115. string ConverterUserkey = "WLUHzXhndQKyrTJVzvZ+dvPXDQDZeJpcSvklX3GJwRX4+urd8eQskYgbeCf0NXLZ/qJkS/k10x+qGad34i4v5rI/ASFIx901c/Nw5C0YJMH7X87dib141tdAmSmQhnKLO5TBi4FiAidboyvnLFLrYGMmS2kLQOXFPwPj5zQUv5A=";
  116. string ConverterUserSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iK16EcneqBPRe2eKQLuJXpA79IONX9GVI/Ap3uWzMcNWaitc2UB6gDeexJXFPVaXOFAoV6NtcUJC8skonXVk7k/oKTJGcYKLPGdXenrzHolQ==";
  117. try
  118. {
  119. /*LicenseError licenseerror = CPDFConverter.SDKLicenseVerify(ConverterDevKey, ConverterDevSecret, ConverterUserkey, ConverterUserSecret);
  120. string resPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location) + "\\";
  121. if (licenseerror != LicenseError.ERR_SUCCESS)
  122. {
  123. return false;
  124. }
  125. CPDFConverter.Init(resPath);*/
  126. string resPath = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location) + "\\";
  127. LicenseError licenseerror = CPDFConverter.LicenseVerify(ConverterDevKey, ConverterDevSecret, ConverterUserkey, ConverterUserSecret);
  128. if (licenseerror != LicenseError.ERR_SUCCESS)
  129. {
  130. //MessageBox.Show("ComPDFKit Conversion SDK Load Failed!");
  131. return false;
  132. }
  133. CPDFConverter.Init(resPath);
  134. }
  135. catch{ }
  136. return result;
  137. }
  138. protected override void OnExit(ExitEventArgs e)
  139. {
  140. Environment.Exit(1);
  141. base.OnExit(e);
  142. }
  143. }
  144. }