12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using ComPDFKit.NativeMethod;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.Linq;
- using System.Reflection;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Xml;
- namespace PDFViewer
- {
- public class SDKLicenseHelper
- {
- public string key = string.Empty;
- public string secret = string.Empty;
- public SDKLicenseHelper()
- {
- string sdkLicensePath = "license_key_win.xml";
- Assembly assembly = Assembly.GetExecutingAssembly();
- XmlDocument xmlDocument = new XmlDocument();
- xmlDocument.Load(sdkLicensePath);
- var node = xmlDocument.SelectSingleNode("License");
- if (node != null)
- {
- key = node.Attributes["key"].Value;
- secret = node.Attributes["secret"].Value;
- }
- }
- }
- /// <summary>
- /// Interaction logic for App.xaml
- /// </summary>
- ///
- public partial class App : Application
- {
- static public bool DefaultPDFLoaded = false;
- public static List<string> OpenedFilePathList = new List<string>();
- protected override void OnStartup(StartupEventArgs e)
- {
- string str = this.GetType().Assembly.Location;
- base.OnStartup(e);
- LicenseVerify();
- }
- private static bool LicenseVerify()
- {
- bool result = false;
- result = CPDFSDKVerifier.LoadNativeLibrary();
- if (!result)
- return false;
- SDKLicenseHelper sdkLicenseHelper = new SDKLicenseHelper();
- LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
- if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
- return false;
- return result;
- }
- }
- }
|