Separation of abstract user interface and specific user interface for cross-platform development (WinForms, Cocoa, GTK +)

I am currently creating an application with shared code on a server. As presentation layers I use WinForms, Cocoa (MonoMac) and GTK # (Linux).

I am looking for a way to describe my user interface in an abstract way, so that specific user interface implementations (Cocoa, WinForms, GTK #) need only worry about displaying and drawing .

Is it that I can - activate events (button clicks, data entry) from specific views and bind them to functions in the controller / or abstract view handler.? - let the controller / abstract view / model update the view.?

So, basically I'm trying to get some kind of IView, IController and IModel setup, or Model-View-Presenter, or MVVM, are there any application examples there ...? Because there is a lot of theory, but no concrete examples.


EDIT January 2017: Electron

For those who want to create cross-platform desktop applications on both LINUX / WINDOWS and MAC, I would also suggest looking at Electron ( electron.atom.io ). This is basically Chromium + NodeJS - this means that the user interface design for a single browser has the power of Node (and npm packages). You can also connect .NET code through EdgeJS .

+5
source share
1 answer

EDIT January 2017: Electron

For those who want to create cross-platform desktop applications on both LINUX / WINDOWS and MAC, I would also suggest looking at Electron ( electronic.atom.io ). This is basically Chromium + NodeJS - this means that the user interface design for a single browser has the power of Node (and npm packages). You can also connect .NET code through EdgeJS .


Each project will have its own needs, but others are trying to find the answer, that’s what I implemented.

I decided to explore the Model-View-Presenter design pattern. For a detailed reading, check out the Wikipedia article or in this Martin Fowler article . Another alternative implementation is "thedersen.com" - read the article here .


Custom implementation

I finished my own basic implementation of the design pattern. This is for a better understanding of the template and more complete control over implementation details. The latter is important, since the implementation must be able to handle several user interface methods other than the standard Microsoft ones. For example: Cocoa (MonoMac) , GTK # (GTK +) , etc.

Execution will perform passive browsing and will consider these recommendations:

  • Interaction with the model is carried out exclusively by the leader;
  • The view is updated exclusively by the accountant;
  • The view may inform the host about broadcast events;

Diagram

enter image description here


Framework code Check pastebin for interfaces and base classes. http://pastebin.com/k6xhwrJ8

Code example

This example will show the main bootstrapper screen. All code does not contain pastebins. Some methods (for creating and creating instances of controls) are absent, as this is not the focus of the example.

Example of how it looks on Windows. On MacOS the view will have it's native UI ofcourse.


This concludes my main decision. This is baisc yes, but it helps me create the backend code and not worry too much about how to link the views together.

Extension points may include:

  • Adding a presentation manager and a presentation manager so that you can use the IoC method ...
  • Adding more advanced base views and presenters for different scenarios ...
+4
source

Source: https://habr.com/ru/post/1212213/


All Articles