internal EditingScope(ModelTreeManager modelTreeManager, EditingScope outerScope) { this.modelTreeManager = modelTreeManager; this.changes = new List <Change>(); this.outerScope = outerScope; this.HasModelChanges = false; this.itemsAdded = new HashSet <ModelItem>(); this.itemsRemoved = new HashSet <ModelItem>(); }
internal EditingScope(ModelTreeManager modelTreeManager, EditingScope outerScope) { this.modelTreeManager = modelTreeManager; this.changes = new List<Change>(); this.outerScope = outerScope; this.HasModelChanges = false; this.itemsAdded = new HashSet<ModelItem>(); this.itemsRemoved = new HashSet<ModelItem>(); }
public EditingScopeUndoUnit(EditingContext context, ModelTreeManager modelTreeManager, EditingScope editingScope) : base(context) { Fx.Assert(context != null, "context cannot be null"); Fx.Assert(modelTreeManager != null, "modelTreeManager cannot be null"); Fx.Assert(editingScope != null, "editingScope cannot be null"); this.context = context; this.modelTreeManager = modelTreeManager; this.editingScope = editingScope; this.Description = this.editingScope.Description; SaveGlobalState(); }
internal static ModelEditingScope ModelItemBeginEdit(ModelTreeManager modelTreeManager, string description, bool shouldApplyChangesImmediately) { if (shouldApplyChangesImmediately && modelTreeManager.Context.Services.GetService <UndoEngine>().IsBookmarkInPlace) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR.InvalidNestedModelItemBeginEditExceptionMessage)); } EditingScope editingScope = modelTreeManager.CreateEditingScope(description, shouldApplyChangesImmediately); if (shouldApplyChangesImmediately && editingScope == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR.InvalidNestedModelItemBeginEditExceptionMessage)); } return(editingScope); }
protected override void OnGotMouseCapture(MouseEventArgs e) { ModelItem stateContainerModelItem = this.ParentStateContainerEditor.ModelItem; string undoItemName = string.Empty; if (stateContainerModelItem.ItemType == typeof(StateMachine)) { undoItemName = SR.StateMachineResize; } else if (stateContainerModelItem.ItemType == typeof(State)) { undoItemName = SR.StateResize; } else { Fx.Assert(false, "The model item type is invalid"); } this.scope = (EditingScope)this.ParentStateContainerEditor.ModelItem.BeginEdit(undoItemName); base.OnGotMouseCapture(e); }
internal static void TryCreateImmediateEditingScopeAndExecute(EditingContext context, string editingScopeDescription, Action <EditingScope> modelEditingWork) { Fx.Assert(context != null, "context should not be null."); Fx.Assert(modelEditingWork != null, "modelEditingWork should not be null."); ModelTreeManager manager = context.Services.GetRequiredService <ModelTreeManager>(); if (manager.CanCreateImmediateEditingScope()) { using (EditingScope editingScope = manager.CreateEditingScope(editingScopeDescription, true)) { modelEditingWork(editingScope); } } else { modelEditingWork(null); } }
protected override void OnLostMouseCapture(MouseEventArgs e) { if (this.scope != null) { this.scope.Complete(); this.scope.Dispose(); this.scope = null; } base.OnLostMouseCapture(e); }
static bool IsTransitionReordering(EditingScope scope) { return scope.Changes.Any<Change>((p) => { return p != null && p.GetType() == typeof(TransitionReorderChange); }); }
static bool ShouldSuppressAddingConnectorsWhenAddingStateVisuals(EditingScope scope) { return scope.Changes.Any<Change>((p) => { return p != null && p.GetType() == typeof(SuppressAddingConnectorWhenAddingStateVisual); }); }