123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Globalization;
- using System.IO;
- using System.Reflection;
- using System.Resources;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Data;
- using System.Windows.Threading;
- using System.Xml;
- using ComPDFKit.NativeMethod;
- using Compdfkit_Tools.Helper;
- using PDFViewer.Properties;
- namespace PDFViewer
- {
- /// <summary>
- /// Interaction logic for App.xaml
- /// </summary>
- public partial class App : Application
- {
- public static string CurrentCulture = Settings.Default.Cultrue;
- public static List<string> SupportedCultureList = new List<string>()
- {
- "en-US", "zh-CN"
- };
- public static FilePathList OpenedFilePathList = new FilePathList();
- public static ResourceManager MainResourceManager = new ResourceManager("PDFViewer.Strings.SettingDialog", Assembly.GetExecutingAssembly());
- public static bool LicenseVerify()
- {
- if (!CPDFSDKVerifier.LoadNativeLibrary())
- {
- return false;
- }
- LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(SDKLicenseHelper.ParseLicenseXML(), false);
- return (verifyResult == LicenseErrorCode.E_LICENSE_SUCCESS);
- }
- protected override void OnStartup(StartupEventArgs e)
- {
- if (string.IsNullOrEmpty(CurrentCulture))
- {
- CurrentCulture = CultureInfo.CurrentCulture.Name;
- if (!SupportedCultureList.Contains(CurrentCulture))
- {
- CurrentCulture = "en-US";
- }
- Settings.Default.Cultrue = CurrentCulture;
- Settings.Default.Save();
- }
- Thread.CurrentThread.CurrentUICulture = new CultureInfo(CurrentCulture);
- Thread.CurrentThread.CurrentCulture = new CultureInfo(CurrentCulture);
- base.OnStartup(e);
-
- LicenseVerify();
- CPDFSDKVerifier.PrintPermissions();
- //CPDFSDKVerifier.LicenseRefreshed -= CPDFSDKVerifier_LicenseRefreshed;
- //CPDFSDKVerifier.LicenseRefreshed += CPDFSDKVerifier_LicenseRefreshed;
- HistoryFile(@"TestFile\ComPDFKit_Sample_File_Windows.pdf");
- FileHistoryHelper<PDFFileInfo>.Instance.LoadHistory();
- }
- //private void CPDFSDKVerifier_LicenseRefreshed(object sender, ResponseModel e)
- //{
- // if(e != null)
- // {
- // string message = string.Format("{0} {1}", e.Code, e.Message);
- // Trace.WriteLine(message);
- // }
- // else
- // {
- // Trace.WriteLine("Network not connected.");
- // }
- //}
- private void HistoryFile(string item)
- {
- PDFFileInfo fileInfo = new PDFFileInfo();
- fileInfo.FilePath = item;
- fileInfo.FileName = Path.GetFileName(item);
- fileInfo.FileSize = CommonHelper.GetFileSize(fileInfo.FilePath);
- fileInfo.OpenDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- FileHistoryHelper<PDFFileInfo>.Instance.AddHistory(fileInfo);
- FileHistoryHelper<PDFFileInfo>.Instance.SaveHistory();
- }
- }
- public class FilePathList : List<string>
- {
- public new void Add(string item)
- {
- base.Add(item);
- }
- }
- public class ResourceConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (parameter == null || string.IsNullOrEmpty(parameter.ToString()))
- {
- return string.Empty;
- }
- return App.MainResourceManager.GetString(parameter.ToString());
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
- }
- }
|