[mapguide-commits] r9117 - in trunk/Tools/Maestro: Maestro.Editors/WebLayout OSGeo.MapGuide.MaestroAPI/Resource/Conversion
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jan 11 06:46:52 PST 2017
Author: jng
Date: 2017-01-11 06:46:51 -0800 (Wed, 11 Jan 2017)
New Revision: 9117
Modified:
trunk/Tools/Maestro/Maestro.Editors/WebLayout/MenuEditorCtrl.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Conversion/IResourceConverter.cs
Log:
Ensure MapTip is in the command set when upgrading a Web Layout document.
Also fix adding of built-in commands to also include MapTip if the Web Layout is >= 2.4.0
Fixes #2503
Modified: trunk/Tools/Maestro/Maestro.Editors/WebLayout/MenuEditorCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/WebLayout/MenuEditorCtrl.cs 2017-01-11 14:20:09 UTC (rev 9116)
+++ trunk/Tools/Maestro/Maestro.Editors/WebLayout/MenuEditorCtrl.cs 2017-01-11 14:46:51 UTC (rev 9117)
@@ -27,6 +27,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
+using System.Linq;
using System.Windows.Forms;
namespace Maestro.Editors.WebLayout
@@ -107,6 +108,13 @@
mi.Tag = type;
mnuBuiltin.DropDown.Items.Add(mi);
}
+ //Need to make sure MapTip is available for v2.4 onwards
+ if (_wl.ResourceVersion >= new Version(2, 4, 0))
+ {
+ ToolStripMenuItem mi = new ToolStripMenuItem(BasicCommandActionType.MapTip.ToString(), null, new EventHandler(OnAddBuiltInCommand));
+ mi.Tag = BasicCommandActionType.MapTip;
+ mnuBuiltin.DropDown.Items.Add(mi);
+ }
}
private void RemoveCustomCommandEntry(ToolStripMenuItem tsi, ICommand cmd)
@@ -160,10 +168,10 @@
var tsi = sender as ToolStripItem;
if (tsi != null && tsi.Tag != null)
{
- BuiltInCommandType cmdType = (BuiltInCommandType)tsi.Tag;
-
+ int cmdAction = Convert.ToInt32(tsi.Tag);
//Append to end of model of active treeview
- var cmd = _wl.GetCommandByName(cmdType.ToString());
+ //var cmd = _wl.GetCommandByName(cmdName);
+ var cmd = _wl.CommandSet.Commands.OfType<IBasicCommand>().FirstOrDefault(c => cmdAction == (int)c.Action);
if (cmd != null)
{
var ci = _wl.CreateCommandItem(cmd.Name);
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Conversion/IResourceConverter.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Conversion/IResourceConverter.cs 2017-01-11 14:20:09 UTC (rev 9116)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Conversion/IResourceConverter.cs 2017-01-11 14:46:51 UTC (rev 9117)
@@ -21,8 +21,10 @@
#endregion Disclaimer / License
using OSGeo.MapGuide.ObjectModels;
+using OSGeo.MapGuide.ObjectModels.WebLayout;
using System;
using System.IO;
+using System.Linq;
using System.Text;
namespace OSGeo.MapGuide.MaestroAPI.Resource.Conversion
@@ -89,6 +91,18 @@
var convRes = ObjectFactory.DeserializeXml(xml.ToString());
convRes.ResourceID = resource.ResourceID;
+
+ //If upgraded to WebLayout 2.4 or higher need to add MapTip to command set
+ var wl = convRes as IWebLayout;
+ if (wl != null && wl.ResourceVersion >= new Version(2, 4, 0))
+ {
+ if (!wl.CommandSet.Commands.Any(cmd => cmd.Name == "MapTip"))
+ {
+ var maptip = wl.CreateBasicCommand("Maptip", "Click to enable/disable display of map tooltips", "Click to enable/disable display of map tooltips", "icon_maptip", TargetViewerType.All, BasicCommandActionType.MapTip);
+ wl.CommandSet.AddCommand(maptip);
+ }
+ }
+
return convRes;
}
}
More information about the mapguide-commits
mailing list