示例#1
0
        public async Task OpenPdfFileFromActivation(Windows.ApplicationModel.Activation.FileActivatedEventArgs args)
        {
            while (!contentLoaded)
            {
                await Task.Delay(50);
            }

            try
            {
                foreach (var file in args.Files)
                {
                    if (IsFileOpen(file.Path))
                    {
                        continue;
                    }

                    if (ContentFrame.Content is PdfViewerPageContent content)
                    {
                        if (file is StorageFile tempFile)
                        {
                            var tempFolder  = ApplicationData.Current.TemporaryFolder;
                            var storageFile = await tempFile.CopyAsync(tempFolder, file.Name, NameCollisionOption.ReplaceExisting);

                            if (storageFile != null)
                            {
                                PdfFile pdfFile = null;
                                if (PdfFiles.Exists(x => x.FullFilePath == file.Path))
                                {
                                    pdfFile = PdfFiles.Find(x => x.FullFilePath == file.Path);
                                    pdfFile.LastTimeOpened = DateTime.Now;
                                    await SaveSettings(PdfFiles);
                                }
                                else
                                {
                                    var token = StorageApplicationPermissions.FutureAccessList.Add(tempFile);
                                    pdfFile = new PdfFile()
                                    {
                                        FullFilePath = file.Path, IsFavorite = false, LastTimeOpened = DateTime.Now, FileToken = token
                                    };
                                    await RemovePdfFileLastUsedAsync();

                                    PdfFiles.Add(pdfFile);
                                    await SaveSettings(PdfFiles);
                                }

                                var pdfFileModel = Mapper.Map <PdfFileModel>(pdfFile);
                                content.LoadPdfViewer(storageFile, pdfFileModel);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }
        }
示例#2
0
        public async void LoadKml(Windows.ApplicationModel.Activation.FileActivatedEventArgs args)
        {
            var file      = args.Files.FirstOrDefault() as Windows.Storage.StorageFile;
            var localFile = await Windows.Storage.ApplicationData.Current.TemporaryFolder.CreateFileAsync(file.Name, Windows.Storage.CreationCollisionOption.ReplaceExisting);

            await file.CopyAndReplaceAsync(localFile);

            AddKmlLayer("file:///" + localFile.Path);
        }
示例#3
0
        public static async Task <RecentFile> RegisterFile(Windows.ApplicationModel.Activation.FileActivatedEventArgs e)
        {
            foreach (IStorageItem storageItem in e.Files)
            {
                if (storageItem is IStorageFile)
                {
                    //Log._Test(storageItem.Path);
                    RecentFile result = await RegisterFile(storageFile : storageItem as IStorageFile);

                    if (result != null)
                    {
                        return(result);
                    }
                }
                else
                {
                    Log.FatalError("Not a file: ", storageItem);
                }
            }
            return(null);
        }
示例#4
0
 public static void HandleWeChatCallback(Windows.ApplicationModel.Activation.FileActivatedEventArgs e)
 {
     if (currentFrame.TryGetTarget(out var f) && f.Content is AuthPage p)
     {
         p.Handle(e);
     }