示例#1
0
 public void MoveToTop()
 {
     _axmap.MoveLayerTop(_axmap.get_LayerPosition(_currentMapLayer.Handle));
     _axmap.Redraw();
 }
示例#2
0
 public bool MoveTop(int initialPosition)
 {
     return(_axMap.MoveLayerTop(initialPosition));
 }
示例#3
0
        /// <summary>
        /// Saves a grid25 fishing map image  to the filename specified
        /// </summary>
        /// <returns></returns>
        private bool SaveGrid25MapToImage()
        {
            var        layerDictionary = MapLayersHandler.LayerDictionary;
            List <int> layersOnTop     = new List <int>();

            //sort the dictionary according to the weight of the layer. Layers with bigger weights are placed below those with smaller weights.
            foreach (KeyValuePair <int, MapLayer> kv in layerDictionary.OrderByDescending(r => r.Value.LayerWeight).Take(layerDictionary.Count))
            {
                if (kv.Value.Visible)
                {
                    //the layers with heavier weights are moved to the top. As the loop progresses, layers with ligter weights are placed on
                    //top. When the loop finishes, the lightest layer is on top while the heaviest layer is at the bottom.
                    if (kv.Value.LayerWeight != null)
                    {
                        _axMap.MoveLayerTop(_axMap.get_LayerPosition(kv.Value.Handle));
                    }
                    else
                    {
                        //layers whose weights are null will be placed below layers with weight values
                        _axMap.get_Shapefile(kv.Key).Labels.VerticalPosition = tkVerticalPosition.vpAboveParentLayer;
                    }

                    if (kv.Value.IsGrid25Layer)
                    {
                        switch (kv.Value.Name)
                        {
                        case "MBR":
                            _handleGridBoundary = kv.Value.Handle;
                            break;

                        case "Labels":
                            _handleLabels = kv.Value.Handle;

                            break;

                        case "Major grid":
                            _handleMajorGrid = kv.Value.Handle;
                            break;

                        case "Minor grid":
                            _handleMinorGrid = kv.Value.Handle;
                            break;
                        }
                    }

                    if (kv.Value.KeepOnTop)
                    {
                        layersOnTop.Add(kv.Value.Handle);
                    }
                }
            }

            foreach (int lyr in layersOnTop)
            {
                _axMap.MoveLayerTop(_axMap.get_LayerPosition(lyr));
            }

            //add a mask to the map control
            SetMask();
            var handleMask = MapLayersHandler.AddLayer(_shapeFileMask, "Grid mask", true);

            //move the mask layer to the top
            _axMap.MoveLayerTop(_axMap.get_LayerPosition(handleMask));

            //move the boundary layer on top so that it won't be hidden by the mask
            _axMap.MoveLayerTop(_axMap.get_LayerPosition(_handleGridBoundary));

            //make sure that map labels are placed on top of all layers
            _axMap.get_Shapefile(_handleLabels).Labels.VerticalPosition = tkVerticalPosition.vpAboveAllLayers;

            _axMap.get_Shapefile(_handleLabels).Labels.AvoidCollisions = false;

            bool success = false;

            try
            {
                success = SaveMapHelper(handleMask);
            }
            catch
            {
                success = false;
            }
            return(success);
        }