|
@@ -1,17 +1,70 @@
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Configuration;
|
|
|
-using System.Data;
|
|
|
-using System.Linq;
|
|
|
-using System.Threading.Tasks;
|
|
|
+using ComPDFKit.NativeMethod;
|
|
|
+using System.IO;
|
|
|
+using System.Reflection;
|
|
|
using System.Windows;
|
|
|
+using System.Xml;
|
|
|
+using static ComPDFKit.NativeMethod.CPDFSDKVerifier;
|
|
|
|
|
|
namespace viewer_ctrl_demo
|
|
|
{
|
|
|
+ public class SDKLicenseHelper
|
|
|
+ {
|
|
|
+ public string key = string.Empty;
|
|
|
+ public string secret = string.Empty;
|
|
|
+ public SDKLicenseHelper() {
|
|
|
+
|
|
|
+ string sdkLicensePath = "..\\..\\..\\SDKLicense.xml";
|
|
|
+ Assembly assembly = Assembly.GetExecutingAssembly();
|
|
|
+ string stream = (string)Properties.Resources.ResourceManager.GetObject(sdkLicensePath);
|
|
|
+ XmlDocument xmlDocument = new XmlDocument();
|
|
|
+ if (!File.Exists(sdkLicensePath))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ xmlDocument.LoadXml(stream);
|
|
|
+ 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
|
|
|
{
|
|
|
+ protected override void OnStartup(StartupEventArgs e)
|
|
|
+ {
|
|
|
+ string str = this.GetType().Assembly.Location;
|
|
|
+ base.OnStartup(e);
|
|
|
+ LicenseVerify();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static bool LicenseVerify()
|
|
|
+ {
|
|
|
+ bool result = false;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ result = CPDFSDKVerifier.LoadNativeLibrary();
|
|
|
+ if (!result)
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {}
|
|
|
+ SDKLicenseHelper sdkLicenseHelper = new SDKLicenseHelper();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
|
|
|
+ if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
}
|