Esempio n. 1
0
        /// <summary>
        /// Adds the specified channel type.
        /// </summary>
        /// <param name="type">The type of channel to add.</param>
        /// <returns>The channel created.</returns>
        public MotionChannel AddChannel(ChannelType type)
        {
            if (!Enum.IsDefined(typeof(ChannelType), type))
            {
                throw new InvalidMotionChannelType((int)type);
            }

            MotionChannel channel = (MotionChannel)type.GetAttributeValue <MotionChannelTypeAttribute, object>(x => x.CreateInstance());

            AddChannel(channel);

            return(channel);
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the file from the specified stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public override void Load(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("EUC-KR"));

            string identifier = reader.ReadNullTerminatedString();

            if (string.Compare(identifier, FILE_IDENTIFIER, false) != 0)
            {
                throw new FileIdentifierMismatchException(FilePath, FILE_IDENTIFIER, identifier);
            }

            FramesPerSecond = reader.ReadInt32();
            int frameCount   = reader.ReadInt32();
            int channelCount = reader.ReadInt32();

            for (int i = 0; i < channelCount; i++)
            {
                ChannelType type = (ChannelType)reader.ReadInt32();

                if (!Enum.IsDefined(typeof(ChannelType), type))
                {
                    throw new InvalidMotionChannelType((int)type);
                }

                MotionChannel channel = (MotionChannel)type.GetAttributeValue <MotionChannelTypeAttribute, object>(x => x.CreateInstance());
                channel.Index      = reader.ReadInt32();
                channel.FrameCount = frameCount;

                channels.Add(channel);
            }

            for (int i = 0; i < frameCount; i++)
            {
                for (int j = 0; j < channelCount; j++)
                {
                    MotionChannel channel = channels[j];
                    channel.ReadFrame(reader, i);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Adds the specified channel type.
        /// </summary>
        /// <param name="type">The type of channel to add.</param>
        /// <returns>The channel created.</returns>
        public MotionChannel AddChannel(ChannelType type)
        {
            if (!Enum.IsDefined(typeof(ChannelType), type)) {
                throw new InvalidMotionChannelType((int)type);
            }

            MotionChannel channel = (MotionChannel)type.GetAttributeValue<MotionChannelTypeAttribute, object>(x => x.CreateInstance());
            AddChannel(channel);

            return channel;
        }