EditingScopeUndoUnit.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / EditingScopeUndoUnit.cs / 1305376 / EditingScopeUndoUnit.cs

                            //---------------------------------------------------------------- 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//---------------------------------------------------------------

namespace System.Activities.Presentation 
{
    using System; 
    using System.Collections.Generic; 
    using System.Text;
    using System.Activities.Presentation.View; 
    using System.Activities.Presentation.Model;

    class EditingScopeUndoUnit : UndoUnit
    { 
        ModelTreeManager modelTreeManager;
        EditingScope editingScope; 
        WorkflowDesigner workflowDesigner; 

        public EditingScopeUndoUnit(WorkflowDesigner workflowDesigner, ModelTreeManager modelTreeManager, EditingScope editingScope) : base(workflowDesigner.Context) 
        {
            this.workflowDesigner = workflowDesigner;
            this.modelTreeManager = modelTreeManager;
            this.editingScope = editingScope; 
            this.Description = this.editingScope.Description;
            SaveGlobalState(); 
        } 

        public override void Redo() 
        {
            this.modelTreeManager.StopTracking();
            EditingScope redoEditingScope = this.modelTreeManager.CreateEditingScope(this.editingScope.Description);
            redoEditingScope.Changes.AddRange(editingScope.Changes); 
            redoEditingScope.Complete();
            this.modelTreeManager.StartTracking(); 
            ApplyGlobalState(); 

        } 

        public override void Undo()
        {
            this.modelTreeManager.StopTracking(); 
            EditingScope undoEditingScope = this.modelTreeManager.CreateEditingScope(this.editingScope.Description);
            foreach (Change change in editingScope.Changes) 
            { 
                Change inverseChange = change.GetInverse();
                if (inverseChange != null) 
                {
                    undoEditingScope.Changes.Add(inverseChange);
                }
            } 
            undoEditingScope.Changes.Reverse();
            undoEditingScope.Complete(); 
            this.modelTreeManager.StartTracking(); 
            ApplyGlobalState();
        } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//---------------------------------------------------------------- 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//---------------------------------------------------------------

namespace System.Activities.Presentation 
{
    using System; 
    using System.Collections.Generic; 
    using System.Text;
    using System.Activities.Presentation.View; 
    using System.Activities.Presentation.Model;

    class EditingScopeUndoUnit : UndoUnit
    { 
        ModelTreeManager modelTreeManager;
        EditingScope editingScope; 
        WorkflowDesigner workflowDesigner; 

        public EditingScopeUndoUnit(WorkflowDesigner workflowDesigner, ModelTreeManager modelTreeManager, EditingScope editingScope) : base(workflowDesigner.Context) 
        {
            this.workflowDesigner = workflowDesigner;
            this.modelTreeManager = modelTreeManager;
            this.editingScope = editingScope; 
            this.Description = this.editingScope.Description;
            SaveGlobalState(); 
        } 

        public override void Redo() 
        {
            this.modelTreeManager.StopTracking();
            EditingScope redoEditingScope = this.modelTreeManager.CreateEditingScope(this.editingScope.Description);
            redoEditingScope.Changes.AddRange(editingScope.Changes); 
            redoEditingScope.Complete();
            this.modelTreeManager.StartTracking(); 
            ApplyGlobalState(); 

        } 

        public override void Undo()
        {
            this.modelTreeManager.StopTracking(); 
            EditingScope undoEditingScope = this.modelTreeManager.CreateEditingScope(this.editingScope.Description);
            foreach (Change change in editingScope.Changes) 
            { 
                Change inverseChange = change.GetInverse();
                if (inverseChange != null) 
                {
                    undoEditingScope.Changes.Add(inverseChange);
                }
            } 
            undoEditingScope.Changes.Reverse();
            undoEditingScope.Complete(); 
            this.modelTreeManager.StartTracking(); 
            ApplyGlobalState();
        } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK