What is the best free and the best commercial tool that lets me draw uml hierarchical statechats like in the picture below. It would also be cool if it could generate the c# source code stubs.
Take a look at the Domain-Specific Languages tools in the Visual Studio SDK. They include a DSL for state charts.
You can generate any code you need from one of these DSLs by using T4 Templates.
Some resources:
- Visual Studio Visualization and Modeling SDK (was DSL SDK)
- Getting Started with Visualization and Modeling SDK
- Visualization and Modeling SDK - Domain-Specific Languages
Note that these links are all for VS2010. That's because I can no longer find the VS2008 links, but the DSL Toolkit has a State Chart template in VS2008 as well.
I didn't see the "best commercial" part of your question.
I use Sparx Enterprise Architect. It can do full UML statecharts, and I believe it can generate code from just about any model, or transform one model into another. You might have to transform a state model into a model of the classes representing your states before then generating code from the classes, but that's the worst you'd have to do.