/// <summary>
        /// Sets this <see cref="PhysicalWorkspace"/> with a previously created memento.
        /// </summary>
        /// <param name="memento">Memento to set.</param>
        /// <remarks>
        /// This method restores the state of a <see cref="PhysicalWorkspace"/> with
        /// a memento previously created by <see cref="CreateMemento"/>.
        /// </remarks>
        public virtual void SetMemento(object memento)
        {
            Platform.CheckForNullReference(memento, "memento");

            PhysicalWorkspaceMemento workspaceMemento = (PhysicalWorkspaceMemento)memento;

            //locked is not part of the memento.
            bool locked = Locked;

            SetLocked(false);

            this.ImageBoxes.Clear();

            for (int i = 0; i < workspaceMemento.ImageBoxes.Count; i++)
            {
                object    imageBoxMemento = workspaceMemento.ImageBoxMementos[i];
                IImageBox imageBox        = workspaceMemento.ImageBoxes[i];
                imageBox.SetMemento(imageBoxMemento);

                this.ImageBoxes.Add(imageBox);
            }

            _rows    = workspaceMemento.Rows;
            _columns = workspaceMemento.Columns;

            SetImageBoxGrid();

            //restore locked state.
            SetLocked(locked);

            OnLayoutCompleted();

            //The command in the command history should be drawable.
            //Draw();
        }
        /// <summary>
        /// Creates a memento for this <see cref="PhysicalWorkspace"/>.
        /// </summary>
        /// <returns>A memento for this <see cref="PhysicalWorkspace"/>.</returns>
        /// <remarks>
        /// This method is used to remember the current state of a
        /// <see cref="PhysicalWorkspace"/>.  The memento remembers the actual <see cref="ImageBox"/>
        /// <i>instances</i> contained in the <see cref="PhysicalWorkspace"/>.  Calling
        /// <see cref="SetMemento"/> at a later time restores
        /// those instances.
        /// </remarks>
        public virtual object CreateMemento()
        {
            List <object> imageBoxMementos = new List <object>();

            foreach (ImageBox imageBox in this.ImageBoxes)
            {
                imageBoxMementos.Add(imageBox.CreateMemento());
            }

            PhysicalWorkspaceMemento workspaceMemento =
                new PhysicalWorkspaceMemento(new ImageBoxCollection(this.ImageBoxes),
                                             imageBoxMementos,
                                             this.Rows,
                                             this.Columns);

            return(workspaceMemento);
        }