Esempio n. 1
0
 /// <summary>
 /// Attach embedded viewer to the reader control. 
 /// </summary>
 private void AttachViewer(IFlowDocumentViewer viewer) 
 { 
     Invariant.Assert(viewer != null && viewer is FrameworkElement);
     FrameworkElement feViewer = (FrameworkElement)viewer; 
     // Set document
     viewer.SetDocument(Document);
     // Set TemplatedParent
     //feViewer._templatedParent = TemplatedParent; 
     // Register event handlers.
     viewer.PageCountChanged += new EventHandler(OnPageCountChanged); 
     viewer.PageNumberChanged += new EventHandler(OnPageNumberChanged); 
     viewer.PrintStarted += new EventHandler(OnViewerPrintStarted);
     viewer.PrintCompleted += new EventHandler(OnViewerPrintCompleted); 
     // Create property bindings.
     CreateTwoWayBinding(feViewer, ZoomProperty, "Zoom");
     CreateTwoWayBinding(feViewer, MaxZoomProperty, "MaxZoom");
     CreateTwoWayBinding(feViewer, MinZoomProperty, "MinZoom"); 
     CreateTwoWayBinding(feViewer, ZoomIncrementProperty, "ZoomIncrement");
 } 
Esempio n. 2
0
 /// <summary> 
 /// Detach embedded viewer form the reader control.
 /// </summary> 
 private void DetachViewer(IFlowDocumentViewer viewer)
 {
     Invariant.Assert(viewer != null && viewer is FrameworkElement);
     FrameworkElement feViewer = (FrameworkElement)viewer; 
     // Clear property bindings.
     BindingOperations.ClearBinding(feViewer, ZoomProperty); 
     BindingOperations.ClearBinding(feViewer, MaxZoomProperty); 
     BindingOperations.ClearBinding(feViewer, MinZoomProperty);
     BindingOperations.ClearBinding(feViewer, ZoomIncrementProperty); 
     // Unregister event handlers.
     viewer.PageCountChanged -= new EventHandler(OnPageCountChanged);
     viewer.PageNumberChanged -= new EventHandler(OnPageNumberChanged);
     viewer.PrintStarted -= new EventHandler(OnViewerPrintStarted); 
     viewer.PrintCompleted -= new EventHandler(OnViewerPrintCompleted);
     // Clear TemplatedParent 
     //feViewer._templatedParent = null; 
     // Detach document
     viewer.SetDocument(null); 
 }