Exemple #1
0
        /// <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>
        /// Inheritors can override this method to do any additional processing and/or to
        /// modify the resulting command, if necessary.
        /// </remarks>
        protected virtual UndoableCommand Apply(IUndoableOperation <T> operation, T item)
        {
            if (operation.AppliesTo(item))
            {
                IMemorable originator = operation.GetOriginator(item);
                if (originator != null)
                {
                    object beginState = originator.CreateMemento();
                    if (beginState != null)
                    {
                        operation.Apply(item);

                        object endState = originator.CreateMemento();
                        if (!Equals(beginState, endState))
                        {
                            MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(originator);
                            memorableCommand.BeginState = beginState;
                            memorableCommand.EndState   = endState;

                            return(memorableCommand);
                        }
                    }
                }
            }

            return(null);
        }
        private void CaptureEndState()
        {
            if (this.SelectedPresentationImage == null)
            {
                return;
            }

            if (!(this.SelectedPresentationImage is IDynamicTeProvider))
            {
                return;
            }

            if (_command == null)
            {
                return;
            }

            _applicator.ApplyToLinkedImages();

            _command.EndState = _applicator.CreateMemento();

            // If the state hasn't changed since MouseDown just return
            if (_command.EndState.Equals(_command.BeginState))
            {
                _command = null;
                return;
            }

            this.Context.Viewer.CommandHistory.AddCommand(_command);
        }
Exemple #3
0
        private void AnalyzeInternal()
        {
            IPresentationImage       presImage            = this.ImageViewer.SelectedPresentationImage;
            IImageGraphicProvider    imageGraphicProvider = presImage as IImageGraphicProvider;
            GrayscaleImageGraphic    imageGraphic         = imageGraphicProvider.ImageGraphic as GrayscaleImageGraphic;
            IOverlayGraphicsProvider overlayProvider      = presImage as IOverlayGraphicsProvider;

            CadOverlayGraphic cadOverlay = GetCadOverlayGraphic(overlayProvider);

            if (cadOverlay == null)
            {
                cadOverlay = new CadOverlayGraphic(imageGraphic);
                overlayProvider.OverlayGraphics.Add(cadOverlay);
            }

            MemorableUndoableCommand command = new MemorableUndoableCommand(cadOverlay);

            command.BeginState   = cadOverlay.CreateMemento();
            cadOverlay.Threshold = (int)this.Threshold;
            cadOverlay.Opacity   = (int)this.Opacity;
            cadOverlay.Analyze();
            command.EndState = cadOverlay.CreateMemento();

            this.ImageViewer.CommandHistory.AddCommand(command);
        }
Exemple #4
0
        private void Update()
        {
            if (!this.ProbabilityMapEnabled)
            {
                return;
            }

            IDynamicTeProvider provider = this.ImageViewer.SelectedPresentationImage as IDynamicTeProvider;

            if (provider == null)
            {
                return;
            }

            ImageOperationApplicator applicator = new ImageOperationApplicator(this.ImageViewer.SelectedPresentationImage, this);
            MemorableUndoableCommand command    = new MemorableUndoableCommand(applicator);

            command.Name       = "Dynamic Te";
            command.BeginState = applicator.CreateMemento();

            DynamicTe dynamicTe = provider.DynamicTe;

            dynamicTe.ProbabilityMapVisible = this.ProbabilityMapVisible;
            dynamicTe.ApplyProbabilityThreshold((int)this.Threshold, (int)this.Opacity);

            provider.Draw();

            command.EndState = applicator.CreateMemento();

            this.ImageViewer.CommandHistory.AddCommand(command);

            base.NotifyAllPropertiesChanged();
        }
        public static void SetTileLayout(IImageViewer imageViewer, int rows, int columns)
        {
            Platform.CheckForNullReference(imageViewer, "imageViewer");
            Platform.CheckArgumentRange(rows, 1, LayoutSettings.MaximumTileRows, "rows");
            Platform.CheckArgumentRange(columns, 1, LayoutSettings.MaximumTileColumns, "columns");

            IImageBox imageBox = imageViewer.PhysicalWorkspace.SelectedImageBox;

            if (imageBox == null || imageBox.ParentPhysicalWorkspace.Locked)
            {
                return;
            }

            var memorableCommand = new MemorableUndoableCommand(imageBox)
            {
                BeginState = imageBox.CreateMemento()
            };

            int index = imageBox.TopLeftPresentationImageIndex;

            imageBox.SetTileGrid(rows, columns);
            imageBox.TopLeftPresentationImageIndex = index;
            imageBox.Draw();
            imageBox.SelectDefaultTile();

            memorableCommand.EndState = imageBox.CreateMemento();

            var historyCommand = new DrawableUndoableCommand(imageBox)
            {
                Name = SR.CommandLayoutTiles
            };

            historyCommand.Enqueue(memorableCommand);
            imageViewer.CommandHistory.AddCommand(historyCommand);
        }
        private bool CaptureEndState()
        {
            if (_memorableCommand == null || _currentImageBox == null)
            {
                _currentImageBox = null;
                return(false);
            }

            bool commandAdded = false;

            // If nothing's changed then just return
            if (_initialPresentationImageIndex != _currentImageBox.SelectedTile.PresentationImageIndex)
            {
                // Capture state after stack
                _memorableCommand.EndState = _currentImageBox.CreateMemento();
                if (!_memorableCommand.EndState.Equals(_memorableCommand.BeginState))
                {
                    var historyCommand = new DrawableUndoableCommand(_currentImageBox)
                    {
                        Name = SR.CommandStack
                    };
                    historyCommand.Enqueue(_memorableCommand);
                    Context.Viewer.CommandHistory.AddCommand(historyCommand);
                    commandAdded = true;
                }
            }

            _memorableCommand = null;
            _currentImageBox  = null;

            return(commandAdded);
        }
Exemple #7
0
        private void CaptureEndState()
        {
            if (!CanPan() || _memorableCommand == null)
            {
                return;
            }

            _memorableCommand.EndState = GetSelectedImageTransform().CreateMemento();
            UndoableCommand         applicatorCommand = _toolBehavior.Behavior.SelectedImagePanTool ? 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.CommandPan;
                this.Context.Viewer.CommandHistory.AddCommand(historyCommand);
            }

            _memorableCommand = null;
        }
Exemple #8
0
        /// <summary>
        /// Helper method to add the operation of an <see cref="ControlGraphic"/> implementing <see cref="IMemorable"/> to the associated command history.
        /// </summary>
        /// <typeparam name="T">The derived type of <see cref="ControlGraphic"/>. Must implement <see cref="IMemorable"/>.</typeparam>
        /// <param name="originator">The <see cref="ControlGraphic"/> that performed the operation.</param>
        /// <param name="beginState">The memento created by <see cref="IMemorable.CreateMemento"/> before the operation.</param>
        /// <param name="endState">The memento created by <see cref="IMemorable.CreateMemento"/> after the operation.</param>
        protected static void AddToCommandHistory <T>(T originator, object beginState, object endState) where T : ControlGraphic, IMemorable
        {
            if (originator.ImageViewer == null)
            {
                return;
            }
            if (beginState == endState)             // ensure that both states aren't simultaneously null and that they're not the same states
            {
                return;
            }
            if (beginState != null && beginState.Equals(endState))             // ensure that beginState isn't equivalent to endState
            {
                return;
            }

            MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(originator);

            memorableCommand.BeginState = beginState;
            memorableCommand.EndState   = endState;

            DrawableUndoableCommand command = new DrawableUndoableCommand(originator);

            command.Name = originator.CommandName;
            command.Enqueue(memorableCommand);

            originator.ImageViewer.CommandHistory.AddCommand(command);
        }
Exemple #9
0
        private void BeginCaptureUndo()
        {
            _historyCommand = new CompositeUndoableCommand();
            DrawableUndoableCommand drawableUndoableCommand = new DrawableUndoableCommand(_imageBox);

            _imageBoxCommand            = new MemorableUndoableCommand(_imageBox);
            _imageBoxCommand.BeginState = _imageBox.CreateMemento();
            drawableUndoableCommand.Enqueue(_imageBoxCommand);
            _historyCommand.Enqueue(drawableUndoableCommand);
        }
        private void ExplodeImageBox()
        {
            IImageBox imageBox = ImageViewer.SelectedImageBox;

            if (!CanExplodeImageBox(imageBox))
            {
                return;
            }

            IPhysicalWorkspace       workspace        = imageBox.ParentPhysicalWorkspace;
            MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(workspace);

            memorableCommand.BeginState = workspace.CreateMemento();

            _imageBoxesObserver.SuppressChangedEvent = true;

            //set this here so checked will be correct.
            _unexplodeMemento = memorableCommand.BeginState;
            _oldImageBox      = imageBox;
            IDisplaySet        displaySet    = _oldImageBox.DisplaySet;
            IPresentationImage selectedImage = _oldImageBox.SelectedTile.PresentationImage;

            object imageBoxMemento = _oldImageBox.CreateMemento();

            workspace.SetImageBoxGrid(1, 1);
            IImageBox newImageBox = workspace.ImageBoxes[0];

            newImageBox.SetMemento(imageBoxMemento);

            //TODO (architecture): this wouldn't be necessary if we had a SetImageBoxGrid(imageBox[,]).
            //This stuff with mementos is actually a hacky workaround.

            bool locked = newImageBox.DisplaySetLocked;

            newImageBox.DisplaySetLocked         = false;
            newImageBox.DisplaySet               = displaySet;
            newImageBox.TopLeftPresentationImage = selectedImage;
            newImageBox.DisplaySetLocked         = locked;

            _imageBoxesObserver.SuppressChangedEvent = false;

            workspace.Draw();
            workspace.SelectDefaultImageBox();

            memorableCommand.EndState = workspace.CreateMemento();
            DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(workspace);

            historyCommand.Name = SR.CommandSurveyExplode;
            historyCommand.Enqueue(memorableCommand);
            base.ImageViewer.CommandHistory.AddCommand(historyCommand);

            OnCheckedChanged();
            UpdateEnabled();
        }
Exemple #11
0
        private void ExplodeImageBoxes()
        {
            if (0 == imageBoxHistory.Count ||
                !CanExplodeImageBox(ImageViewer.SelectedImageBox))
            {
                return;
            }

            IPhysicalWorkspace       workspace        = ImageViewer.SelectedImageBox.ParentPhysicalWorkspace;
            MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(workspace);

            memorableCommand.BeginState = workspace.CreateMemento();

            _imageBoxesObserver.SuppressChangedEvent = true;

            //set this here so checked will be correct.
            _unexplodeMemento = memorableCommand.BeginState;
            List <IImageBox> explodeImageBoxes = new List <IImageBox>(imageBoxHistory.Skip(imageBoxHistory.Count - WorkspaceScreenCount()));

            explodeImageBoxes.Reverse();

            List <object> mementoList = new List <object>();

            foreach (IImageBox imageBox in explodeImageBoxes)
            {
                mementoList.Add(imageBox.CreateMemento());
            }

            workspace.SetImageBoxGrid(1, explodeImageBoxes.Count);
            int i = 0;

            foreach (IImageBox imageBox in explodeImageBoxes)
            {
                IImageBox newImageBox = workspace.ImageBoxes[i];
                oldImageBoxMap.Add(imageBox, newImageBox);
                newImageBox.SetMemento(mementoList[i]);
                i++;
            }

            _imageBoxesObserver.SuppressChangedEvent = false;

            workspace.Draw();
            workspace.SelectDefaultImageBox();

            memorableCommand.EndState = workspace.CreateMemento();
            DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(workspace);

            historyCommand.Name = SR.CommandSurveyExplode;
            historyCommand.Enqueue(memorableCommand);
            base.ImageViewer.CommandHistory.AddCommand(historyCommand);

            OnCheckedChanged();
            UpdateEnabled();
        }
        private void CaptureBeginState(IImageBox imageBox)
        {
            _memorableCommand = new MemorableUndoableCommand(imageBox)
            {
                BeginState = imageBox.CreateMemento()
            };
            // Capture state before stack
            _currentImageBox = imageBox;

            _initialPresentationImageIndex = imageBox.SelectedTile.PresentationImageIndex;
        }
        private void DeleteCurrentPage(object sender, EventArgs args)
        {
            if (this.Context.Viewer == null || this.Context.Viewer.SelectedImageBox == null || this.Context.Viewer.SelectedImageBox.DisplaySet == null)
            {
                return;
            }
            PrintViewImageBox imageBox = this.ImageViewer.SelectedImageBox as PrintViewImageBox;
            var memorableCommand       = new MemorableUndoableCommand(imageBox)
            {
                BeginState = CreateMemento()
            };
            var printImageViewer = Context.Viewer as PrintImageViewerComponent;

            foreach (PrintViewTile tile in imageBox.Tiles)
            {
                if (tile.PresentationImage == null)
                {
                    int number1 = imageBox.TotleImageCount - imageBox.DisplaySet.PresentationImages.Count;
                    if (number1 > 0)
                    {
                        imageBox.TotleImageCount = imageBox.TotleImageCount - 1;
                    }
                    tile.Deselect();
                    continue;
                }

                if (imageBox.DisplaySet.PresentationImages.Contains(tile.PresentationImage))
                {
                    if (printImageViewer.SelectPresentationImages.Contains(tile.PresentationImage as PresentationImage))
                    {
                        var pi = tile.PresentationImage as PresentationImage;
                        pi.Selected = false;
                        printImageViewer.SelectPresentationImages.Remove(pi);
                    }
                    imageBox.DisplaySet.PresentationImages.Remove(tile.PresentationImage);
                    //tile.PresentationImage.Dispose();
                    tile.PresentationImage = null;
                    tile.Deselect();
                }
            }

            imageBox.TopLeftPresentationImageIndex = imageBox.TopLeftPresentationImageIndex - imageBox.Tiles.Count;
            imageBox.Draw();
            imageBox.SelectDefaultTile();
            memorableCommand.EndState = CreateMemento();
            var historyCommand = new DrawableUndoableCommand(imageBox)
            {
                Name = SR.CommandPrintPreviewDeleteImage
            };

            historyCommand.Enqueue(memorableCommand);
            this.Context.Viewer.CommandHistory.AddCommand(historyCommand);
            PropertyChanged();
        }
Exemple #14
0
        private bool CaptureBeginState()
        {
            if (CanStart())
            {
                _selectedImageBox            = ImageViewer.SelectedImageBox;
                _memorableCommand            = new MemorableUndoableCommand(_selectedImageBox);
                _memorableCommand.BeginState = _selectedImageBox.CreateMemento();

                return(true);
            }

            return(false);
        }
        private void CaptureBeginState()
        {
            if (!CanAdjustAlpha())
            {
                return;
            }

            ILayerOpacityManager originator = GetSelectedLayerOpacityManager();

            _applicator                  = new ImageOperationApplicator(this.SelectedPresentationImage, _operation);
            _memorableCommand            = new MemorableUndoableCommand(originator);
            _memorableCommand.BeginState = originator.CreateMemento();
        }
Exemple #16
0
        private void CaptureBeginState()
        {
            if (!CanPan())
            {
                return;
            }

            _applicator = new ImageOperationApplicator(this.SelectedPresentationImage, _operation);
            IMemorable originator = GetSelectedImageTransform();

            _memorableCommand            = new MemorableUndoableCommand(originator);
            _memorableCommand.BeginState = originator.CreateMemento();
        }
        private void CaptureBeginState()
        {
            if (!CanWindowLevel())
            {
                return;
            }

            IVoiLutManager originator = GetSelectedImageVoiLutManager();

            _applicator                  = new ImageOperationApplicator(SelectedPresentationImage, _operation);
            _memorableCommand            = new MemorableUndoableCommand(originator);
            _memorableCommand.BeginState = originator.CreateMemento();
        }
Exemple #18
0
        private void UnexplodeImageBoxes()
        {
            if (!CanUnexplodeImageBox(ImageViewer.SelectedImageBox))
            {
                return;
            }

            IPhysicalWorkspace workspace = ImageViewer.SelectedImageBox.ParentPhysicalWorkspace;

            Dictionary <IImageBox, object> imageBoxMementoDictionary = new Dictionary <IImageBox, object>();

            foreach (IImageBox imageBox in workspace.ImageBoxes)
            {
                imageBoxMementoDictionary.Add(imageBox, imageBox.CreateMemento());
            }
            Dictionary <IImageBox, IImageBox> oldMap = oldImageBoxMap;

            MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(workspace);

            memorableCommand.BeginState = workspace.CreateMemento();

            workspace.SetMemento(_unexplodeMemento);

            if (0 != oldMap.Count)
            {
                foreach (IImageBox box in workspace.ImageBoxes)
                {
                    //Keep the state of the image box the same.
                    if (oldMap.ContainsKey(box))
                    {
                        box.SetMemento(imageBoxMementoDictionary[oldMap[box]]);
                    }
                }
            }

            workspace.Draw();

            memorableCommand.EndState = workspace.CreateMemento();

            DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(workspace);

            historyCommand.Name = SR.CommandSurveyExplode;
            historyCommand.Enqueue(memorableCommand);
            base.ImageViewer.CommandHistory.AddCommand(historyCommand);

            CancelExplodeMode();
            OnCheckedChanged();
            UpdateEnabled();
        }
Exemple #19
0
        private void EndCaptureUndo()
        {
            if (_imageBoxCommand != null)
            {
                _imageBoxCommand.EndState = _imageBox.CreateMemento();
                if (!_imageBoxCommand.BeginState.Equals(_imageBoxCommand.EndState))
                {
                    _historyCommand.Name = SR.CommandNameStackImageScroller;
                    _imageBox.ImageViewer.CommandHistory.AddCommand(_historyCommand);
                }
            }

            _imageBoxCommand = null;
            _historyCommand  = null;
        }
        private void CaptureBeginState()
        {
            if (this.SelectedPresentationImage == null)
            {
                return;
            }

            if (!(this.SelectedPresentationImage is IDynamicTeProvider))
            {
                return;
            }

            _applicator         = new ImageOperationApplicator(this.SelectedPresentationImage, this);
            _command            = new MemorableUndoableCommand(_applicator);
            _command.Name       = "Dynamic Te";
            _command.BeginState = _applicator.CreateMemento();
        }
            private void OnControlGraphicUndoableOperationStop(object sender, EventArgs e)
            {
                if (base.ImageViewer.CommandHistory != null)
                {
                    DrawableUndoableCommand compositeCommand = new DrawableUndoableCommand(this.ImageViewer.PhysicalWorkspace);
                    compositeCommand.Name = ((ControlGraphic)sender).CommandName;

                    MemorableUndoableCommand toolGroupStateCommand = new MemorableUndoableCommand(this);
                    toolGroupStateCommand.BeginState = _controlGraphicBeginState;
                    toolGroupStateCommand.EndState   = this.CreateMemento();
                    compositeCommand.Enqueue(toolGroupStateCommand);

                    base.ImageViewer.CommandHistory.AddCommand(compositeCommand);
                }

                _controlGraphicBeginState = null;
            }
        public void Undoable(string name, Func <bool> action)
        {
            IPhysicalWorkspace       workspace        = Context.Viewer.PhysicalWorkspace;
            MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(workspace);

            memorableCommand.BeginState = workspace.CreateMemento();
            if (!action())
            {
                return;
            }
            memorableCommand.EndState = workspace.CreateMemento();
            DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(workspace);

            historyCommand.Name = name;
            historyCommand.Enqueue(memorableCommand);
            Context.Viewer.CommandHistory.AddCommand(historyCommand);
        }
            private static void Execute(IImageBox imageBox, object unexplodeMemento)
            {
                MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);

                memorableCommand.BeginState = imageBox.CreateMemento();

                IDisplaySet        displaySet = imageBox.DisplaySet;
                IPresentationImage selectedImage;

                if (imageBox.SelectedTile != null)
                {
                    selectedImage = imageBox.SelectedTile.PresentationImage;
                }
                else
                {
                    selectedImage = imageBox.TopLeftPresentationImage;
                }

                imageBox.SetMemento(unexplodeMemento);

                //TODO (architecture): this wouldn't be necessary if we had a SetImageBoxGrid(imageBox[,]).
                //This stuff with mementos is actually a hacky workaround.

                bool locked = imageBox.DisplaySetLocked;

                imageBox.DisplaySetLocked = false;
                imageBox.DisplaySet       = displaySet;
                imageBox.DisplaySetLocked = locked;

                if (selectedImage != null)
                {
                    imageBox.TopLeftPresentationImage = selectedImage;
                }

                imageBox.Draw();
                imageBox.SelectDefaultTile();

                memorableCommand.EndState = imageBox.CreateMemento();

                DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);

                historyCommand.Name = SR.CommandExplodeTile;
                historyCommand.Enqueue(memorableCommand);
                imageBox.ParentPhysicalWorkspace.ImageViewer.CommandHistory.AddCommand(historyCommand);
            }
Exemple #24
0
        public CineApplicationComponent(IDesktopWindow desktopWindow)
            : base(desktopWindow)
        {
            _enabled = true;

            _minimumScale = 0;
            _maximumScale = 100;
            _minimumScaleWaitMilliseconds = 250;
            _currentScaleValue            = 50;

            _selectedImageBox = null;
            _memorableCommand = null;

            _threadLock = new object();
            _stopThread = false;
            _cineThread = null;
            _uiThreadSynchronizationContext = null;
        }
        private void UnexplodeImageBox()
        {
            IImageBox imageBox = ImageViewer.SelectedImageBox;

            if (!CanUnexplodeImageBox(imageBox))
            {
                return;
            }

            object imageBoxMemento = imageBox.CreateMemento();

            IPhysicalWorkspace       workspace        = imageBox.ParentPhysicalWorkspace;
            MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(workspace);

            memorableCommand.BeginState = workspace.CreateMemento();

            IImageBox oldImageBox = _oldImageBox;

            workspace.SetMemento(_unexplodeMemento);

            foreach (IImageBox box in workspace.ImageBoxes)
            {
                //Keep the state of the image box the same.
                if (box == oldImageBox)
                {
                    box.SetMemento(imageBoxMemento);
                    break;
                }
            }

            workspace.Draw();

            memorableCommand.EndState = workspace.CreateMemento();

            DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(workspace);

            historyCommand.Name = SR.CommandSurveyExplode;
            historyCommand.Enqueue(memorableCommand);
            base.ImageViewer.CommandHistory.AddCommand(historyCommand);

            CancelExplodeMode();
            OnCheckedChanged();
            UpdateEnabled();
        }
Exemple #26
0
        public void AdvanceDisplaySet(int direction)
        {
            if (!Enabled)
            {
                return;
            }

            IDisplaySet sourceDisplaySet = GetSourceDisplaySet();

            if (sourceDisplaySet == null)
            {
                return;
            }

            IImageBox imageBox       = base.Context.Viewer.SelectedImageBox;
            IImageSet parentImageSet = sourceDisplaySet.ParentImageSet;

            int sourceDisplaySetIndex = parentImageSet.DisplaySets.IndexOf(sourceDisplaySet);

            sourceDisplaySetIndex += direction;

            if (sourceDisplaySetIndex < 0)
            {
                sourceDisplaySetIndex = parentImageSet.DisplaySets.Count - 1;
            }
            else if (sourceDisplaySetIndex >= parentImageSet.DisplaySets.Count)
            {
                sourceDisplaySetIndex = 0;
            }

            MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);

            memorableCommand.BeginState = imageBox.CreateMemento();

            imageBox.DisplaySet = parentImageSet.DisplaySets[sourceDisplaySetIndex].CreateFreshCopy();
            imageBox.Draw();

            memorableCommand.EndState = imageBox.CreateMemento();

            DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);

            historyCommand.Enqueue(memorableCommand);
            base.Context.Viewer.CommandHistory.AddCommand(historyCommand);
        }
        public void PrintPreviewPaste()
        {
            var imageBox = this.ImageViewer.SelectedImageBox;

            if (imageBox == null || imageBox.DisplaySet == null || imageBox.SelectedTile == null || selectPresentationImages == null)
            {
                return;
            }

            var memorableCommand = new MemorableUndoableCommand(imageBox)
            {
                BeginState = CreateMemento()
            };

            if (this.Context.Viewer.SelectedPresentationImage == null)
            {
                foreach (var selectPresentationImage in selectPresentationImages)
                {
                    imageBox.DisplaySet.PresentationImages.Add(ImageExporter.ClonePresentationImage(selectPresentationImage));
                }
            }
            else
            {
                int index = imageBox.DisplaySet.PresentationImages.IndexOf(this.Context.Viewer.SelectedPresentationImage);

                for (int i = selectPresentationImages.Count - 1; i >= 0; i--)
                {
                    imageBox.DisplaySet.PresentationImages.Insert(index, ImageExporter.ClonePresentationImage(selectPresentationImages[i]));
                }
            }
            imageBox.TopLeftPresentationImageIndex = imageBox.TopLeftPresentationImageIndex;
            imageBox.Draw();
            imageBox.SelectDefaultTile();
            memorableCommand.EndState = CreateMemento();
            var historyCommand = new DrawableUndoableCommand(imageBox)
            {
                Name = SR.CommandPrintPreviewPaste
            };

            historyCommand.Enqueue(memorableCommand);
            this.Context.Viewer.CommandHistory.AddCommand(historyCommand);
            PropertyChanged();
        }
Exemple #28
0
        private void CommitEndState()
        {
            if (_memorableCommand != null)
            {
                _selectedImageBox.ImageViewer.CommandHistory.CurrentCommandChanging -= OnCommandChanging;

                if (!_memorableCommand.BeginState.Equals(_memorableCommand.EndState))
                {
                    DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(_selectedImageBox);
                    historyCommand.Name = SR.CommandCine;
                    historyCommand.Enqueue(_memorableCommand);
                    _selectedImageBox.ImageViewer.CommandHistory.AddCommand(historyCommand);
                }

                _selectedImageBox.ImageViewer.CommandHistory.CurrentCommandChanging += OnCommandChanging;
            }

            _selectedImageBox = null;
            _memorableCommand = null;
        }
Exemple #29
0
        public void ResetAll()
        {
            DrawableUndoableCommand command = new DrawableUndoableCommand(this.ImageViewer.PhysicalWorkspace);

            command.Name = SR.CommandMprReset;

            MemorableUndoableCommand toolGroupStateCommand = new MemorableUndoableCommand(this.ToolGroupState);

            toolGroupStateCommand.BeginState = this.ToolGroupState.CreateMemento();
            toolGroupStateCommand.EndState   = this.InitialToolGroupStateMemento;
            command.Enqueue(toolGroupStateCommand);

            command.Execute();

            if (this.ImageViewer.CommandHistory != null)
            {
                this.ImageViewer.CommandHistory.AddCommand(command);
            }

            this.CanReset = false;
        }
Exemple #30
0
            private void OnGraphicBuilderDone(object sender, GraphicEventArgs e)
            {
                if (base.ImageViewer.CommandHistory != null)
                {
                    DrawableUndoableCommand compositeCommand = new DrawableUndoableCommand(this.ImageViewer.PhysicalWorkspace);
                    compositeCommand.Name = SR.CommandMprReslice;

                    MemorableUndoableCommand toolGroupStateCommand = new MemorableUndoableCommand(_resliceToolGroup.ToolGroupState);
                    toolGroupStateCommand.BeginState = _originalResliceToolsState;
                    toolGroupStateCommand.EndState   = _resliceToolGroup.ToolGroupState.CreateMemento();
                    compositeCommand.Enqueue(toolGroupStateCommand);

                    base.ImageViewer.CommandHistory.AddCommand(compositeCommand);
                }

                _originalResliceToolsState = null;

                RemoveGraphicBuilder();

                _lastTopLeftPresentationImageIndex = this.SliceImageBox.TopLeftPresentationImageIndex;
            }