public static UInt16 Get(BasicTypeDeSerializerContext context, UInt16 data) { data = Get(context); data <<= 8; data |= Get(context); return(data); }
public static Int16 Get(BasicTypeDeSerializerContext context, Int16 data) { UInt16 temp; temp = Get(context); temp <<= 8; temp |= Get(context); return (Int16)temp; }
public static Int16 Get(BasicTypeDeSerializerContext context, Int16 data) { UInt16 temp; temp = Get(context); temp <<= 8; temp |= Get(context); return((Int16)temp); }
public static Int32 Get(BasicTypeDeSerializerContext context, Int32 data) { data = Get(context); data <<= 8; data |= Get(context); data <<= 8; data |= Get(context); data <<= 8; data |= Get(context); return(data); }
public static byte[] Get(BasicTypeDeSerializerContext context, byte[] bytes) { ushort length = 0; length = Get(context, length); if (length != 0) { var buffer = new byte[length]; var index = 0; while (length-- != 0) { buffer[index++] = Get(context); } return(buffer); } return(null); }
public static UInt64[] Get(BasicTypeDeSerializerContext context, UInt64[] array) { ushort length = 0; length = Get(context, length); if (length != 0) { var buffer = new UInt64[length]; var index = 0; UInt64 data = 0; while (length-- != 0) { buffer[index++] = Get(context, data); } return(buffer); } return(null); }
public static unsafe float Get(BasicTypeDeSerializerContext context, float data) { var temp = new byte[4]; if (context.IsLittleEndian) { // Reverse the buffer going from Big Endian (network byte order) to Little Endian temp[3] = context.Retrieve(); temp[2] = context.Retrieve(); temp[1] = context.Retrieve(); temp[0] = context.Retrieve(); } else // Already in Big Endian format { temp[0] = context.Retrieve(); temp[1] = context.Retrieve(); temp[2] = context.Retrieve(); temp[3] = context.Retrieve(); } UInt32 value = Utility.ExtractValueFromArray(temp, 0, 4); return(*((float *)&value)); }
public static string Get(BasicTypeDeSerializerContext context, string text) { byte IsASCII = 0; IsASCII = Get(context); ushort length = 0; length = Get(context, length); if (length != 0) { if (IsASCII == 1) { var bytes = new byte[length]; var index = 0; while (length-- != 0) { bytes[index++] = Get(context); } Get(context); // Skip null byte terminator return(new string(Encoding.UTF8.GetChars(bytes))); } else { var unicodeChars = new char[length]; var index = 0; ushort unicodeChar = 0; while (length-- != 0) { unicodeChars[index++] = (char)Get(context, unicodeChar); } Get(context, unicodeChar); // Skip null character terminator return(new string(unicodeChars)); } } return(""); }
private void GetDrawArrow(BasicTypeDeSerializerContext context) { ushort x = 0; ushort y = 0; ushort size = 0; ushort direction = 0; ushort color = 0; x = BasicTypeDeSerializer.Get(context, x); y = BasicTypeDeSerializer.Get(context, y); size = BasicTypeDeSerializer.Get(context, size); direction = BasicTypeDeSerializer.Get(context, direction); color = BasicTypeDeSerializer.Get(context, color); DrawArrow(x, y, size, (DrawingDirection)direction, (BasicColor)color); }
private void GetDrawCornerFilled(BasicTypeDeSerializerContext context) { ushort xCenter = 0; ushort yCenter = 0; ushort radius = 0; ushort position = 0; ushort color = 0; xCenter = BasicTypeDeSerializer.Get(context, xCenter); yCenter = BasicTypeDeSerializer.Get(context, yCenter); radius = BasicTypeDeSerializer.Get(context, radius); position = BasicTypeDeSerializer.Get(context, position); color = BasicTypeDeSerializer.Get(context, color); DrawCornerFilled(xCenter, yCenter, radius, (CornerPosition)position, (BasicColor)color); }
private void GetDrawCircleFilled(BasicTypeDeSerializerContext context) { ushort xCenter = 0; ushort yCenter = 0; ushort radius = 0; ushort color = 0; xCenter = BasicTypeDeSerializer.Get(context, xCenter); yCenter = BasicTypeDeSerializer.Get(context, yCenter); radius = BasicTypeDeSerializer.Get(context, radius); color = BasicTypeDeSerializer.Get(context, color); DrawCircleFilled(xCenter, yCenter, radius, (BasicColor)color); }
private void GetDrawLineDotted(BasicTypeDeSerializerContext context) { ushort x0 = 0; ushort y0 = 0; ushort x1 = 0; ushort y1 = 0; ushort empty = 0; ushort solid = 0; ushort color = 0; x0 = BasicTypeDeSerializer.Get(context, x0); y0 = BasicTypeDeSerializer.Get(context, y0); x1 = BasicTypeDeSerializer.Get(context, x1); y1 = BasicTypeDeSerializer.Get(context, y1); color = BasicTypeDeSerializer.Get(context, color); empty = BasicTypeDeSerializer.Get(context, empty); solid = BasicTypeDeSerializer.Get(context, solid); DrawLineDotted(x0, y0, x1, y1, empty, solid, (BasicColor)color); }
public static void Main() { var contextSerializer = new BasicTypeSerializerContext(); BasicTypeSerializer.Put(contextSerializer,(byte)byte.MaxValue); BasicTypeSerializer.Put(contextSerializer,(UInt16)UInt16.MaxValue); BasicTypeSerializer.Put(contextSerializer,(Int16)Int16.MinValue); BasicTypeSerializer.Put(contextSerializer,(UInt32)UInt32.MaxValue); BasicTypeSerializer.Put(contextSerializer,(Int32)Int32.MinValue); BasicTypeSerializer.Put(contextSerializer,(UInt64)UInt64.MaxValue); BasicTypeSerializer.Put(contextSerializer,(Int64)Int64.MinValue); BasicTypeSerializer.Put(contextSerializer,(float)float.MaxValue); BasicTypeSerializer.Put(contextSerializer,(float)float.MinValue); BasicTypeSerializer.Put(contextSerializer,"Unicode String"); BasicTypeSerializer.Put(contextSerializer,"ASCII String",true); BasicTypeSerializer.Put(contextSerializer,new byte[] { byte.MinValue, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, byte.MaxValue }); BasicTypeSerializer.Put(contextSerializer,new ushort[] { ushort.MinValue, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, UInt16.MaxValue }); BasicTypeSerializer.Put(contextSerializer,new UInt32[] { UInt32.MinValue, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, UInt32.MaxValue }); BasicTypeSerializer.Put(contextSerializer,new UInt64[] { UInt64.MinValue, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, UInt64.MaxValue }); byte byteValue = 0; UInt16 UInt16Value = 0; Int16 Int16Value = 0; UInt32 UInt32Value = 0; Int32 Int32Value = 0; UInt64 UInt64Value = 0; Int64 Int64Value = 0; float floatValue = 0.0F; string UnicodeString = null; string AsciiString = null; byte[] byteArray = null; ushort[] ushortArray = null; UInt32[] UInt32Array = null; UInt64[] UInt64Array = null; Debug.Print("sizeof(byte)=" + sizeof(byte)); Debug.Print("sizeof(UInt16)=" + sizeof(UInt16)); Debug.Print("sizeof(Int16)=" + sizeof(Int16)); Debug.Print("sizeof(UInt32)=" + sizeof(UInt32)); Debug.Print("sizeof(Int32)=" + sizeof(Int32)); Debug.Print("sizeof(UInt64)=" + sizeof(UInt64)); Debug.Print("sizeof(Int64)=" + sizeof(Int64)); Debug.Print("sizeof(float)=" + sizeof(float)); Debug.Print("sizeof(double)=" + sizeof(double)); var contextDeserializer = new BasicTypeDeSerializerContext(contextSerializer.GetBuffer()); byteValue = BasicTypeDeSerializer.Get(contextDeserializer); if (byteValue != byte.MaxValue) throw new ApplicationException("byteValue"); UInt16Value = BasicTypeDeSerializer.Get(contextDeserializer, UInt16Value); if (UInt16Value != UInt16.MaxValue) throw new ApplicationException("UInt16Value"); Int16Value = BasicTypeDeSerializer.Get(contextDeserializer, Int16Value); if (Int16Value != Int16.MinValue) throw new ApplicationException("Int16Value"); UInt32Value = BasicTypeDeSerializer.Get(contextDeserializer, UInt32Value); if (UInt32Value != UInt32.MaxValue) throw new ApplicationException("UInt32Value"); Int32Value = BasicTypeDeSerializer.Get(contextDeserializer, Int32Value); if (Int32Value != Int32.MinValue) throw new ApplicationException("Int32Value"); UInt64Value = BasicTypeDeSerializer.Get(contextDeserializer, UInt64Value); if (UInt64Value != UInt64.MaxValue) throw new ApplicationException("UInt64Value"); Int64Value = BasicTypeDeSerializer.Get(contextDeserializer, Int64Value); if (Int64Value != Int64.MinValue) throw new ApplicationException("Int64Value"); floatValue = BasicTypeDeSerializer.Get(contextDeserializer, floatValue); if (floatValue != float.MaxValue) throw new ApplicationException("floatValue"); floatValue = BasicTypeDeSerializer.Get(contextDeserializer, floatValue); if (floatValue != float.MinValue) throw new ApplicationException("floatValue"); UnicodeString = BasicTypeDeSerializer.Get(contextDeserializer, ""); if (UnicodeString != "Unicode String") throw new ApplicationException("UnicodeString"); AsciiString = BasicTypeDeSerializer.Get(contextDeserializer, ""); if (AsciiString != "ASCII String") throw new ApplicationException("AsciiString"); byteArray = BasicTypeDeSerializer.Get(contextDeserializer, byteArray); if (byteArray[0] != byte.MinValue || byteArray[15] != byte.MaxValue) throw new ApplicationException("byteArray"); ushortArray = BasicTypeDeSerializer.Get(contextDeserializer, ushortArray); if (ushortArray[0] != ushort.MinValue || ushortArray[15] != ushort.MaxValue) throw new ApplicationException("ushortArray"); UInt32Array = BasicTypeDeSerializer.Get(contextDeserializer, UInt32Array); if (UInt32Array[0] != UInt32.MinValue || UInt32Array[15] != UInt32.MaxValue) throw new ApplicationException("UInt32Array"); UInt64Array = BasicTypeDeSerializer.Get(contextDeserializer, UInt64Array); if (UInt64Array[0] != UInt64.MinValue || UInt64Array[15] != UInt64.MaxValue) throw new ApplicationException("UInt64Array"); }
public static string Get(BasicTypeDeSerializerContext context, string text) { byte IsASCII = 0; IsASCII = Get(context); ushort length = 0; length = Get(context, length); if (length != 0) { if (IsASCII == 1) { var bytes = new byte[length]; var index = 0; while (length-- != 0) { bytes[index++] = Get(context); } Get(context); // Skip null byte terminator return new string(Encoding.UTF8.GetChars(bytes)); } else { var unicodeChars = new char[length]; var index = 0; ushort unicodeChar = 0; while (length-- != 0) { unicodeChars[index++] = (char)Get(context, unicodeChar); } Get(context, unicodeChar); // Skip null character terminator return new string(unicodeChars); } } return ""; }
private void GetDrawTriangleFilled(BasicTypeDeSerializerContext context) { ushort x0 = 0; ushort y0 = 0; ushort x1 = 0; ushort y1 = 0; ushort x2 = 0; ushort y2 = 0; ushort color = 0; x0 = BasicTypeDeSerializer.Get(context, x0); y0 = BasicTypeDeSerializer.Get(context, y0); x1 = BasicTypeDeSerializer.Get(context, x1); y1 = BasicTypeDeSerializer.Get(context, y1); x2 = BasicTypeDeSerializer.Get(context, x2); y2 = BasicTypeDeSerializer.Get(context, y2); color = BasicTypeDeSerializer.Get(context, color); DrawTriangleFilled(x0, y0, x1, y1, x2, y2, (BasicColor)color); }
public static byte Get(BasicTypeDeSerializerContext context) { return context.Retrieve(); }
private void GetDrawCirclePoints(BasicTypeDeSerializerContext context) { ushort cx = 0; ushort cy = 0; ushort x = 0; ushort y = 0; ushort color = 0; cx = BasicTypeDeSerializer.Get(context, cx); cy = BasicTypeDeSerializer.Get(context, cy); x = BasicTypeDeSerializer.Get(context, x); y = BasicTypeDeSerializer.Get(context, y); color = BasicTypeDeSerializer.Get(context, color); DrawCirclePoints(cx, cy, x, y, (BasicColor)color); }
private void GetDrawString(BasicTypeDeSerializerContext context) { ushort x = 0; ushort y = 0; ushort color = 0; ushort fontInfoID = 0; string text; x = BasicTypeDeSerializer.Get(context, x); y = BasicTypeDeSerializer.Get(context, y); color = BasicTypeDeSerializer.Get(context, color); fontInfoID = BasicTypeDeSerializer.Get(context, fontInfoID); text = BasicTypeDeSerializer.Get(context, ""); DrawString(x, y, (BasicColor)color, FontInfoLookUp(fontInfoID), text); }
private void GetDrawIcon16(BasicTypeDeSerializerContext context) { ushort x = 0; ushort y = 0; ushort color = 0; ushort[] icon = null; x = BasicTypeDeSerializer.Get(context, x); y = BasicTypeDeSerializer.Get(context, y); color = BasicTypeDeSerializer.Get(context, color); icon = BasicTypeDeSerializer.Get(context, icon); DrawIcon16(x, y, (BasicColor)color, icon); }
private void GetDrawButton(BasicTypeDeSerializerContext context) { ushort x=0; ushort y=0; ushort width=0; ushort height=0; ushort fontInfoID=0; ushort fontHeight=0; ushort borderColor=0; ushort fillColor=0; ushort fontColor=0; string text; ushort cornerStyle = 0; x = BasicTypeDeSerializer.Get(context, x); y = BasicTypeDeSerializer.Get(context, y); width = BasicTypeDeSerializer.Get(context, width); height = BasicTypeDeSerializer.Get(context, height); fontInfoID = BasicTypeDeSerializer.Get(context, fontInfoID); fontHeight = BasicTypeDeSerializer.Get(context, fontHeight); borderColor = BasicTypeDeSerializer.Get(context, borderColor); fillColor = BasicTypeDeSerializer.Get(context, fillColor); fontColor = BasicTypeDeSerializer.Get(context, fontColor); text = BasicTypeDeSerializer.Get(context, ""); cornerStyle = BasicTypeDeSerializer.Get(context, cornerStyle); DrawButton( x, y, width, height, FontInfoLookUp(fontInfoID), fontHeight, (BasicColor)borderColor, (BasicColor)fillColor, (BasicColor)fontColor, text, (RoundedCornerStyle)cornerStyle); }
private void GetDrawProgressBar(BasicTypeDeSerializerContext context) { ushort x = 0; ushort y = 0; ushort width = 0; ushort height = 0; ushort borderCorners = 0; ushort progressCorners = 0; ushort borderColor = 0; ushort borderFillColor = 0; ushort progressBorderColor = 0; ushort progressFillColor = 0; ushort progress = 0; x = BasicTypeDeSerializer.Get(context, x); y = BasicTypeDeSerializer.Get(context, y); width = BasicTypeDeSerializer.Get(context, width); height = BasicTypeDeSerializer.Get(context, height); borderCorners = BasicTypeDeSerializer.Get(context, borderCorners); progressCorners = BasicTypeDeSerializer.Get(context, progressCorners); borderColor = BasicTypeDeSerializer.Get(context, borderColor); borderFillColor = BasicTypeDeSerializer.Get(context, borderFillColor); progressBorderColor = BasicTypeDeSerializer.Get(context, progressBorderColor); progressFillColor = BasicTypeDeSerializer.Get(context, progressFillColor); progress = BasicTypeDeSerializer.Get(context, progress); DrawProgressBar( x, y, width, height, (RoundedCornerStyle)borderCorners,(RoundedCornerStyle)progressCorners, (BasicColor)borderColor, (BasicColor)borderFillColor, (BasicColor)progressBorderColor, (BasicColor)progressFillColor, progress); }
private void GetDrawRectangle(BasicTypeDeSerializerContext context) { ushort x0 = 0; ushort y0 = 0; ushort x1 = 0; ushort y1 = 0; ushort color = 0; x0 = BasicTypeDeSerializer.Get(context, x0); y0 = BasicTypeDeSerializer.Get(context, y0); x1 = BasicTypeDeSerializer.Get(context, x1); y1 = BasicTypeDeSerializer.Get(context, y1); color = BasicTypeDeSerializer.Get(context, color); DrawRectangle(x0, y0, x1, y1, (BasicColor)color); }
private void GetDrawRectangleRounded(BasicTypeDeSerializerContext context) { ushort x0 = 0; ushort y0 = 0; ushort x1 = 0; ushort y1 = 0; ushort color = 0; ushort radius = 0; ushort corners = 0; x0 = BasicTypeDeSerializer.Get(context, x0); y0 = BasicTypeDeSerializer.Get(context, y0); x1 = BasicTypeDeSerializer.Get(context, x1); y1 = BasicTypeDeSerializer.Get(context, y1); color = BasicTypeDeSerializer.Get(context, color); radius = BasicTypeDeSerializer.Get(context, radius); corners = BasicTypeDeSerializer.Get(context, corners); DrawRectangleRounded(x0, y0, x1, y1, (BasicColor)color, radius, (RoundedCornerStyle)corners); }
public static UInt64[] Get(BasicTypeDeSerializerContext context, UInt64[] array) { ushort length = 0; length = Get(context, length); if (length != 0) { var buffer = new UInt64[length]; var index = 0; UInt64 data = 0; while (length-- != 0) { buffer[index++] = Get(context, data); } return buffer; } return null; }
public static byte[] Get(BasicTypeDeSerializerContext context, byte[] bytes) { ushort length = 0; length = Get(context, length); if (length != 0) { var buffer = new byte[length]; var index = 0; while (length-- != 0) { buffer[index++] = Get(context); } return buffer; } return null; }
public static Int64 Get(BasicTypeDeSerializerContext context, Int64 data) { return (Int64)Get(context, (UInt64)data); }
private void GetSetOrientation(BasicTypeDeSerializerContext context) { ushort orientation = 0; orientation = BasicTypeDeSerializer.Get(context, orientation); SetOrientation((LCD.Orientation)orientation); }
public static UInt32 Get(BasicTypeDeSerializerContext context, UInt32 data) { data = Get(context); data <<= 8; data |= Get(context); data <<= 8; data |= Get(context); data <<= 8; data |= Get(context); return data; }
public static Int64 Get(BasicTypeDeSerializerContext context, Int64 data) { return((Int64)Get(context, (UInt64)data)); }
public void Replay(BasicTypeDeSerializerContext context) { if (context == null) throw new ArgumentNullException("context"); byte command = 0; while (context.MoreData) { command = BasicTypeDeSerializer.Get(context); switch ((Command)command) { case Command.DrawTestPattern: DrawTestPattern(); break; case Command.DrawPixel: GetDrawPixel(context); break; case Command.DrawFill: GetDrawFill(context); break; case Command.DrawLine: GetDrawLine(context); break; case Command.DrawLineDotted: GetDrawLineDotted(context); break; case Command.DrawCircle: GetDrawCircle(context); break; case Command.DrawCircleFilled: GetDrawCircleFilled(context); break; case Command.DrawCornerFilled: GetDrawCornerFilled(context); break; case Command.DrawArrow: GetDrawArrow(context); break; case Command.DrawRectangle: GetDrawRectangle(context); break; case Command.DrawRectangleFilled: GetDrawRectangleFilled(context); break; case Command.DrawRectangleRounded: GetDrawRectangleRounded(context); break; case Command.DrawTriangle: GetDrawTriangle(context); break; case Command.DrawTriangleFilled: GetDrawTriangleFilled(context); break; case Command.DrawProgressBar: GetDrawProgressBar(context); break; case Command.DrawButton: GetDrawButton(context); break; case Command.DrawIcon16: GetDrawIcon16(context); break; case Command.DrawString: GetDrawString(context); break; case Command.DrawBitmapImage: throw new NotImplementedException("command"); case Command.DrawCirclePoints: GetDrawCirclePoints(context); break; case Command.SetOrientation: GetSetOrientation(context); break; default: throw new ApplicationException("command"); } } }
private void GetDrawPixel(BasicTypeDeSerializerContext context) { ushort x = 0; ushort y = 0; ushort color = 0; x = BasicTypeDeSerializer.Get(context, x); y = BasicTypeDeSerializer.Get(context, y); color = BasicTypeDeSerializer.Get(context, color); DrawPixel(x, y, (BasicColor)color); }
private void GetDrawFill(BasicTypeDeSerializerContext context) { ushort color = 0; color = BasicTypeDeSerializer.Get(context, color); DrawFill((BasicColor)color); }
public static byte Get(BasicTypeDeSerializerContext context) { return(context.Retrieve()); }
public static unsafe float Get(BasicTypeDeSerializerContext context, float data) { var temp = new byte[4]; if (context.IsLittleEndian) { // Reverse the buffer going from Big Endian (network byte order) to Little Endian temp[3] = context.Retrieve(); temp[2] = context.Retrieve(); temp[1] = context.Retrieve(); temp[0] = context.Retrieve(); } else { // Already in Big Endian format temp[0] = context.Retrieve(); temp[1] = context.Retrieve(); temp[2] = context.Retrieve(); temp[3] = context.Retrieve(); } UInt32 value = Utility.ExtractValueFromArray(temp, 0, 4); return *((float*)&value); }