public RDPINPUT_CONTACT_DATA()
 {
     fieldsPresent = new TWO_BYTE_UNSIGNED_INTEGER();
     x = new FOUR_BYTE_SIGNED_INTEGER();
     y = new FOUR_BYTE_SIGNED_INTEGER();
     contactFlags = new FOUR_BYTE_UNSIGNED_INTEGER();
     contactRectLeft = null;
     contactRectTop = null;
     contactRectRight = null;
     contactRectBottom = null;
     orientation = null;
     pressure = null;
 }
        public override bool Decode(PduMarshaler marshaler)
        {
            try
            {
                if (!base.Decode(marshaler))
                {
                    return false;
                }
                encodeTime = new FOUR_BYTE_UNSIGNED_INTEGER();
                if (!encodeTime.Decode(marshaler))
                {
                    return false;
                }
                frameCount = new TWO_BYTE_UNSIGNED_INTEGER();
                if (!frameCount.Decode(marshaler))
                {
                    return false;
                }
                ushort count = frameCount.ToUShort();
                if (count > 0)
                {
                    frames = new RDPINPUT_TOUCH_FRAME[count];
                }
                for (int i = 0; i < count; i++)
                {
                    frames[i] = new RDPINPUT_TOUCH_FRAME();
                    if (!frames[i].contactCount.Decode(marshaler) || !frames[i].frameOffset.Decode(marshaler))
                    {
                        return false;
                    }
                    ushort contactCount = frames[i].contactCount.ToUShort();
                    if (contactCount > 0)
                    {
                        frames[i].contacts = new RDPINPUT_CONTACT_DATA[contactCount];
                    }
                    for (int j = 0; j < contactCount; j++)
                    {
                        frames[i].contacts[j] = new RDPINPUT_CONTACT_DATA();
                        frames[i].contacts[j].contactId = marshaler.ReadByte();
                        if (!frames[i].contacts[j].fieldsPresent.Decode(marshaler) || !frames[i].contacts[j].x.Decode(marshaler)
                            || !frames[i].contacts[j].y.Decode(marshaler) || !frames[i].contacts[j].contactFlags.Decode(marshaler))
                        {
                            return false;
                        }

                        ushort fieldsPresent = frames[i].contacts[j].fieldsPresent.ToUShort();
                        if ((ushort)(fieldsPresent & (ushort)(RDPINPUT_CONTACT_DATA_FieldsPresent.CONTACT_DATA_CONTACTRECT_PRESENT)) == (ushort)RDPINPUT_CONTACT_DATA_FieldsPresent.CONTACT_DATA_CONTACTRECT_PRESENT)
                        {
                            TWO_BYTE_SIGNED_INTEGER left = new TWO_BYTE_SIGNED_INTEGER();
                            if (!left.Decode(marshaler))
                            {
                                return false;
                            }
                            frames[i].contacts[j].contactRectLeft = left;
                            TWO_BYTE_SIGNED_INTEGER top = new TWO_BYTE_SIGNED_INTEGER();
                            if (!top.Decode(marshaler))
                            {
                                return false;
                            }
                            frames[i].contacts[j].contactRectTop = top;
                            TWO_BYTE_SIGNED_INTEGER right = new TWO_BYTE_SIGNED_INTEGER();
                            if (!right.Decode(marshaler))
                            {
                                return false;
                            }
                            frames[i].contacts[j].contactRectRight = right;
                            TWO_BYTE_SIGNED_INTEGER bottom = new TWO_BYTE_SIGNED_INTEGER();
                            if (!bottom.Decode(marshaler))
                            {
                                return false;
                            }
                            frames[i].contacts[j].contactRectBottom = bottom;
                        }
                        if ((ushort)(fieldsPresent & (ushort)(RDPINPUT_CONTACT_DATA_FieldsPresent.CONTACT_DATA_ORIENTATION_PRESENT)) == (ushort)RDPINPUT_CONTACT_DATA_FieldsPresent.CONTACT_DATA_ORIENTATION_PRESENT)
                        {
                            FOUR_BYTE_UNSIGNED_INTEGER orientation = new FOUR_BYTE_UNSIGNED_INTEGER();
                            if (!orientation.Decode(marshaler))
                            {
                                return false;
                            }
                            frames[i].contacts[j].orientation = orientation;
                        }
                        if ((ushort)(fieldsPresent & (ushort)(RDPINPUT_CONTACT_DATA_FieldsPresent.CONTACT_DATA_PRESSURE_PRESENT)) == (ushort)RDPINPUT_CONTACT_DATA_FieldsPresent.CONTACT_DATA_PRESSURE_PRESENT)
                        {
                            FOUR_BYTE_UNSIGNED_INTEGER pressure = new FOUR_BYTE_UNSIGNED_INTEGER();
                            if (!pressure.Decode(marshaler))
                            {
                                return false;
                            }
                            frames[i].contacts[j].pressure = pressure;
                        }
                    }
                }
                return true;
            }
            catch
            {
                return false;
            }
        }