Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / TextTreeExtractElementUndoUnit.cs / 1305600 / TextTreeExtractElementUndoUnit.cs
//---------------------------------------------------------------------------- // // File: TextTreeExtractElementUndoUnit.cs // // Description: Undo unit for TextContainer.ExtractElement calls. // // History: // 03/03/2004 : [....] - Created // //--------------------------------------------------------------------------- using System; using MS.Internal; namespace System.Windows.Documents { // Undo unit for TextContainer.ExtractElement calls. internal class TextTreeExtractElementUndoUnit : TextTreeUndoUnit { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors // Creates a new undo unit instance. internal TextTreeExtractElementUndoUnit(TextContainer tree, TextTreeTextElementNode elementNode) : base(tree, elementNode.GetSymbolOffset(tree.Generation)) { _symbolCount = elementNode.SymbolCount; _type = elementNode.TextElement.GetType(); _localValues = GetPropertyRecordArray(elementNode.TextElement); _resources = elementNode.TextElement.Resources; // Table requires additional work for storing its Columns collection if (elementNode.TextElement is Table) { _columns = TextTreeDeleteContentUndoUnit.SaveColumns((Table)elementNode.TextElement); } } #endregion Constructors //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods // Called by the undo manager. Restores tree state to its condition // when the unit was created. Assumes the tree state matches conditions // just after the unit was created. public override void DoCore() { TextPointer start; TextPointer end; TextElement element; VerifyTreeContentHashCode(); start = new TextPointer(this.TextContainer, this.SymbolOffset, LogicalDirection.Forward); end = new TextPointer(this.TextContainer, this.SymbolOffset + _symbolCount - 2, LogicalDirection.Forward); // Insert a new element. element = (TextElement)Activator.CreateInstance(_type); element.Reposition(start, end); // Restore local resources element.Resources = _resources; // Move end into the scope of the new element. end.MoveToNextContextPosition(LogicalDirection.Backward); // Then restore local property values. // this.TextContainer.SetValues(end, ArrayToLocalValueEnumerator(_localValues)); if (element is Table) { TextTreeDeleteContentUndoUnit.RestoreColumns((Table)element, _columns); } } #endregion Public Methods //------------------------------------------------------ // // Private Fields // //------------------------------------------------------ #region Private Fields // Count of symbols covered by the extracted TextElement, including its 2 edges. private readonly int _symbolCount; // Type of the extracted TextElement. private readonly Type _type; // Collection of all local property values set on the extracted TextElement. private readonly PropertyRecord []_localValues; // Resources defined locally on the TextElement private readonly ResourceDictionary _resources; // TableColumns collection private readonly TableColumn[] _columns; #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // File: TextTreeExtractElementUndoUnit.cs // // Description: Undo unit for TextContainer.ExtractElement calls. // // History: // 03/03/2004 : [....] - Created // //--------------------------------------------------------------------------- using System; using MS.Internal; namespace System.Windows.Documents { // Undo unit for TextContainer.ExtractElement calls. internal class TextTreeExtractElementUndoUnit : TextTreeUndoUnit { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors // Creates a new undo unit instance. internal TextTreeExtractElementUndoUnit(TextContainer tree, TextTreeTextElementNode elementNode) : base(tree, elementNode.GetSymbolOffset(tree.Generation)) { _symbolCount = elementNode.SymbolCount; _type = elementNode.TextElement.GetType(); _localValues = GetPropertyRecordArray(elementNode.TextElement); _resources = elementNode.TextElement.Resources; // Table requires additional work for storing its Columns collection if (elementNode.TextElement is Table) { _columns = TextTreeDeleteContentUndoUnit.SaveColumns((Table)elementNode.TextElement); } } #endregion Constructors //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods // Called by the undo manager. Restores tree state to its condition // when the unit was created. Assumes the tree state matches conditions // just after the unit was created. public override void DoCore() { TextPointer start; TextPointer end; TextElement element; VerifyTreeContentHashCode(); start = new TextPointer(this.TextContainer, this.SymbolOffset, LogicalDirection.Forward); end = new TextPointer(this.TextContainer, this.SymbolOffset + _symbolCount - 2, LogicalDirection.Forward); // Insert a new element. element = (TextElement)Activator.CreateInstance(_type); element.Reposition(start, end); // Restore local resources element.Resources = _resources; // Move end into the scope of the new element. end.MoveToNextContextPosition(LogicalDirection.Backward); // Then restore local property values. // this.TextContainer.SetValues(end, ArrayToLocalValueEnumerator(_localValues)); if (element is Table) { TextTreeDeleteContentUndoUnit.RestoreColumns((Table)element, _columns); } } #endregion Public Methods //------------------------------------------------------ // // Private Fields // //------------------------------------------------------ #region Private Fields // Count of symbols covered by the extracted TextElement, including its 2 edges. private readonly int _symbolCount; // Type of the extracted TextElement. private readonly Type _type; // Collection of all local property values set on the extracted TextElement. private readonly PropertyRecord []_localValues; // Resources defined locally on the TextElement private readonly ResourceDictionary _resources; // TableColumns collection private readonly TableColumn[] _columns; #endregion Private Fields } } // 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
- ScriptResourceInfo.cs
- DataGridView.cs
- FacetValueContainer.cs
- FacetValues.cs
- MediaScriptCommandRoutedEventArgs.cs
- CachedFontFamily.cs
- ExpanderAutomationPeer.cs
- ISCIIEncoding.cs
- PathSegmentCollection.cs
- HMACMD5.cs
- ExpandableObjectConverter.cs
- ErrorHandler.cs
- ValueUtilsSmi.cs
- ValidatorCollection.cs
- DataBoundControlHelper.cs
- Subtree.cs
- BrowserCapabilitiesFactoryBase.cs
- BackgroundFormatInfo.cs
- Style.cs
- DependencyPropertyDescriptor.cs
- Int16KeyFrameCollection.cs
- PropertyTabAttribute.cs
- MemberDescriptor.cs
- SymbolTable.cs
- PtsHelper.cs
- SqlBulkCopy.cs
- AssociatedControlConverter.cs
- COAUTHIDENTITY.cs
- TableLayoutPanelBehavior.cs
- DbDataSourceEnumerator.cs
- ToolStripTextBox.cs
- SelectionListDesigner.cs
- DynamicRouteExpression.cs
- LambdaCompiler.Address.cs
- Int64KeyFrameCollection.cs
- XMLSchema.cs
- ConfigXmlReader.cs
- ColorContext.cs
- RayMeshGeometry3DHitTestResult.cs
- DataGridViewMethods.cs
- QueryOperatorEnumerator.cs
- ClassDataContract.cs
- SessionStateModule.cs
- GeometryModel3D.cs
- SymmetricKeyWrap.cs
- RawStylusInput.cs
- ContentPlaceHolder.cs
- DataSourceView.cs
- BindingsCollection.cs
- Attribute.cs
- CultureMapper.cs
- SendActivityValidator.cs
- RegexCompiler.cs
- DataGridColumnsPage.cs
- DecimalStorage.cs
- WebConfigurationHost.cs
- ColorTransformHelper.cs
- ArgumentElement.cs
- ScriptDescriptor.cs
- QilStrConcatenator.cs
- FrugalMap.cs
- CqlLexer.cs
- Stylesheet.cs
- SqlNotificationRequest.cs
- EventLogEntryCollection.cs
- HtmlCalendarAdapter.cs
- FileAuthorizationModule.cs
- ProofTokenCryptoHandle.cs
- JsonWriter.cs
- Menu.cs
- ColumnMapVisitor.cs
- SafeLibraryHandle.cs
- SecurityTokenTypes.cs
- SynchronizationContext.cs
- SetMemberBinder.cs
- HttpCapabilitiesSectionHandler.cs
- SHA512Cng.cs
- DesignerCommandAdapter.cs
- AuthStoreRoleProvider.cs
- SqlConnectionPoolGroupProviderInfo.cs
- CompModSwitches.cs
- PageAsyncTaskManager.cs
- SectionInformation.cs
- VariableQuery.cs
- ButtonChrome.cs
- Hex.cs
- EncoderParameters.cs
- TiffBitmapDecoder.cs
- BamlBinaryWriter.cs
- Transform.cs
- Transform3DCollection.cs
- ADMembershipUser.cs
- EventBuilder.cs
- SQLConvert.cs
- ComponentChangingEvent.cs
- Vector3DKeyFrameCollection.cs
- HtmlShim.cs
- DiscoveryClientBindingElement.cs
- InvalidPrinterException.cs
- ResourceCodeDomSerializer.cs