none
Porting tool to convert Windows Forms applications to Metro Style applications

    General discussion

  • Hi all,

    In these forums we have discussed a lot about Metro Style development and it seems very interesting to move from Windows forms development to here. But I would like to draw your attention to another aspect of this. Moving up to metro development could be easier to a developer who has been working not only with Winforms but also with WPF and Silverlight, as most of the basic concepts have flowed down from there. But to a newbie Winform developer this migration would not be that easy. This is a real concern if you want to write your current Winforms project in Metro Style. You don’t have any shortcuts available other than writing from the scratch. Do you?

    As a solution for this (for our university research project) we are developing a tool which has the capability of converting a .NET 4 C# based (we are considering the lower versions as well) Windows Forms project to Metro Style C# based (WinRT) project. I’m not going to describe things in detail but basically following is how we perform this conversion/mapping.

    UI Conversion: All the code related to GUI component, which mainly include in a designer.cs file, will be mapped into corresponding Xaml control tags. For an example if we consider the button control our mapping includes all possible properties and events. Of course there might be cases that a property of windows from UI component doesn’t have a proper mapping in its Metro control. But for some of those situations we have used some workarounds. The final output of this conversion is the generated XAMLl UI descriptor file.

    Logical Code Conversion: This converts all logical code with possible mappings to corresponding new libraries. This mapping could be either a class as a whole or a member of a class. For an example in metro, coding and the concept of message box is slightly different and that should be mapped in the conversion. Concepts such as navigation, lifecycle of an app are completely different from the standard windows form application.  We have managed to convert the basic instance of these occurrences into Metro.

    Hope you have a basic idea what I have tried to say. We have tested our tool for simple C# projects and hoping to expand the functionality. What we need is your comments and guidelines because that might come handy in our future development process as an invaluable input. We do know that the scope of the tool (the area we can map in .NET framework) would be limited but as a startup we would like to provide the conversion of basic and frequently used libraries.

    Please add your comments and ask any question. That is highly appreciated. I will post more details in near future. 

    Cheers!






    Tuesday, August 07, 2012 5:18 AM

All replies

  • Hi,

    I think it's quite difficult.

    Maybe we can seperate the logical code and UI code , reserve the logical code and recreate a UI for Metro Style. It's hard to convert the WinForm UI code to Metro's.

    Metro apps based on WinRT have many differents from WinForm, not only the namespace or method name but some implementing code are different. There are lots of method we can use or information we can get in WinForm are not supported in Metro. 

    Converting WinForm to Metro will be a large project I think. 

      


    Aaron Xue [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, August 09, 2012 8:36 AM
  • Hi,

    Thanks for the comments! Yeah, as you mentioned converting a Winform to Metro is not easy. Maybe it might not possible to convert something complex, like a business oriented application. I can understand the fact you mentioned to separate the two conversions.

    In this project what we want to prove is that there are possibilities to do this conversion though some may argue that current desktop applications have no value in Metro.  So for the moment we tried to limit our scope to the basic controls and convert a simple, useful applications.

    We selected a scientific calculator as our first target which is simple but still useful in both environments. This Winform application contains few buttons, textboxes, labels and radio buttons in  UI. Logical code is simple (System.Math lib used) except the usage of the message box which should be ported by the application. Our porting tool can handle this conversion which means  we can now focus on porting other apps which has the similar depth, maybe simple games or applications.

    We found this document very helpful in this process but let me know if there are any other place I can get more information.

    I think if we or someone else could success with this kind of a tool at least for a certain extent it would be great for all developers because then we don’t have to code our applications from the scratch to Metro.

    Cheers, 


    Thursday, August 09, 2012 11:56 AM
  • I'd second Aaron. We aro also starting to think about expanding our applications to Metro style and my first thought was to leave the business logic intact as much as possible and to create the GUI from scratch.

    That said, your initiative can help a great deal even if in the first phase it would only support simple apps. Good luck!

    Michael

    Thursday, September 06, 2012 5:49 AM