Пример #1
0
        public bool StartSelecting(string layerName)
        {
            ILayer selectionLayer = MapControlTools.Layers.Where(m => m.Name == layerName).FirstOrDefault();

            if (selectionLayer == null)
            {
                return(false);
            }
            CurrentSelectionLayers = new List <ILayer>();

            UnselectAllLayer();

            AddLayerToSelectionList(selectionLayer);

            IsEditing           = true;
            AxMap.SendMouseDown = true;
            AxMap.SendMouseUp   = true;

            AxMap.ShapeIdentified -= AxMap_ShapeIdentified;
            AxMap.ShapeIdentified += AxMap_ShapeIdentified;

            Events.MapControl_SelectingStateChange selectingStateChange = new Events.MapControl_SelectingStateChange()
            {
                SelectingState = Events.SelectingState.StartSelecting, SelectingLayers = CurrentSelectionLayers
            };
            On_SelectingStateChange(selectingStateChange);


            AxMap.Identifier.IdentifierMode = tkIdentifierMode.imAllLayers;
            AxMap.Identifier.OutlineColor   = utils.ColorByName(tkMapColor.Yellow);
            AxMap.CursorMode = tkCursorMode.cmIdentify;


            return(true);
        }
Пример #2
0
        public bool StartSelecting(Layer.ResTBPostGISType type)
        {
            CurrentSelectionLayers = new List <ILayer>();

            UnselectAllLayer();

            foreach (ILayer layer in MapControlTools.Layers)
            {
                if (layer.GetType() == typeof(ResTBDamagePotentialLayer))
                {
                    if (((ResTBPostGISLayer)layer).ResTBPostGISType == type)
                    {
                        ResTBDamagePotentialLayer resTBDamagePotentialLayer = (ResTBDamagePotentialLayer)layer;

                        CurrentSelectionLayers.Add(resTBDamagePotentialLayer);

                        Shapefile sf = AxMap.get_Shapefile(resTBDamagePotentialLayer.PointHandle);
                        sf.Identifiable = true;
                        sf.Selectable   = true;
                        sf = AxMap.get_Shapefile(resTBDamagePotentialLayer.LineHandle);
                        sf.Identifiable = true;
                        sf.Selectable   = true;
                        sf = AxMap.get_Shapefile(resTBDamagePotentialLayer.PolygonHandle);
                        sf.Identifiable = true;
                        sf.Selectable   = true;
                    }
                }
                else if (layer.GetType().BaseType == typeof(ResTBPostGISLayer))
                {
                    if (((ResTBPostGISLayer)layer).ResTBPostGISType == type)
                    {
                        AddLayerToSelectionList(layer);
                    }
                }
            }

            IsEditing           = true;
            AxMap.SendMouseDown = true;
            AxMap.SendMouseUp   = true;

            AxMap.ShapeIdentified -= AxMap_ShapeIdentified;
            AxMap.ShapeIdentified += AxMap_ShapeIdentified;

            Events.MapControl_SelectingStateChange selectingStateChange = new Events.MapControl_SelectingStateChange()
            {
                SelectingState = Events.SelectingState.StartSelecting, SelectingLayers = CurrentSelectionLayers
            };
            On_SelectingStateChange(selectingStateChange);

            AxMap.Identifier.IdentifierMode = tkIdentifierMode.imAllLayers;
            AxMap.Identifier.OutlineColor   = utils.ColorByName(tkMapColor.Yellow);
            AxMap.CursorMode = tkCursorMode.cmIdentify;

            return(true);
        }
Пример #3
0
        public bool StartSelecting(DB.Models.NatHazard natHazard, bool beforeMeasure)
        {
            CurrentSelectionLayers = new List <ILayer>();

            UnselectAllLayer();

            foreach (ILayer layer in MapControlTools.Layers)
            {
                if (layer.GetType() == typeof(ResTBHazardMapLayer))
                {
                    if (beforeMeasure)
                    {
                        if ((((ResTBHazardMapLayer)layer).NatHazard.ID == natHazard.ID) && (((ResTBHazardMapLayer)layer).ResTBPostGISType == ResTBPostGISType.HazardMapBefore))
                        {
                            AddLayerToSelectionList(layer);
                        }
                    }
                    else
                    {
                        if ((((ResTBHazardMapLayer)layer).NatHazard.ID == natHazard.ID) && (((ResTBHazardMapLayer)layer).ResTBPostGISType == ResTBPostGISType.HazardMapAfter))
                        {
                            AddLayerToSelectionList(layer);
                        }
                    }
                }
            }

            IsEditing           = true;
            AxMap.SendMouseDown = true;
            AxMap.SendMouseUp   = true;

            AxMap.ShapeIdentified -= AxMap_ShapeIdentified;
            AxMap.ShapeIdentified += AxMap_ShapeIdentified;

            Events.MapControl_SelectingStateChange selectingStateChange = new Events.MapControl_SelectingStateChange()
            {
                SelectingState = Events.SelectingState.StartSelecting, SelectingLayers = CurrentSelectionLayers
            };
            On_SelectingStateChange(selectingStateChange);

            AxMap.Identifier.IdentifierMode = tkIdentifierMode.imAllLayers;
            AxMap.Identifier.OutlineColor   = utils.ColorByName(tkMapColor.Yellow);
            AxMap.CursorMode = tkCursorMode.cmIdentify;

            return(true);
        }
Пример #4
0
        public void StopSelecting()
        {
            IsEditing = false;
            if (CurrentSelectionLayers != null)
            {
                foreach (ILayer layer in CurrentSelectionLayers)
                {
                    Shapefile sf = AxMap.get_Shapefile(layer.Handle);
                    sf.SelectNone();

                    if (layer.GetType() == typeof(ResTBDamagePotentialLayer))
                    {
                        ResTBDamagePotentialLayer resTBDamagePotentialLayer = (ResTBDamagePotentialLayer)layer;


                        sf = AxMap.get_Shapefile(resTBDamagePotentialLayer.PointHandle);
                        sf.SelectNone();
                        sf = AxMap.get_Shapefile(resTBDamagePotentialLayer.LineHandle);
                        sf.SelectNone();
                        sf = AxMap.get_Shapefile(resTBDamagePotentialLayer.PolygonHandle);
                        sf.SelectNone();
                    }
                }
            }

            CurrentSelectionLayers = null;
            //AxMap.ChooseLayer -= AxMap_ChooseLayer;
            AxMap.ShapeIdentified -= AxMap_ShapeIdentified;

            AxMap.CursorMode = tkCursorMode.cmNone;
            Events.MapControl_SelectingStateChange selectingStateChange = new Events.MapControl_SelectingStateChange()
            {
                SelectingState = Events.SelectingState.StopSelecting, SelectingLayers = CurrentSelectionLayers
            };
            On_SelectingStateChange(selectingStateChange);
        }
Пример #5
0
        private void AxMap_ShapeIdentified(object sender, AxMapWinGIS._DMapEvents_ShapeIdentifiedEvent e)
        {
            int selectedLayerHandle = e.layerHandle;
            int selectedShapeIndex  = e.shapeIndex;

            // multiple layers clicked, for simplicity just take the point-type, because on others we can click somewhere
            if (e.layerHandle == -1)
            {
                SelectionList sl = AxMap.IdentifiedShapes;

                // check for raste layers (remove them, we dont need it)
                for (int i = 0; i < sl.Count; i++)
                {
                    Shapefile sf = AxMap.get_Shapefile(sl.LayerHandle[i]);
                    if (sf == null)
                    {
                        sl.RemoveByLayerHandle(sl.LayerHandle[i]);
                    }
                }
                if (sl.Count > 1)
                {
                    for (int i = 0; i < sl.Count; i++)
                    {
                        Shapefile sf = AxMap.get_Shapefile(sl.LayerHandle[i]);

                        if (sf.ShapefileType == ShpfileType.SHP_POINT)
                        {
                            selectedLayerHandle = sl.LayerHandle[i];
                            selectedShapeIndex  = sl.ShapeIndex[i];
                        }
                        else
                        {
                            sl.RemoveByLayerHandle(sl.LayerHandle[i]);
                        }
                    }
                }


                // if there was no point, just take the first one
                if (selectedLayerHandle == -1)
                {
                    selectedLayerHandle = sl.LayerHandle[0];
                    selectedShapeIndex  = sl.ShapeIndex[0];
                }
            }

            foreach (ILayer layer in CurrentSelectionLayers)
            {
                if (layer.GetType() == typeof(ResTBDamagePotentialLayer))
                {
                    if ((selectedLayerHandle == ((ResTBDamagePotentialLayer)layer).PointHandle) || (selectedLayerHandle == ((ResTBDamagePotentialLayer)layer).LineHandle) || (selectedLayerHandle == ((ResTBDamagePotentialLayer)layer).PolygonHandle))
                    {
                        Events.MapControl_Clicked clicked = new Events.MapControl_Clicked();
                        Shapefile sf = AxMap.get_Shapefile(selectedLayerHandle);

                        clicked.ClickedShape      = sf.Shape[selectedShapeIndex];
                        clicked.ClickedShapeFile  = sf;
                        clicked.ClickedShapeIndex = selectedShapeIndex;
                        clicked.Layer             = layer;
                        MapControlTools.On_ShapeClicked(clicked);

                        Events.MapControl_SelectingStateChange selectingStateChange = new Events.MapControl_SelectingStateChange()
                        {
                            SelectingState = Events.SelectingState.ShapeSelected, SelectingLayers = CurrentSelectionLayers
                        };
                        On_SelectingStateChange(selectingStateChange);

                        //StopSelecting();
                    }
                }
                else if (selectedLayerHandle == layer.Handle)
                {
                    Events.MapControl_Clicked clicked = new Events.MapControl_Clicked();
                    Shapefile sf = AxMap.get_Shapefile(selectedLayerHandle);

                    clicked.ClickedShape      = sf.Shape[selectedLayerHandle];
                    clicked.ClickedShapeFile  = sf;
                    clicked.ClickedShapeIndex = selectedShapeIndex;
                    clicked.Layer             = layer;
                    MapControlTools.On_ShapeClicked(clicked);
                    Events.MapControl_SelectingStateChange selectingStateChange = new Events.MapControl_SelectingStateChange()
                    {
                        SelectingState = Events.SelectingState.ShapeSelected, SelectingLayers = CurrentSelectionLayers
                    };
                    On_SelectingStateChange(selectingStateChange);

                    //StopSelecting();
                }
            }
        }
Пример #6
0
 /// <summary>
 /// On_SelectingStateChange when a starting selecting, stopping, ...
 /// </summary>
 public void On_SelectingStateChange(Events.MapControl_SelectingStateChange e)
 {
     MapControlTools.On_SelectingStateChange(e);
 }