Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / Documents / XamlRtfConverter.cs / 1 / XamlRtfConverter.cs
//----------------------------------------------------------------------------
//
// File: XamlRtfConverter.cs
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// Description: Xaml-Rtf Converter.
//
//---------------------------------------------------------------------------
using System.IO;
using System.Text;
namespace System.Windows.Documents
{
///
/// XamlRtfConverter is a static class that convert from/to rtf content to/from xaml content.
///
internal class XamlRtfConverter
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// create new instance of XamlRtfConverter that convert the content between xaml and rtf.
///
internal XamlRtfConverter()
{
}
#endregion Constructors
// ----------------------------------------------------------------------
//
// Internal Methods
//
// ---------------------------------------------------------------------
#region Internal Methods
///
/// Converts an xaml content to rtf content.
///
///
/// The source xaml text content to be converted into Rtf content.
///
///
/// Well-formed representing rtf equivalent string for the source xaml content.
///
internal string ConvertXamlToRtf(string xamlContent)
{
// Check the parameter validation
if (xamlContent == null)
{
throw new ArgumentNullException("xamlContent");
}
string rtfContent = string.Empty;
if (xamlContent != string.Empty)
{
// Creating the converter that process the content data from Xaml to Rtf
XamlToRtfWriter xamlToRtfWriter = new XamlToRtfWriter(xamlContent);
// Set WpfPayload package that contained the image for the specified Xaml
if (WpfPayload != null)
{
xamlToRtfWriter.WpfPayload = WpfPayload;
}
// Process the converting from xaml to rtf
xamlToRtfWriter.Process();
// Set rtf content that representing resulting from Xaml to Rtf converting.
rtfContent = xamlToRtfWriter.Output;
}
return rtfContent;
}
///
/// Converts an rtf content to xaml content.
///
///
/// The source rtf content that to be converted into xaml content.
///
///
/// Well-formed xml representing XAML equivalent content for the input rtf content string.
///
internal string ConvertRtfToXaml(string rtfContent)
{
// Check the parameter validation
if (rtfContent == null)
{
throw new ArgumentNullException("rtfContent");
}
// xaml content to be converted from rtf
string xamlContent = string.Empty;
if (rtfContent != string.Empty)
{
// Create RtfToXamlReader instance for converting the content
// from rtf to xaml and set ForceParagraph
RtfToXamlReader rtfToXamlReader = new RtfToXamlReader(rtfContent);
rtfToXamlReader.ForceParagraph = ForceParagraph;
// Set WpfPayload package that contained the image for the specified Xaml
if (WpfPayload != null)
{
rtfToXamlReader.WpfPayload = WpfPayload;
}
//Process the converting from rtf to xaml
rtfToXamlReader.Process();
// Set Xaml content string that representing resulting Rtf-Xaml converting
xamlContent = rtfToXamlReader.Output;
}
return xamlContent;
}
#endregion Internal Methods
// ----------------------------------------------------------------------
//
// Internal Properties
//
// ----------------------------------------------------------------------
#region Internal Properties
// ForceParagraph property indicates whether ForcePagraph for RtfToXamlReader.
internal bool ForceParagraph
{
get
{
return _forceParagraph;
}
set
{
_forceParagraph = value;
}
}
// WpfPayload package property for getting or placing image data for Xaml content
internal WpfPayload WpfPayload
{
get
{
return _wpfPayload;
}
set
{
_wpfPayload = value;
}
}
#endregion Internal Properties
// ---------------------------------------------------------------------
//
// Internal Fields
//
// ----------------------------------------------------------------------
#region Internal Fields
// Rtf encoding codepage that is 1252 ANSI
internal const int RtfCodePage = 1252;
#endregion Internal Fields
// ---------------------------------------------------------------------
//
// Private Fields
//
// ---------------------------------------------------------------------
#region Private Fields
// Flag that indicate the forcing paragragh for RtfToXamlReader
private bool _forceParagraph;
// The output WpfPayload package for placing image data into it
private WpfPayload _wpfPayload;
#endregion Private Fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
// File: XamlRtfConverter.cs
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// Description: Xaml-Rtf Converter.
//
//---------------------------------------------------------------------------
using System.IO;
using System.Text;
namespace System.Windows.Documents
{
///
/// XamlRtfConverter is a static class that convert from/to rtf content to/from xaml content.
///
internal class XamlRtfConverter
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// create new instance of XamlRtfConverter that convert the content between xaml and rtf.
///
internal XamlRtfConverter()
{
}
#endregion Constructors
// ----------------------------------------------------------------------
//
// Internal Methods
//
// ---------------------------------------------------------------------
#region Internal Methods
///
/// Converts an xaml content to rtf content.
///
///
/// The source xaml text content to be converted into Rtf content.
///
///
/// Well-formed representing rtf equivalent string for the source xaml content.
///
internal string ConvertXamlToRtf(string xamlContent)
{
// Check the parameter validation
if (xamlContent == null)
{
throw new ArgumentNullException("xamlContent");
}
string rtfContent = string.Empty;
if (xamlContent != string.Empty)
{
// Creating the converter that process the content data from Xaml to Rtf
XamlToRtfWriter xamlToRtfWriter = new XamlToRtfWriter(xamlContent);
// Set WpfPayload package that contained the image for the specified Xaml
if (WpfPayload != null)
{
xamlToRtfWriter.WpfPayload = WpfPayload;
}
// Process the converting from xaml to rtf
xamlToRtfWriter.Process();
// Set rtf content that representing resulting from Xaml to Rtf converting.
rtfContent = xamlToRtfWriter.Output;
}
return rtfContent;
}
///
/// Converts an rtf content to xaml content.
///
///
/// The source rtf content that to be converted into xaml content.
///
///
/// Well-formed xml representing XAML equivalent content for the input rtf content string.
///
internal string ConvertRtfToXaml(string rtfContent)
{
// Check the parameter validation
if (rtfContent == null)
{
throw new ArgumentNullException("rtfContent");
}
// xaml content to be converted from rtf
string xamlContent = string.Empty;
if (rtfContent != string.Empty)
{
// Create RtfToXamlReader instance for converting the content
// from rtf to xaml and set ForceParagraph
RtfToXamlReader rtfToXamlReader = new RtfToXamlReader(rtfContent);
rtfToXamlReader.ForceParagraph = ForceParagraph;
// Set WpfPayload package that contained the image for the specified Xaml
if (WpfPayload != null)
{
rtfToXamlReader.WpfPayload = WpfPayload;
}
//Process the converting from rtf to xaml
rtfToXamlReader.Process();
// Set Xaml content string that representing resulting Rtf-Xaml converting
xamlContent = rtfToXamlReader.Output;
}
return xamlContent;
}
#endregion Internal Methods
// ----------------------------------------------------------------------
//
// Internal Properties
//
// ----------------------------------------------------------------------
#region Internal Properties
// ForceParagraph property indicates whether ForcePagraph for RtfToXamlReader.
internal bool ForceParagraph
{
get
{
return _forceParagraph;
}
set
{
_forceParagraph = value;
}
}
// WpfPayload package property for getting or placing image data for Xaml content
internal WpfPayload WpfPayload
{
get
{
return _wpfPayload;
}
set
{
_wpfPayload = value;
}
}
#endregion Internal Properties
// ---------------------------------------------------------------------
//
// Internal Fields
//
// ----------------------------------------------------------------------
#region Internal Fields
// Rtf encoding codepage that is 1252 ANSI
internal const int RtfCodePage = 1252;
#endregion Internal Fields
// ---------------------------------------------------------------------
//
// Private Fields
//
// ---------------------------------------------------------------------
#region Private Fields
// Flag that indicate the forcing paragragh for RtfToXamlReader
private bool _forceParagraph;
// The output WpfPayload package for placing image data into it
private WpfPayload _wpfPayload;
#endregion Private Fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BulletedListEventArgs.cs
- ObservableDictionary.cs
- SqlNodeTypeOperators.cs
- DataSourceXmlAttributeAttribute.cs
- IndexedGlyphRun.cs
- FileDialog_Vista_Interop.cs
- SqlMultiplexer.cs
- IdnMapping.cs
- ReadWriteSpinLock.cs
- panel.cs
- ProcessThreadCollection.cs
- DeclarationUpdate.cs
- ManualResetEvent.cs
- BitmapEffectState.cs
- MessageFilterTable.cs
- AutoGeneratedField.cs
- CustomAttribute.cs
- CheckBoxStandardAdapter.cs
- DocumentViewerConstants.cs
- ExceptionUtil.cs
- ALinqExpressionVisitor.cs
- TraceLevelHelper.cs
- SmtpDateTime.cs
- Selection.cs
- CachedBitmap.cs
- Content.cs
- SafeSystemMetrics.cs
- FloaterBaseParagraph.cs
- WmfPlaceableFileHeader.cs
- ArraySortHelper.cs
- RegionIterator.cs
- XmlLinkedNode.cs
- ApplicationSecurityManager.cs
- XmlBinaryReader.cs
- ManagementClass.cs
- ObjectCacheSettings.cs
- RootBrowserWindow.cs
- EncryptedKey.cs
- FormatConvertedBitmap.cs
- WorkItem.cs
- DataReaderContainer.cs
- PlatformCulture.cs
- HandleCollector.cs
- XamlTypeMapper.cs
- DataGridViewComboBoxCell.cs
- MachineKeySection.cs
- AssemblyNameProxy.cs
- SqlDataSourceView.cs
- ErrorHandlingAcceptor.cs
- StyleHelper.cs
- BatchServiceHost.cs
- NodeLabelEditEvent.cs
- ZipIOCentralDirectoryFileHeader.cs
- ErrorProvider.cs
- DataTableMapping.cs
- XmlWriterTraceListener.cs
- Rectangle.cs
- PipelineDeploymentState.cs
- XmlSchemaDatatype.cs
- TagMapCollection.cs
- KeyPullup.cs
- CharUnicodeInfo.cs
- SerialPort.cs
- TimerElapsedEvenArgs.cs
- InlinedAggregationOperatorEnumerator.cs
- TextEditorCharacters.cs
- ServiceHttpHandlerFactory.cs
- WorkflowDesigner.cs
- XmlMtomReader.cs
- WsdlBuildProvider.cs
- HtmlElementErrorEventArgs.cs
- DiscoveryServerProtocol.cs
- AuthenticatingEventArgs.cs
- ScrollData.cs
- SerializationStore.cs
- XamlWrapperReaders.cs
- Collection.cs
- QilInvoke.cs
- AnnotationAdorner.cs
- TypedCompletedAsyncResult.cs
- ObjectAssociationEndMapping.cs
- TransformerTypeCollection.cs
- PartManifestEntry.cs
- SqlTrackingWorkflowInstance.cs
- SqlFormatter.cs
- XmlNodeList.cs
- Attributes.cs
- HelpProvider.cs
- ComponentDispatcherThread.cs
- PolyLineSegmentFigureLogic.cs
- LassoHelper.cs
- RegexCaptureCollection.cs
- SettingsPropertyValue.cs
- _DigestClient.cs
- StylusPoint.cs
- TimeSpanSecondsConverter.cs
- LogicalMethodInfo.cs
- DialogWindow.cs
- MessageQueue.cs
- Cell.cs