// ------------------------- PrintVisualsAsync ------------------------ /// <summary> /// Initiates asynchronous output of a given list of /// visuals to a specified document writer.</summary> /// <param name="xpsdw"> /// The document writer to output to.</param> /// <param name="vc"> /// The list of visuals to print.</param> private void PrintVisualsAsync(XpsDocumentWriter xpsdw, List<Visual> vc) { _xpsdwActive = xpsdw; // Save the active document writer. xpsdw.WritingCompleted += new WritingCompletedEventHandler(AsyncPrintCompleted); xpsdw.WritingProgressChanged += new WritingProgressChangedEventHandler(AsyncPrintingProgress); // Setup for writing multiple visuals VisualsToXpsDocument vToXpsD = (VisualsToXpsDocument)xpsdw.CreateVisualsCollator(); _batchProgress = 0; _activeVtoXPSD = vToXpsD; // Iterate through all visuals in the collection. foreach (Visual v in vc) { vToXpsD.WriteAsync(v); //Write each visual to a single page. } }
// --------------------------- PrintVisuals --------------------------- /// <summary> /// Synchronously prints of a given list of /// visuals to a specified document writer.</summary> /// <param name="xpsdw"> /// The document writer to output to.</param> /// <param name="vc"> /// The list of visuals to print.</param> private void PrintVisuals(XpsDocumentWriter xpsdw, List<Visual> vc) { // Setup for writing multiple visuals VisualsToXpsDocument vToXpsD = (VisualsToXpsDocument)xpsdw.CreateVisualsCollator(); // Iterate through all visuals in the collection foreach (Visual v in vc) { vToXpsD.Write(v); //Write each visual to single page } // End writing multiple visuals vToXpsD.EndBatchWrite(); }