public bool readFromStream(FileStream stream)
        {
            byte[] buffer = new byte[length];
            int    result = stream.Read(buffer, 0, buffer.Length);

            if (result != buffer.Length)
            {
                return(false);
            }

            MemoryInputStream ms = new MemoryInputStream(buffer, isLittleEndian);

            downTime            = ms.readInt64();
            upTimeFromDownTime  = ms.readInt32();
            pageId              = ms.readInt32();
            status              = (byte)ms.ReadByte();
            penTipType          = (byte)ms.ReadByte();
            penTipColor         = ms.readInt32();
            codeTableFileNumber = ms.readInt16();
            codeTableFileOffset = ms.readInt32();
            codeCount           = ms.readInt16();
            successRate         = (byte)ms.ReadByte();
            checkSum            = (byte)ms.ReadByte();

            byte sum = ms.getByteCheckSum(0, buffer.Length - 1);

            return(sum == checkSum);
        }
        public bool readFromStream(FileStream stream)
        {
            byte[] buffer = new byte[length];
            int    result = stream.Read(buffer, 0, buffer.Length);

            if (result != buffer.Length)
            {
                return(false);
            }

            MemoryInputStream ms = new MemoryInputStream(buffer, isLittleEndian);

            timestampDelta = (byte)ms.ReadByte();
            force          = ms.readInt16();

            x  = ms.readInt16() & 0xffff;
            y  = ms.readInt16() & 0xffff;
            fx = ms.ReadByte() & 0xff;
            fy = ms.ReadByte() & 0xff;

            xTilt      = (byte)ms.ReadByte();
            yTilt      = (byte)ms.ReadByte();
            twist      = ms.readInt16();
            labelCount = (byte)ms.ReadByte();
            brightnessAndProcessTime = (byte)ms.ReadByte();
            checkSum = (byte)ms.ReadByte();

            byte sum = ms.getByteCheckSum(0, buffer.Length - 1);

            return(sum == checkSum);
        }
Esempio n. 3
0
        public void ReadByte_EndOfStream_ReturnEndOfStreamIntCode()
        {
            // Arrange
            const int    endOfFileCode     = -1;
            IInputStream memoryInputStream = new MemoryInputStream(new byte[0]);

            // Act
            int result = memoryInputStream.ReadByte();

            memoryInputStream.Dispose();

            // Assert
            Assert.Equal(endOfFileCode, result);
        }
Esempio n. 4
0
        public void ReadByte_StreamWithData_ReturnFirstByte()
        {
            // Arrange
            const int    expectedResult    = 0x31;
            IInputStream memoryInputStream = new MemoryInputStream(new byte[] { 0x31, 0x32 });

            // Act
            int result = memoryInputStream.ReadByte();

            memoryInputStream.Dispose();

            // Assert
            Assert.Equal(expectedResult, result);
        }
        public bool readFromStream(FileStream stream)
        {
            byte[] buffer = new byte[length];
            int    result = stream.Read(buffer, 0, buffer.Length);

            if (result != buffer.Length)
            {
                return(false);
            }

            isLittleEndian = buffer[endianByteIndex] != 0;

            MemoryInputStream ms = new MemoryInputStream(buffer, isLittleEndian);

            fileType = (byte)ms.ReadByte();
            if ((char)fileType != 'C')
            {
                return(false);
            }

            version    = ms.readInt16();
            fileNumber = ms.readInt16();

            long n = ms.readInt64();

            sectionId = (int)(n >> 56);
            ownerId   = (int)(n >> 32) & 0x00ffffff;
            noteId    = (int)(n & 0xffffffff);

            ms.Read(macAddress, 0, macAddress.Length);
            ms.Read(reserved, 0, reserved.Length);
            checkSum = (byte)ms.ReadByte();

            byte sum = ms.getByteCheckSum(0, buffer.Length - 1);

            return(sum == checkSum);
        }