At a high level, you should be able to do something close to the following:
1. In your project, add a new Web User Control
2. Add the code from the example to the control's markup and code behind
3a. Register the user control on a widget or page template (Design > Page Templates, Design > Widget Templates)
3b. Follow the instructions here to add the widget to the toolbox so you can just drop it on a page: http://www.sitefinity.com/documentation/documentationarticles/adding-controls-to-the-toolbox
Without knowing how specifically you'd like to use the control, I'm not sure what to specifically suggest. If you could post a little more detail on how you need to use the widget, that'd be helpful.