コード例 #1
0
        /// <summary>
        /// Restores the state of this <see cref="VerticesControlGraphic"/>.
        /// </summary>
        /// <param name="memento">The object that was originally created with <see cref="VerticesControlGraphic.CreateMemento"/>.</param>
        public override void SetMemento(object memento)
        {
            PointsMemento pointsMemento = memento as PointsMemento;

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

            _suspendSubjectPointChangeEvents = true;
            this.Subject.CoordinateSystem    = CoordinateSystem.Source;
            try
            {
                int numPoints = Math.Min(this.Subject.Points.Count, pointsMemento.Count);
                for (int n = 0; n < numPoints; n++)
                {
                    this.Subject.Points[n] = pointsMemento[n];
                }
                for (int n = numPoints; n < this.Subject.Points.Count; n++)
                {
                    this.Subject.Points.RemoveAt(numPoints);
                }
                for (int n = numPoints; n < pointsMemento.Count; n++)
                {
                    this.Subject.Points.Add(pointsMemento[n]);
                }
            }
            finally
            {
                this.Subject.ResetCoordinateSystem();
                _suspendSubjectPointChangeEvents = false;
                this.OnSubjectPointsChanged(this, new EventArgs());
            }
        }
コード例 #2
0
        /// <summary>
        /// Captures the current state of this <see cref="LineSegmentStretchControlGraphic"/>.
        /// </summary>
        public override object CreateMemento()
        {
            PointsMemento pointsMemento = new PointsMemento();

            this.Subject.CoordinateSystem = CoordinateSystem.Source;
            try
            {
                pointsMemento.Add(this.Subject.Point1);
                pointsMemento.Add(this.Subject.Point2);
            }
            finally
            {
                this.Subject.ResetCoordinateSystem();
            }

            return(pointsMemento);
        }
コード例 #3
0
        /// <summary>
        /// Captures the current state of this <see cref="VerticesControlGraphic"/>.
        /// </summary>
        public override object CreateMemento()
        {
            PointsMemento pointsMemento = new PointsMemento();

            this.Subject.CoordinateSystem = CoordinateSystem.Source;
            try
            {
                foreach (PointF point in this.Subject.Points)
                {
                    pointsMemento.Add(point);
                }
            }
            finally
            {
                this.Subject.ResetCoordinateSystem();
            }

            return(pointsMemento);
        }
コード例 #4
0
        /// <summary>
        /// Restores the state of this <see cref="LineSegmentStretchControlGraphic"/>.
        /// </summary>
        /// <param name="memento">The object that was originally created with <see cref="LineSegmentStretchControlGraphic.CreateMemento"/>.</param>
        public override void SetMemento(object memento)
        {
            PointsMemento pointsMemento = memento as PointsMemento;

            if (pointsMemento == null || pointsMemento.Count != 2)
            {
                throw new ArgumentException("The provided memento is not the expected type.", "memento");
            }

            this.Subject.CoordinateSystem = CoordinateSystem.Source;
            try
            {
                this.Subject.Point1 = pointsMemento[0];
                this.Subject.Point2 = pointsMemento[1];
            }
            finally
            {
                this.Subject.ResetCoordinateSystem();
            }
        }
コード例 #5
0
        public bool Equals(PointsMemento other)
        {
            if (this == other)
            {
                return(true);
            }
            if (other == null || this.Count != other.Count)
            {
                return(false);
            }

            for (int i = 0; i < this.Count; i++)
            {
                if (this[i] != other[i])
                {
                    return(false);
                }
            }
            return(true);
        }