Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / InlineUIContainer.cs / 1305600 / InlineUIContainer.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // // Description: InlineUIContainer - a wrapper for embedded UIElements in text // flow content inline collections // //--------------------------------------------------------------------------- using System.ComponentModel; // DesignerSerializationVisibility using System.Windows.Markup; // XamlDesignerSerializationManager using MS.Internal; using MS.Internal.Documents; namespace System.Windows.Documents { ////// InlineUIContainer - a wrapper for embedded UIElements in text /// flow content inline collections /// [ContentProperty("Child")] [TextElementEditingBehaviorAttribute(IsMergeable = false)] public class InlineUIContainer : Inline { //------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors ////// Initializes a new instance of InlineUIContainer element. /// ////// The purpose of this element is to be a wrapper for UIElements /// when they are embedded into text flow - as items of /// InlineCollections. /// public InlineUIContainer() { } ////// Initializes an InlineBox specifying its child UIElement /// /// /// UIElement set as a child of this inline item /// public InlineUIContainer(UIElement childUIElement) : this(childUIElement, null) { } ////// Creates a new InlineUIContainer instance. /// /// /// Optional child of the new InlineUIContainer, may be null. /// /// /// Optional position at which to insert the new InlineUIContainer. May /// be null. /// public InlineUIContainer(UIElement childUIElement, TextPointer insertionPosition) { if (insertionPosition != null) { insertionPosition.TextContainer.BeginChange(); } try { if (insertionPosition != null) { // This will throw InvalidOperationException if schema validity is violated. insertionPosition.InsertInline(this); } this.Child = childUIElement; } finally { if (insertionPosition != null) { insertionPosition.TextContainer.EndChange(); } } } #endregion Constructors //-------------------------------------------------------------------- // // Public Properties // //------------------------------------------------------------------- #region Public Properties ////// The content spanned by this TextElement. /// public UIElement Child { get { return this.ContentStart.GetAdjacentElement(LogicalDirection.Forward) as UIElement; } set { TextContainer textContainer = this.TextContainer; textContainer.BeginChange(); try { TextPointer contentStart = this.ContentStart; UIElement child = Child; if (child != null) { textContainer.DeleteContentInternal(contentStart, this.ContentEnd); ContainerTextElementField.ClearValue(child); } if (value != null) { ContainerTextElementField.SetValue(value, this); contentStart.InsertUIElement(value); } } finally { textContainer.EndChange(); } } } #endregion Public Properties #region Internal Properties ////// UIElementIsland representing embedded Element Layout island within content world. /// internal UIElementIsland UIElementIsland { get { UpdateUIElementIsland(); return _uiElementIsland; } } #endregion Internal Properties #region Private Methods ////// Ensures the _uiElementIsland variable is up to date /// private void UpdateUIElementIsland() { UIElement childElement = this.Child; if(_uiElementIsland == null || _uiElementIsland.Root != childElement) { if(_uiElementIsland != null) { _uiElementIsland.Dispose(); _uiElementIsland = null; } if(childElement != null) { _uiElementIsland = new UIElementIsland(childElement); } } } #endregion Private Methods #region Private Data private UIElementIsland _uiElementIsland; #endregion Private Data } } // 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: InlineUIContainer - a wrapper for embedded UIElements in text // flow content inline collections // //--------------------------------------------------------------------------- using System.ComponentModel; // DesignerSerializationVisibility using System.Windows.Markup; // XamlDesignerSerializationManager using MS.Internal; using MS.Internal.Documents; namespace System.Windows.Documents { ////// InlineUIContainer - a wrapper for embedded UIElements in text /// flow content inline collections /// [ContentProperty("Child")] [TextElementEditingBehaviorAttribute(IsMergeable = false)] public class InlineUIContainer : Inline { //------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors ////// Initializes a new instance of InlineUIContainer element. /// ////// The purpose of this element is to be a wrapper for UIElements /// when they are embedded into text flow - as items of /// InlineCollections. /// public InlineUIContainer() { } ////// Initializes an InlineBox specifying its child UIElement /// /// /// UIElement set as a child of this inline item /// public InlineUIContainer(UIElement childUIElement) : this(childUIElement, null) { } ////// Creates a new InlineUIContainer instance. /// /// /// Optional child of the new InlineUIContainer, may be null. /// /// /// Optional position at which to insert the new InlineUIContainer. May /// be null. /// public InlineUIContainer(UIElement childUIElement, TextPointer insertionPosition) { if (insertionPosition != null) { insertionPosition.TextContainer.BeginChange(); } try { if (insertionPosition != null) { // This will throw InvalidOperationException if schema validity is violated. insertionPosition.InsertInline(this); } this.Child = childUIElement; } finally { if (insertionPosition != null) { insertionPosition.TextContainer.EndChange(); } } } #endregion Constructors //-------------------------------------------------------------------- // // Public Properties // //------------------------------------------------------------------- #region Public Properties ////// The content spanned by this TextElement. /// public UIElement Child { get { return this.ContentStart.GetAdjacentElement(LogicalDirection.Forward) as UIElement; } set { TextContainer textContainer = this.TextContainer; textContainer.BeginChange(); try { TextPointer contentStart = this.ContentStart; UIElement child = Child; if (child != null) { textContainer.DeleteContentInternal(contentStart, this.ContentEnd); ContainerTextElementField.ClearValue(child); } if (value != null) { ContainerTextElementField.SetValue(value, this); contentStart.InsertUIElement(value); } } finally { textContainer.EndChange(); } } } #endregion Public Properties #region Internal Properties ////// UIElementIsland representing embedded Element Layout island within content world. /// internal UIElementIsland UIElementIsland { get { UpdateUIElementIsland(); return _uiElementIsland; } } #endregion Internal Properties #region Private Methods ////// Ensures the _uiElementIsland variable is up to date /// private void UpdateUIElementIsland() { UIElement childElement = this.Child; if(_uiElementIsland == null || _uiElementIsland.Root != childElement) { if(_uiElementIsland != null) { _uiElementIsland.Dispose(); _uiElementIsland = null; } if(childElement != null) { _uiElementIsland = new UIElementIsland(childElement); } } } #endregion Private Methods #region Private Data private UIElementIsland _uiElementIsland; #endregion Private Data } } // 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
- TCPListener.cs
- AssemblyCache.cs
- AsyncSerializedWorker.cs
- LayoutManager.cs
- LoginUtil.cs
- IdentityNotMappedException.cs
- xsdvalidator.cs
- QueryIntervalOp.cs
- DurableEnlistmentState.cs
- PermissionSetEnumerator.cs
- HttpClientCertificate.cs
- HttpRequest.cs
- Panel.cs
- APCustomTypeDescriptor.cs
- NetStream.cs
- WebResourceAttribute.cs
- RawMouseInputReport.cs
- DocumentReferenceCollection.cs
- DataGridViewTextBoxCell.cs
- FlagsAttribute.cs
- QilVisitor.cs
- RadioButton.cs
- OleDbDataReader.cs
- FlagsAttribute.cs
- IpcClientManager.cs
- VisualStyleElement.cs
- NumericExpr.cs
- TypeElementCollection.cs
- ReadOnlyHierarchicalDataSource.cs
- CapabilitiesUse.cs
- XmlAttribute.cs
- sqlpipe.cs
- UiaCoreTypesApi.cs
- DependencyObject.cs
- WebBrowserUriTypeConverter.cs
- TextTreeTextElementNode.cs
- QilStrConcat.cs
- SynchronizedDispatch.cs
- StructuredTypeEmitter.cs
- DataException.cs
- StringValueConverter.cs
- Coordinator.cs
- SamlSecurityTokenAuthenticator.cs
- UrlAuthFailedErrorFormatter.cs
- FontNamesConverter.cs
- PipeStream.cs
- Size3DConverter.cs
- TextTreeUndoUnit.cs
- WebBaseEventKeyComparer.cs
- SupportingTokenProviderSpecification.cs
- SettingsPropertyWrongTypeException.cs
- TextChangedEventArgs.cs
- ScrollProviderWrapper.cs
- sqlser.cs
- ObjectListField.cs
- Activator.cs
- SpecularMaterial.cs
- LocalizabilityAttribute.cs
- SqlCrossApplyToCrossJoin.cs
- SettingsBindableAttribute.cs
- SQLResource.cs
- CellTreeNodeVisitors.cs
- Encoder.cs
- DescendantQuery.cs
- WindowsListBox.cs
- KeyPressEvent.cs
- DataServiceRequest.cs
- SoapProcessingBehavior.cs
- UIElementParaClient.cs
- TableLayoutRowStyleCollection.cs
- FieldTemplateFactory.cs
- DependencyProperty.cs
- EntityDataSourceSelectedEventArgs.cs
- CodeCompiler.cs
- ContractUtils.cs
- CodeValidator.cs
- WindowsTokenRoleProvider.cs
- DispatcherExceptionEventArgs.cs
- NullEntityWrapper.cs
- FormsAuthenticationConfiguration.cs
- processwaithandle.cs
- RuntimeConfigurationRecord.cs
- SqlRowUpdatingEvent.cs
- URI.cs
- WinFormsSpinner.cs
- StackOverflowException.cs
- ISAPIRuntime.cs
- UncommonField.cs
- XmlSchemaComplexContentRestriction.cs
- HttpResponse.cs
- DragStartedEventArgs.cs
- DebugInfoGenerator.cs
- StateBag.cs
- ControlBuilderAttribute.cs
- GridViewColumnHeader.cs
- X509Certificate2Collection.cs
- DispatcherProcessingDisabled.cs
- Form.cs
- ScalarOps.cs
- DataContractSerializerOperationFormatter.cs