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);
        }
예제 #2
0
			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);
			}
예제 #3
0
        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);
        }
예제 #4
0
            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);
            }
예제 #5
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);
        }
예제 #6
0
        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();
        }
예제 #7
0
        private void CaptureBeginState(IImageBox imageBox)
        {
            _memorableCommand = new MemorableUndoableCommand(imageBox)
            {
                BeginState = imageBox.CreateMemento()
            };
            // Capture state before stack
            _currentImageBox = imageBox;

            _initialPresentationImageIndex = imageBox.SelectedTile.PresentationImageIndex;
        }
예제 #8
0
        private void Sort(ImageComparerList.Item item)
        {
            IImageBox   imageBox = ImageViewer.SelectedImageBox;
            IDisplaySet displaySet;

            if (imageBox == null || (displaySet = ImageViewer.SelectedImageBox.DisplaySet) == null)
            {
                return;
            }

            if (displaySet.PresentationImages.Count == 0)
            {
                return;
            }

            //try to keep the top-left image the same.
            IPresentationImage topLeftImage = imageBox.TopLeftPresentationImage;

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

            displaySet.PresentationImages.Sort(item.Comparer);
            imageBox.TopLeftPresentationImage = topLeftImage;
            imageBox.Draw();

            command.EndState = imageBox.CreateMemento();
            if (!command.BeginState.Equals(command.EndState))
            {
                var historyCommand = new DrawableUndoableCommand(imageBox)
                {
                    Name = SR.CommandSortImages
                };
                historyCommand.Enqueue(command);
                Context.Viewer.CommandHistory.AddCommand(historyCommand);
            }

            UpdateCheckState();
        }
예제 #9
0
        private bool CaptureBeginState()
        {
            if (CanStart())
            {
                _selectedImageBox            = ImageViewer.SelectedImageBox;
                _memorableCommand            = new MemorableUndoableCommand(_selectedImageBox);
                _memorableCommand.BeginState = _selectedImageBox.CreateMemento();

                return(true);
            }

            return(false);
        }
            internal static void AssignDisplaySetToImageBox(IImageBox imageBox, IDisplaySet displaySet)
            {
                MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);

                memorableCommand.BeginState = imageBox.CreateMemento();

                // always create a 'fresh copy' to show in the image box.  We never want to show
                // the 'originals' (e.g. the ones in IImageSet.DisplaySets) because we want them
                // to remain clean and unaltered - consider them to be templates for what actually
                // gets shown.
                imageBox.DisplaySet = displaySet.CreateFreshCopy();

                imageBox.Draw();
                //this.ImageViewer.SelectedImageBox[0, 0].Select();

                memorableCommand.EndState = imageBox.CreateMemento();

                DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);

                historyCommand.Enqueue(memorableCommand);
                imageBox.ImageViewer.CommandHistory.AddCommand(historyCommand);
            }
예제 #11
0
        private void ExplodeSelectedTile(IImageBox imageBox)
        {
            MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);

            memorableCommand.BeginState = imageBox.CreateMemento();

            //set this here so checked will be correct.
            object unexplodeMemento = memorableCommand.BeginState;

            _unexplodeCommands[imageBox] = new UnexplodeTileCommand(imageBox, unexplodeMemento, RemoveUnexplodeCommand);

            IDisplaySet        displaySet    = imageBox.DisplaySet;
            IPresentationImage selectedImage = imageBox.SelectedTile.PresentationImage;

            imageBox.SetTileGrid(1, 1);

            //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;

            imageBox.TopLeftPresentationImage = selectedImage;

            memorableCommand.EndState = imageBox.CreateMemento();

            DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);

            historyCommand.Name = SR.CommandExplodeTile;
            historyCommand.Enqueue(memorableCommand);
            imageBox.ParentPhysicalWorkspace.ImageViewer.CommandHistory.AddCommand(historyCommand);

            imageBox.Draw();
            imageBox.SelectDefaultTile();
        }
예제 #12
0
        private void AdvanceImage()
        {
            if (!_stopThread)
            {
                if (_memorableCommand == null)
                {
                    if (!CaptureBeginState())
                    {
                        StopCine();
                        return;
                    }
                }

                if (_reverse)
                {
                    if (_selectedImageBox.TopLeftPresentationImageIndex == 0)
                    {
                        _selectedImageBox.TopLeftPresentationImageIndex = _selectedImageBox.DisplaySet.PresentationImages.Count - 1;
                    }
                    else
                    {
                        --_selectedImageBox.TopLeftPresentationImageIndex;
                    }
                }
                else
                {
                    if (_selectedImageBox.TopLeftPresentationImageIndex == _selectedImageBox.DisplaySet.PresentationImages.Count - _selectedImageBox.Tiles.Count)
                    {
                        _selectedImageBox.TopLeftPresentationImageIndex = 0;
                    }
                    else
                    {
                        ++_selectedImageBox.TopLeftPresentationImageIndex;
                    }
                }

                _memorableCommand.EndState = _selectedImageBox.CreateMemento();
                _selectedImageBox.Draw();
            }

            lock (_threadLock)
            {
                Monitor.Pulse(_threadLock);
            }
        }
예제 #13
0
        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();
        }
예제 #14
0
			internal static void AssignDisplaySetToImageBox(IImageBox imageBox, IDisplaySet displaySet)
			{
                MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);
                memorableCommand.BeginState = imageBox.CreateMemento();

                // always create a 'fresh copy' to show in the image box.  We never want to show
                // the 'originals' (e.g. the ones in IImageSet.DisplaySets) because we want them 
                // to remain clean and unaltered - consider them to be templates for what actually
                // gets shown.
                imageBox.DisplaySet = displaySet.CreateFreshCopy();

                imageBox.Draw();
                //this.ImageViewer.SelectedImageBox[0, 0].Select();

                memorableCommand.EndState = imageBox.CreateMemento();

                DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);
                historyCommand.Enqueue(memorableCommand);
                imageBox.ImageViewer.CommandHistory.AddCommand(historyCommand);
            }
        private object[,] GetImageBoxMementos()
        {
            int rows    = PhysicalWorkspace.Rows;
            int columns = PhysicalWorkspace.Columns;

            object[,] mementos = new object[rows, columns];

            for (int row = 0; row < rows; ++row)
            {
                for (int column = 0; column < columns; ++column)
                {
                    IImageBox imageBox = PhysicalWorkspace[row, column];
                    if (imageBox.DisplaySet != null)
                    {
                        mementos[row, column] = imageBox.CreateMemento();
                    }
                }
            }

            return(mementos);
        }
예제 #16
0
		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();
		}
예제 #17
0
		private void ExplodeSelectedTile(IImageBox imageBox)
		{
			MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);
			memorableCommand.BeginState = imageBox.CreateMemento();

			//set this here so checked will be correct.
			object unexplodeMemento = memorableCommand.BeginState;
			_unexplodeCommands[imageBox] = new UnexplodeTileCommand(imageBox, unexplodeMemento, RemoveUnexplodeCommand);
			
			IDisplaySet displaySet = imageBox.DisplaySet;
			IPresentationImage selectedImage = imageBox.SelectedTile.PresentationImage;
			imageBox.SetTileGrid(1, 1);

			//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;

			imageBox.TopLeftPresentationImage = selectedImage;

			memorableCommand.EndState = imageBox.CreateMemento();

			DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);
			historyCommand.Name = SR.CommandExplodeTile;
			historyCommand.Enqueue(memorableCommand);
			imageBox.ParentPhysicalWorkspace.ImageViewer.CommandHistory.AddCommand(historyCommand);
		
			imageBox.Draw();
            imageBox.SelectDefaultTile();
        }
예제 #18
0
파일: StackTool.cs 프로젝트: nhannd/Xian
		private void CaptureBeginState(IImageBox imageBox)
		{
			_memorableCommand = new MemorableUndoableCommand(imageBox) {BeginState = imageBox.CreateMemento()};
			// Capture state before stack
		    _currentImageBox = imageBox;

			_initialPresentationImageIndex = imageBox.SelectedTile.PresentationImageIndex;
		}