Incorporated existing codes and rgenlib
Using Winform because  there's a wpf bug
Switched dialog back to wpf