Ejemplo n.º 1
0
        private void SelectExtents(MapWinGIS.Extents ext)
        {
            object[] Shapes = new object[m_Map.NumLayers];
            if (m_CurrentLayer == -1 || m_CurrentLayer >= m_Map.NumLayers)
            {
                for (int lyr = 0; lyr < m_Map.NumLayers; lyr++)
                {
                    object ob = m_Map.get_GetObject(lyr);
                    if (ob.GetType() != typeof(MapWinGIS.Shapefile))
                    {
                        return;
                    }
                    MapWinGIS.Shapefile sf = ob as MapWinGIS.Shapefile;
                    sf.SelectShapes(ext, 0, MapWinGIS.SelectMode.INTERSECTION, ref Shapes[m_CurrentLayer]);
                }
            }
            else
            {
                object ob = m_Map.get_GetObject(m_CurrentLayer);
                if (ob.GetType() != typeof(MapWinGIS.Shapefile))
                {
                    return;
                }
                MapWinGIS.Shapefile sf = ob as MapWinGIS.Shapefile;
                sf.SelectShapes(ext, 0, MapWinGIS.SelectMode.INTERSECTION, ref Shapes[m_CurrentLayer]);
            }

            m_Map.SuspendLayout();
            // If shift is down then we append to the selection
            if (m_ShiftPressed == false)
            {
                // Clear the selection first

                ClearSelectedShapes();
            }

            //Append selected shapes
            for (int lyr = 0; lyr < m_Map.NumLayers; lyr++)
            {
                int[] myShapes = Shapes[lyr] as int[];
                for (int shp = 0; shp <= myShapes.GetUpperBound(0); shp++)
                {
                    if (m_SelectedShapes[lyr].Contains(myShapes[shp]))
                    {
                        continue;
                    }
                    m_SelectedShapes[lyr].Add(myShapes[shp]);
                }
            }

            for (int lyr = 0; lyr < m_SelectedShapes.GetUpperBound(0); lyr++)
            {
                Highlight_Layer(lyr);
            }

            m_Map.ResumeLayout();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Launches a GeoProcDialog with Union Options for a Non-Static instance
        /// </summary>
        public void Union()
        {
            MapWinGeoProc.Dialogs.GeoProcDialog GPD = new MapWinGeoProc.Dialogs.GeoProcDialog();

            string[] LayerNames     = new string[m_Map.NumLayers];
            int      NumShapeLayers = 0;

            for (int lyr = 0; lyr < m_Map.NumLayers; lyr++)
            {
                // Only consider Shapefile Layers for the Union operation
                object ob = m_Map.get_GetObject(lyr);
                if (ob.GetType() != typeof(MapWinGIS.Shapefile))
                {
                    continue;
                }

                string name = m_Map.get_LayerName(lyr);
                if (name != null)
                {
                    LayerNames[lyr] = name;
                }
                else
                {
                    MapWinGIS.Shapefile sf = ob as MapWinGIS.Shapefile;
                    LayerNames[lyr] = sf.Filename;
                }
                NumShapeLayers++;
            }


            // First Input Layer or File
            MapWinGeoProc.Dialogs.LayerFileElement LF1 = GPD.Add_LayerFileElement(MapWinGeoProc.Dialogs.GeoProcDialog.ElementTypes.OpenShapefile);
            LF1.Caption = "Shapefile or Shape Layer Input";
            if (NumShapeLayers > 0)
            {
                // They can't use selected shapes unless this is a layer
                LF1.LayerNames = LayerNames;
                MapWinGeoProc.Dialogs.BooleanElement BE = GPD.Add_BooleanElement();
                // If the name is not a layer name, then this will be disabled
                LF1.LayerOnlyBoolElements.Add(BE);
                BE.Text = "Use Selected Shapes";
            }

            // Second Input Layer or File
            MapWinGeoProc.Dialogs.LayerFileElement LF2 = GPD.Add_LayerFileElement(MapWinGeoProc.Dialogs.GeoProcDialog.ElementTypes.OpenShapefile);
            if (NumShapeLayers > 0)
            {
                // They can't use selected shapes unless this is a layer
                LF2.LayerNames = LayerNames;
                MapWinGeoProc.Dialogs.BooleanElement BE2 = GPD.Add_BooleanElement();
                // If the name is not a layer name, then this will be disabled
                LF2.LayerOnlyBoolElements.Add(BE2);
                BE2.Text = "Use Selected Shapes";
            }

            MapWinGeoProc.Dialogs.FileElement Fout = GPD.Add_FileElement(MapWinGeoProc.Dialogs.GeoProcDialog.ElementTypes.SaveShapefile);



            GPD.ShowDialog();
        }