[mapguide-commits] r8243 - in trunk/Tools/Maestro: Maestro.Editors/Fusion Maestro.Editors/Fusion/MapEditors OSGeo.MapGuide.MaestroAPI/ObjectModels

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Jun 18 02:39:48 PDT 2014


Author: jng
Date: 2014-06-18 02:39:48 -0700 (Wed, 18 Jun 2014)
New Revision: 8243

Modified:
   trunk/Tools/Maestro/Maestro.Editors/Fusion/MapCtrl.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/Fusion/MapCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/Fusion/MapEditors/EditorFactory.cs
   trunk/Tools/Maestro/Maestro.Editors/Fusion/MapEditors/MapGuideEditor.Designer.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinitionInterfaces.cs
Log:
#1635: Finish off the Fusion editor loose ends. This implements the move up/down and remove map buttons for the re-vamped map group editor.

Modified: trunk/Tools/Maestro/Maestro.Editors/Fusion/MapCtrl.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Fusion/MapCtrl.Designer.cs	2014-06-18 09:02:42 UTC (rev 8242)
+++ trunk/Tools/Maestro/Maestro.Editors/Fusion/MapCtrl.Designer.cs	2014-06-18 09:39:48 UTC (rev 8243)
@@ -104,6 +104,7 @@
             resources.ApplyResources(this.btnRemoveMap, "btnRemoveMap");
             this.btnRemoveMap.Image = global::Maestro.Editors.Properties.Resources.map__minus;
             this.btnRemoveMap.Name = "btnRemoveMap";
+            this.btnRemoveMap.Click += new System.EventHandler(this.btnRemoveMap_Click);
             // 
             // toolStripSeparator1
             // 
@@ -116,6 +117,7 @@
             resources.ApplyResources(this.btnMapUp, "btnMapUp");
             this.btnMapUp.Image = global::Maestro.Editors.Properties.Resources.arrow_090;
             this.btnMapUp.Name = "btnMapUp";
+            this.btnMapUp.Click += new System.EventHandler(this.btnMapUp_Click);
             // 
             // btnMapDown
             // 
@@ -123,6 +125,7 @@
             resources.ApplyResources(this.btnMapDown, "btnMapDown");
             this.btnMapDown.Image = global::Maestro.Editors.Properties.Resources.arrow_270;
             this.btnMapDown.Name = "btnMapDown";
+            this.btnMapDown.Click += new System.EventHandler(this.btnMapDown_Click);
             // 
             // grpChildMap
             // 

Modified: trunk/Tools/Maestro/Maestro.Editors/Fusion/MapCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Fusion/MapCtrl.cs	2014-06-18 09:02:42 UTC (rev 8242)
+++ trunk/Tools/Maestro/Maestro.Editors/Fusion/MapCtrl.cs	2014-06-18 09:39:48 UTC (rev 8243)
@@ -101,15 +101,21 @@
             _edSvc.RegisterCustomNotifier(this);
             _models = new BindingList<MapModel>();
             lstMaps.DataSource = _models;
-            foreach (var m in group.Map.Select(x => new MapModel(x)))
-            {
-                _models.Add(m);
-            }
+            UpdateMapList();
             txtMapId.Text = _widget.MapId;
 
             LoadMapOptions();
         }
 
+        private void UpdateMapList()
+        {
+            _models.Clear();
+            foreach (var m in _group.Map.Select(x => new MapModel(x)))
+            {
+                _models.Add(m);
+            }
+        }
+
         private void LoadMapOptions()
         {
             foreach (var option in EditorFactory.GetAvailableOptions(_group))
@@ -117,9 +123,45 @@
                 var ed = option;
                 btnNewMap.DropDown.Items.Add(ed.Name, null, (s, e) =>
                 {
+                    bool bAddedCommercialLayer = false;
                     var map = ed.Action();
+                    if (map.Type == EditorFactory.Type_Google)
+                    {
+                        _appDef.SetValue("GoogleScript", EditorFactory.GOOGLE_URL);
+                        bAddedCommercialLayer = true;
+                    }
+                    else if (map.Type == EditorFactory.Type_Bing)
+                    {
+                        _appDef.SetValue("VirtualEarthScript", EditorFactory.BING_URL);
+                        bAddedCommercialLayer = true;
+                    }
+                    else if (map.Type == EditorFactory.Type_OSM)
+                    {
+                        _appDef.SetValue("OpenStreetMapScript", EditorFactory.OSM_URL);
+                        bAddedCommercialLayer = true;
+                    }
                     _group.AddMap(map);
                     _models.Add(new MapModel(map));
+                    if (bAddedCommercialLayer)
+                    {
+                        foreach (var m in _group.Map)
+                        {
+                            if (m.Type == EditorFactory.Type_MapGuide)
+                            {
+                                m.OverlayOptions = m.CreateOverlayOptions(false, true, "EPSG:900913"); //NOXLATE
+                            }
+                        }
+                    }
+                    else
+                    {
+                        foreach (var m in _group.Map)
+                        {
+                            if (m.Type == EditorFactory.Type_MapGuide)
+                            {
+                                m.OverlayOptions = null;
+                            }
+                        }
+                    }
                 });
             }
         }
@@ -146,11 +188,59 @@
             var map = lstMaps.SelectedItem as MapModel;
             if (map != null)
             {
+                btnRemoveMap.Enabled = btnMapUp.Enabled = btnMapDown.Enabled = true;
+
                 grpChildMap.Controls.Clear();
                 var control = EditorFactory.GetEditor(_edSvc, _group, map.Map);
                 control.Dock = DockStyle.Fill;
                 grpChildMap.Controls.Add(control);
             }
+            else
+            {
+                btnRemoveMap.Enabled = btnMapUp.Enabled = btnMapDown.Enabled = false;
+            }
         }
+
+        private void btnRemoveMap_Click(object sender, EventArgs e)
+        {
+            var map = lstMaps.SelectedItem as MapModel;
+            if (map != null)
+            {
+                _models.Remove(map);
+                _group.RemoveMap(map.Map);
+            }
+        }
+
+        private void btnMapUp_Click(object sender, EventArgs e)
+        {
+            var map = lstMaps.SelectedItem as MapModel;
+            if (map != null)
+            {
+                int idx = _models.IndexOf(map);
+                if (_group.MoveUp(map.Map))
+                {
+                    idx--;
+                    UpdateMapList();
+                    if (idx >= 0 && idx < lstMaps.Items.Count - 1)
+                        lstMaps.SelectedIndex = idx;
+                }
+            }
+        }
+
+        private void btnMapDown_Click(object sender, EventArgs e)
+        {
+            var map = lstMaps.SelectedItem as MapModel;
+            if (map != null)
+            {
+                int idx = _models.IndexOf(map);
+                if (_group.MoveDown(map.Map))
+                {
+                    idx++;
+                    UpdateMapList();
+                    if (idx >= 0 && idx < lstMaps.Items.Count - 1)
+                        lstMaps.SelectedIndex = idx;
+                }
+            }
+        }
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Editors/Fusion/MapEditors/EditorFactory.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Fusion/MapEditors/EditorFactory.cs	2014-06-18 09:02:42 UTC (rev 8242)
+++ trunk/Tools/Maestro/Maestro.Editors/Fusion/MapEditors/EditorFactory.cs	2014-06-18 09:39:48 UTC (rev 8243)
@@ -37,19 +37,19 @@
         const string BING_AERIAL = "Aerial"; //NOXLATE
         const string BING_HYBRID = "Hybrid"; //NOXLATE
 
-        const string Type_Google = "Google"; //NOXLATE
-        const string Type_Bing = "VirtualEarth"; //NOXLATE
-        const string Type_OSM = "OpenStreetMap"; //NOXLATE
-        const string Type_MapGuide = "MapGuide"; //NOXLATE
+        internal const string Type_Google = "Google"; //NOXLATE
+        internal const string Type_Bing = "VirtualEarth"; //NOXLATE
+        internal const string Type_OSM = "OpenStreetMap"; //NOXLATE
+        internal const string Type_MapGuide = "MapGuide"; //NOXLATE
         const string Type_Generic = "Generic"; //NOXLATE
 
         const string OSM_MAP_MAPNIK = "Mapnik"; //NOXLATE
         const string OSM_MAP_TRANSPORTMAP = "TransportMap"; //NOXLATE
         const string OSM_MAP_CYCLEMAP = "CycleMap"; //NOXLATE
 
-        const string OSM_URL = "http://www.openstreetmap.org/openlayers/OpenStreetMap.js"; //NOXLATE
-        const string GOOGLE_URL = "http://maps.google.com/maps/api/js?sensor=false"; //NOXLATE
-        const string BING_URL = "http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"; //NOXLATE
+        internal const string OSM_URL = "http://www.openstreetmap.org/openlayers/OpenStreetMap.js"; //NOXLATE
+        internal const string GOOGLE_URL = "http://maps.google.com/maps/api/js?sensor=false"; //NOXLATE
+        internal const string BING_URL = "http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"; //NOXLATE
 
         internal static Control GetEditor(IEditorService edSvc, IMapGroup group, IMap map)
         {

Modified: trunk/Tools/Maestro/Maestro.Editors/Fusion/MapEditors/MapGuideEditor.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Fusion/MapEditors/MapGuideEditor.Designer.cs	2014-06-18 09:02:42 UTC (rev 8242)
+++ trunk/Tools/Maestro/Maestro.Editors/Fusion/MapEditors/MapGuideEditor.Designer.cs	2014-06-18 09:39:48 UTC (rev 8243)
@@ -50,7 +50,7 @@
             // 
             this.chkSelectionAsOverlay.AutoSize = true;
             this.chkSelectionAsOverlay.ImeMode = System.Windows.Forms.ImeMode.NoControl;
-            this.chkSelectionAsOverlay.Location = new System.Drawing.Point(311, 107);
+            this.chkSelectionAsOverlay.Location = new System.Drawing.Point(317, 107);
             this.chkSelectionAsOverlay.Name = "chkSelectionAsOverlay";
             this.chkSelectionAsOverlay.Size = new System.Drawing.Size(124, 17);
             this.chkSelectionAsOverlay.TabIndex = 19;
@@ -218,7 +218,7 @@
             this.Controls.Add(this.txtMapDefinition);
             this.Controls.Add(this.btnBrowseMdf);
             this.Name = "MapGuideEditor";
-            this.Size = new System.Drawing.Size(460, 142);
+            this.Size = new System.Drawing.Size(460, 138);
             this.groupBox1.ResumeLayout(false);
             this.groupBox1.PerformLayout();
             this.ResumeLayout(false);

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs	2014-06-18 09:02:42 UTC (rev 8242)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs	2014-06-18 09:39:48 UTC (rev 8243)
@@ -697,6 +697,40 @@
 
     partial class MapGroupType : IMapGroup
     {
+        bool IMapGroup.MoveUp(IMap map)
+        {
+            var mt = map as MapType;
+            if (mt != null)
+            {
+                var idx = this.mapField.IndexOf(mt);
+                if (idx > 0)
+                {
+                    this.mapField.RemoveAt(idx);
+                    idx--;
+                    this.mapField.Insert(idx, mt);
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        bool IMapGroup.MoveDown(IMap map)
+        {
+            var mt = map as MapType;
+            if (mt != null)
+            {
+                var idx = this.mapField.IndexOf(mt);
+                if (idx < this.mapField.Count - 1)
+                {
+                    this.mapField.RemoveAt(idx);
+                    idx++;
+                    this.mapField.Insert(idx, mt);
+                    return true;
+                }
+            }
+            return false;
+        }
+
         IMap IMapGroup.CreateMapGuideEntry(string mapDefinition)
         {
             var map = new MapType()

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinitionInterfaces.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinitionInterfaces.cs	2014-06-18 09:02:42 UTC (rev 8242)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinitionInterfaces.cs	2014-06-18 09:39:48 UTC (rev 8243)
@@ -1123,6 +1123,10 @@
         IMap CreateCmsMapEntry(string type, bool singleTile, string name, string olType);
 
         IMap CreateGenericEntry();
+
+        bool MoveUp(IMap map);
+
+        bool MoveDown(IMap map);
     }
 
     public interface IMap : INotifyPropertyChanged, IExtensibleElement



More information about the mapguide-commits mailing list