I want to create a Tool which is something similar to this

I don’t want to create with this many options, but just a basic set of 2/3 options like drawing lines. How do they build this kind of things? Can I build something similar in C# or Java? Also what I want to do is when ever someone draws something I will generate code in the background which will not be related to the drawing the person has created.
Beside previous example, you can go take a look at code from SweetHome3D. As its source is available, you can with ease inspire yourself from it.