Exemplo n.º 1
0
        /// <summary>
        /// Removes the specified channel.
        /// </summary>
        /// <param name="channel">The channel to remove.</param>
        public void RemoveChannel(MotionChannel channel)
        {
            if (!channels.Contains(channel))
            {
                throw new ArgumentException("channel", "Channel list does not contain the specified channel");
            }

            int channelIndex = channels.IndexOf(channel);

            RemoveChannel(channelIndex);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Adds the specified channel.
 /// </summary>
 /// <param name="channel">The channel to add.</param>
 public void AddChannel(MotionChannel channel)
 {
     channel.FrameCount = frameCount;
     channels.Add(channel);
 }