XpsDocumentWriter.WritingProgressChanged 이벤트
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
XpsDocumentWriter가 진행률을 업데이트할 때 발생합니다.
public:
override event System::Windows::Documents::Serialization::WritingProgressChangedEventHandler ^ WritingProgressChanged;
public override event System.Windows.Documents.Serialization.WritingProgressChangedEventHandler WritingProgressChanged;
member this.WritingProgressChanged : System.Windows.Documents.Serialization.WritingProgressChangedEventHandler
Public Overrides Custom Event WritingProgressChanged As WritingProgressChangedEventHandler
이벤트 유형
예제
다음 예제에서는 이벤트 처리기를 만들고 사용하는 WritingProgressChanged 방법을 보여줍니다.
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();
}
Private Sub SaveMultipleFixedContentDocumentsAsync(ByVal xpsdw As XpsDocumentWriter, ByVal fds As FixedDocumentSequence)
_xpsdwActive = xpsdw
AddHandler xpsdw.WritingCompleted, AddressOf AsyncSaveCompleted
AddHandler xpsdw.WritingProgressChanged, AddressOf AsyncSavingProgress
' Write the FixedDocumentSequence as a
' collection of documents asynchronously.
xpsdw.WriteAsync(fds)
End Sub
' Cancel an async operation
Public Sub CancelAsync()
_xpsdwActive.CancelAsync()
End Sub
#End Region ' Asynchronous Save Methods
#Region "Async Event Handlers"
'
' Create an "async operation complete" event handler
' for saving a FixedDocumentSequence
'
Private Sub AsyncSaveCompleted(ByVal sender As Object, ByVal e As WritingCompletedEventArgs)
Dim result As String
If e.Cancelled Then
result = "Canceled"
ElseIf e.Error IsNot Nothing Then
result = "Error"
Else
result = "Asynchronous operation Completed"
End If
' Close the pakcage
_xpsDocument.Close()
If OnAsyncSaveChangeEvent IsNot Nothing Then
Dim asyncInfo As New AsyncSaveEventArgs(result, True)
RaiseEvent OnAsyncSaveChange(Me, asyncInfo)
End If
End Sub
'
' Create an "async operation progress" event handler for
' monitoring the progress of saving a FixedDocumentSequence.
'
Private Sub AsyncSavingProgress(ByVal sender As Object, ByVal e As WritingProgressChangedEventArgs)
_batchProgress += 1
If OnAsyncSaveChangeEvent IsNot Nothing Then
Dim progress As String = String.Format("{0} - {1}", e.WritingLevel.ToString(), e.Number.ToString())
Dim asyncInfo As New AsyncSaveEventArgs(progress, False)
RaiseEvent OnAsyncSaveChange(Me, asyncInfo)
End If
' Call EndBatchWrite when serializing multiple visuals.
If (_activeVtoXPSD IsNot Nothing) AndAlso (_batchProgress = 3) Then
_activeVtoXPSD.EndBatchWrite()
End If
End Sub
적용 대상
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET