2 using System
.Collections
.Generic
;
5 using System
.Windows
.Documents
.Serialization
;
6 using System
.Windows
.Documents
;
7 using System
.Windows
.Markup
;
8 using System
.Windows
.Media
;
15 class RtfSerializerWriter
: SerializerWriter
17 public RtfSerializerWriter(Stream stream
)
22 /// Write a single Visual and close package
24 public override void Write(Visual visual
)
30 /// Write a single Visual and close package
32 public override void Write(Visual visual
, PrintTicket printTicket
)
34 SerializeObjectTree(visual
);
38 /// Asynchronous Write a single Visual and close package
40 public override void WriteAsync(Visual visual
)
42 throw new NotSupportedException();
46 /// Asynchronous Write a single Visual and close package
48 public override void WriteAsync(Visual visual
, object userState
)
50 throw new NotSupportedException();
55 /// Asynchronous Write a single Visual and close package
57 public override void WriteAsync(Visual visual
, PrintTicket printTicket
)
59 throw new NotSupportedException();
64 /// Asynchronous Write a single Visual and close package
66 public override void WriteAsync(Visual visual
, PrintTicket printTicket
, object userState
)
68 throw new NotSupportedException();
72 /// Write a single DocumentPaginator and close package
74 public override void Write(DocumentPaginator documentPaginator
)
76 Write(documentPaginator
, null);
80 /// Write a single DocumentPaginator and close package
82 public override void Write(DocumentPaginator documentPaginator
, PrintTicket printTicket
)
84 SerializeObjectTree(documentPaginator
.Source
);
88 /// Asynchronous Write a single DocumentPaginator and close package
90 public override void WriteAsync(DocumentPaginator documentPaginator
)
92 throw new NotSupportedException();
96 /// Asynchronous Write a single DocumentPaginator and close package
98 public override void WriteAsync(DocumentPaginator documentPaginator
, PrintTicket printTicket
)
100 throw new NotSupportedException();
104 /// Asynchronous Write a single DocumentPaginator and close package
106 public override void WriteAsync(DocumentPaginator documentPaginator
, object userState
)
108 throw new NotSupportedException();
112 /// Asynchronous Write a single DocumentPaginator and close package
114 public override void WriteAsync(DocumentPaginator documentPaginator
, PrintTicket printTicket
, object userState
)
116 throw new NotSupportedException();
120 /// Write a single FixedPage and close package
122 public override void Write(FixedPage fixedPage
)
124 Write(fixedPage
, null);
128 /// Write a single FixedPage and close package
130 public override void Write(FixedPage fixedPage
, PrintTicket printTicket
)
132 SerializeObjectTree(fixedPage
);
136 /// Asynchronous Write a single FixedPage and close package
138 public override void WriteAsync(FixedPage fixedPage
)
140 throw new NotSupportedException();
144 /// Asynchronous Write a single FixedPage and close package
146 public override void WriteAsync(FixedPage fixedPage
, PrintTicket printTicket
)
148 throw new NotSupportedException();
152 /// Asynchronous Write a single FixedPage and close package
154 public override void WriteAsync(FixedPage fixedPage
, object userState
)
156 throw new NotSupportedException();
160 /// Asynchronous Write a single FixedPage and close package
162 public override void WriteAsync(FixedPage fixedPage
, PrintTicket printTicket
, object userState
)
164 throw new NotSupportedException();
169 /// Write a single FixedDocument and close package
171 public override void Write(FixedDocument fixedDocument
)
173 Write(fixedDocument
, null);
177 /// Write a single FixedDocument and close package
179 public override void Write(FixedDocument fixedDocument
, PrintTicket printTicket
)
181 SerializeObjectTree(fixedDocument
);
185 /// Asynchronous Write a single FixedDocument and close package
187 public override void WriteAsync(FixedDocument fixedDocument
)
189 throw new NotSupportedException();
193 /// Asynchronous Write a single FixedDocument and close package
195 public override void WriteAsync(FixedDocument fixedDocument
, PrintTicket printTicket
)
197 throw new NotSupportedException();
201 /// Asynchronous Write a single FixedDocument and close package
203 public override void WriteAsync(FixedDocument fixedDocument
, object userState
)
205 throw new NotSupportedException();
209 /// Asynchronous Write a single FixedDocument and close package
211 public override void WriteAsync(FixedDocument fixedDocument
, PrintTicket printTicket
, object userState
)
213 throw new NotSupportedException();
217 /// Write a single FixedDocumentSequence and close package
219 public override void Write(FixedDocumentSequence fixedDocumentSequence
)
221 Write(fixedDocumentSequence
, null);
225 /// Write a single FixedDocumentSequence and close package
227 public override void Write(FixedDocumentSequence fixedDocumentSequence
, PrintTicket printTicket
)
229 SerializeObjectTree(fixedDocumentSequence
);
233 /// Asynchronous Write a single FixedDocumentSequence and close package
235 public override void WriteAsync(FixedDocumentSequence fixedDocumentSequence
)
237 throw new NotSupportedException();
241 /// Asynchronous Write a single FixedDocumentSequence and close package
243 public override void WriteAsync(FixedDocumentSequence fixedDocumentSequence
, PrintTicket printTicket
)
245 throw new NotSupportedException();
249 /// Asynchronous Write a single FixedDocumentSequence and close package
251 public override void WriteAsync(FixedDocumentSequence fixedDocumentSequence
, object userState
)
253 throw new NotSupportedException();
257 /// Asynchronous Write a single FixedDocumentSequence and close package
259 public override void WriteAsync(FixedDocumentSequence fixedDocumentSequence
, PrintTicket printTicket
, object userState
)
261 throw new NotSupportedException();
265 /// Cancel Asynchronous Write
267 public override void CancelAsync()
269 throw new NotSupportedException();
273 /// Create a SerializerWriterCollator to gobble up multiple Visuals
275 public override SerializerWriterCollator
CreateVisualsCollator()
277 throw new NotSupportedException();
281 /// Create a SerializerWriterCollator to gobble up multiple Visuals
283 public override SerializerWriterCollator
CreateVisualsCollator(PrintTicket documentSequencePT
, PrintTicket documentPT
)
285 throw new NotSupportedException();
289 /// This event will be invoked if the writer wants a PrintTicker
291 public override event WritingPrintTicketRequiredEventHandler WritingPrintTicketRequired
;
294 /// This event will be invoked if the writer progress changes
296 public override event WritingProgressChangedEventHandler WritingProgressChanged
;
299 /// This event will be invoked if the writer is done
301 public override event WritingCompletedEventHandler WritingCompleted
;
304 /// This event will be invoked if the writer has been cancelled
306 public override event WritingCancelledEventHandler WritingCancelled
;
308 private void SerializeObjectTree(object objectTree
)
310 TextWriter writer
= new StreamWriter(_stream
);
314 string fileContent
= XamlRtfConverter
.ConvertXamlToRtf(
315 XamlWriter
.Save(objectTree
));
316 writer
.Write(fileContent
);
326 private Stream _stream
;