Professional Documents
Culture Documents
using System.Collections.Generic;
using System.Diagnostics;
usin
prop.SetValue(list);
break;
}
case IDENTIFIER.COLORLIST:
{
int numColors = header.sizeInBytes / 4;
var list = new List<Color>(numColors);
prop.SetValue(list);
break;
}
case IDENTIFIER.STRING:
{
int numChars = header.sizeInBytes / 2;
string text = "";
start = cursor;
return prop;
}
switch ((IDENTIFIER)prop.Header.typeID)
{
case IDENTIFIER.INTLIST:
{
if(prop.Header.sizeInBytes != 0)
{
var list = prop.GetValue() as List<Int32>;
writer.Write(list.Count);
PadToMultipleOf(writer, 8);
break;
}
case IDENTIFIER.COLORLIST:
{
if (prop.Header.sizeInBytes != 0)
{
var list = prop.GetValue() as List<Color>;
PadToMultipleOf(writer, 8);
break;
}
case IDENTIFIER.STRING:
{
var str = prop.GetValue() as string;
writer.Write(Encoding.Unicode.GetBytes(str));
writer.Write((ushort)0); // null term.
PadToMultipleOf(writer, 8);
break;
}
// 32 byte property, (header carries data)
case IDENTIFIER.FILENAME:
case IDENTIFIER.FILENAME_LITE:
case IDENTIFIER.DISKSTREAM:
case IDENTIFIER.FONT:
{
// data is in the header
break;
}
// 40 byte property (32 byte header + 4 byte int + 4 byte padding)
case IDENTIFIER.INT:
case IDENTIFIER.SIZE:
case IDENTIFIER.ENUM:
case IDENTIFIER.HIGHCONTRASTCOLORTYPE:
{
if (prop.Header.shortFlag == 0)
{
writer.Write((int)prop.GetValue());
}
PadToMultipleOf(writer, 8);
break;
}
// 40 byte property, (32 byte header + 4 byte bool + 4 byte
padding)
case IDENTIFIER.BOOLTYPE:
{
if (prop.Header.shortFlag == 0)
{
int val = (bool)prop.GetValue() ? 1 : 0;
writer.Write(val);
}
PadToMultipleOf(writer, 8);
break;
}
// 40 byte property, (32 byte header + 4 byte color type + 4 byte
padding)
case IDENTIFIER.COLOR:
{
if (prop.Header.shortFlag == 0)
{
Color col = (Color)prop.GetValue();
writer.Write(col.R);
writer.Write(col.G);
writer.Write(col.B);
writer.Write((byte)0);
}
PadToMultipleOf(writer, 8);
break;
}
// 40 byte property, (32 byte header + 8 byte position type)
case IDENTIFIER.POSITION:
{
if (prop.Header.shortFlag == 0)
{
Size s = (Size)prop.GetValue();
writer.Write(s.Width);
writer.Write(s.Height);
}
PadToMultipleOf(writer, 8);
break;
}
// 48 byte property, (32 byte header + 12 byte rect type)
case IDENTIFIER.RECTTYPE:
case IDENTIFIER.MARGINS:
{
if (prop.Header.shortFlag == 0)
{
Margins m = prop.GetValue() as Margins;
writer.Wri