Beispiel #1
0
        /// <summary>
        /// Sets a memento for this object.
        /// </summary>
        /// <param name="memento"></param>
        public virtual void SetMemento(object memento)
        {
            PointMemento pointMemento = (PointMemento)memento;

            this.CoordinateSystem = CoordinateSystem.Source;
            this.TextLocation     = pointMemento.Point;
            this.ResetCoordinateSystem();
        }
Beispiel #2
0
        /// <summary>
        /// Creates a memento of this object.
        /// </summary>
        /// <returns></returns>
        public virtual object CreateMemento()
        {
            // Must store source coordinates in memento
            this.CoordinateSystem = CoordinateSystem.Source;
            PointMemento memento = new PointMemento(this.TextLocation);

            this.ResetCoordinateSystem();

            return(memento);
        }
Beispiel #3
0
        /// <summary>
        /// Captures the state of an object.
        /// </summary>
        /// <remarks>
        /// The implementation of <see cref="IMemorable.CreateMemento"/> should return an
        /// object containing enough state information so that
        /// when <see cref="IMemorable.SetMemento"/> is called, the object can be restored
        /// to the original state.
        /// </remarks>
        public object CreateMemento()
        {
            PointMemento pointMemento;

            this.CoordinateSystem = CoordinateSystem.Source;
            try
            {
                pointMemento = new PointMemento(this.Anchor);
            }
            finally
            {
                this.ResetCoordinateSystem();
            }

            return(pointMemento);
        }
        /// <summary>
        /// Captures the current state of this <see cref="TextPlaceholderControlGraphic"/>.
        /// </summary>
        public override object CreateMemento()
        {
            PointMemento pointMemento;

            this.Subject.CoordinateSystem = CoordinateSystem.Source;
            try
            {
                pointMemento = new PointMemento(this.Subject.Location);
            }
            finally
            {
                this.Subject.ResetCoordinateSystem();
            }

            return(pointMemento);
        }
        /// <summary>
        /// Restores the state of this <see cref="TextPlaceholderControlGraphic"/>.
        /// </summary>
        /// <param name="memento">The object that was originally created with <see cref="TextPlaceholderControlGraphic.CreateMemento"/>.</param>
        public override void SetMemento(object memento)
        {
            PointMemento pointMemento = memento as PointMemento;

            if (pointMemento == null)
            {
                throw new ArgumentException("The provided memento is not the expected type.", "memento");
            }

            this.Subject.CoordinateSystem = CoordinateSystem.Source;
            try
            {
                this.Subject.Location = pointMemento.Point;
            }
            finally
            {
                this.Subject.ResetCoordinateSystem();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Restores the state of an object.
        /// </summary>
        /// <param name="memento">The object that was
        /// originally created with <see cref="IMemorable.CreateMemento"/>.</param>
        /// <remarks>
        /// The implementation of <see cref="IMemorable.SetMemento"/> should return the
        /// object to the original state captured by <see cref="IMemorable.CreateMemento"/>.
        /// </remarks>
        public void SetMemento(object memento)
        {
            PointMemento pointMemento = memento as PointMemento;

            if (pointMemento == null)
            {
                throw new ArgumentException("The provided memento is not the expected type.", "memento");
            }

            this.CoordinateSystem = CoordinateSystem.Source;
            try
            {
                // figure out what delta is needed to move the anchor to the desired point specified by the memento
                this.Move(Vector.CalculatePositionDelta(this.Anchor, pointMemento.Point));
            }
            finally
            {
                this.ResetCoordinateSystem();
            }
        }
Beispiel #7
0
        /// <summary>
        /// Restores the state of this <see cref="AnchorPointControlGraphic"/>.
        /// </summary>
        /// <param name="memento">The object that was originally created with <see cref="AnchorPointControlGraphic.CreateMemento"/>.</param>
        public override void SetMemento(object memento)
        {
            PointMemento pointMemento = memento as PointMemento;

            if (pointMemento == null)
            {
                throw new ArgumentException("The provided memento is not the expected type.", "memento");
            }

            _suspendSubjectPointChangeEvents = true;
            this.Subject.CoordinateSystem    = CoordinateSystem.Source;
            try
            {
                this.Subject.Point = pointMemento.Point;
            }
            finally
            {
                this.Subject.ResetCoordinateSystem();
                _suspendSubjectPointChangeEvents = false;
                this.OnSubjectPointChanged(this, EventArgs.Empty);
            }
        }