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 / TextTreeExtractElementUndoUnit.cs / 1 / TextTreeExtractElementUndoUnit.cs
//---------------------------------------------------------------------------- // // File: TextTreeExtractElementUndoUnit.cs // // Description: Undo unit for TextContainer.ExtractElement calls. // // History: // 03/03/2004 : benwest - 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 = LocalValueEnumeratorToArray(elementNode.TextElement.GetLocalValueEnumerator()); _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 : benwest - 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 = LocalValueEnumeratorToArray(elementNode.TextElement.GetLocalValueEnumerator()); _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
- followingquery.cs
- KeySpline.cs
- WorkflowEventArgs.cs
- PerfProviderCollection.cs
- EmbossBitmapEffect.cs
- SerializationInfoEnumerator.cs
- DataPagerCommandEventArgs.cs
- SqlDataSourceCommandEventArgs.cs
- TextParagraphCache.cs
- Axis.cs
- RegistrationServices.cs
- MembershipValidatePasswordEventArgs.cs
- BridgeDataReader.cs
- XpsResourceDictionary.cs
- DiscreteKeyFrames.cs
- UnsafeNativeMethods.cs
- ColorConverter.cs
- BoundField.cs
- Brushes.cs
- CollectionEditor.cs
- StateWorkerRequest.cs
- HttpCapabilitiesEvaluator.cs
- CatalogZoneDesigner.cs
- ArithmeticLiteral.cs
- CodeChecksumPragma.cs
- StaticTextPointer.cs
- WebScriptClientGenerator.cs
- ArrayConverter.cs
- ZipIOLocalFileBlock.cs
- ToolStripPanelRow.cs
- WebControlsSection.cs
- RangeBaseAutomationPeer.cs
- FillBehavior.cs
- DocumentXmlWriter.cs
- DbConnectionPool.cs
- DeferredReference.cs
- RowTypePropertyElement.cs
- XamlVector3DCollectionSerializer.cs
- XPathNavigatorKeyComparer.cs
- StyleTypedPropertyAttribute.cs
- ChannelTraceRecord.cs
- InputMethod.cs
- BinaryWriter.cs
- XmlSchemaCollection.cs
- CroppedBitmap.cs
- OrderedDictionary.cs
- MouseOverProperty.cs
- DataView.cs
- TraceFilter.cs
- SqlWriter.cs
- OleDbSchemaGuid.cs
- AddInAttribute.cs
- Events.cs
- ControlValuePropertyAttribute.cs
- DeferredSelectedIndexReference.cs
- HttpDictionary.cs
- SoapMessage.cs
- TitleStyle.cs
- ManagementOperationWatcher.cs
- ContourSegment.cs
- Header.cs
- MenuAdapter.cs
- Rectangle.cs
- EventProxy.cs
- HyperLinkStyle.cs
- Normalization.cs
- ManagedWndProcTracker.cs
- LinqDataSourceUpdateEventArgs.cs
- NameValueSectionHandler.cs
- ArrayElementGridEntry.cs
- _NegotiateClient.cs
- XamlSerializer.cs
- DictionaryGlobals.cs
- NativeMethods.cs
- SortKey.cs
- EmptyStringExpandableObjectConverter.cs
- OleDbPropertySetGuid.cs
- AssemblyFilter.cs
- ReadOnlyHierarchicalDataSourceView.cs
- DataGridCommandEventArgs.cs
- OrderByQueryOptionExpression.cs
- FtpWebResponse.cs
- LinkGrep.cs
- StrongNameMembershipCondition.cs
- sitestring.cs
- Header.cs
- SqlDataSourceCache.cs
- Point4D.cs
- ValueTypeFixupInfo.cs
- ImageListImageEditor.cs
- HostedHttpContext.cs
- OleDbParameterCollection.cs
- DocumentPageHost.cs
- DependencyProperty.cs
- ToolStripOverflow.cs
- CompositeClientFormatter.cs
- WebPartHelpVerb.cs
- SqlStream.cs
- MatcherBuilder.cs
- InheritanceUI.cs