Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / Documents / Run.cs / 1 / Run.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // // Description: Run class - Text node in Flow content (text run) // //--------------------------------------------------------------------------- using MS.Internal; // Invariant.Assert using System.Windows.Markup; // ContentProperty namespace System.Windows.Documents { ////// A terminal element in text flow hierarchy - contains a uniformatted run of unicode characters /// [ContentProperty("Text")] public class Run : Inline { //------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors ////// Initializes an instance of Run class. /// public Run() { } ////// Initializes an instance of Run class specifying its text content. /// /// /// Text content assigned to the Run. /// public Run(string text) : this(text, null) { } ////// Creates a new Run instance. /// /// /// Optional text content. May be null. /// /// /// Optional position at which to insert the new Run. May /// be null. /// public Run(string text, TextPointer insertionPosition) { if (insertionPosition != null) { insertionPosition.TextContainer.BeginChange(); } try { if (insertionPosition != null) { // This will throw InvalidOperationException if schema validity is violated. insertionPosition.InsertInline(this); } if (text != null) { // Do not use Text property as it has perf impact on parser. this.ContentStart.InsertTextInRun(text); } } finally { if (insertionPosition != null) { insertionPosition.TextContainer.EndChange(); } } } #endregion Constructors //-------------------------------------------------------------------- // // Public Properties // //------------------------------------------------------------------- #region Public Properties ////// The content spanned by this TextElement. /// public string Text { get { return TextRangeBase.GetTextInternal(this.ContentStart, this.ContentEnd); } set { if (value == null) { value = String.Empty; } TextContainer textContainer = this.TextContainer; textContainer.BeginChange(); try { TextPointer contentStart = this.ContentStart; if (!this.IsEmpty) { textContainer.DeleteContentInternal(contentStart, this.ContentEnd); } contentStart.InsertTextInRun(value); } finally { textContainer.EndChange(); } } } #endregion Public Properties //-------------------------------------------------------------------- // // Internal Methods // //-------------------------------------------------------------------- #region Internal Methods // // This property // 1. Finds the correct initial size for the _effectiveValues store on the current DependencyObject // 2. This is a performance optimization // internal override int EffectiveValuesInitialSize { get { return 13; } } ////// This method is used by TypeDescriptor to determine if this property should /// be serialized. /// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] public bool ShouldSerializeText(XamlDesignerSerializationManager manager) { return manager != null && manager.XmlWriter == null; } #endregion Internal Methods } } // 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. // // Description: Run class - Text node in Flow content (text run) // //--------------------------------------------------------------------------- using MS.Internal; // Invariant.Assert using System.Windows.Markup; // ContentProperty namespace System.Windows.Documents { ////// A terminal element in text flow hierarchy - contains a uniformatted run of unicode characters /// [ContentProperty("Text")] public class Run : Inline { //------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors ////// Initializes an instance of Run class. /// public Run() { } ////// Initializes an instance of Run class specifying its text content. /// /// /// Text content assigned to the Run. /// public Run(string text) : this(text, null) { } ////// Creates a new Run instance. /// /// /// Optional text content. May be null. /// /// /// Optional position at which to insert the new Run. May /// be null. /// public Run(string text, TextPointer insertionPosition) { if (insertionPosition != null) { insertionPosition.TextContainer.BeginChange(); } try { if (insertionPosition != null) { // This will throw InvalidOperationException if schema validity is violated. insertionPosition.InsertInline(this); } if (text != null) { // Do not use Text property as it has perf impact on parser. this.ContentStart.InsertTextInRun(text); } } finally { if (insertionPosition != null) { insertionPosition.TextContainer.EndChange(); } } } #endregion Constructors //-------------------------------------------------------------------- // // Public Properties // //------------------------------------------------------------------- #region Public Properties ////// The content spanned by this TextElement. /// public string Text { get { return TextRangeBase.GetTextInternal(this.ContentStart, this.ContentEnd); } set { if (value == null) { value = String.Empty; } TextContainer textContainer = this.TextContainer; textContainer.BeginChange(); try { TextPointer contentStart = this.ContentStart; if (!this.IsEmpty) { textContainer.DeleteContentInternal(contentStart, this.ContentEnd); } contentStart.InsertTextInRun(value); } finally { textContainer.EndChange(); } } } #endregion Public Properties //-------------------------------------------------------------------- // // Internal Methods // //-------------------------------------------------------------------- #region Internal Methods // // This property // 1. Finds the correct initial size for the _effectiveValues store on the current DependencyObject // 2. This is a performance optimization // internal override int EffectiveValuesInitialSize { get { return 13; } } ////// This method is used by TypeDescriptor to determine if this property should /// be serialized. /// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] public bool ShouldSerializeText(XamlDesignerSerializationManager manager) { return manager != null && manager.XmlWriter == null; } #endregion Internal Methods } } // 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
- PropertyPathConverter.cs
- SharedUtils.cs
- RoleManagerSection.cs
- MouseActionValueSerializer.cs
- PathSegment.cs
- SmtpMail.cs
- _NegotiateClient.cs
- OpenTypeLayout.cs
- TokenBasedSetEnumerator.cs
- EntitySet.cs
- DetailsViewModeEventArgs.cs
- DesignerForm.cs
- FilteredDataSetHelper.cs
- Inline.cs
- shaper.cs
- MessageQueueKey.cs
- XmlBindingWorker.cs
- ErrorsHelper.cs
- ConfigurationManager.cs
- UniqueIdentifierService.cs
- DriveNotFoundException.cs
- RawStylusInputReport.cs
- SQLStringStorage.cs
- glyphs.cs
- CodeValidator.cs
- Vector3DAnimationBase.cs
- TypeInitializationException.cs
- Publisher.cs
- TextFindEngine.cs
- WebPartZoneCollection.cs
- CompositeDataBoundControl.cs
- SqlDataSourceCommandEventArgs.cs
- NotImplementedException.cs
- NamespaceCollection.cs
- StrongNamePublicKeyBlob.cs
- DbConnectionPoolCounters.cs
- LinkedList.cs
- HttpResponseHeader.cs
- EntityDataSourceDataSelectionPanel.cs
- ConfigurationLocationCollection.cs
- FigureParagraph.cs
- Vector3DIndependentAnimationStorage.cs
- XmlParserContext.cs
- GraphicsPathIterator.cs
- DataServiceKeyAttribute.cs
- AutomationElementCollection.cs
- Setter.cs
- DispatcherExceptionFilterEventArgs.cs
- BoundingRectTracker.cs
- XMLSyntaxException.cs
- ObjectDataSourceMethodEventArgs.cs
- PenThread.cs
- BitmapCodecInfoInternal.cs
- HtmlForm.cs
- HtmlElementEventArgs.cs
- Simplifier.cs
- PageThemeParser.cs
- PropertyPushdownHelper.cs
- StringValueSerializer.cs
- ErrorLog.cs
- TransformedBitmap.cs
- SafeBitVector32.cs
- DataRelation.cs
- SerializationException.cs
- EntityDataSourceChangingEventArgs.cs
- PersonalizationStateInfo.cs
- ScrollBar.cs
- FrameworkReadOnlyPropertyMetadata.cs
- SerialStream.cs
- SamlConstants.cs
- TreeViewImageKeyConverter.cs
- ColumnResizeUndoUnit.cs
- _AutoWebProxyScriptEngine.cs
- Events.cs
- FacetDescriptionElement.cs
- EncoderNLS.cs
- TrackingProfileSerializer.cs
- SubclassTypeValidator.cs
- HtmlTableCellCollection.cs
- DbDataSourceEnumerator.cs
- StrokeRenderer.cs
- PasswordRecovery.cs
- UnmanagedMarshal.cs
- ObjectItemCollection.cs
- ChangePassword.cs
- WizardSideBarListControlItemEventArgs.cs
- NavigationPropertyEmitter.cs
- ParameterToken.cs
- ButtonStandardAdapter.cs
- ConnectionManagementSection.cs
- RelationshipConverter.cs
- SystemIPAddressInformation.cs
- _SslState.cs
- ThousandthOfEmRealDoubles.cs
- Interfaces.cs
- DataDesignUtil.cs
- _LocalDataStoreMgr.cs
- TextEndOfParagraph.cs
- SerialStream.cs
- TransformedBitmap.cs