Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / System / Windows / Documents / TextTreeInsertElementUndoUnit.cs / 1 / TextTreeInsertElementUndoUnit.cs
//----------------------------------------------------------------------------
//
// File: TextTreeInsertElementUndoUnit.cs
//
// Description: Undo unit for TextContainer.InsertElement calls.
//
// History:
// 03/03/2004 : [....] - Created
//
//---------------------------------------------------------------------------
using System;
using MS.Internal;
namespace System.Windows.Documents
{
// Undo unit for TextContainer.InsertElement calls.
internal class TextTreeInsertElementUndoUnit : TextTreeUndoUnit
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
// Creates a new undo unit instance.
// symbolOffset should be just before the start edge of the TextElement to remove.
// If deep is true, this unit will undo not only the scoping element
// insert, but also all content scoped by the element.
internal TextTreeInsertElementUndoUnit(TextContainer tree, int symbolOffset, bool deep) : base(tree, symbolOffset)
{
_deep = deep;
}
#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);
Invariant.Assert(start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart, "TextTree undo unit out of sync with TextTree.");
element = start.GetAdjacentElementFromOuterPosition(LogicalDirection.Forward);
if (_deep)
{
// Extract the element and its content.
end = new TextPointer(this.TextContainer, element.TextElementNode, ElementEdge.AfterEnd);
this.TextContainer.DeleteContentInternal(start, end);
}
else
{
// Just extract the element, not its content.
this.TextContainer.ExtractElementInternal(element);
}
}
#endregion Public Methods
//------------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
// If true, this unit tracks a TextElement and its scoped content.
// Otherwise, this unit only tracks the TextElement.
private readonly bool _deep;
#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
- TreeViewItem.cs
- ToolStripProgressBar.cs
- MaskDescriptors.cs
- DataServiceRequestOfT.cs
- CookieProtection.cs
- IncrementalHitTester.cs
- UiaCoreApi.cs
- XPathChildIterator.cs
- ContentDisposition.cs
- ItemMap.cs
- AnnotationHelper.cs
- ExpiredSecurityTokenException.cs
- ScriptComponentDescriptor.cs
- Int16Storage.cs
- ColumnMapCopier.cs
- XmlHierarchicalDataSourceView.cs
- CellParagraph.cs
- FocusWithinProperty.cs
- OleDbReferenceCollection.cs
- DbXmlEnabledProviderManifest.cs
- XamlVector3DCollectionSerializer.cs
- PropertySourceInfo.cs
- SessionEndingCancelEventArgs.cs
- SqlServer2KCompatibilityCheck.cs
- XmlSerializerVersionAttribute.cs
- ItemChangedEventArgs.cs
- OpenTypeLayoutCache.cs
- PeerToPeerException.cs
- RemoteEndpointMessageProperty.cs
- StructuredProperty.cs
- Stack.cs
- TdsRecordBufferSetter.cs
- XmlSchemaSimpleContent.cs
- DuplicateWaitObjectException.cs
- BookmarkInfo.cs
- UInt32Storage.cs
- Assert.cs
- PhysicalAddress.cs
- HandlerBase.cs
- Renderer.cs
- TimeEnumHelper.cs
- TcpHostedTransportConfiguration.cs
- Reference.cs
- AnnouncementEndpoint.cs
- KeyValueConfigurationElement.cs
- RoutedUICommand.cs
- UriTemplatePathSegment.cs
- Pen.cs
- FontNamesConverter.cs
- WindowAutomationPeer.cs
- CounterCreationDataCollection.cs
- PersonalizationDictionary.cs
- DictionarySurrogate.cs
- WebPartVerbCollection.cs
- SectionXmlInfo.cs
- AppDomain.cs
- FormCollection.cs
- DbFunctionCommandTree.cs
- KeySpline.cs
- CodeBlockBuilder.cs
- Workspace.cs
- WebBrowserNavigatedEventHandler.cs
- InstanceData.cs
- CookielessHelper.cs
- XmlDataSourceNodeDescriptor.cs
- BaseCollection.cs
- StateMachineExecutionState.cs
- NativeObjectSecurity.cs
- Function.cs
- WebServiceParameterData.cs
- Crc32Helper.cs
- SafeFileMappingHandle.cs
- BindingCollection.cs
- NavigationExpr.cs
- BaseTemplateParser.cs
- PrimitiveType.cs
- BatchServiceHost.cs
- cookie.cs
- DesignTimeTemplateParser.cs
- ResourceDisplayNameAttribute.cs
- DataGridViewCellValueEventArgs.cs
- HtmlLink.cs
- FixedSOMPage.cs
- NamedObject.cs
- TreeNodeStyleCollection.cs
- MulticastDelegate.cs
- HitTestWithGeometryDrawingContextWalker.cs
- XslVisitor.cs
- GradientStop.cs
- SelectionEditingBehavior.cs
- ToolStripContentPanelRenderEventArgs.cs
- DataGridViewRowConverter.cs
- NameSpaceEvent.cs
- DatePicker.cs
- HitTestResult.cs
- DesignerView.xaml.cs
- HatchBrush.cs
- TraceData.cs
- FixedSOMLineCollection.cs
- MaterialCollection.cs