Beispiel #1
0
        private async void OpenFile()
        {
            try
            {
                if (UrlFile != string.Empty)
                {
                    dialogService.ShowProgress();
                    string ext = System.IO.Path.GetExtension(UrlFile).ToLower();

                    switch (ext)
                    {
                    case ".pdf":
                        var pdf = await fileSelectService.SavePdf(UrlFile, System.IO.Path.GetRandomFileName());

                        medicalVideoCall.UrlPdf       = Device.RuntimePlatform == Device.Android ? $"file:///android_asset/pdfjs/web/viewer.html?file=file://{WebUtility.UrlEncode(pdf)}" : pdf;
                        medicalVideoCall.IsVisiblePdf = true;
                        medicalVideoCall.Close        = true;
                        break;

                    case ".png":
                    case ".jpg":
                    case ".jpeg":
                        medicalVideoCall.UrlImage       = urlFile;
                        medicalVideoCall.IsVisibleImage = true;
                        medicalVideoCall.Close          = true;
                        break;

                    case ".xlsx":
                    case ".docx":
                        await dialogService.ShowMessage("Atención", "Se abrirá una pantalla nueva de la cual podrás descargar el archivo");

                        await Browser.OpenAsync(UrlFile, BrowserLaunchMode.SystemPreferred);

                        break;

                    default:
                        await dialogService.ShowMessage("", "Formato de archivo no soportado");

                        break;
                    }
                    medicalVideoCall.UrlFile = UrlFile;
                }
            }
            catch (Exception e)
            {
                ServiceLocator.Current.GetInstance <IExceptionService>().RegisterException(e);
            }
            finally
            {
                dialogService.HideProgress();
            }
        }
Beispiel #2
0
        public async void OpenPdf(string urlPdf = "", string name = "", byte[] array = null, bool share = false, string title = "")
        {
            IsVisibleShare = share;
            Title          = title;
            PdfPath        = await fileSelectService.SavePdf(urlPdf, name, array);

            PdfSource = Device.RuntimePlatform == Device.Android ? $"file:///android_asset/pdfjs/web/viewer.html?file=file://{WebUtility.UrlEncode(PdfPath)}" : PdfPath;
            if (!string.IsNullOrWhiteSpace(PdfSource))
            {
                await navigationService.Navigate(Enumerations.AppPages.PdfPage);
            }
            if (Device.RuntimePlatform != Device.Android)
            {
                await dialogService.ShowMessage("", "En caso de no poder visualizar el pdf, lo puedes descargar o compartir en el icono que encontrás en la parte inferior de tu pantalla.");
            }
        }