private static string GetPdfViewString(PdfViewStyle pdfViewStyle) { switch (pdfViewStyle) { case PdfViewStyle.HorizontalFit: return("FitH"); case PdfViewStyle.VerticalFit: return("FitV"); default: case PdfViewStyle.Default: return(string.Empty); } }
public void ShowWeb( string mediaItemFilePath, Guid mediaItemId, int pdfStartingPage, PdfViewStyle pdfViewStyle, bool showMirror, ScreenPosition screenPosition) { _useMirror = showMirror; if (string.IsNullOrEmpty(mediaItemFilePath)) { return; } _showing = false; _mediaItemId = mediaItemId; ScreenPositionHelper.SetScreenPosition(_browserGrid, screenPosition); OnMediaChangeEvent(CreateMediaEventArgs(mediaItemId, MediaChange.Starting)); string?webAddress; if (Path.GetExtension(mediaItemFilePath).Equals(".pdf", StringComparison.OrdinalIgnoreCase)) { // https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf var viewString = GetPdfViewString(pdfViewStyle); var cacheBusterString = DateTime.Now.Ticks.ToString(); webAddress = $"pdf://{mediaItemFilePath}?t={cacheBusterString}#view={viewString}&page={pdfStartingPage}"; } else { var urlHelper = new WebShortcutHelper(mediaItemFilePath); webAddress = urlHelper.Uri; } _currentMediaItemUrl = webAddress; RemoveAnimation(); _browserGrid.Visibility = Visibility.Visible; _browser.Load(webAddress); }