1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation
8 using System.Collections.Generic;
10 using System.Activities.Presentation.View;
11 using System.Activities.Presentation.Model;
13 public abstract class UndoUnit
15 EditingContext context;
16 ModelItem designerRoot;
18 public string Description { get; set; }
19 public abstract void Redo();
20 public abstract void Undo();
22 protected UndoUnit(EditingContext context)
26 throw FxTrace.Exception.AsError(new ArgumentNullException("context"));
28 this.context = context;
30 protected void SaveGlobalState()
32 DesignerView designerView = context.Services.GetService<DesignerView>();
33 if (designerView != null && designerView.RootDesigner != null)
35 designerRoot = ((WorkflowViewElement)designerView.RootDesigner).ModelItem;
39 protected void ApplyGlobalState()
41 DesignerView designerView = context.Services.GetService<DesignerView>();
42 if (designerView != null && designerView.RootDesigner != null)
44 ModelItem currentDesignerRoot = ((WorkflowViewElement)designerView.RootDesigner).ModelItem;
45 if (currentDesignerRoot != designerRoot)
47 designerView.MakeRootDesigner(designerRoot);