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 / 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
- ServicePointManager.cs
- HMAC.cs
- ControlIdConverter.cs
- CompilerParameters.cs
- BinaryConverter.cs
- CodeEntryPointMethod.cs
- SiteMembershipCondition.cs
- StorageModelBuildProvider.cs
- HwndSource.cs
- RoleServiceManager.cs
- AutoResizedEvent.cs
- WmfPlaceableFileHeader.cs
- X509SubjectKeyIdentifierClause.cs
- TextEditorLists.cs
- DomainConstraint.cs
- BitVector32.cs
- IProvider.cs
- StandardCommandToolStripMenuItem.cs
- TrustManagerMoreInformation.cs
- SelectionRangeConverter.cs
- OleDbCommand.cs
- DoubleIndependentAnimationStorage.cs
- SecureUICommand.cs
- TagPrefixCollection.cs
- configsystem.cs
- DrawListViewSubItemEventArgs.cs
- LogicalTreeHelper.cs
- AssemblyName.cs
- ZipIOLocalFileHeader.cs
- Object.cs
- AssemblyNameProxy.cs
- LinqDataSourceUpdateEventArgs.cs
- StyleBamlTreeBuilder.cs
- BuildProvidersCompiler.cs
- DateRangeEvent.cs
- TemplateControl.cs
- MarkupExtensionSerializer.cs
- BatchParser.cs
- RoleBoolean.cs
- ChtmlTextBoxAdapter.cs
- _ProxyChain.cs
- ConfigXmlComment.cs
- ButtonFieldBase.cs
- RowCache.cs
- ImageField.cs
- ADMembershipUser.cs
- DashStyle.cs
- httpapplicationstate.cs
- Debug.cs
- DuplexClientBase.cs
- XmlUnspecifiedAttribute.cs
- HttpFileCollection.cs
- FileNotFoundException.cs
- UnsafeNativeMethods.cs
- RewritingPass.cs
- MethodImplAttribute.cs
- AdornerPresentationContext.cs
- DeadCharTextComposition.cs
- Soap.cs
- DuplicateDetector.cs
- DataError.cs
- XmlDocumentType.cs
- TypeBuilder.cs
- MarkupExtensionSerializer.cs
- X509ChainPolicy.cs
- SchemaName.cs
- SymLanguageType.cs
- Localizer.cs
- DataGridViewImageColumn.cs
- ProcessRequestArgs.cs
- WindowsUpDown.cs
- Transform3DGroup.cs
- TableCellCollection.cs
- IntSecurity.cs
- SettingsProperty.cs
- EasingKeyFrames.cs
- ShaderEffect.cs
- GatewayIPAddressInformationCollection.cs
- ResourceProviderFactory.cs
- XmlAttributeCache.cs
- MasterPage.cs
- XamlFilter.cs
- ExpressionBuilderContext.cs
- XPathConvert.cs
- MappingMetadataHelper.cs
- DesignerInterfaces.cs
- GPPOINT.cs
- FrugalMap.cs
- DecoratedNameAttribute.cs
- TableColumnCollectionInternal.cs
- IntegerValidator.cs
- MultipartIdentifier.cs
- ExpressionBuilder.cs
- HuffmanTree.cs
- LiteralSubsegment.cs
- SocketPermission.cs
- SystemNetHelpers.cs
- OracleParameterCollection.cs
- StringBuilder.cs
- X509CertificateStore.cs