How to port C# applications from windows for linux? - winforms

Windows.Forms library contain many bugs which effectively prevent applications from working. WinForms Designer is unable to put WebBrowser control on form. NotifyIcon class doesn't work under LXDE (see the bugtracker of KeePass). Clipboard class is incompatible with default manager of Calculate Linux. Drag and Drop have problems in DockPanelSuite. WinForms Designer is not finished because of opacity problems. WPF was never implemented and no plans to do it.
And mono team says "we don't want to develop WinForms, because this is old technology."
How should one port desktop C# application from Windows to Linux? Rewriting it with Gtk# seems to be too hard...
What is easier - to fix mono WinForms, to implement WPF, or to rewrite all applications in the world to Gtk# ?

As you have already found out Mono WinForms implementation is suitable only for very simple applications. Take a look at "Cross-Platform Desktop UIs" blog post from Xamarin employee Mike James who summarizes available solutions:
Traditional approach
WPF or WinForms frontend on Windows, GTK# frontend on Linux and Xamarin.Mac on Mac OS X. IMO this is the best way to go and it may be easier than it looks if you have correctly separated business and presentation layers in your app.
XWT
XWT toolkit uses the same API and provides native look on all platforms but only a limited subset of components is implemented. Its usability for your projects depends on what components you really need.
HTML frontend
Create HTML frontend using simple WebView component or Awesomium HTML UI Engine. This may be a viable option in some cases but I am not sure whether it is possible to implement systray icons with this approach.
QTSHARP
Open source project which aims to implement .NET bindings for multiplatform QT toolkit. I have never tried it but according to project website it seems to be in early stage and currently tested only on Windows.
BTW I am currently using WinForms for Pkcs11Admin application but I plan to use traditional approach as soon as I hit a blocker bug on any of the supported platforms.

Related

Do any of the Windows system applications use WPF?

Context: I am looking for examples of popular applications that use WPF for their UI.
With Windows 8 and Windows 10, certain parts of the OS got a new 'look-and-feel', for example:
The system settings dialog
The taskbar and the start menu
The calculator app
The task manager
Do those or any other Windows system applications use WPF for their UI?
This question already provides a list of existing applications that use WPF: What real world WPF applications are out there?. However, I would like to know if there are any builtin Windows system applications that use WPF.
None of those applications use WPF. Instead they use UWP, which was inspired by WPF, but is quite a different framework underneath.
There are WPF applications in many default Windows installations, though. For example, the PowerShell ISE is one.
You could try Snooping them to find out - It's not been updated for several years but I tried it on a splinter new 4.6 app I'm developing and it's detecting it and works fine. Whatever it can detect is certainly a WPF app - the inverse is not true however.
That being said it did not detect calculator or task manager for me.

Is there any cross-platform GUI framework that support data binding like in WPF?

Recently I'm working on a game project, and we need to develop some editors for designers to use. While other programmers are all working on Windows, I'm working on Mac OS X. I'm familiar with WPF and Windows Forms development and I'm looking for some GUI frameworks that support data bindings similar to WPF or Windows Forms development.
The GUI framework should satisfy these:
Cross platform
Support data bindings to object (like WPF or Windows Forms)
It's best that it support XML serialization because XML is our data format
By the way, I don't care about the programming language, GUI frameworks based on any programming language are all welcome.
Silverlight runs on MacOS.
It also runs out of browser so you can create an application that doesn't require the browser to be run and hence looks like a regular desktop application.
Depends on the platforms that you want to support, but you could have a look at Moonlight the mono port of silverlight. Have a look at the alternative section of this page:
http://www.mono-project.com/WPF
Knockout.js is said to be good. My colleagues prefer it over Wpf and Silverlight bindings. For instance if you have a fullname prop, which is a result of firstname and lastname, you have to hassle in Wpf with propertychanged, in Knockout.js you define it observable and the runtime makes it correctly notify its observers. It also supports validation.
Although it doesn't have data binding like WPF or Windows Forms, Real Studio does works wonderfully for creating cross-platform applications. And XML is supported, of course.
Try JavaFx, it supports binding better than Java Swing. Also styling is based on CSS instead of Microsoft proprietary style logic.
Both WPF and JavaFX will target the GPU for extra fast rendering; they are comparable and competitor technologies. But JavaFX is cross platform and less likely to be abandoned given Microsoft's track record.
http://www.oracle.com/technetwork/java/javase/overview/javafx-overview-2158620.html
Also, other answers here say Silverlight but Microsoft has abandoned this.

UI development for windows (desktop + web application) and windows CE

I am working on a project where there is requirement of GUI to be created in Silverlight. Some key requirements are:
Extremely rich GUI
Real time visualization process graphics
Support multiple themes
Support different display size
Support charting / trending controls
Same functionality for Desktop / Web using same code base
Same functionality to be available on embedded controller (based on Windows CE)
I understand that using Silverlight we can have same codebase for desktop / web applications. However challenge is to have the Silverlight application (windows and/or web) for Windows CE. I would like to understand what is the best way to implement Silverlight application on Windows CE with as much code reuse as possible.
I would appreciate if you could provide some inputs on what should our architecture approach be for this application development. Also, please let me know if you need more inputs on the requirement side...
"Silverlight" for Windows Embedded (SWE) is a bad name. It's not really what most would call Silverlight. It's simply a XAML-based engine that you can use Blend to develop for. For Windows CE, you must use C++ to develop for SWE. You cannot reuse SWE assemblies in other Silverlight projects. You cannot use other Silverlight assemblies in an SWE project. Your XAML itself will probably have some reusability, but XAML sharing from a code perspective is a challenge in its own right.

MVP or MVVM framework for both WPF and .NET CF 3.5 development

I am creating a draft architecture outline for a disconnected client-server platform, that involves multiple different client types. I need to support: web clients, desktop workstations and mobile devices (WM 6.x now and Android later).
I am searching for a MVP or MVVM based framework that would let me to reuse as much of the code and architecture as possible between clients, while:
using WPF for desktop development
using .NET CF 3.5 for Windows Mobile development
This framework does not obviously need to support Android, however I am considering Mono for Android to develop the Android client (for easier maintenance of the whole platform), so portability would have been an added asset.
So far I ruled out:
Prism (does not support WM based mobile devices - Windows Phone 7 only)
MVC# (does not support WPF)
I would appreciate any hints that would aid in researching the subject further.
These MVVM Frameworks work with Windows Phone 7:
Caliburn Micro
MVVM Light (it doesn't advertise it, but I've been to a demo where it was used on WP7)
ReactiveUI (Uses the Reactive Extensions for .NET)
My personal favorite is ReactiveUI, but if you've never used the Reactive Extensions it can be a brain burner at first.
As for UI Composition (you mentioned Prism), there aren't a lot of options, mostly due to reflection restrictions on the phone. I have seen an article where someone got basic MEF working on the phone and MEF is probably all most people need in this situation. You can check out that article here.
Hope this helps.
In my opinion, this would be a custom Framework with a mix of UI Processes for different client types. The business logic or entities can definitely be reused to suit the needs of the view.
I did the same research and I concluded the following (which I did not implement yet):
There aren't any open source MVVM frameworks that support .NETCF. You
can only find MVC or MVP, but not MVVM.
Suggestion: get the source code of an Open Source MVVM framework that supports the Full/Desktop .NET, and see if you can adapt it(so that it recompiles) to the .NETCF. I found the following two, which also support the other platforms that you mentioned:
MVVM FX for Windows Forms and Visual WebGUI - Home
MugenMvvmToolkit
Other than that, I don't see any other way of doing this.
HTH,
MVVM wouldn't make much sense in Windows Mobile + .NETCF since you don't have INotifyPropertyChanged and implementing Model-View-Presenter in WPF or any INotifiyPropertyChanged supported framework wouldn't be as effective as Model-View-ViewModel
You can share assets between the full and compact framework by moving most of the business logic into a seperate class library (or several) that target the .NETCF. You can reference a .NETCF library from a full framework project, but not the other way around.
Check out this very good article by Daniel Moth describing how to share assets between the compact and full framework:
http://msdn.microsoft.com/msdnmag/issues/07/07/ShareCode/default.aspx

Can you build an entire application in Silverlight?

Is it possible to build a good medium to full sized application using just silverlight as a host?
A few things that would be needed:
- dynamic pages (one silverlight "screen" can switch between screens, like a normal app.
- similar to a java applet which launches from the browser
I see that Telerik sells RadControls for WPF...but this is only useful (to me) if Silverlight can be a rich client platform through the web.
Although still a somewhat immature platform, Silverlight 2.0 supports many of the features that I would expect from a platform needed to create full sized applications.
Data access through web services and local data/object query support with Linq
Many feature rich controls such as datagrid, treeview, etc
A very usable subset of the CLR (common language runtime)
Access to restricted local storage on the client machine
It is cross platform
There are already some great add-ons, like Telerik and the Silverlight Control Toolkit
For your specific scenario, Microsoft has published a tutorial on Multi-page Applications
Absolutely. I've been looking into this and believe that it's as easy to do in Silverlight as it is in any other language. Remember that Silverlight 2 uses C# 3.0 and from that you can build anything that's not included in the Silverlight version of the CLR. Also, the fact that Microsoft gives you access to the .NET source code means that you can compile the missing parts of the .NET libraries with your application. (No idea about the licensing issues with that though.)
I've seen a presentation of a full featured CRM application two days ago. Although it's still alpha: It looks and feels like any office application. I don't know details but for me it's a proof of concept.

Resources