App.xaml.cs 6.7 KB

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