Esempio n. 1
0
        private void Demo_Load(object sender, EventArgs e)
        {
            this.polygonLayer = map.AddLayer(shpRName) as DotSpatial.Controls.MapPolygonLayer;
            this.map.ZoomToMaxExtent();
            this.map.SizeChanged += map_SizeChanged;
            // this.map.MouseClick += map_MouseClick;
            if (polygonLayer != null)
            {
            }
            map.ActivateMapFunction(new DotSpatial.Controls.MapFunctionZoom(map));
            map.ActivateMapFunction(new DotSpatial.Controls.MapFunctionSelect(map));
            map.MouseMove += map_MouseMove;

            this.pointLayer = map.AddLayer(shpPName) as DotSpatial.Controls.MapPointLayer;
            if (this.pointLayer == null)
            {
                throw new Exception("加载点数据失败");
            }
            this.lineLayer = map.AddLayer(shpLName) as DotSpatial.Controls.MapLineLayer;
            if (this.lineLayer == null)
            {
                throw new Exception("加载线数据失败");
            }
            this.lineLayer.SelectionChanged    += lineLayer_SelectionChanged;
            this.pointLayer.SelectionChanged   += pointLayer_SelectionChanged;
            this.polygonLayer.SelectionChanged += polygonLayer_SelectionChanged;
            this.OutputLog("加载成功");
        }
Esempio n. 2
0
        public void SelectedLayerNullIfLayerRemoved()
        {
            DotSpatial.Controls.Map map = new DotSpatial.Controls.Map();
            string    path    = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFiles", "test-randomPts.shp");
            IMapLayer myLayer = map.AddLayer(path);

            Assert.IsNotNull(myLayer, "the added map layer should not be null.");

            myLayer.IsSelected = true;
            Assert.AreEqual(map.Layers.SelectedLayer, myLayer, "the selected layer should be equal to myLayer.");

            //now remove all layers
            map.Layers.Clear();

            //selectedLayer should be null
            Assert.IsNull(map.Layers.SelectedLayer, "SelectedLayer should be null after removing all layers");
        }
        public void SelectedLayerNullIfLayerRemoved()
        {
            DotSpatial.Controls.Map map = new DotSpatial.Controls.Map();
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFiles", "test-randomPts.shp");
            IMapLayer myLayer = map.AddLayer(path);

            Assert.IsNotNull(myLayer, "the added map layer should not be null.");

            myLayer.IsSelected = true;
            Assert.AreEqual(map.Layers.SelectedLayer, myLayer, "the selected layer should be equal to myLayer.");

            //now remove all layers
            map.Layers.Clear();

            //selectedLayer should be null
            Assert.IsNull(map.Layers.SelectedLayer, "SelectedLayer should be null after removing all layers");
        }