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

            PrintImageBoxMemento imageBoxMemento = (PrintImageBoxMemento)memento;

            Tiles.Clear();
            foreach (PrintViewTile tile in imageBoxMemento.TileCollection)
            {
                tile.Deselect();
                Tiles.Add(tile);
            }
            _normalizedRectangle = RectangleF.Empty;
            this.TotleImageCount = imageBoxMemento.TotleTileCount;

            DisplaySetLocked = false;
            this.DisplaySet  = imageBoxMemento.DisplaySet;
            if (this.DisplaySet != null)
            {
                this.DisplaySet.SetMemento(imageBoxMemento.DisplaySetMemento);
            }

            this.DisplaySetLocked = imageBoxMemento.DisplaySetLocked;

            this.NormalizedRectangle = imageBoxMemento.NormalizedRectangle;

            if (imageBoxMemento.TopLeftPresentationImageIndex != -1)
            {
                this.TopLeftPresentationImageIndex = imageBoxMemento.TopLeftPresentationImageIndex;
            }

            if (imageBoxMemento.IndexOfSelectedTile != -1)
            {
                ITile selectedTile = this.Tiles[imageBoxMemento.IndexOfSelectedTile];
                selectedTile.Select();
            }

            EventsHelper.Fire(_layoutCompletedEvent, this, EventArgs.Empty);
            if (_imageViewer != null)
            {
                _imageViewer.PropertyValueChanged();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a memento for this <see cref="ImageBox"/>.
        /// </summary>
        /// <returns>A memento for this <see cref="ImageBox"/>.</returns>
        /// <remarks>
        /// This method is used to remember the current state of a
        /// <see cref="ImageBox"/>.  The memento remembers the actual <see cref="Tile"/>
        /// <i>instances</i> contained in the <see cref="ImageBox"/>.  Calling
        /// <see cref="ImageBox.SetMemento"/> at a later time restores those instances.
        /// </remarks>
        public virtual object CreateMemento()
        {
            object displaySetMemento = null;

            if (this.DisplaySet != null)
            {
                displaySetMemento = this.DisplaySet.CreateMemento();
            }
            TileCollection tileCollection = new TileCollection();

            tileCollection.AddRange(Tiles);

            PrintImageBoxMemento imageBoxMemento =
                new PrintImageBoxMemento(this.DisplaySet,
                                         this.DisplaySetLocked,
                                         displaySetMemento,
                                         tileCollection,
                                         this.TopLeftPresentationImageIndex,
                                         this.NormalizedRectangle,
                                         this.IndexOfSelectedTile,
                                         this.TotleImageCount);

            return(imageBoxMemento);
        }