Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- TransportChannelListener.cs
- OdbcEnvironment.cs
- CapiSymmetricAlgorithm.cs
- XPathAncestorIterator.cs
- DrawingDrawingContext.cs
- UrlPath.cs
- CodeAttributeArgument.cs
- WebServiceParameterData.cs
- ElementsClipboardData.cs
- DataGridViewCellStateChangedEventArgs.cs
- HeaderedItemsControl.cs
- PinnedBufferMemoryStream.cs
- OleDbDataAdapter.cs
- CustomErrorsSection.cs
- XmlUtf8RawTextWriter.cs
- PageParserFilter.cs
- FloaterBaseParaClient.cs
- DeviceSpecificChoiceCollection.cs
- ToolStripDropDownClosedEventArgs.cs
- Quaternion.cs
- TemplateXamlParser.cs
- UnionCodeGroup.cs
- Nullable.cs
- UdpTransportBindingElement.cs
- arclist.cs
- SerializerProvider.cs
- GridViewItemAutomationPeer.cs
- WindowsFormsSectionHandler.cs
- QuadraticBezierSegment.cs
- StoreAnnotationsMap.cs
- DynamicILGenerator.cs
- Border.cs
- SafeUserTokenHandle.cs
- HttpApplicationFactory.cs
- PnrpPeerResolverBindingElement.cs
- sortedlist.cs
- CheckPair.cs
- IteratorFilter.cs
- Util.cs
- AssemblyCacheEntry.cs
- DomNameTable.cs
- ModelVisual3D.cs
- PropertyValueChangedEvent.cs
- PrePrepareMethodAttribute.cs
- cache.cs
- ForeignConstraint.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- DataListCommandEventArgs.cs
- SQLSingleStorage.cs
- Button.cs
- OrderByExpression.cs
- XmlSchemaInclude.cs
- SByteStorage.cs
- CompositeScriptReferenceEventArgs.cs
- Literal.cs
- ReferenceConverter.cs
- WebBrowsableAttribute.cs
- SerializableTypeCodeDomSerializer.cs
- DeviceContext2.cs
- DataSourceBooleanViewSchemaConverter.cs
- InputBuffer.cs
- CodeMemberProperty.cs
- DataSetSchema.cs
- TextBoxView.cs
- RecordsAffectedEventArgs.cs
- SpellerInterop.cs
- DataSourceHelper.cs
- MetadataArtifactLoaderCompositeFile.cs
- DocumentXmlWriter.cs
- SqlCharStream.cs
- ImplicitInputBrush.cs
- OleDbPropertySetGuid.cs
- DataContractSerializer.cs
- TextRunCacheImp.cs
- FileSystemInfo.cs
- Invariant.cs
- COM2ColorConverter.cs
- GenericWebPart.cs
- BindableAttribute.cs
- ArcSegment.cs
- SqlConnectionPoolGroupProviderInfo.cs
- ListViewGroupConverter.cs
- ServiceNotStartedException.cs
- MultipleViewPattern.cs
- ClaimComparer.cs
- InstanceNormalEvent.cs
- HitTestWithPointDrawingContextWalker.cs
- GridViewPageEventArgs.cs
- TransformPattern.cs
- RandomNumberGenerator.cs
- Schema.cs
- DispatchChannelSink.cs
- SynchronizedDisposablePool.cs
- HwndSource.cs
- Transform3DGroup.cs
- CompletionCallbackWrapper.cs
- GPRECTF.cs
- ImageListUtils.cs
- RectKeyFrameCollection.cs
- LambdaCompiler.Address.cs