Instead of "rectangle.ShapeType =" you should use:
rectangle.SetShapeType( (int)ShapeTypes.Rectangle );
(ShapeType is POI enumeration.)rectangle.SetShapeType( (int)ShapeTypes.Rectangle );
(ShapeType is POI enumeration.)