Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / MS / Internal / Text / InlineObject.cs / 1 / InlineObject.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // // File: InlineObject.cs // // Description: Cached metrics of an inline objects. // // History: // 04/25/2003 : grzegorz - moving from Avalon branch. // //--------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.TextFormatting; using MS.Internal; namespace MS.Internal.Text { ////// Inline object representation as TextRun. /// internal sealed class InlineObject: TextEmbeddedObject { ////// Constructor. /// /// Text position of the inline object in the text array. /// Number of text position in the text array occupied by the inline object. /// UIElement representing the inline object. /// Text run properties for the inline object. /// TextBlock element - the host of the inline object. internal InlineObject(int dcp, int cch, UIElement element, TextRunProperties textProps, System.Windows.Controls.TextBlock host) { _dcp = dcp; _cch = cch; _element = element; _textProps = textProps; _host = host; } ////// Get inline object's measurement metrics. /// /// Remaining paragraph width. ///Inline object metrics. public override TextEmbeddedObjectMetrics Format(double remainingParagraphWidth) { Size desiredSize = _host.MeasureChild(this); // Make sure that LS/PTS limitations are not exceeded for object's size. TextDpi.EnsureValidObjSize(ref desiredSize); double baseline = desiredSize.Height; double baselineOffsetValue = (double) Element.GetValue(TextBlock.BaselineOffsetProperty); if(!DoubleUtil.IsNaN(baselineOffsetValue)) { baseline = baselineOffsetValue; } return new TextEmbeddedObjectMetrics(desiredSize.Width, desiredSize.Height, baseline); } ////// Get computed bounding box of the inline 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 override Rect ComputeBoundingBox(bool rightToLeft, bool sideways) { if (_element.IsArrangeValid) { // Initially assume that bounding box is the same as layout box. Size size = _element.DesiredSize; double baseline = !sideways ? size.Height : size.Width; double baselineOffsetValue = (double)Element.GetValue(TextBlock.BaselineOffsetProperty); if (!sideways && !DoubleUtil.IsNaN(baselineOffsetValue)) { baseline = (double)baselineOffsetValue; } return new Rect(0, -baseline, sideways ? size.Height : size.Width, sideways ? size.Width : size.Height); } else { return Rect.Empty; } } ////// Draw the inline 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 override void Draw(DrawingContext drawingContext, Point origin, bool rightToLeft, bool sideways) { // Inline object has its own visual and it is attached to a visual // tree during arrange process. // Do nothing here. } ////// Reference to character buffer. /// public override CharacterBufferReference CharacterBufferReference { get { return new CharacterBufferReference(String.Empty, 0); } } ////// Length of the inline object run. /// public override int Length { get { return _cch; } } ////// A set of properties shared by every characters in the run /// public override TextRunProperties Properties { get { return _textProps; } } ////// Line break condition before the inline object. /// public override LineBreakCondition BreakBefore { get { return LineBreakCondition.BreakDesired; } } ////// Line break condition after the inline object. /// public override LineBreakCondition BreakAfter { get { return LineBreakCondition.BreakDesired; } } ////// Flag indicates whether inline object has fixed size regardless of where /// it is placed within a line. /// public override bool HasFixedSize { get { // Size of inline object is not dependent on position in the line. return true; } } ////// Text position on the inline object in the text array. /// internal int Dcp { get { return _dcp; } } ////// UIElement representing the inline object. /// internal UIElement Element { get { return _element; } } ////// Text position on the inline object in the text array. /// private readonly int _dcp; ////// Number of text position in the text array occupied by the inline object. /// private readonly int _cch; ////// UIElement representing the inline object. /// private readonly UIElement _element; ////// Text run properties for the inline object. /// private readonly TextRunProperties _textProps; ////// Text element - the host of the inline object. /// private readonly System.Windows.Controls.TextBlock _host; } } // 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: InlineObject.cs // // Description: Cached metrics of an inline objects. // // History: // 04/25/2003 : grzegorz - moving from Avalon branch. // //--------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.TextFormatting; using MS.Internal; namespace MS.Internal.Text { ////// Inline object representation as TextRun. /// internal sealed class InlineObject: TextEmbeddedObject { ////// Constructor. /// /// Text position of the inline object in the text array. /// Number of text position in the text array occupied by the inline object. /// UIElement representing the inline object. /// Text run properties for the inline object. /// TextBlock element - the host of the inline object. internal InlineObject(int dcp, int cch, UIElement element, TextRunProperties textProps, System.Windows.Controls.TextBlock host) { _dcp = dcp; _cch = cch; _element = element; _textProps = textProps; _host = host; } ////// Get inline object's measurement metrics. /// /// Remaining paragraph width. ///Inline object metrics. public override TextEmbeddedObjectMetrics Format(double remainingParagraphWidth) { Size desiredSize = _host.MeasureChild(this); // Make sure that LS/PTS limitations are not exceeded for object's size. TextDpi.EnsureValidObjSize(ref desiredSize); double baseline = desiredSize.Height; double baselineOffsetValue = (double) Element.GetValue(TextBlock.BaselineOffsetProperty); if(!DoubleUtil.IsNaN(baselineOffsetValue)) { baseline = baselineOffsetValue; } return new TextEmbeddedObjectMetrics(desiredSize.Width, desiredSize.Height, baseline); } ////// Get computed bounding box of the inline 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 override Rect ComputeBoundingBox(bool rightToLeft, bool sideways) { if (_element.IsArrangeValid) { // Initially assume that bounding box is the same as layout box. Size size = _element.DesiredSize; double baseline = !sideways ? size.Height : size.Width; double baselineOffsetValue = (double)Element.GetValue(TextBlock.BaselineOffsetProperty); if (!sideways && !DoubleUtil.IsNaN(baselineOffsetValue)) { baseline = (double)baselineOffsetValue; } return new Rect(0, -baseline, sideways ? size.Height : size.Width, sideways ? size.Width : size.Height); } else { return Rect.Empty; } } ////// Draw the inline 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 override void Draw(DrawingContext drawingContext, Point origin, bool rightToLeft, bool sideways) { // Inline object has its own visual and it is attached to a visual // tree during arrange process. // Do nothing here. } ////// Reference to character buffer. /// public override CharacterBufferReference CharacterBufferReference { get { return new CharacterBufferReference(String.Empty, 0); } } ////// Length of the inline object run. /// public override int Length { get { return _cch; } } ////// A set of properties shared by every characters in the run /// public override TextRunProperties Properties { get { return _textProps; } } ////// Line break condition before the inline object. /// public override LineBreakCondition BreakBefore { get { return LineBreakCondition.BreakDesired; } } ////// Line break condition after the inline object. /// public override LineBreakCondition BreakAfter { get { return LineBreakCondition.BreakDesired; } } ////// Flag indicates whether inline object has fixed size regardless of where /// it is placed within a line. /// public override bool HasFixedSize { get { // Size of inline object is not dependent on position in the line. return true; } } ////// Text position on the inline object in the text array. /// internal int Dcp { get { return _dcp; } } ////// UIElement representing the inline object. /// internal UIElement Element { get { return _element; } } ////// Text position on the inline object in the text array. /// private readonly int _dcp; ////// Number of text position in the text array occupied by the inline object. /// private readonly int _cch; ////// UIElement representing the inline object. /// private readonly UIElement _element; ////// Text run properties for the inline object. /// private readonly TextRunProperties _textProps; ////// Text element - the host of the inline object. /// private readonly System.Windows.Controls.TextBlock _host; } } // 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
- BuiltInPermissionSets.cs
- fixedPageContentExtractor.cs
- WindowsAuthenticationEventArgs.cs
- Button.cs
- EventProviderWriter.cs
- WindowsListView.cs
- CoreSwitches.cs
- BaseParser.cs
- SecurityContextSecurityToken.cs
- ExtentJoinTreeNode.cs
- EventLogPermissionAttribute.cs
- QilGenerator.cs
- SerializationException.cs
- HttpContextServiceHost.cs
- RegistrySecurity.cs
- CodeStatement.cs
- SelectedDatesCollection.cs
- SecurityChannel.cs
- ColorTransformHelper.cs
- WorkflowMarkupSerializerMapping.cs
- TCPClient.cs
- GridViewCellAutomationPeer.cs
- PartialTrustVisibleAssemblyCollection.cs
- DispatcherExceptionEventArgs.cs
- ProfileManager.cs
- UserControlBuildProvider.cs
- DataGridViewSelectedCellCollection.cs
- ConcurrentDictionary.cs
- HtmlInputSubmit.cs
- sqlpipe.cs
- BindingValueChangedEventArgs.cs
- DataTable.cs
- TaiwanLunisolarCalendar.cs
- DBAsyncResult.cs
- ValueChangedEventManager.cs
- DebugHandleTracker.cs
- COM2ExtendedBrowsingHandler.cs
- LongTypeConverter.cs
- RadioButtonList.cs
- DescendantBaseQuery.cs
- EntityKeyElement.cs
- ExternalCalls.cs
- ChannelDispatcherBase.cs
- KoreanCalendar.cs
- DATA_BLOB.cs
- PerspectiveCamera.cs
- ViewManager.cs
- OracleTransaction.cs
- PolyBezierSegmentFigureLogic.cs
- HandlerFactoryWrapper.cs
- MULTI_QI.cs
- TypeUtil.cs
- ControlBuilderAttribute.cs
- BoundPropertyEntry.cs
- DetailsViewPagerRow.cs
- RSAPKCS1SignatureFormatter.cs
- CodeExpressionStatement.cs
- RequestQueryProcessor.cs
- JsonEnumDataContract.cs
- DocumentsTrace.cs
- RotateTransform.cs
- GradientStopCollection.cs
- reliableinputsessionchannel.cs
- UInt16Converter.cs
- PersonalizationDictionary.cs
- DefinitionUpdate.cs
- ResXDataNode.cs
- TraceSource.cs
- TypeBuilderInstantiation.cs
- BevelBitmapEffect.cs
- RegisteredHiddenField.cs
- DBBindings.cs
- TableHeaderCell.cs
- HttpListenerRequest.cs
- FontFamily.cs
- PlaceHolder.cs
- XmlWrappingReader.cs
- MinMaxParagraphWidth.cs
- VariableElement.cs
- OdbcTransaction.cs
- MailSettingsSection.cs
- XmlDataSourceView.cs
- BoolExpressionVisitors.cs
- ActivityContext.cs
- SimpleRecyclingCache.cs
- RowBinding.cs
- UiaCoreTypesApi.cs
- PropertyItem.cs
- Psha1DerivedKeyGeneratorHelper.cs
- SelectionRange.cs
- StateItem.cs
- ServicesSection.cs
- FacetDescription.cs
- DataTableClearEvent.cs
- HwndSourceParameters.cs
- DataGridViewDataErrorEventArgs.cs
- CookieProtection.cs
- Executor.cs
- ThrowHelper.cs
- SecurityDocument.cs