public void Activate() { if (!_operation.AppliesTo(SelectedPresentationImage)) { return; } var applicator = new ImageOperationApplicator(SelectedPresentationImage, _operation); var historyCommand = _toolBehavior.Behavior.SelectedImageResetTool ? applicator.ApplyToReferenceImage() : applicator.ApplyToAllImages(); if (historyCommand != null) { historyCommand.Name = SR.CommandReset; 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(historyCommand); } } }
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 void Activate() { if (!AppliesTo(ReferenceImage)) { return; } CalculateReferenceDisplayValues(); if (Math.Abs(_referenceDisplayRectangle.Width) < 50) { Context.DesktopWindow.ShowMessageBox(SR.MessageNotEnoughImageVisible, MessageBoxActions.Ok); return; } var historyCommand = new DrawableUndoableOperationCommand <IPresentationImage>(this, GetAllImages()); historyCommand.Execute(); if (historyCommand.Count > 0) { historyCommand.Name = SR.CommandMatchScale; base.ImageViewer.CommandHistory.AddCommand(historyCommand); } }
/// <summary> /// Applies the same <see cref="IUndoableOperation{T}"/> to the current image as well as all its linked images. /// </summary> /// <remarks> /// <para> /// <see cref="IUndoableOperation{T}.Apply"/> will be called only for images where /// <see cref="IUndoableOperation{T}.AppliesTo"/> has returned true <b>and</b> <see cref="IUndoableOperation{T}.GetOriginator"/> /// has returned a non-null value. /// </para> /// <para> /// Each affected image is drawn automatically by this method. /// </para> /// </remarks> public UndoableCommand ApplyToAllImages() { _imageEnumerator.ExcludeReferenceImage = false; DrawableUndoableOperationCommand<IPresentationImage> command = new DrawableUndoableOperationCommand<IPresentationImage>(_operation, _imageEnumerator); command.Execute(); if (command.Count == 0) return null; else return command; }