/// <summary> /// Loads a remote document through url /// </summary> /// <param name="path">url path in string</param> /// <param name="streaming">whether to use HttpStreamingPartRetriever instead of HttpPartRetriever</param> public void LoadDocument(String path, bool streaming = false) { if (System.ComponentModel.DesignerProperties.IsInDesignTool) { return; } if (path == null || path == String.Empty) { return; } if (myRetriever != null) { myRetriever.CancelAllRequests(); } Uri uri = new Uri(path, UriKind.RelativeOrAbsolute); if (streaming) { myRetriever = new HttpStreamingPartRetriever(uri); } else { myRetriever = new HttpPartRetriever(uri); } FixedDocViewer.LoadAsync(myRetriever, OnLoadAsyncCallback); this.OnDocumentChanged(uri); }
/// <summary> /// Sets the page layout mode of the current document viewer /// </summary> /// <param name="mode">the LayoutModes to change to</param> private void SetLayout(LayoutModes mode) { Debug.WriteLine("Entering SetLayout " + DateTime.Now); if (mode == LayoutModes.Continuous) { FixedDocViewer.Template = (ControlTemplate)this.Resources["VerticalLayoutTemplate"]; } else if (mode == LayoutModes.FacingContinous) { FixedDocViewer.Template = (ControlTemplate)this.Resources["FacingLayoutTemplate"]; } else if (mode == LayoutModes.FacingCoverContinuous) { FixedDocViewer.Template = (ControlTemplate)this.Resources["FacingCoverContinousLayoutTemplate"]; } else if (mode == LayoutModes.SinglePage) { FixedDocViewer.Template = (ControlTemplate)this.Resources["VerticalLayoutTemplate"]; } else if (mode == LayoutModes.FacingCover) { FixedDocViewer.Template = (ControlTemplate)this.Resources["FacingCoverContinousLayoutTemplate"]; } else if (mode == LayoutModes.Facing) { FixedDocViewer.Template = (ControlTemplate)this.Resources["FacingLayoutTemplate"]; } if (mode == LayoutModes.SinglePage) { FixedDocViewer.DisplayMode = DocumentViewer.DisplayModes.SinglePage; } else if (mode == LayoutModes.Facing) { FixedDocViewer.DisplayMode = DocumentViewer.DisplayModes.DualPageFacing; } else if (mode == LayoutModes.FacingCover) { FixedDocViewer.DisplayMode = DocumentViewer.DisplayModes.DualPageCoverFacing; } else { FixedDocViewer.DisplayMode = DocumentViewer.DisplayModes.AllPages; } FixedDocViewer.RefreshTemplate(); }
/// <summary> /// Loads a local document from client file system /// </summary> public void LoadLocalDocument() { OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = false; dlg.Filter = "XOD Files (*.xod)|*.xod"; // open dialog bool ok = (bool)dlg.ShowDialog(); if (ok) { if (myRetriever as LocalPartRetriever != null) { ((LocalPartRetriever)myRetriever).Dispose(); } FileStream fileStream = dlg.File.OpenRead(); myRetriever = new LocalPartRetriever(fileStream); FixedDocViewer.LoadAsync(myRetriever, OnLoadAsyncCallback); this.OnDocumentChanged(dlg.File); } }
/// <summary> /// Loads a remote document through url /// </summary> /// <param name="uri">url path in Uri</param> /// <param name="streaming">whether to use HttpStreamingPartRetriever instead of HttpPartRetriever</param> public void LoadDocument(Uri uri, bool streaming = false) { if (System.ComponentModel.DesignerProperties.IsInDesignTool) { return; } if (uri == null) { return; } if (streaming) { myRetriever = new HttpStreamingPartRetriever(uri); } else { myRetriever = new HttpPartRetriever(uri); } FixedDocViewer.LoadAsync(myRetriever, OnLoadAsyncCallback); this.OnDocumentChanged(uri); }