当前位置: 首页>>代码示例>>C#>>正文


C# XpsDocumentWriter.WritingCompleted事件代码示例

本文整理汇总了C#中System.Windows.Xps.XpsDocumentWriter.WritingCompleted事件的典型用法代码示例。如果您正苦于以下问题:C# XpsDocumentWriter.WritingCompleted事件的具体用法?C# XpsDocumentWriter.WritingCompleted怎么用?C# XpsDocumentWriter.WritingCompleted使用的例子?那么, 这里精选的事件代码示例或许可以为您提供帮助。您也可以进一步了解该事件所在System.Windows.Xps.XpsDocumentWriter的用法示例。


在下文中一共展示了XpsDocumentWriter.WritingCompleted事件的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveMultipleFixedContentDocumentsAsync

private void SaveMultipleFixedContentDocumentsAsync(
             XpsDocumentWriter xpsdw, FixedDocumentSequence fds)
{
    _xpsdwActive = xpsdw;

    xpsdw.WritingCompleted +=
        new WritingCompletedEventHandler(AsyncSaveCompleted);

    xpsdw.WritingProgressChanged +=
        new WritingProgressChangedEventHandler(AsyncSavingProgress);

    // Write the FixedDocumentSequence as a
    // collection of documents asynchronously.
    xpsdw.WriteAsync(fds);
}

// Cancel an async operation
public void CancelAsync()
{
    _xpsdwActive.CancelAsync();
}
#endregion // Asynchronous Save Methods

#region Async Event Handlers
//
// Create an "async operation complete" event handler
// for saving a FixedDocumentSequence
//
private void AsyncSaveCompleted(
             object sender, WritingCompletedEventArgs e)
{
    string result;
    if (e.Cancelled)          result = "Canceled";
    else if (e.Error != null) result = "Error";
    else                      result = "Asynchronous operation Completed";

    // Close the pakcage
    _xpsDocument.Close();

    if (OnAsyncSaveChange != null)
    {
        AsyncSaveEventArgs asyncInfo =
            new AsyncSaveEventArgs(result, true);
        OnAsyncSaveChange(this, asyncInfo);
    }
}

//
// Create an "async operation progress" event handler for
// monitoring the progress of saving a FixedDocumentSequence.
//
private void AsyncSavingProgress(
                object sender, WritingProgressChangedEventArgs e)
{
    _batchProgress++;

    if (OnAsyncSaveChange != null)
    {
        String progress =
            String.Format("{0} - {1}", e.WritingLevel.ToString(),
                          e.Number.ToString());
        AsyncSaveEventArgs asyncInfo =
            new AsyncSaveEventArgs(progress, false);
        OnAsyncSaveChange(this, asyncInfo);
    }

    // Call EndBatchWrite when serializing multiple visuals.
    if ( (_activeVtoXPSD != null) && (_batchProgress == 3) )
        _activeVtoXPSD.EndBatchWrite();
}
开发者ID:.NET开发者,项目名称:System.Windows.Xps,代码行数:70,代码来源:XpsDocumentWriter.WritingCompleted


注:本文中的System.Windows.Xps.XpsDocumentWriter.WritingCompleted事件示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。