using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Data; using System.Xml; using ComPDFKit.NativeMethod; using Compdfkit_Tools.Helper; using PDFViewer.Properties; namespace PDFViewer { /// /// Interaction logic for App.xaml /// public partial class App: Application { public static bool DefaultPDFLoaded = false; public Dictionary Languages; public static FilePathList OpenedFilePathList = new FilePathList(); public static ResourceManager MainResourceManager = new ResourceManager("PDFViewer.Strings.SettingDialog", Assembly.GetExecutingAssembly()); protected override void OnStartup(StartupEventArgs e) { Languages = new Dictionary() { {"English","en-US"}, {"简体中文","zh-CN"}}; string culture = Languages.TryGetValue(Settings.Default.Language, out culture) ? culture : "en-US"; Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture); Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); base.OnStartup(e); LicenseVerify(); FileHistoryHelper.Instance.LoadHistory(); } private static bool LicenseVerify() { if (!CPDFSDKVerifier.LoadNativeLibrary()) return false; LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify("license_key_windows.txt", true); return (verifyResult != LicenseErrorCode.E_LICENSE_SUCCESS); } } public class FilePathList : List { public new void Add(string item) { base.Add(item); HistoryFile(item); } 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.Instance.AddHistory(fileInfo); FileHistoryHelper.Instance.SaveHistory(); } } 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(); } } }