Just few tips, a triangle has 3 vertices a square has 4 at least (you may need more).
Find where you declare vertices,
You will need a switch to check if you are in square mode or triangle mode, and to a way to change that switch at runtime. (By switch I mean a Bool variable, True, False)
There is no square mode.
A square is simply a list of two triangles instead of 1. The simplest way would be to add the 3 vertices of the second triangle to your vertex array , change the "3*" in the CreateVertexBuffer call to "6*" and change the "1" in the DrawPrimitive call to "2".
Get that working first, don't bother with the other primitive types yet.