Esempio n. 1
0
        private static async void OnPdfPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            PdfViewerControl control = source as PdfViewerControl;
            var pdfSource            = e.NewValue as String;

            if (string.IsNullOrEmpty(pdfSource))
            {
                return;
            }

            try
            {
                if (control != null)
                {
                    control.ClearSource();
                    var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(pdfSource));
                    await ShowProgressIndicatorIfNecessary(control, file);

                    control.LoadPDF(file);
                }
            }
            catch
            {
                // TODO Log exception here
            }
        }
Esempio n. 2
0
        private static async Task ShowProgressIndicatorIfNecessary(PdfViewerControl control, StorageFile file)
        {
            var size = await file.GetSize();

            var sizeInMB = size / 1048576.0;

            if (sizeInMB > ProgressIndicationFileSizeLimitInMB)
            {
                control.IsLoading  = true;
                control.IsPdfError = false;
            }
        }