Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- DefaultWorkflowLoaderService.cs
- XmlLoader.cs
- ConnectivityStatus.cs
- SystemResourceHost.cs
- JapaneseCalendar.cs
- DbDataRecord.cs
- NumberFormatter.cs
- EventProxy.cs
- FillBehavior.cs
- NativeMethods.cs
- KeyGesture.cs
- DeviceContexts.cs
- COAUTHINFO.cs
- TerminatingOperationBehavior.cs
- EntityDataSourceReferenceGroup.cs
- EventDescriptorCollection.cs
- XComponentModel.cs
- ColumnHeaderConverter.cs
- ReachNamespaceInfo.cs
- ConstructorNeedsTagAttribute.cs
- ArglessEventHandlerProxy.cs
- AbstractExpressions.cs
- CodeGenerator.cs
- FixedSOMContainer.cs
- ProbeDuplexCD1AsyncResult.cs
- DirectoryNotFoundException.cs
- Size.cs
- Scheduler.cs
- Substitution.cs
- objectquery_tresulttype.cs
- ScriptResourceHandler.cs
- AsyncInvokeContext.cs
- ProfileServiceManager.cs
- SimpleTypeResolver.cs
- SettingsPropertyWrongTypeException.cs
- FigureParagraph.cs
- WebEvents.cs
- TraceSwitch.cs
- QilName.cs
- MetaModel.cs
- SafeFreeMibTable.cs
- SingleStorage.cs
- CompModHelpers.cs
- DataGridViewLinkCell.cs
- XmlSchemaInfo.cs
- TreeNodeBindingCollection.cs
- ProfileModule.cs
- StylusCollection.cs
- TreeViewItemAutomationPeer.cs
- DynamicValidatorEventArgs.cs
- wmiprovider.cs
- BinaryParser.cs
- NumericUpDown.cs
- ConvertEvent.cs
- UIPropertyMetadata.cs
- XmlSchemaAttribute.cs
- BitmapEffectvisualstate.cs
- UrlPath.cs
- AtomEntry.cs
- TableChangeProcessor.cs
- EUCJPEncoding.cs
- PointUtil.cs
- safex509handles.cs
- CodeMethodInvokeExpression.cs
- DataFormat.cs
- BaseTemplateBuildProvider.cs
- IndicShape.cs
- GridItem.cs
- DataGridTable.cs
- TabControlAutomationPeer.cs
- DeviceContext.cs
- CompilerGlobalScopeAttribute.cs
- MultiSelector.cs
- TiffBitmapDecoder.cs
- XmlNamespaceManager.cs
- ProcessManager.cs
- WebPartUserCapability.cs
- ChangeTracker.cs
- DebuggerAttributes.cs
- TextTreeTextNode.cs
- SerializationTrace.cs
- SoapSchemaImporter.cs
- ContractDescription.cs
- FileUpload.cs
- ToolStripStatusLabel.cs
- CmsUtils.cs
- UnionExpr.cs
- InvokeHandlers.cs
- EntityDataSourceContainerNameItem.cs
- PerfCounters.cs
- DuplicateContext.cs
- UserMapPath.cs
- Annotation.cs
- XmlCharCheckingWriter.cs
- InternalSafeNativeMethods.cs
- EraserBehavior.cs
- SqlDataSource.cs
- _SecureChannel.cs
- TypeHelper.cs
- _NetRes.cs