private void addSeaSpawn(object obj, EventArgs e)
 {
     var spawn = new Spawn(PanAndZoom.fromLocalToGlobal(editor.LeftClickPoint), spawnNumber++, SpawnType.Sea);
     scenarioItems.Add(spawn);
     editor.addScenarioItem(spawn, true);
 }
        private void doZoneProperties()
        {
            var list=data.Classes.First().Instances.First().PropertyValues.First().Value as NdfCollection;
            foreach (var item in list)
            {
                var reference=item.Value as NdfObjectReference;
                if (reference.Instance == null) continue;
                var designItem = reference.Instance;
                var position = designItem.PropertyValues.First(x=>x.Property.Name.Equals("Position")).Value as NdfVector;
                var rotation = designItem.PropertyValues.First(x => x.Property.Name.Equals("Rotation")).Value as NdfSingle;
                var scale = designItem.PropertyValues.First(x => x.Property.Name.Equals("Scale")).Value as NdfVector;
                var addonReference = designItem.PropertyValues.First(x => x.Property.Name.Equals("AddOn")).Value as NdfObjectReference;

                var addon = addonReference.Instance;

                var q = (Point3D)position.Value;
                var p = new AreaVertex();
                p.X = (float)q.X;
                p.Y = (float)q.Y;
                Zone zone;

                    zone = zones.FirstOrDefault(x =>
                        Geometry.isInside(p, x.getRawOutline())
                        );

                if (addon.Class.Name.Equals("TGameDesignAddOn_CommandPoints") && zone != null)
                {
                    var pos = addon.PropertyValues.First(x => x.Property.Name.Equals("Points")).Value as NdfInt32;
                    if (pos == null)
                    {
                        zone.value = 0;
                    }
                    else
                    {
                        zone.value = (int)pos.Value;
                    }
                }

                if (addon.Class.Name.Equals("TGameDesignAddOn_StartingPoint")&&zone != null)
                {

                        var pos=addon.PropertyValues.First(x => x.Property.Name.Equals("AllianceNum")).Value as NdfInt32;
                        if (pos == null)
                        {
                            zone.possession = (Possession)0;
                        }
                        else
                        {
                            zone.possession = (Possession)pos.Value;
                        }

                }
                if (addon.Class.Name.Equals("TGameDesignAddOn_ReinforcementLocation") && zone != null)
                {
                    var spawn = new Spawn(Geometry.convertPoint(q), (float)rotation.Value, (float)((Point3D)scale.Value).X, spawnNumber++,SpawnType.Land);
                    editor.addScenarioItem(spawn);
                    scenarioItems.Add(spawn);
                }
                if (addon.Class.Name.Equals("TGameDesignAddOn_MaritimeCorridor") && zone != null)
                {
                    var spawn = new Spawn(Geometry.convertPoint(q), (float)rotation.Value, (float)((Point3D)scale.Value).X, spawnNumber++,SpawnType.Sea);
                    editor.addScenarioItem(spawn);
                    scenarioItems.Add(spawn);
                }
                if (addon.Class.Name.Equals("TGameDesignAddOn_AerialCorridor") && zone != null)
                {
                    float s=1;
                    if (scale != null) s = (float)((Point3D)scale.Value).X;
                    var spawn = new Spawn(Geometry.convertPoint(q), (float)rotation.Value, s, spawnNumber++,SpawnType.Air);
                    editor.addScenarioItem(spawn);
                    scenarioItems.Add(spawn);
                }
                if (addon.Class.Name.Equals("TGameDesignAddOn_StartingCommandUnit") && zone != null)
                {

                    var prop=addon.PropertyValues.First(x => x.Property.Name.Equals("AllocationPriority"));
                    int prio = 0;
                    if (!(prop.Value is NdfNull))
                    {
                        prio = (int)((NdfInt32)prop.Value).Value;
                    }
                    var startPos = new Icon(Geometry.convertPoint(q), startPosNumber++, IconType.CV, prio);
                    editor.addScenarioItem(startPos);
                    scenarioItems.Add(startPos);
                }
                if (addon.Class.Name.Equals("TGameDesignAddOn_StartingFOB") && zone != null)
                {
                    var prop = addon.PropertyValues.First(x => x.Property.Name.Equals("AllocationPriority"));
                    int prio=0;
                    if (!(prop.Value is NdfNull))
                    {
                        prio=(int)((NdfInt32)prop.Value).Value;
                    }
                    var startPos = new Icon(Geometry.convertPoint(q), startPosNumber++, IconType.FOB, prio);
                    editor.addScenarioItem(startPos);
                    scenarioItems.Add(startPos);
                }

                //Console.WriteLine(rotation);
            }
        }
 private void addLandSpawn(object obj, EventArgs e)
 {
     var spawn = new Spawn(PanAndZoom.fromLocalToGlobal(editor.LeftClickPoint),spawnNumber,SpawnType.Land);
     scenarioItems.Add(spawn);
     editor.addScenarioItem(spawn, true);
     //Console.WriteLine("add land spawn");
 }