void SelectPenRecord (float lineWidth)
{
var lineWidthInTwips = (int)(lineWidth * TwipsFromUnits + 0.5f);
var objectIndex = -1;
for (var i = 2; i < objects.Count; i++) {
var o = objects[i];
if (!o.IsBrush && o.WidthInTwips == lineWidthInTwips && o.Color == _lastColor) {
objectIndex = i;
break;
}
}
if (objectIndex < 0) {
var pen = new GObject {
IsBrush = false,
WidthInTwips = lineWidthInTwips,
Color = _lastColor,
};
objectIndex = objects.Count;
objects.Add (pen);
StartRecord (Function.CreatePenIndirect);
rw.Write ((ushort)PenStyle.Solid);
rw.Write ((ushort)lineWidthInTwips); // PointS.x = width of pen (0 = default)
rw.Write ((ushort)0); // PointS.y
rw.Write ((byte)_lastColor.Red); // ColorRef.Red
rw.Write ((byte)_lastColor.Green); // ColorRef.Green
rw.Write ((byte)_lastColor.Blue); // ColorRef.Blue
rw.Write ((byte)0); // ColorRef.Reserved
EndRecord ();
}
SelectObjectRecord (objectIndex);
}