private void CaptureEndState() { if (!CanAdjustAlpha() || _memorableCommand == null) { return; } if (this.SelectedLayerOpacityProvider != null) { _memorableCommand.EndState = GetSelectedLayerOpacityManager().CreateMemento(); UndoableCommand applicatorCommand = _applicator.ApplyToLinkedImages(); DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(this.SelectedPresentationImage); if (!_memorableCommand.EndState.Equals(_memorableCommand.BeginState)) { historyCommand.Enqueue(_memorableCommand); } if (applicatorCommand != null) { historyCommand.Enqueue(applicatorCommand); } if (historyCommand.Count > 0) { historyCommand.Name = SR.CommandAdjustOpacity; this.Context.Viewer.CommandHistory.AddCommand(historyCommand); } } }
private void CaptureEndState() { if (!CanZoom() || _memorableCommand == null) { return; } _memorableCommand.EndState = GetSelectedImageTransform().CreateMemento(); UndoableCommand applicatorCommand = _toolBehavior.Behavior.SelectedImageZoomTool ? null : _applicator.ApplyToLinkedImages(); DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(this.SelectedPresentationImage); if (!_memorableCommand.EndState.Equals(_memorableCommand.BeginState)) { historyCommand.Enqueue(_memorableCommand); } if (applicatorCommand != null) { historyCommand.Enqueue(applicatorCommand); } if (historyCommand.Count > 0) { historyCommand.Name = SR.CommandZoom; this.Context.Viewer.CommandHistory.AddCommand(historyCommand); } _memorableCommand = null; }
public void Undo() { if (commandStack.Count > 0) { UndoableCommand command = (UndoableCommand)commandStack.Pop(); command.Undo(); } }
public void Undo() { if (commandStack.Count > 0) { UndoableCommand cmd = (UndoableCommand)commandStack.Pop(); cmd.Undo(); //Debug.Log("Undo: " + cmd.GetType()); } }
//private bool _isCurrent = false; private CommandInfo(UndoableCommand command) { _name = command.Name; _hashcode = command.GetHashCode(); Type type = command.GetType(); _type = type.FullName; _assembly = type.Assembly.FullName; }
/// <inheritdoc /> public override void PushUndo(UndoableCommand command) { var obj = WindowState.AssetModel as Object; if (obj != null) { Undo.RegisterCompleteObjectUndo(new[] { obj }, command?.UndoString ?? ""); } base.PushUndo(command); }
private void Apply() { ImageOperationApplicator applicator = new ImageOperationApplicator(_ownerTool.SelectedPresentationImage, this); UndoableCommand historyCommand = _ownerTool._toolBehavior.Behavior.SelectedImageColorMapTool ? applicator.ApplyToReferenceImage() : applicator.ApplyToAllImages(); if (historyCommand != null) { historyCommand.Name = SR.CommandColorMap; _ownerTool.Context.Viewer.CommandHistory.AddCommand(historyCommand); } }
internal static CommandInfo CreateCommandInfo(UndoableCommand command) { if (command is MemorableUndoableCommand) { return(new MemorableCommandInfo((MemorableUndoableCommand)command)); } else if (command is CompositeUndoableCommand) { return(new CompositeCommandInfo((CompositeUndoableCommand)command)); } return(new CommandInfo(command)); }
/// <summary> /// Applies <paramref name="operation"/> to <paramref name="item"/> and returns /// an <see cref="UndoableCommand"/> that can undo and redo the operation. /// </summary> /// <returns> /// An <see cref="UndoableCommand"/> if application of <paramref name="operation"/> /// resulted in a change to the internal state of <paramref name="item"/>, otherwise null. /// </returns> /// <remarks> /// <para> /// The default implementation takes the <see cref="MemorableUndoableCommand"/> returned /// by the base method and wraps it in a <see cref="DrawableUndoableCommand"/>. /// </para> /// <para> /// Inheritors can override this method to do any additional processing and/or to /// modify the resulting command, if necessary. /// </para> /// </remarks> protected override UndoableCommand Apply(IUndoableOperation <T> operation, T item) { UndoableCommand command = base.Apply(operation, item); if (command != null) { item.Draw(); DrawableUndoableCommand drawableCommand = new DrawableUndoableCommand(item); drawableCommand.Enqueue(command); command = drawableCommand; } return(command); }
public virtual void Add(UndoableCommand cmd) { if (updating > 0) { return; } history.AddLast(cmd); if (history.Count > maxHistoryLength) { history.RemoveFirst(); } redoStack.Clear(); }
public void Apply() { if (_operation.GetOriginator(this.Context.Viewer.SelectedPresentationImage) == null) { return; } ImageOperationApplicator applicator = new ImageOperationApplicator(SelectedPresentationImage, _operation); UndoableCommand historyCommand = _toolBehavior.Behavior.SelectedImageInvertTool ? applicator.ApplyToReferenceImage() : applicator.ApplyToAllImages(); if (historyCommand != null) { historyCommand.Name = SR.CommandInvert; Context.Viewer.CommandHistory.AddCommand(historyCommand); } }
public void Activate() { if (!_operation.AppliesTo(this.SelectedPresentationImage)) { return; } ImageOperationApplicator applicator = new ImageOperationApplicator(SelectedPresentationImage, _operation); UndoableCommand historyCommand = _toolBehavior.Behavior.SelectedImageResetTool ? applicator.ApplyToReferenceImage() : applicator.ApplyToAllImages(); if (historyCommand != null) { historyCommand.Name = SR.CommandReset; Context.Viewer.CommandHistory.AddCommand(historyCommand); } }
public IEnumerator TestRebuildType(UndoableCommand command, UpdateType rebuildType) { // Do the initial update. yield return(null); m_GraphViewStateObserver.UpdateType = UpdateType.None; CommandDispatcher.Dispatch(command); yield return(null); Assert.That(m_GraphViewStateObserver.UpdateType, Is.EqualTo(rebuildType)); m_GraphViewStateObserver.UpdateType = UpdateType.None; yield return(null); Assert.That(m_GraphViewStateObserver.UpdateType, Is.EqualTo(UpdateType.None)); }
private bool Execute(UndoableCommand command) { if (!command.CanExecute(this)) { return(false); } bool success = false; try { success = command.Execute(this); } catch (Exception ex) { ShowErrorMessage(ex.Message); } if (success) { undoManager.Add(command); RaiseStateChanged(); } return(true); }
/// <summary> /// On the first call, the <see cref="IUndoableOperation{T}"/> is applied and this /// object is populated with the <see cref="MemorableUndoableCommand"/>s to undo /// the operation. /// </summary> /// <remarks> /// You should call <see cref="Execute"/> and check that the <see cref="CompositeUndoableCommand.Count"/> /// is non-zero before adding to the <see cref="CommandHistory"/>. Otherwise, there will end up /// being 'no-op' commands in the <see cref="CommandHistory"/>. /// </remarks> public override void Execute() { if (_operation != null) { foreach (T item in _items) { UndoableCommand command = Apply(_operation, item); if (command != null) { Enqueue(command); } } _operation = null; _items = null; } else { base.Execute(); } }
private void CaptureEndState() { if (!CanWindowLevel() || _memorableCommand == null) { return; } if (SelectedVoiLutProvider.VoiLutManager.VoiLut is IBasicVoiLutLinear) { _memorableCommand.EndState = GetSelectedImageVoiLutManager().CreateMemento(); UndoableCommand applicatorCommand = _toolBehavior.Behavior.SelectedImageWindowLevelTool ? null : _applicator.ApplyToLinkedImages(); DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(SelectedPresentationImage); if (!_memorableCommand.EndState.Equals(_memorableCommand.BeginState)) { historyCommand.Enqueue(_memorableCommand); } if (applicatorCommand != null) { historyCommand.Enqueue(applicatorCommand); } if (historyCommand.Count > 0) { historyCommand.Name = SR.CommandWindowLevel; Context.Viewer.CommandHistory.AddCommand(historyCommand); } } if (GetCheckedSync() == true) { var historyCommand2 = new DrawableUndoableOperationCommand <IPresentationImage>(this._operation, GetAllImages()); historyCommand2.Execute(); if (historyCommand2.Count > 0) { historyCommand2.Name = SR.CommandMatchScale; base.ImageViewer.CommandHistory.AddCommand(historyCommand2); } } }
private void CaptureEndState() { if (!CanZoom() || _memorableCommand == null) { return; } _memorableCommand.EndState = GetSelectedImageTransform().CreateMemento(); UndoableCommand applicatorCommand = _toolBehavior.Behavior.SelectedImageZoomTool ? null : _applicator.ApplyToLinkedImages(); DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(this.SelectedPresentationImage); if (!_memorableCommand.EndState.Equals(_memorableCommand.BeginState)) { historyCommand.Enqueue(_memorableCommand); } if (applicatorCommand != null) { historyCommand.Enqueue(applicatorCommand); } if (historyCommand.Count > 0) { historyCommand.Name = SR.CommandZoom; this.Context.Viewer.CommandHistory.AddCommand(historyCommand); } _memorableCommand = null; if (GetCheckedSync() == true) { var historyCommand2 = new DrawableUndoableOperationCommand <IPresentationImage>(this._operation, GetAllImages()); historyCommand2.Execute(); if (historyCommand2.Count > 0) { historyCommand2.Name = SR.CommandMatchScale; base.ImageViewer.CommandHistory.AddCommand(historyCommand); } } }
public MultiRangeCommand(UndoableCommand command) : base(command.ts) { this.cmd = command; range = ts.CurrentTB.Selection.Clone(); }
public void Push(UndoableCommand command) { _histories.Push(command); }
public void push(UndoableCommand command) { commands.Add(command); }
public void ExecuteCommand(UndoableCommand command) { this.ExecuteCommandCalled = true; this.ExecuteCommandArgument = command; this.ExecuteCommandNumberOfCalls++; }
public void Push(UndoableCommand command) { Commands.Enqueue(command); }