In the project I am currently working on http://sourcecodecloud.codeplex.com/ I have a library containing nontrivial geometry & layout algorithms. They are completely graphic engine independent.
The app was initially written for GDI+, now I am going to implement a Silverlight and/or WPF port of it. The problem is that all my algorithms use System.Drawing.PointF, SizeF, RectangleF structures. They are all float based. Corresponding WPF / Silverlight classes are double.
The question is, have anyone experience on that? What is the best way?
- Create own wrappers for Size, Point, Rectangle etc. which can wrap both variants.
- Stick either with System.Drawing or System.Windows and cast it in another. Negative impact is unneeded reference on the ‘alien’ assembly.
- Some other magic?
I would begin with Portable Library Tools as your base. Any types in there are suitable for use across all your projects. For any types not present in there, I would create your own abstract types, and implement derived types which wrap the relevant type from each framework separately. Use the abstract types you create as much as possible from your own code.