Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / MS / Internal / PtsHost / TextFormatterHost.cs / 1305600 / TextFormatterHost.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File: ContainerParagraph.cs
//
// Description: TextFormatter host.
//
// History:
// 05/05/2003 : [....] - moving from Avalon branch.
//
//---------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.TextFormatting;
namespace MS.Internal.PtsHost
{
// ---------------------------------------------------------------------
// TextFormatter host.
// ---------------------------------------------------------------------
internal sealed class TextFormatterHost : TextSource
{
internal TextFormatterHost(TextFormatter textFormatter, TextFormattingMode textFormattingMode)
{
if(textFormatter == null)
{
TextFormatter = TextFormatter.FromCurrentDispatcher(textFormattingMode);
}
else
{
TextFormatter = textFormatter;
}
}
//--------------------------------------------------------------------
// GetTextRun
//-------------------------------------------------------------------
public override TextRun GetTextRun(int textSourceCharacterIndex)
{
Debug.Assert(Context != null, "TextFormatter host is not initialized.");
Debug.Assert(textSourceCharacterIndex >= 0, "Character index must be non-negative.");
return Context.GetTextRun(textSourceCharacterIndex);
}
//--------------------------------------------------------------------
// GetPrecedingText
//--------------------------------------------------------------------
public override TextSpan GetPrecedingText(int textSourceCharacterIndexLimit)
{
Debug.Assert(Context != null, "TextFormatter host is not initialized.");
Debug.Assert(textSourceCharacterIndexLimit >= 0, "Character index must be non-negative.");
return Context.GetPrecedingText(textSourceCharacterIndexLimit);
}
///
/// TextFormatter to map a text source character index to a text effect character index
///
/// text source character index
/// the text effect index corresponding to the text effect character index
public override int GetTextEffectCharacterIndexFromTextSourceCharacterIndex(
int textSourceCharacterIndex
)
{
Debug.Assert(Context != null, "TextFormatter host is not initialized.");
Debug.Assert(textSourceCharacterIndex>= 0, "Character index must be non-negative.");
return Context.GetTextEffectCharacterIndexFromTextSourceCharacterIndex(textSourceCharacterIndex);
}
//-------------------------------------------------------------------
// TextFormatterHost context, object responsible for providing
// formatting information.
//--------------------------------------------------------------------
internal LineBase Context;
//-------------------------------------------------------------------
// TextFormatter.
//-------------------------------------------------------------------
internal TextFormatter TextFormatter;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File: ContainerParagraph.cs
//
// Description: TextFormatter host.
//
// History:
// 05/05/2003 : [....] - moving from Avalon branch.
//
//---------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.TextFormatting;
namespace MS.Internal.PtsHost
{
// ---------------------------------------------------------------------
// TextFormatter host.
// ---------------------------------------------------------------------
internal sealed class TextFormatterHost : TextSource
{
internal TextFormatterHost(TextFormatter textFormatter, TextFormattingMode textFormattingMode)
{
if(textFormatter == null)
{
TextFormatter = TextFormatter.FromCurrentDispatcher(textFormattingMode);
}
else
{
TextFormatter = textFormatter;
}
}
//--------------------------------------------------------------------
// GetTextRun
//-------------------------------------------------------------------
public override TextRun GetTextRun(int textSourceCharacterIndex)
{
Debug.Assert(Context != null, "TextFormatter host is not initialized.");
Debug.Assert(textSourceCharacterIndex >= 0, "Character index must be non-negative.");
return Context.GetTextRun(textSourceCharacterIndex);
}
//--------------------------------------------------------------------
// GetPrecedingText
//--------------------------------------------------------------------
public override TextSpan GetPrecedingText(int textSourceCharacterIndexLimit)
{
Debug.Assert(Context != null, "TextFormatter host is not initialized.");
Debug.Assert(textSourceCharacterIndexLimit >= 0, "Character index must be non-negative.");
return Context.GetPrecedingText(textSourceCharacterIndexLimit);
}
///
/// TextFormatter to map a text source character index to a text effect character index
///
/// text source character index
/// the text effect index corresponding to the text effect character index
public override int GetTextEffectCharacterIndexFromTextSourceCharacterIndex(
int textSourceCharacterIndex
)
{
Debug.Assert(Context != null, "TextFormatter host is not initialized.");
Debug.Assert(textSourceCharacterIndex>= 0, "Character index must be non-negative.");
return Context.GetTextEffectCharacterIndexFromTextSourceCharacterIndex(textSourceCharacterIndex);
}
//-------------------------------------------------------------------
// TextFormatterHost context, object responsible for providing
// formatting information.
//--------------------------------------------------------------------
internal LineBase Context;
//-------------------------------------------------------------------
// TextFormatter.
//-------------------------------------------------------------------
internal TextFormatter TextFormatter;
}
}
// 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
- TextServicesDisplayAttribute.cs
- RuleRefElement.cs
- OleDbPropertySetGuid.cs
- AutomationElementCollection.cs
- SQLRoleProvider.cs
- IDQuery.cs
- ReadOnlyDataSource.cs
- DatagridviewDisplayedBandsData.cs
- AutomationPropertyInfo.cs
- TableItemPatternIdentifiers.cs
- QueueProcessor.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- CodeSubDirectoriesCollection.cs
- PageRequestManager.cs
- ValueTypePropertyReference.cs
- HwndSourceKeyboardInputSite.cs
- WorkflowRuntimeServiceElement.cs
- RenderData.cs
- WindowsButton.cs
- PrintPreviewGraphics.cs
- RewritingValidator.cs
- MsmqProcessProtocolHandler.cs
- UdpTransportSettings.cs
- DiagnosticsElement.cs
- dtdvalidator.cs
- XmlQueryTypeFactory.cs
- EntityModelBuildProvider.cs
- TransformerConfigurationWizardBase.cs
- SaveLedgerEntryRequest.cs
- GroupPartitionExpr.cs
- RuleSetDialog.cs
- SoapAttributeOverrides.cs
- ZipFileInfo.cs
- NamedElement.cs
- DefaultAssemblyResolver.cs
- RuleProcessor.cs
- Identity.cs
- ObjectSecurityT.cs
- TraceListeners.cs
- XmlSchemaSimpleContentRestriction.cs
- XamlReaderConstants.cs
- ReliableSessionBindingElement.cs
- NullExtension.cs
- SuppressMessageAttribute.cs
- HwndAppCommandInputProvider.cs
- FormsIdentity.cs
- ParameterCollection.cs
- SelectionEditor.cs
- ContractBase.cs
- RegistryKey.cs
- TextServicesProperty.cs
- ExtendedPropertyDescriptor.cs
- TypefaceMap.cs
- Activity.cs
- SchemaImporterExtension.cs
- DoubleLinkList.cs
- SqlCrossApplyToCrossJoin.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- FileUtil.cs
- XmlDataCollection.cs
- MetadataArtifactLoaderCompositeResource.cs
- StrokeSerializer.cs
- SmtpException.cs
- ThreadExceptionEvent.cs
- BindValidationContext.cs
- DataGridViewBand.cs
- SqlClientFactory.cs
- Grid.cs
- HttpHandler.cs
- PersistNameAttribute.cs
- TypedDataSetSchemaImporterExtension.cs
- XmlNullResolver.cs
- SortableBindingList.cs
- WebPartDeleteVerb.cs
- dataprotectionpermission.cs
- Html32TextWriter.cs
- returneventsaver.cs
- SystemInfo.cs
- UserControlCodeDomTreeGenerator.cs
- _AuthenticationState.cs
- OutputCacheSettingsSection.cs
- DataGridViewAccessibleObject.cs
- LambdaSerializationException.cs
- CodeStatementCollection.cs
- RSAProtectedConfigurationProvider.cs
- FontClient.cs
- RenderCapability.cs
- WindowsSpinner.cs
- XmlSiteMapProvider.cs
- FormattedTextSymbols.cs
- BrowserDefinitionCollection.cs
- DataGridBoolColumn.cs
- CharacterHit.cs
- ConnectionManager.cs
- Timeline.cs
- WSAddressing10ProblemHeaderQNameFault.cs
- ManualWorkflowSchedulerService.cs
- GrabHandleGlyph.cs
- XamlSerializationHelper.cs
- PseudoWebRequest.cs