So there is only one way.
I have to seperate the UI and the main program completely, make UI platform specific and main part portable.
[EDIT]
It is not hard to be done. In my current design they are seperated. The only thing I have to do is erasing res before the Painter class and using string instead of String^.