Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / Documents / ChangeBlockUndoRecord.cs / 1 / ChangeBlockUndoRecord.cs
//---------------------------------------------------------------------------- // // File: ChangeBlockUndoRecord.cs // // Description: Undo wrapper for any edit on or through a TextRange or // TextContainer. // //--------------------------------------------------------------------------- using System; using System.Windows; using MS.Internal; using MS.Internal.Documents; namespace System.Windows.Documents { // Undo wrapper for any edit on or through a TextRange or TextContainer. internal class ChangeBlockUndoRecord { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors // Constructor, called when a change block is opening. internal ChangeBlockUndoRecord(ITextContainer textContainer, string actionDescription) { if (textContainer.UndoManager != null) { _undoManager = textContainer.UndoManager; if (_undoManager.IsEnabled) { // Don't bother opening an undo unit if the owning control is // still being initialized (ie, programmatic load by parser). if (textContainer.TextView != null) { // Don't bother opening a new undo unit if we're already nested // inside another. if (_undoManager.OpenedUnit == null) { if (textContainer.TextSelection != null) { _parentUndoUnit = new TextParentUndoUnit(textContainer.TextSelection); } else { _parentUndoUnit = new ParentUndoUnit(actionDescription); } _undoManager.Open(_parentUndoUnit); } } else { // If the owning control isn't initialized (parser is still running), // don't add anything to the undo record. Instead, clear it. _undoManager.Clear(); } } } } #endregion Constructors //------------------------------------------------------ // // Internal Methods // //----------------------------------------------------- #region Internal Methods // Called when a change block is closing. internal void OnEndChange() { // Commit our undo unit. if (_parentUndoUnit != null) { IParentUndoUnit openedUnit; if (_parentUndoUnit.Container is UndoManager) { openedUnit = ((UndoManager)_parentUndoUnit.Container).OpenedUnit; } else { openedUnit = ((IParentUndoUnit)_parentUndoUnit.Container).OpenedUnit; } // UIElementPropertyUndoUnit can clear the undo stack if a change is made to a databound property if (openedUnit == _parentUndoUnit) { if (_parentUndoUnit is TextParentUndoUnit) { ((TextParentUndoUnit)_parentUndoUnit).RecordRedoSelectionState(); } Invariant.Assert(_undoManager != null); _undoManager.Close(_parentUndoUnit, (_parentUndoUnit.LastUnit != null) ? UndoCloseAction.Commit : UndoCloseAction.Discard); } } } #endregion Internal Methods //------------------------------------------------------ // // Private Fields // //------------------------------------------------------ #region Private Fields private readonly UndoManager _undoManager; private readonly IParentUndoUnit _parentUndoUnit; #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // File: ChangeBlockUndoRecord.cs // // Description: Undo wrapper for any edit on or through a TextRange or // TextContainer. // //--------------------------------------------------------------------------- using System; using System.Windows; using MS.Internal; using MS.Internal.Documents; namespace System.Windows.Documents { // Undo wrapper for any edit on or through a TextRange or TextContainer. internal class ChangeBlockUndoRecord { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors // Constructor, called when a change block is opening. internal ChangeBlockUndoRecord(ITextContainer textContainer, string actionDescription) { if (textContainer.UndoManager != null) { _undoManager = textContainer.UndoManager; if (_undoManager.IsEnabled) { // Don't bother opening an undo unit if the owning control is // still being initialized (ie, programmatic load by parser). if (textContainer.TextView != null) { // Don't bother opening a new undo unit if we're already nested // inside another. if (_undoManager.OpenedUnit == null) { if (textContainer.TextSelection != null) { _parentUndoUnit = new TextParentUndoUnit(textContainer.TextSelection); } else { _parentUndoUnit = new ParentUndoUnit(actionDescription); } _undoManager.Open(_parentUndoUnit); } } else { // If the owning control isn't initialized (parser is still running), // don't add anything to the undo record. Instead, clear it. _undoManager.Clear(); } } } } #endregion Constructors //------------------------------------------------------ // // Internal Methods // //----------------------------------------------------- #region Internal Methods // Called when a change block is closing. internal void OnEndChange() { // Commit our undo unit. if (_parentUndoUnit != null) { IParentUndoUnit openedUnit; if (_parentUndoUnit.Container is UndoManager) { openedUnit = ((UndoManager)_parentUndoUnit.Container).OpenedUnit; } else { openedUnit = ((IParentUndoUnit)_parentUndoUnit.Container).OpenedUnit; } // UIElementPropertyUndoUnit can clear the undo stack if a change is made to a databound property if (openedUnit == _parentUndoUnit) { if (_parentUndoUnit is TextParentUndoUnit) { ((TextParentUndoUnit)_parentUndoUnit).RecordRedoSelectionState(); } Invariant.Assert(_undoManager != null); _undoManager.Close(_parentUndoUnit, (_parentUndoUnit.LastUnit != null) ? UndoCloseAction.Commit : UndoCloseAction.Discard); } } } #endregion Internal Methods //------------------------------------------------------ // // Private Fields // //------------------------------------------------------ #region Private Fields private readonly UndoManager _undoManager; private readonly IParentUndoUnit _parentUndoUnit; #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
- NetSectionGroup.cs
- OleAutBinder.cs
- Knowncolors.cs
- XmlCharType.cs
- StyleBamlRecordReader.cs
- DtdParser.cs
- TextCompositionEventArgs.cs
- RadioButtonStandardAdapter.cs
- odbcmetadatacolumnnames.cs
- XPathSelectionIterator.cs
- TerminatorSinks.cs
- SecurityAlgorithmSuite.cs
- XmlParser.cs
- RecordsAffectedEventArgs.cs
- GradientSpreadMethodValidation.cs
- StringComparer.cs
- TimestampInformation.cs
- ControlEvent.cs
- CodeTypeReference.cs
- oledbmetadatacollectionnames.cs
- TimeSpanMinutesConverter.cs
- PerspectiveCamera.cs
- WebPartCollection.cs
- XamlTypeMapperSchemaContext.cs
- RouteItem.cs
- FileChangesMonitor.cs
- QueuePathDialog.cs
- OleAutBinder.cs
- XmlChoiceIdentifierAttribute.cs
- BadImageFormatException.cs
- AccessViolationException.cs
- StringSorter.cs
- ContainerParaClient.cs
- webclient.cs
- WebControl.cs
- COMException.cs
- DataGridPagerStyle.cs
- PersonalizationProviderCollection.cs
- RegionIterator.cs
- ClientEventManager.cs
- CertificateManager.cs
- RemotingAttributes.cs
- EditorPartCollection.cs
- SiteMapSection.cs
- PointAnimation.cs
- ApplicationActivator.cs
- DotNetATv1WindowsLogEntryDeserializer.cs
- LinqDataSourceHelper.cs
- ModelItemDictionaryImpl.cs
- GridToolTip.cs
- DetailsViewPageEventArgs.cs
- FormsAuthenticationModule.cs
- CriticalFinalizerObject.cs
- PtsHelper.cs
- FontWeightConverter.cs
- CfgSemanticTag.cs
- FrameworkRichTextComposition.cs
- StructuredTypeEmitter.cs
- safex509handles.cs
- TerminateDesigner.cs
- MSAAEventDispatcher.cs
- GZipDecoder.cs
- StreamGeometry.cs
- SqlDataSourceCache.cs
- Pens.cs
- WindowsToolbarAsMenu.cs
- Stack.cs
- CheckBoxDesigner.cs
- MetafileEditor.cs
- PerformanceCounterPermissionEntry.cs
- AmbientValueAttribute.cs
- KeyedHashAlgorithm.cs
- MetadataItem.cs
- SRef.cs
- FixedTextContainer.cs
- OneToOneMappingSerializer.cs
- ActiveXSite.cs
- Crypto.cs
- CheckBoxStandardAdapter.cs
- SingleSelectRootGridEntry.cs
- SelectionService.cs
- sqlpipe.cs
- Stroke2.cs
- cookie.cs
- SystemTcpStatistics.cs
- Html32TextWriter.cs
- TiffBitmapEncoder.cs
- Accessors.cs
- URLMembershipCondition.cs
- PublisherIdentityPermission.cs
- SequenceRange.cs
- DependencyPropertyValueSerializer.cs
- DataGridViewCellParsingEventArgs.cs
- XmlSchemaSimpleTypeRestriction.cs
- WebPartDeleteVerb.cs
- ObjectAssociationEndMapping.cs
- InternalConfirm.cs
- VisualProxy.cs
- InvokeProviderWrapper.cs
- EasingKeyFrames.cs