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(); }