コード例 #1
0
ファイル: Animation.cs プロジェクト: sahwar/Pixelaria
        /// <summary>
        /// Internal method that adds the given frame to this Animation. The method has an optional flag to specify
        /// that the dimensions should not be tested, and if set to true no exceptions will be thrown if the frame's
        /// dimensions don't match this animation's.
        /// The method does nothing if the frame is already in this animation
        /// </summary>
        /// <param name="frame">The frame to add to this animation</param>
        /// <param name="index">The index to add the frame at. -1 adds the frame to the end of the frame list</param>
        /// <param name="ignoreSize">Whether to ignore the size of the frame and add it even if it is in different dimensions than the rest of the animation</param>
        // ReSharper disable once UnusedParameter.Local
        private void InternalAddFrame(IFrame frame, int index, bool ignoreSize = false)
        {
            if (!frame.Initialized)
            {
                throw new ArgumentException("The frame provided has not been intialized");
            }

            if (_frames.ContainsReference(frame))
            {
                return;
            }

            if (!ignoreSize && (frame.Width != Width || frame.Height != Height))
            {
                throw new ArgumentException(AnimationMessages.Exception_UnmatchedFramedimensions, nameof(frame));
            }

            frame.Added(this);

            if (frame.ID == -1 && FrameIdGenerator != null)
            {
                frame.ID = FrameIdGenerator.GetNextUniqueFrameId();
            }

            if (index == -1)
            {
                _frames.Add(frame);
            }
            else
            {
                _frames.Insert(index, frame);
            }
        }