Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Media / textformatting / TextEmbeddedObject.cs / 1 / TextEmbeddedObject.cs
//------------------------------------------------------------------------
//
// Microsoft Windows Client Platform
// Copyright (C) Microsoft Corporation, 2004
//
// File: TextEmbeddedObject.cs
//
// Contents: Definition of text embedded object
//
// Spec: http://avalon/text/DesignDocsAndSpecs/Text%20Formatting%20API.doc
//
// Created: 1-2-2004 Worachai Chaoweeraprasit (wchao)
//
//-----------------------------------------------------------------------
using System;
using System.Collections;
using System.Windows;
using System.Windows.Media;
using MS.Internal.TextFormatting;
namespace System.Windows.Media.TextFormatting
{
///
/// Provide definition for a kind of text content in which measuring, hittesting
/// and drawing of the entire content is done in whole. Example of that kind of
/// content is a button in the middle of the line.
///
public abstract class TextEmbeddedObject : TextRun
{
///
/// Line break condition before text object
///
public abstract LineBreakCondition BreakBefore
{ get; }
///
/// Line break condition after text object
///
public abstract LineBreakCondition BreakAfter
{ get; }
///
/// Flag indicates whether text object has fixed size regardless of where
/// it is placed within a line
///
public abstract bool HasFixedSize
{ get; }
///
/// Get text object measurement metrics that will fit within the specified
/// remaining width of the paragraph
///
/// remaining paragraph width
/// text object metrics
public abstract TextEmbeddedObjectMetrics Format(
double remainingParagraphWidth
);
///
/// Get computed bounding box of text object
///
/// run is drawn from right to left
/// run is drawn with its side parallel to baseline
/// computed bounding box size of text object
public abstract Rect ComputeBoundingBox(
bool rightToLeft,
bool sideways
);
///
/// Draw text object
///
/// drawing context
/// origin where the object is drawn
/// run is drawn from right to left
/// run is drawn with its side parallel to baseline
public abstract void Draw(
DrawingContext drawingContext,
Point origin,
bool rightToLeft,
bool sideways
);
}
///
/// Text object properties
///
public class TextEmbeddedObjectMetrics
{
private double _width;
private double _height;
private double _baseline;
///
/// Construct a text object size
///
/// object width
/// object height
/// object baseline in ratio relative to run height
public TextEmbeddedObjectMetrics(
double width,
double height,
double baseline
)
{
_width = width;
_height = height;
_baseline = baseline;
}
///
/// Object width
///
public double Width
{
get { return _width; }
}
///
/// Object height
///
///
public double Height
{
get { return _height; }
}
///
/// Object baseline in ratio relative to run height
///
public double Baseline
{
get { return _baseline; }
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------
//
// Microsoft Windows Client Platform
// Copyright (C) Microsoft Corporation, 2004
//
// File: TextEmbeddedObject.cs
//
// Contents: Definition of text embedded object
//
// Spec: http://avalon/text/DesignDocsAndSpecs/Text%20Formatting%20API.doc
//
// Created: 1-2-2004 Worachai Chaoweeraprasit (wchao)
//
//-----------------------------------------------------------------------
using System;
using System.Collections;
using System.Windows;
using System.Windows.Media;
using MS.Internal.TextFormatting;
namespace System.Windows.Media.TextFormatting
{
///
/// Provide definition for a kind of text content in which measuring, hittesting
/// and drawing of the entire content is done in whole. Example of that kind of
/// content is a button in the middle of the line.
///
public abstract class TextEmbeddedObject : TextRun
{
///
/// Line break condition before text object
///
public abstract LineBreakCondition BreakBefore
{ get; }
///
/// Line break condition after text object
///
public abstract LineBreakCondition BreakAfter
{ get; }
///
/// Flag indicates whether text object has fixed size regardless of where
/// it is placed within a line
///
public abstract bool HasFixedSize
{ get; }
///
/// Get text object measurement metrics that will fit within the specified
/// remaining width of the paragraph
///
/// remaining paragraph width
/// text object metrics
public abstract TextEmbeddedObjectMetrics Format(
double remainingParagraphWidth
);
///
/// Get computed bounding box of text object
///
/// run is drawn from right to left
/// run is drawn with its side parallel to baseline
/// computed bounding box size of text object
public abstract Rect ComputeBoundingBox(
bool rightToLeft,
bool sideways
);
///
/// Draw text object
///
/// drawing context
/// origin where the object is drawn
/// run is drawn from right to left
/// run is drawn with its side parallel to baseline
public abstract void Draw(
DrawingContext drawingContext,
Point origin,
bool rightToLeft,
bool sideways
);
}
///
/// Text object properties
///
public class TextEmbeddedObjectMetrics
{
private double _width;
private double _height;
private double _baseline;
///
/// Construct a text object size
///
/// object width
/// object height
/// object baseline in ratio relative to run height
public TextEmbeddedObjectMetrics(
double width,
double height,
double baseline
)
{
_width = width;
_height = height;
_baseline = baseline;
}
///
/// Object width
///
public double Width
{
get { return _width; }
}
///
/// Object height
///
///
public double Height
{
get { return _height; }
}
///
/// Object baseline in ratio relative to run height
///
public double Baseline
{
get { return _baseline; }
}
}
}
// 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
- CoreChannel.cs
- CryptoConfig.cs
- CreateUserWizardStep.cs
- DelegatingConfigHost.cs
- ExtensionDataObject.cs
- LayoutUtils.cs
- WebZone.cs
- Model3D.cs
- ErrorWrapper.cs
- Point3DCollectionConverter.cs
- SerializationTrace.cs
- TextTreeUndo.cs
- FormViewDesigner.cs
- PrintingPermissionAttribute.cs
- DescendantOverDescendantQuery.cs
- _TimerThread.cs
- OledbConnectionStringbuilder.cs
- AdornerDecorator.cs
- ZipFileInfo.cs
- XmlSchemaNotation.cs
- ActiveXContainer.cs
- Point4D.cs
- NameValueFileSectionHandler.cs
- LicenseException.cs
- TimeIntervalCollection.cs
- FunctionUpdateCommand.cs
- WriteableBitmap.cs
- ResourceExpressionEditorSheet.cs
- BaseParagraph.cs
- InstanceDataCollectionCollection.cs
- ParallelDesigner.xaml.cs
- DTCTransactionManager.cs
- DefaultEventAttribute.cs
- PrintingPermission.cs
- CodeAttributeDeclarationCollection.cs
- DbCommandDefinition.cs
- SQLInt16.cs
- RenderTargetBitmap.cs
- listitem.cs
- LazyTextWriterCreator.cs
- CustomActivityDesigner.cs
- MessageSecurityOverMsmqElement.cs
- TableAdapterManagerMethodGenerator.cs
- PropertyGroupDescription.cs
- CharAnimationBase.cs
- DataProtection.cs
- XappLauncher.cs
- ScrollData.cs
- MasterPageBuildProvider.cs
- PageSetupDialog.cs
- WebBrowserContainer.cs
- ByeMessageApril2005.cs
- FrameworkObject.cs
- XsltContext.cs
- WebPartZoneDesigner.cs
- ExpressionParser.cs
- HotCommands.cs
- ScrollData.cs
- SelectionRange.cs
- FontCacheUtil.cs
- Matrix.cs
- ObfuscateAssemblyAttribute.cs
- MetadataItemCollectionFactory.cs
- ControlIdConverter.cs
- EncodingNLS.cs
- PeerInvitationResponse.cs
- DataSourceXmlElementAttribute.cs
- FunctionNode.cs
- CodePageUtils.cs
- ForwardPositionQuery.cs
- ValueTypePropertyReference.cs
- RegexMatchCollection.cs
- DataServiceSaveChangesEventArgs.cs
- Transactions.cs
- Image.cs
- Expression.cs
- PropertyRef.cs
- CommandLineParser.cs
- DBParameter.cs
- _HeaderInfo.cs
- JsonReader.cs
- InlineObject.cs
- Int64AnimationUsingKeyFrames.cs
- HttpFileCollection.cs
- DuplicateWaitObjectException.cs
- Rss20ItemFormatter.cs
- DBNull.cs
- VBIdentifierNameEditor.cs
- PathNode.cs
- CssClassPropertyAttribute.cs
- RawStylusActions.cs
- GroupBox.cs
- RC2.cs
- ByteAnimation.cs
- ConditionCollection.cs
- Vector3DIndependentAnimationStorage.cs
- ProgressBarBrushConverter.cs
- HtmlEmptyTagControlBuilder.cs
- DiagnosticTrace.cs
- DataServiceBehavior.cs