Generally, all you need to define your own figure is the actual figure class, and a corresponding Creator class (that defines which dependencies are required to be entered by the user to fully specify your figure).
Segment, Ray and Line all inherit from LineBase.
LineBase defines a property called OnScreenCoordinates, which returns a PointPair of actual endpoints drawn in the viewport.
The default LineBase implementation is just to return Coordinates (the two dependency points joined together).
However Ray overrides this virtual property with an implementation which uses the first dependency point as is, and extends the second point of OnScreenCoordinates till the edge of the viewport.
Line overrides this virtual property to extend both ends of the line to the edges of the viewport.
The math to extend a line to end at the viewport edge is in Math.GetLineFromSegment().
Hope this helps,