[mapguide-commits] r5831 - in trunk/Tools/Maestro: Maestro.Editors/MapDefinition Maestro.Editors/Properties OSGeo.MapGuide.MaestroAPI/ObjectModels

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon May 23 08:15:19 EDT 2011


Author: jng
Date: 2011-05-23 05:15:19 -0700 (Mon, 23 May 2011)
New Revision: 5831

Modified:
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/FiniteScaleListCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/FiniteScaleListCtrl.resx
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.resx
   trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinitionInterfaces.cs
Log:
#1631: Implement convert group to base layer group option. Also check that when generating finite display scales, that the number of scale to generate is greater than 0.


Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/FiniteScaleListCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/FiniteScaleListCtrl.cs	2011-05-23 11:04:29 UTC (rev 5830)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/FiniteScaleListCtrl.cs	2011-05-23 12:15:19 UTC (rev 5831)
@@ -107,6 +107,12 @@
 
         private void btnGenerateScales_Click(object sender, EventArgs e)
         {
+            if (numScales.Value == 0)
+            {
+                MessageBox.Show(this, Properties.Resources.NoScalesToGenerate, Properties.Resources.TitleError, MessageBoxButtons.OK);
+                return;
+            }
+
             if (lstDisplayScales.Items.Count > 0)
             {
                 if (MessageBox.Show(this, Properties.Resources.OverwriteDisplayScales, Properties.Resources.Confirm, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)

Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/FiniteScaleListCtrl.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/FiniteScaleListCtrl.resx	2011-05-23 11:04:29 UTC (rev 5830)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/FiniteScaleListCtrl.resx	2011-05-23 12:15:19 UTC (rev 5831)
@@ -448,7 +448,7 @@
     <value>0</value>
   </data>
   <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>17, 17</value>
+    <value>3, 16</value>
   </metadata>
   <data name="btnEditScalesManually.ImageTransparentColor" type="System.Drawing.Color, System.Drawing">
     <value>Magenta</value>

Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs	2011-05-23 11:04:29 UTC (rev 5830)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs	2011-05-23 12:15:19 UTC (rev 5831)
@@ -119,6 +119,7 @@
         {
             _doLayerModel.Invalidate();
             _grpLayerModel.Invalidate();
+            _tiledLayerModel.Invalidate();
         }
 
         public event OpenLayerEventHandler RequestLayerOpen;
@@ -212,9 +213,10 @@
 
         private void RemoveSelectedLayerGroupItem(GroupItem group)
         {
-            _map.RemoveGroup(group.Tag);
+            _map.RemoveLayerGroupAndChildLayers(group.Tag.Name);
             propertiesPanel.Controls.Clear();
             _grpLayerModel.Invalidate();
+            _doLayerModel.Invalidate();
         }
 
         private void btnGRPAddLayer_Click(object sender, EventArgs e)
@@ -253,8 +255,38 @@
             var group = GetSelectedLayerGroupItem() as GroupItem;
             if (group != null)
             {
-                //...
-                throw new NotImplementedException();
+                var layGroup = group.Tag;
+                var layers = _map.GetLayersForGroup(layGroup.Name);
+
+                if (_map.BaseMap == null)
+                    _map.InitBaseMap();
+
+                int counter = 1;
+                string groupName = layGroup.Name;
+                var blg = _map.BaseMap.GetGroup(groupName);
+                while (blg != null)
+                {
+                    groupName = layGroup.Name + " (" + counter + ")";
+                    counter++;
+
+                    blg = _map.BaseMap.GetGroup(groupName);
+                }
+                blg = _map.BaseMap.AddBaseLayerGroup(groupName);
+                blg.LegendLabel = layGroup.LegendLabel;
+
+                foreach (var layer in layers)
+                {
+                    var bl = blg.AddLayer(layer.Name, layer.ResourceId);
+                    bl.LegendLabel = layer.LegendLabel;
+                    bl.Selectable = layer.Selectable;
+                    bl.ShowInLegend = layer.ShowInLegend;
+                    bl.ExpandInLegend = layer.ExpandInLegend;
+                }
+
+                _map.RemoveLayerGroupAndChildLayers(layGroup.Name);
+                MessageBox.Show(string.Format(Properties.Resources.LayerGroupConvertedToBaseLayerGroup, layGroup.Name, groupName));
+                this.RefreshModels();
+                tabControl1.SelectedIndex = 2; //Switch to Base Layer Groups
             }
         }
 

Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.resx	2011-05-23 11:04:29 UTC (rev 5830)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.resx	2011-05-23 12:15:19 UTC (rev 5831)
@@ -565,7 +565,7 @@
     <value>2</value>
   </data>
   <data name="TAB_BASE_LAYERS.Text" xml:space="preserve">
-    <value>Base Layer Grops</value>
+    <value>Base Layer Groups</value>
   </data>
   <data name="&gt;&gt;TAB_BASE_LAYERS.Name" xml:space="preserve">
     <value>TAB_BASE_LAYERS</value>

Modified: trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs	2011-05-23 11:04:29 UTC (rev 5830)
+++ trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs	2011-05-23 12:15:19 UTC (rev 5831)
@@ -1712,6 +1712,15 @@
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Layer Group ({0}) successfully converted to Base Layer Group ({1}).
+        /// </summary>
+        internal static string LayerGroupConvertedToBaseLayerGroup {
+            get {
+                return ResourceManager.GetString("LayerGroupConvertedToBaseLayerGroup", resourceCulture);
+            }
+        }
+        
         internal static System.Drawing.Bitmap layers_stack_arrange {
             get {
                 object obj = ResourceManager.GetObject("layers-stack-arrange", resourceCulture);
@@ -1906,6 +1915,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Number of Scales to generate cannot be less than or equal to 0.
+        /// </summary>
+        internal static string NoScalesToGenerate {
+            get {
+                return ResourceManager.GetString("NoScalesToGenerate", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Feature Source has no schemas.
         /// </summary>
         internal static string NoSchemasInFeatureSource {

Modified: trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx	2011-05-23 11:04:29 UTC (rev 5830)
+++ trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx	2011-05-23 12:15:19 UTC (rev 5831)
@@ -1181,4 +1181,10 @@
   <data name="SpatialContextsFound" xml:space="preserve">
     <value>{0} spatial contexts found</value>
   </data>
+  <data name="LayerGroupConvertedToBaseLayerGroup" xml:space="preserve">
+    <value>Layer Group ({0}) successfully converted to Base Layer Group ({1})</value>
+  </data>
+  <data name="NoScalesToGenerate" xml:space="preserve">
+    <value>Number of Scales to generate cannot be less than or equal to 0</value>
+  </data>
 </root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinitionInterfaces.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinitionInterfaces.cs	2011-05-23 11:04:29 UTC (rev 5830)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinitionInterfaces.cs	2011-05-23 12:15:19 UTC (rev 5831)
@@ -411,6 +411,37 @@
     public static class MapDefinitionExtensions
     {
         /// <summary>
+        /// Removes a layer group and all layers associated with this group
+        /// </summary>
+        /// <param name="map"></param>
+        /// <param name="groupName"></param>
+        /// <returns>The number of layers removed. Returns 0 if the group is empty or does not exist</returns>
+        public static int RemoveLayerGroupAndChildLayers(this IMapDefinition map, string groupName)
+        {
+            Check.NotNull(map, "map");
+            Check.NotEmpty(groupName, "groupName");
+
+            var group = map.GetGroupByName(groupName);
+            if (group != null)
+            {
+                List<IMapLayer> layers = new List<IMapLayer>(map.GetLayersForGroup(groupName));
+
+                int removed = 0;
+                //Remove layers first
+                foreach (var l in layers)
+                {
+                    map.RemoveLayer(l);
+                    removed++;
+                }
+                //Then the group
+                map.RemoveGroup(group);
+
+                return removed;
+            }
+            return 0;
+        }
+
+        /// <summary>
         /// Get a layer by its name
         /// </summary>
         /// <param name="map"></param>



More information about the mapguide-commits mailing list