[mapguide-commits] r5286 - in sandbox/maestro-3.0: MaestroFsPreview OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/ObjectModels

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Oct 14 02:57:40 EDT 2010


Author: jng
Date: 2010-10-13 23:57:40 -0700 (Wed, 13 Oct 2010)
New Revision: 5286

Added:
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinitionInterfaces.cs
Modified:
   sandbox/maestro-3.0/MaestroFsPreview/
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs
Log:
3.0 sandbox changes:
 - Introduce interfaces for Map Definition schema


Property changes on: sandbox/maestro-3.0/MaestroFsPreview
___________________________________________________________________
Modified: svn:ignore
   - obj

   + obj
bin


Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj	2010-10-13 22:34:34 UTC (rev 5285)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj	2010-10-14 06:57:40 UTC (rev 5286)
@@ -197,6 +197,7 @@
     <Compile Include="ObjectModels\Envelope.cs" />
     <Compile Include="ObjectModels\FeatureSource.cs" />
     <Compile Include="ObjectModels\LayerFactory.cs" />
+    <Compile Include="ObjectModels\MapDefinitionInterfaces.cs" />
     <Compile Include="ObjectModels\SymbolInterfaces.cs" />
     <Compile Include="ObjectModels\VectorLayerDefinitionImpl.cs" />
     <Compile Include="ObjectModels\LayerInterfaceExtensions.cs" />

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs	2010-10-13 22:34:34 UTC (rev 5285)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs	2010-10-14 06:57:40 UTC (rev 5286)
@@ -46,7 +46,7 @@
         }
     }
 
-    partial class MapDefinition : IResource
+    partial class MapDefinition : IMapDefinition
     {
         internal MapDefinition() { } 
 
@@ -120,7 +120,7 @@
             get { return true; }
         }
 
-        public MapLayerGroupType AddGroup(string groupName)
+        public IMapLayerGroup AddGroup(string groupName)
         {
             if (this.MapLayerGroup == null)
                 this.MapLayerGroup = new System.ComponentModel.BindingList<MapLayerGroupType>();
@@ -138,7 +138,7 @@
             return group;
         }
 
-        public MapLayerType AddLayer(string groupName, string layerName, string resourceId)
+        public IMapLayer AddLayer(string groupName, string layerName, string resourceId)
         { 
             var layer = new MapLayerType() { 
                 Parent = this,
@@ -156,35 +156,222 @@
             this.MapLayer.Add(layer);
             return layer;
         }
+
+
+        OSGeo.MapGuide.ObjectModels.Common.Envelope IMapDefinition.Extents
+        {
+            get
+            {
+                if (this.Extents != null)
+                {
+                    return new OSGeo.MapGuide.ObjectModels.Common.Envelope()
+                    {
+                        MaxX = this.Extents.MaxX,
+                        MaxY = this.Extents.MaxY,
+                        MinX = this.Extents.MinX,
+                        MinY = this.Extents.MinY
+                    };
+                }
+                else
+                {
+                    return null;
+                }
+            }
+            set
+            {
+                if (value == null)
+                {
+                    this.Extents = null;
+                }
+                else
+                {
+                    if (this.Extents == null)
+                        this.Extents = new Box2DType();
+
+                    this.Extents.MaxX = value.MaxX;
+                    this.Extents.MaxY = value.MaxY;
+                    this.Extents.MinX = value.MinX;
+                    this.Extents.MinY = value.MinY;
+                }
+            }
+        }
+
+        IBaseMapDefinition IMapDefinition.BaseMap
+        {
+            get
+            {
+                return (IBaseMapDefinition)this.BaseMapDefinition;
+            }
+            set
+            {
+                this.BaseMapDefinition = (MapDefinitionTypeBaseMapDefinition)value;
+                if (this.BaseMapDefinition != null)
+                    this.BaseMapDefinition.Parent = this;
+            }
+        }
+
+        IEnumerable<IMapLayer> IMapDefinition.MapLayer
+        {
+            get 
+            {
+                foreach (var layer in this.MapLayer)
+                {
+                    yield return layer;
+                }
+            }
+        }
+
+        void IMapDefinition.RemoveLayer(IMapLayer layer)
+        {
+            var lyr = layer as MapLayerType;
+            if (lyr != null)
+                this.MapLayer.Remove(lyr);
+        }
+
+        IEnumerable<IMapLayerGroup> IMapDefinition.MapLayerGroup
+        {
+            get 
+            {
+                foreach (var grp in this.MapLayerGroup)
+                {
+                    yield return grp;
+                }
+            }
+        }
+
+        void IMapDefinition.RemoveGroup(IMapLayerGroup group)
+        {
+            var grp = group as MapLayerGroupType;
+            if (grp != null)
+                this.MapLayerGroup.Remove(grp);
+        }
     }
 
-    partial class MapLayerType
+    partial class MapDefinitionTypeBaseMapDefinition : IBaseMapDefinition
     {
         [XmlIgnore]
-        public MapDefinition Parent
+        public IMapDefinition Parent
         {
             get;
             set;
         }
+
+        IEnumerable<double> IBaseMapDefinition.FiniteDisplayScale
+        {
+            get 
+            {
+                foreach (var scale in this.FiniteDisplayScale)
+                {
+                    yield return scale;
+                }
+            }
+        }
+
+        public void AddFiniteDisplayScale(double value)
+        {
+            this.FiniteDisplayScale.Add(value);
+        }
+
+        public void RemoveFiniteDisplayScale(double value)
+        {
+            this.FiniteDisplayScale.Remove(value);
+        }
+
+        IEnumerable<IBaseMapGroup> IBaseMapDefinition.BaseMapLayerGroup
+        {
+            get 
+            {
+                foreach (var grp in this.BaseMapLayerGroup)
+                {
+                    yield return grp;
+                }
+            }
+        }
+
+        public void AddBaseLayerGroup(IBaseMapGroup group)
+        {
+            var grp = group as BaseMapLayerGroupCommonType;
+            if (grp != null)
+            {
+                this.BaseMapLayerGroup.Add(grp);
+                grp.Parent = this.Parent;
+            }
+        }
+
+        public void RemoveBaseLayerGroup(IBaseMapGroup group)
+        {
+            var grp = group as BaseMapLayerGroupCommonType;
+            if (grp != null)
+                this.BaseMapLayerGroup.Remove(grp);
+        }
     }
 
-    partial class BaseMapLayerType
+    partial class MapLayerType : IMapLayer
     {
+
+    }
+
+    partial class BaseMapLayerType : IBaseMapLayer
+    {
         [XmlIgnore]
-        public MapDefinition Parent
+        public IMapDefinition Parent
         {
             get;
             set;
         }
     }
 
-    partial class MapLayerGroupType
+    partial class MapLayerGroupType : IMapLayerGroup
     {
         [XmlIgnore]
-        public MapDefinition Parent
+        public IMapDefinition Parent
         {
             get;
             set;
         }
     }
+
+    partial class BaseMapLayerGroupCommonType : IBaseMapGroup
+    {
+        [XmlIgnore]
+        public IMapDefinition Parent
+        {
+            get;
+            set;
+        }
+
+        IEnumerable<IBaseMapLayer> IBaseMapGroup.BaseMapLayer
+        {
+            get 
+            {
+                foreach (var lyr in this.BaseMapLayer)
+                {
+                    yield return lyr;
+                }
+            }
+        }
+
+        public IBaseMapLayer AddLayer(string layerName, string resourceId)
+        {
+            BaseMapLayerType layer = new BaseMapLayerType()
+            {
+                Parent = this.Parent,
+                ExpandInLegend = true,
+                LegendLabel = layerName,
+                Name = layerName,
+                ResourceId = resourceId,
+                ShowInLegend = true,
+                Selectable = true
+            };
+            this.BaseMapLayer.Add(layer);
+            return layer;
+        }
+
+        public void RemoveBaseMapLayer(IBaseMapLayer layer)
+        {
+            var lyr = layer as BaseMapLayerType;
+            if (lyr != null)
+                this.BaseMapLayer.Remove(lyr);
+        }
+    }
 }

Added: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinitionInterfaces.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinitionInterfaces.cs	                        (rev 0)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinitionInterfaces.cs	2010-10-14 06:57:40 UTC (rev 5286)
@@ -0,0 +1,118 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.ObjectModels.Common;
+using System.Drawing;
+using System.ComponentModel;
+
+namespace OSGeo.MapGuide.ObjectModels.MapDefinition
+{
+    public interface IMapDefinition : IResource, INotifyPropertyChanged
+    {
+        string Name { get; set; }
+
+        string CoordinateSystem { get; set; }
+
+        Envelope Extents { get; set; }
+
+        Color BackgroundColor { get; set; }
+
+        string Metadata { get; set; }
+
+        IBaseMapDefinition BaseMap { get; set; }
+
+        IEnumerable<IMapLayer> MapLayer { get; }
+
+        IMapLayer AddLayer(string groupName, string layerName, string resourceId);
+
+        void RemoveLayer(IMapLayer layer);
+
+        IEnumerable<IMapLayerGroup> MapLayerGroup { get; }
+
+        IMapLayerGroup AddGroup(string groupName);
+         
+        void RemoveGroup(IMapLayerGroup group);
+    }
+
+    public interface IBaseMapDefinition
+    {
+        IEnumerable<double> FiniteDisplayScale { get; }
+
+        void AddFiniteDisplayScale(double value);
+
+        void RemoveFiniteDisplayScale(double value);
+
+        IEnumerable<IBaseMapGroup> BaseMapLayerGroup { get; }
+
+        void AddBaseLayerGroup(IBaseMapGroup group);
+
+        void RemoveBaseLayerGroup(IBaseMapGroup group);
+    }
+
+    public interface IMapLegendElementBase : INotifyPropertyChanged
+    {
+        string Name { get; set; }
+
+        bool ShowInLegend { get; set; }
+
+        string LegendLabel { get; set; }
+
+        bool ExpandInLegend { get; set; }
+    }
+
+    public interface IBaseMapLayer : IMapLegendElementBase
+    {
+        string ResourceId { get; set; }
+
+        bool Selectable { get; set; }
+
+        IMapDefinition Parent { get; }
+    }
+
+    public interface IBaseMapGroup : IMapLegendElementBase
+    {
+        bool Visible { get; set; }
+
+        IEnumerable<IBaseMapLayer> BaseMapLayer { get; }
+
+        IBaseMapLayer AddLayer(string layerName, string resourceId);
+
+        void RemoveBaseMapLayer(IBaseMapLayer layer);
+    }
+
+    public interface IMapLayer : IBaseMapLayer
+    {
+        bool Visible { get; set; }
+
+        string Group { get; set; }
+    }
+
+    public interface IMapLayerGroup : IMapLegendElementBase
+    {
+        bool Visible { get; set; }
+
+        string Group { get; set; }
+
+        IMapDefinition Parent { get; }
+    }
+}



More information about the mapguide-commits mailing list