Thursday, 17 May 2012

New mg-desktop binaries: This time with 100% more framework and 100% less coding

Does this look familiar to you?


It looks a lot like this doesn't it?


That's because with the latest binary drop of mg-desktop we now have a full-blown framework (hereby known as the AppLayout Engine) which means you do not have to write a single line of code* to have a functional mapping application.

Introducing the AppLayout Engine


The AppLayout Engine was an idea that came about after my last mg-desktop related post.

I had begun experimenting with the componentization of the existing map functionality (Buffer, Measure, etc), such that you could drag and drop these components from the Visual Studio toolbox into your Form Designer and tie them into the (also dragged-and-dropped) map viewer control by only needing to set the appropriate properties in the VS property grid and not having to write a single line of code to do all this. You still needed to write some code to bootstrap the platform and load in the map, but everything else was done design-time in Visual Studio.

This worked so well that I then started doing the same thing for every map related piece of functionality (Zoom, Pan, etc), and through the magic of WinForms Control Extenders, we can tie menu items and toolbar buttons to components and be able to:
  • Invoke the associated component when clicked
  • Inherit label/tooltip/icons settings from the component
  • Automatically enable/disable itself based on certain component conditions (eg. A zoom button disables itself if there is no map loaded)
All this componentization has meant the Visual Studio toolbox for mg-desktop has become quite hefty:


So through this componentization work, it was now possible to assemble a map viewer in a completely declarative fashion by dragging and dropping the components you're interested in and tying them all together by setting the appropriate properties via the Visual Studio property grid. Building an mg-desktop application in this manner is probably a topic for another post.


It was at this point when I noticed that my components were functionally and conceptually similar to what you already know as Commands in the AJAX Viewer and Widgets in Fusion.

Given that the only code we had to write at this point is to initialize the mg-desktop platform and load the main application window, I figured what the hell? Let's go ahead and make this thing 100% declarative without writing a single line of code and thus the AppLayout Engine was born.

The AppLayout Engine consists of a skeleton Shell window (which serves as your application's main window), that you initialize with an AppLayout document.

The AppLayout document


If you understand WebLayout documents for the AJAX viewer or ApplicationDefinition documents for Fusion, then understanding AppLayout documents is very straightforward, because AppLayout documents are structurally and syntactically similar to both.
  • You declare a series of Component Definitions (ie. Your commands/widgets)
  • You specify the structure of your menus and toolbars and the declared components that they link to
  • You specify a Map Definition that is loaded by the viewer.
  • Customize various aspects of the viewer user interface.
A Component Definition looks like this in its simplest form:


For Components that expose properties, you can set them as well:


Notice the syntatical similarity to an AJAX Viewer command or Fusion widget. It wasn't intentional, I guess the stars aligned or something because the design naturally converged to something very similar to what we already have with the AJAX Viewer and Fusion.

So once you have authored up the AppLayout document, you feed the document to MgAppLayout.exe to have your own custom mapping application. You can take a look at the Sheboygan.AppLayout sample document that's included with this release as a comprehensive example of what an AppLayout document should look like.

MgAppLayout.exe


MgAppLayout.exe is the front-end to the AppLayout Engine. It takes your AppLayout document, and does the following:
  • Parses and registers all the component definitions defined inside the document (and loads the relevant assemblies if these are external components)
  • Constructs the menus and toolbars based on the layouts specified
  • Loads the specified Map Definition and optionally invokes a registered component on startup
The MgAppLayout executable, in conjunction with an AppLayout document, gives you the final mapping application, just like your AJAX and Fusion viewer with their respective WebLayout and ApplicationDefinition documents.


Loading your AppLayout is simply a case of calling MgAppLayout.exe with the path to the AppLayout document you want to load. For example:

MgAppLayout.exe Sheboygan.AppLayout

If you do decide to run the sample Sheboygan.AppLayout, you will need to have the Sheboygan sample data set loaded. The sample AppLayout includes a Load Package component available under the File menu for this very purpose.



The default component set


For this release, this is the list of components that are available to you out of the box for assembling your AppLayout:

  • Buffer
  • Select Radius
  • Clear Selection
  • Copy Map image to clipboard
  • Generic Invoke+
  • Initial View
  • Load Map
  • Load Package
  • Measure
  • Pan
  • Select Polygon
  • Print Map
  • Generic Query
  • Quit
  • Refresh Map
  • Select
  • Theme
  • Tooltip Toggle
  • Viewer Options
  • Zoom In
  • Zoom Out
  • Zoom to Selection

+ The Generic Invoke component is basically our version of the InvokeURL command/widget and is actually used for the Visual Studio drag-and-drop scenario for a way to have your own custom code get called. It's not really usable within the AppLayout framework, but is listed above for completeness.

*Adding your own functionality


If you require custom functionality, you can create your own subclasses of MgComponent (or MgViewerComponent if you need to display a user interface in the Task Pane). This is once again conceptually similar to creating your own InvokeScript and InvokeURL commands in the AJAX and Fusion viewers.

Adding these components to your AppLayout just requires an extra Assembly element in the Component Definition.


The Assembly element is a relative path (from the path of MgAppLayout.exe) to the assembly containing that particular component implementation. This release contains a SampleExtension.dll which contains some external components (used by the sample Sheboygan.AppLayout). The SampleExtension source can be found here


So there you have it. Web Layouts have arrived for mg-desktop, allowing for desktop mapping applications with minimal to zero code required!

Download mg-desktop

Monday, 14 May 2012

SQL Server 2012 FDO support

Does the SQL Server FDO provider work with SQL Server 2012?

If you believe these screenshots ...

FDO Toolbox 1.0 (using 3.6 FDO provider)

SQL Server Management Studio 2012 (connected to SQL Server 2012 express)

... then the answer is yes

Thursday, 10 May 2012

Announcing: MapGuide Maestro 5.0 beta and 4.0.1 maintenance release

It's actually been over 8 weeks since I last touched a line of code in Maestro (must be a record!), so it's time for a overdue release with not one, but two releases of MapGuide Maestro depending on whether you're adventurous (5.0 beta) or conservative (4.0.1)

Firstly, a brief overview of what's new in Maestro 5.0 beta

A fresh visual coat of paint

Somebody finally managed to make my favourite docking library work under Mono, so we've thrown out our hacky UI manager and replaced it with DockPanelSuite. This gives us some extra UI niceties as well such as icons for our editor tabs.



IronPython Scripting


Maestro now includes the IronPython scripting engine to allow for scripting and automating the application.

You can execute snippets of Python through the IronPython REPL console


Runtime Map Inspection


Maestro 5.0 includes a new Runtime Map Inspector utility (RtMapInspector.exe) that allows you to inspect the state of a runtime map given the session ID and the map name.


This tool still needs some work. For one thing I was hoping to get selection inspection working as well, but it  didn't make it for this release.

Resource XML Diffs


The View Changes command allows you to view the comparison between the original resource and its currently edited version.


This tools helps you make better informed decisions whether to save or discard the changes you've made to the currently edited resource.

Assorted UI tweaks

Layer Editors now have a jump button to take you to the related Feature Source / Drawing Source


Text and Path dialogs in the Symbol Definition editor are optimized for better screen usage



The Layer Definition editor gets more screen real estate optimization. Each geometry style is now a separate tab.


4.0.1 Maintenance Release


Maestro 4.0.1 is the first of possibly many long-term maintenance releases and contains a fair number of bug fixes and backported minor enhancements/tweaks from the 5.0 beta. Nothing much to talk about here, 4.0.1 just adds an extra bit of polish to the 4.0 release. You can check out the changelog for all the details.

Download

Wednesday, 9 May 2012

A big shout out

Since Maestro 3.0, the user interface that you have seen was done that way because my favourite WinForms docking library DockPanelSuite was riddled with P/Invokes into Win32, rendering the library un-usable on Mono. We use this library in FDO Toolbox because the FDO .net wrapper was already windows-only so we could get away with it, but not for Maestro.

So as a result, I had no choice but to hack my own clunky pseudo-docking library that is driven by SplitContainers and TabControls. This worked to an extent, but as it turns out, those weird and crazy display problems with the Layer Definition editor (you've probably experienced it. Just try resizing the main window) is the result of bugs caused by this combination. The suggested solution in that link didn't work for me btw.

Rather than try to bolt on some bandaids to an already hacky UI which turns out to be composed of 2 components that don't like each other, I thought I'd take another look to see if there has been any effort to get DockPanelSuite working on Mono. Lo and behind, there was a saviour!

Mr Lex Li has made a patched version of DockPanelSuite with the offending P/Invokes patched out for Mono. What do we lose with these patched out P/Invoke calls? According to Lex, we lose the ability to drag and drop Dock Windows around to different areas of the main window. And you know what? We don't even use that feature! So I had to take a look at this patched DockPanelSuite.

10 minutes of UI refactoring later and behold! The new Maestro 5.0 main window!


And more importantly, here's how it looks on Mono (in Ubuntu)


The only problem I get on Mono at the moment is this big stack dump vomit from DockPanelSuite when Maestro exits, but it looks like a problem that can be worked around.

So a big shout out goes to Lex Li for finally making my original UI plans possible!

Tuesday, 1 May 2012

New mg-desktop binaries

It's been a while, but I've just uploaded some new mg-desktop binaries with some new features worthy of a new blog post.

More Controls


The Map Viewer library (OSGeo.MapGuide.Viewer.dll) has been fitted with some extra user controls which should look familiar to what you've used in the AJAX and Fusion web viewers.

Measure

The MgLineMeasureControl allows you to perform distance-based measurements by tracing the segments you wish to measure on the map. The updated MapViewerTest application demonstrates usage of this control.





Buffer

The MgBufferControl functions exactly like its AJAX and Fusion counterparts. Nothing more to say. If you've used the buffer tool in the AJAX and Fusion viewers, this control is exactly the same.



Query

The MgQueryControl is similar to the AJAX and Fusion counterpart.



The difference is that query results are displayed in a new window, with full data grid display of all attributes.



Zooming and Selection can work on multiple rows in the query result grid. Clicking zoom with multiple selected results will zoom to the aggregate bounding box of the selected features. Clicking select will replace the current map selection with your selected query results.

Profiling Support

This release of mg-desktop also merges the new Profiling feature in MapGuide Open Source 2.4 / AIMS 2013. The MapViewerTest application includes a Profile command which displays the same XML content for profiling results as the Site Administrator.


For this release (and future ones). I'll be putting up 2 flavours of mg-desktop:

  • One that targets .net Framework 2.0 and requires the Visual C++ 2008 redistributable
  • One that targets .net Framework 4.0 and requires the Visual C++ 2010 redistributable
This way you can choose the one that best matches your existing code and libraries, because not everyone is (or can be) on the latest and greatest framework/compiler.


Download mg-desktop