Hi,
In my application I need to store pen objects in a file so they can be
read in at a latter stage from the file to recreate the pen objects in
memory. I'm currently doing this by hand, blindly writing out all the
properties of a pen like a donkey! Surely there must be a neat way in
..NET to read and write such objects? I don't want to simply serialize
the object as that would include a lot of stuff in the file I'm not
interested in. In the future I need to do a similar thing for brushes.
The code below shows how I write and read the compound array property
of a pen:
// Write pen's Compound array
int compLength = edgePens[i].CompoundArray.Length;
binaryWriter.Write(compLength);
for (int j = 0; j < compLength; j++)
{
binaryWriter.Write((double)edgePens[i].CompoundArray[j]);
}
// Read Pen's Compound array
int compLength = binaryReader.ReadInt32();
float compArray = new float[compLength]
for (int j = 0; j < compLength; j++)
{
compArray[j] = (float)binaryReader.ReadDouble()
}
Which as you can see, is a bit ugly when you have to do this kind of
thing for all the pen's properties!
Any help much appreciated.
Tristan.