#region Disclaimer / License
// Copyright (C) 2014, Jackie Ng
// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie@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 Disclaimer / License
#define LDF_240
using OSGeo.MapGuide.ObjectModels.SymbolDefinition;
using System.Drawing;
using System.IO;
#pragma warning disable 1591, 0114, 0108
#if LDF_110
namespace OSGeo.MapGuide.ObjectModels.LayerDefinition.v1_1_0
#elif LDF_120
namespace OSGeo.MapGuide.ObjectModels.LayerDefinition.v1_2_0
#elif LDF_130
namespace OSGeo.MapGuide.ObjectModels.LayerDefinition.v1_3_0
#elif LDF_230
namespace OSGeo.MapGuide.ObjectModels.LayerDefinition.v2_3_0
#elif LDF_240
namespace OSGeo.MapGuide.ObjectModels.LayerDefinition.v2_4_0
#else
namespace OSGeo.MapGuide.ObjectModels.LayerDefinition.v1_0_0
#endif
{
///
/// A publically accessible entry point primarily used for registration with the and
/// classes
///
public static class LdfEntryPoint
{
public static ILayerDefinition CreateDefault(LayerType type)
{
return LayerDefinition.CreateDefault(type);
}
public static IResource Deserialize(string xml)
{
return LayerDefinition.Deserialize(xml);
}
public static Stream Serialize(IResource res)
{
var ldf = (ILayerDefinition)res;
var vl = ldf.SubLayer as IVectorLayerDefinition;
if (vl != null)
{
foreach (var vsr in vl.VectorScaleRange)
{
var vsr2 = vsr as IVectorScaleRange2;
if (vsr2 != null)
{
var ctss = vsr2.CompositeStyle;
if (ctss != null)
{
foreach (var cts in ctss)
{
foreach (var crs in cts.CompositeRule)
{
var csym = crs.CompositeSymbolization;
if (csym != null)
{
foreach (var si in csym.SymbolInstance)
{
if (si.Reference.Type == OSGeo.MapGuide.ObjectModels.SymbolDefinition.SymbolInstanceType.Inline)
{
var symBase = ((ISymbolInstanceReferenceInline)si.Reference).SymbolDefinition;
symBase.RemoveSchemaAttributes();
}
}
}
}
}
}
}
}
}
return res.SerializeToStream();
}
}
partial class LayerDefinition : ILayerElementFactory
{
public static ILayerDefinition CreateDefault(LayerType type)
{
var lyr = new LayerDefinition();
switch (type)
{
case LayerType.Drawing:
lyr.CreateDrawingLayer();
break;
case LayerType.Raster:
lyr.CreateRasterLayer();
break;
case LayerType.Vector:
lyr.CreateVectorLayer();
break;
}
return lyr;
}
protected virtual VectorLayerDefinitionType CreateVectorLayerInstance()
{
return new VectorLayerDefinitionType();
}
protected virtual VectorScaleRangeType CreateVectorScaleRangeInstance()
{
return new VectorScaleRangeType()
{
Items = new System.ComponentModel.BindingList