I'm currently making an application that has shared code on the backend. As presentation layers I'm using WinForms, Cocoa (MonoMac) and GTK# (Linux).
I'm looking for a way to describe my user interface in an abstract way, so that the concrete UI implementations (Cocoa, WinForms, GTK#) only need to worry about displaying and drawing.
This so I can - wire up events (button clicks, data input) from the concrete views and bind them to a function in the controller/or the abstract view handler..? - let the controller/abstract view/model update the view..?
So basically i'm trying to get a kind of IView, IController and IModel setup going.. or Model-View-Presenter, or MVVM, are there any example applications out there...? Because there's a lot of theory, but no concrete examples.
For those wanting to make cross platform applications for desktop both on LINUX / WINDOWS and MAC I'd suggest also looking into Electron (electron.atom.io). It's basically Chromium+NodeJS - which means UI design for one browser with the power of Node (and npm packages). You can also hook .NET code via EdgeJS.
For those wanting to make cross platform applications for desktop both on LINUX / WINDOWS and MAC I'd suggest also looking into Electron (electron.atom.io). It's basically Chromium+NodeJS - which means UI design for one browser with the power of Node (and npm packages). You can also hook .NET code via EdgeJS.
Every project will have it's own needs, but others trying to find an answer, here's what I implemented.
I decided to investigate the Passive Model-View-Presenter design pattern. For detailed reading check the Wikipedia article, or this article by Martin Fowler. Another alternative implementation is the one by "thedersen.com" - read the article here.
Custom Implementation
I ended up making my own basic implementation of the design pattern. This for better understanding the pattern, and having more control over the implementation details. The latter one is important as the implementation would need to be able to handle multiple UI techniques other than the standard Microsoft ones. E.g.: Cocoa (MonoMac), GTK# (GTK+), etc...
The implemantation will implement the Passive View, and will keep these guidelines in mind:
Diagram
Framework Code Check this pastebin for the interfaces and base classes. http://pastebin.com/k6xhwrJ8
Example Code
The example will show a basic loading screen (bootstrapper). All code is in never expiring pastebins. Some methods (for creating and instantiating controls) are not present, as this is not the focus of the example ofcourse.
Check this pastebin for the "Api"/"BackEnd" code of a "Bootstrapper": http://pastebin.com/NrKFrz77
Check this pastebin for the WinForms implementation code of the Bootstrapper View: http://pastebin.com/gmu3eFFs
Check this pastebin for the Cocoa (MonoMac) implementation code of the Bootstrapper View: http://pastebin.com/iTTvk8pJ
That wraps up my basic solution. It's baisc yes, but it does help me create backend code and don't worry too much about how to link the views together.
Extension points may include:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With