Closed zur003 closed 8 years ago
This is good Eric and what I was expecting
If we were to move to using GtkSharp, what would be the strategy? Is there an iterative way to do it or does someone down tools for 3(?) months and just do it?
I don't see any way to do this in a nice stepwise fashion, beyond starting by setting up a simple test framework or two to make sure all the bits and pieces we want to use actually work nicely. We wouldn't want to invest substantial amounts of time in porting stuff only to find that it doesn't quite do what we want. I'm still a bit uncertain about rendering HTML, for example, or the details of setting up a text editor with intellisense capabilities.
Speaking from the point of view of a windows user and someone who has endured pain in helping progress the current UI to a usable state... I am not keen to throw away what has done already until the alternative is working at least as well. However, provided that the UI works well I don't really mind what technology it is built upon. It would be easy enough to develop a 2nd UI in parallel to the current one until it is ready to replace what we already have??
It strikes me that there are two development imperatives that are in conflict here. 1. The desire for APSIM to work cross platform (which is important). 2. the desire to have a clean and tidy development platform (which is also important). Currently all facets of APSIMX can be worked on from Visual studio in the same .sln file and the build, release procedures seem to work nicely. I have no real expertise in this but I wonder what pain we could be setting our selves up for if we start cobbling multiple platforms together again as we have done in the current version of APSIM.
Good questions, Hamish.
I'm still trying to get a good understanding of how all this stuff works, but what I hope to do is to develop a second GUI in parallel with the existing one. That shouldn't be too overwhelming a task. After all, a major reason for using the model-view-presenter paradigm is that it should be relatively easy to swap out one view and replace it with another. There should be no reason to pull the plug on the current Windows.Forms GUI until a substitute is fully functional (if that ever happens).
The question of development platforms in an important one. The main contenders for a suitable IDE are Visual Studio and Xamarin Studio (aka MonoDevelop). Both can use the same .sln files, and compile the same code, but there are a few differences. The APSIM development team is already familiar with Visual Studio, the community edition is free, and it integrates with lots of other stuff, so there are good reasons to stick with it. MonoDevelop is also free and works pretty well, but also has an integrated designer (named "stetic") for GtkSharp development, whereas Visual Studio does not. However, the stetic designer currently supports only Gtk 2, not Gtk 3. I think we're probably better off targetting Gtk 3, so that kind of eliminates the main advantage of MonoDevelop. At this point, I'd recommend sticking with Visual Studio on Windows, but using MonoDevelop if your normal work platform was Mac or Linux.
One reason for preferring Gtk 3 over 2 is that the support libraries for it are readily available via NuGet, so it's pretty easy to get started with it in Visual Studio. Gtk 3 also seems like the way to go if we're keeping an eye on the future.
As I mentioned, there is no integrated form designer for GtkSharp in Visual Studio. A developer has a couple of alternatives. It is possible to do all the design work non-visually, and construct everything using code. This would be similar to constructing WinForms Designer.cs files by hand. You would have a lot of control, but it's tedious work. The alternative is to use Glade, a stand-alone forms designer which generates an XML description of the form contents. The resulting XML can be embedded as a resource in an application, then used to initialize a form using only a couple of lines of code. The Glade approach is the one I'm currently taking. (There are Windows versions of Glade for both Gtk 2 and Gtk 3; these can both generate two different XML formats [libglade and GtkBuilder]. I'm currently trying to do development using Gtk 3 and the Gtk Builder format.)
I'm hoping to play with this for a few weeks and see how far I can get. The learning curve is reasonably steep...
As a early step towards making this work, I'm going to try to remove use of the WIndows.Forms namespace from everything except the Views in UserInterface. The hope here is that it will be possible to use the same Presenter source for both the Windows.Forms and GtkSharp versions of the GUI. This may require a small bit of refactoring.
Have you all considered something like Electron along with edge.js for the .NET integration? Seems like a perfect use case for these technologies. This would give you a truly cross platform UI including Web and mobile all done with common web technologies that many developers are already familiar with.
Rather than having an ApsimNG directory that duplicates everything in the user interface folder, it would be good to only have the files that are different. For example, I notice in the presenters folder under ApsimNG, there are many files that are the same as the one in the presenters folder under user interface. The same probably applies to some of the other folders under ApsimNG.
Is this doable?
That would be good. I've tried to keep the differences between "UserInterface" and "ApsimNG" as small as possible, which means most of the files in the Commands and Presenters folders are identical, or nearly so. It should be possible to use links for the identical files. I've been waiting until I get to the point where ApsimNG is being built during the Jenkins tests. It's nearly to that stage, but the build machine will need to have the Gtk libraries installed on it first.
I've been looking into the cross-platform operation of ApsimX, and thought this might be a good place to jot down some of my thoughts and observations, and also solicit the views of others.
The current GUI, based on Windows Forms, works reasonably well on Windows (as expected, though there are still a few rough spots), but rather poorly on Linux or Macintosh. My (admittedly limited) tests on Linux indicate rather poor responsiveness, the need to use a version of ICSharpCode.TextEditor more recent than that available via NuGet, and poor (that is, slow and with incorrect layout) display of the summary file. The situation is similar on the Mac which, although more forgiving in use of the TextEditor, tends to fail completely on any attempt to view the summary file. For both Linux and Mac, the worst performing aspect of GUI performance currently is the display of the summary file, which is implemented via an RTF representation. I'd like to see us get rid of this in any case: RTF is a difficult format to use. HTML would be much better, if we can find a suitable rendering engine that works across platforms.
If we really want to achieve good cross-platform performance, I think we would need to move away from Windows Forms completely, and move to GtkSharp. With GtkSharp, we should have access to the various controls we need with decent cross-platform support. These include: tabs, trees, grids, charts (Oxyplot has a GtkSharp implementation), context-sensitive code editing (using Mono.TextEditor from MonoDevelop). I'm a little less certain about rendering "rich" text, but I think cross-platform HTML rendering under GtkSharp should be possible via WebKit.
So the positive side of moving to a GtkSharp-based GUI would be a much better cross-platform experience. But there are negative sides as well. Here are a few I can think of: