コード例 #1
0
        /// <summary>
        /// handles the event when a new visible layer is added into the map
        /// </summary>
        /// <param name="mapLayersHandler"></param>
        /// <param name="e"></param>
        private void OnLayerRead(MapLayersHandler mapLayersHandler, LayerEventArg e)
        {
            if (e.ShowInLayerUI)
            {
                //set the layer preview thumbnail
                PictureBox pic = new PictureBox
                {
                    Height  = layerGrid.RowTemplate.Height,
                    Width   = layerGrid.Columns[2].Width,
                    Visible = false
                };
                _mapLayersHandler.LayerSymbol(e.LayerHandle, pic, e.LayerType);

                if (!_mapLayersHandler[e.LayerHandle].IsMaskLayer)
                {
                    layerGrid.Invoke((MethodInvoker) delegate
                    {
                        //we always insert a new layer in the first row of the dataGrid
                        layerGrid.Rows.Insert(0, new object[] { e.LayerVisible, e.LayerName, pic.Image });

                        //we assign the layerhandle to the tag of cell 0,0
                        layerGrid[0, 0].Tag = e.LayerHandle;

                        //symbolize the current layer by making it bold font
                        MarkCurrentLayerName(CurrentLayerRow());
                    });
                }
            }
        }