/// <summary>
        /// Handles the Mouse Up situation.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected override void OnMouseUp(GeoMouseArgs e)
        {
            _currentPoint = e.Location;
            _isDragging   = false;
            Map.Invalidate();
            if (_geoStartPoint != null)
            {
                SelectionEnvelope = new Envelope(_geoStartPoint.X, e.GeographicLocation.X, _geoStartPoint.Y, e.GeographicLocation.Y);
            }

            // If they are not pressing shift, then first clear the selection before adding new members to it.
            if ((Control.ModifierKeys & Keys.Shift) != Keys.Shift)
            {
                foreach (IMapLayer lyr in Map.MapFrame.Layers)
                {
                    IMapFeatureLayer fl = lyr as IMapFeatureLayer;
                    fl?.LabelLayer?.ClearSelection();
                }
            }

            _doSelect = true;
            e.Map.MapFrame.ResetBuffer();
            e.Map.Invalidate();
            base.OnMouseUp(e);
        }
        /// <summary>
        /// Draws the label.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected override void OnDraw(MapDrawArgs e)
        {
            if (_isDragging)
            {
                Rectangle r = Opp.RectangleFromPoints(_startPoint, _currentPoint);
                r.Width  -= 1;
                r.Height -= 1;
                e.Graphics.DrawRectangle(Pens.White, r);
                e.Graphics.DrawRectangle(_selectionPen, r);
            }

            if (_doSelect)
            {
                foreach (IMapLayer lyr in Map.MapFrame.Layers)
                {
                    IMapFeatureLayer fl = lyr as IMapFeatureLayer;
                    fl?.LabelLayer?.Invalidate();
                }

                _doSelect = false;
                _selectTimer.Start();
            }

            base.OnDraw(e);
        }
示例#3
0
        internal IMapFeatureLayer CreateLayer(string type, string layerName)
        {
            IMapFeatureLayer layer = null;

            switch (type)
            {
            case "Polygon":
                layer = new MapPolygonLayer();
                break;

            case "Line":
                layer = new MapLineLayer();
                break;

            case "Point":
                layer = new MapPointLayer();
                break;

            case "MultiPolygon":
                layer = new MapPolygonLayer();
                break;

            default:
                throw new Exception("Wrong Layer Class:" + type);
            }
            layer.DataSet.Name = layerName;
            layer.LegendText   = layerName;
            return(layer);
        }
        /// <summary>
        /// This overload automatically constructs a new MapLayer from the specified
        /// feature layer with the default drawing characteristics and returns a valid
        /// IMapLayer which can be further cast into a PointLayer, MapLineLayer or
        /// a PolygonLayer, depending on the data that is passed in.
        /// </summary>
        /// <param name="featureSet">Any valid IFeatureSet that does not yet have drawing characteristics</param>
        /// <returns>A newly created valid implementation of FeatureLayer which at least gives a few more common
        /// drawing related methods and can also be cast into the appropriate Point, Line or Polygon layer.</returns>
        public virtual IMapFeatureLayer Add(IFeatureSet featureSet)
        {
            if (featureSet == null)
            {
                return(null);
            }

            featureSet.ProgressHandler = ProgressHandler;
            IMapFeatureLayer res = null;

            if (featureSet.FeatureType == FeatureType.Point || featureSet.FeatureType == FeatureType.MultiPoint)
            {
                res = new MapPointLayer(featureSet);
            }
            else if (featureSet.FeatureType == FeatureType.Line)
            {
                res = new MapLineLayer(featureSet);
            }
            else if (featureSet.FeatureType == FeatureType.Polygon)
            {
                res = new MapPolygonLayer(featureSet);
            }

            if (res != null)
            {
                base.Add(res);
                res.ProgressHandler = ProgressHandler;
            }

            return(res);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected override void OnDraw(MapDrawArgs e)
 {
     if (_isDragging)
     {
         Rectangle r = Opp.RectangleFromPoints(_startPoint, _currentPoint);
         r.Width  -= 1;
         r.Height -= 1;
         e.Graphics.DrawRectangle(Pens.White, r);
         e.Graphics.DrawRectangle(_selectionPen, r);
     }
     if (_doSelect)
     {
         foreach (IMapLayer lyr in Map.MapFrame.Layers)
         {
             IMapFeatureLayer fl = lyr as IMapFeatureLayer;
             if (fl == null)
             {
                 continue;
             }
             IMapLabelLayer gll = fl.LabelLayer;
             //gll.Select(_selectionEnvelope, e); // using this form of selection can test the actual pixel rectangles
             if (gll != null)
             {
                 gll.Invalidate();
             }
         }
         _doSelect = false;
         _selectTimer.Start();
     }
     base.OnDraw(e);
 }
        void saveAlignmentAttribute()
        {
            if (ProjectFile.LyrAlignment != -1)
            {
                IMapFeatureLayer alignmentFe = pvMap.Layers[ProjectFile.LyrAlignment] as IMapFeatureLayer;
                int nShp = alignmentFe.DataSet.NumRows();

                for (int iRow = 0; iRow < nShp; iRow++)
                {
                    IFeature fs = alignmentFe.DataSet.GetFeature(iRow);
                    try
                    {
                        if (chkSystemSpacing.Checked == true)
                        {
                            grdAlignment.Rows[iRow].Cells[1].Value = Convert.ToDouble(txtDx.Text);
                        }
                        fs.DataRow.BeginEdit();
                        fs.DataRow["spacing"] = grdAlignment.Rows[iRow].Cells[1].Value;
                        fs.DataRow["Remark"]  = grdAlignment.Rows[iRow].Cells[2].Value;
                        fs.DataRow.EndEdit();
                    }
                    catch { }
                }
            }
        }
示例#7
0
        private void menu_Click(object sender, EventArgs e)
        {
            FormContour Frm = new FormContour();

            Frm.layers = App.Map.GetRasterLayers();

            if (Frm.layers.GetLength(0) <= 0)
            {
                MessageBox.Show("No raster layer found!");
                return;
            }

            if (Frm.ShowDialog() == DialogResult.OK)
            {
                IMapFeatureLayer fl = App.Map.Layers.Add(Frm.Contours);
                fl.LegendText = Frm.LayerName + " - Contours";

                int numlevs = Frm.lev.GetLength(0);

                switch (Frm.contourtype)
                {
                case (Contour.ContourType.Line):
                {
                    LineScheme ls = new LineScheme();
                    ls.Categories.Clear();

                    for (int i = 0; i < Frm.color.GetLength(0); i++)
                    {
                        LineCategory lc = new LineCategory(Frm.color[i], 2.0);

                        lc.FilterExpression = "[Value] = " + Frm.lev[i].ToString();
                        lc.LegendText       = Frm.lev[i].ToString();

                        ls.AddCategory(lc);
                    }

                    fl.Symbology = ls;
                }
                break;

                case (Contour.ContourType.Polygon):
                {
                    PolygonScheme ps = new PolygonScheme();
                    ps.Categories.Clear();

                    for (int i = 0; i < Frm.color.GetLength(0); i++)
                    {
                        PolygonCategory pc = new PolygonCategory(Frm.color[i], Color.Transparent, 0);
                        pc.FilterExpression = "[Lev] = " + i.ToString();
                        pc.LegendText       = Frm.lev[i].ToString() + " - " + Frm.lev[i + 1].ToString();

                        ps.AddCategory(pc);
                    }

                    fl.Symbology = ps;
                }
                break;
                }
            }
        }
        private void updateAlignment()
        {
            if (ProjectFile.LyrAlignment != -1)
            {
                IMapFeatureLayer alignmentFe = pvMap.Layers[ProjectFile.LyrAlignment] as IMapFeatureLayer;
                int nShp = alignmentFe.DataSet.NumRows();

                for (int iRow = 0; iRow < nShp; iRow++)
                {
                    IFeature fs = alignmentFe.DataSet.GetFeature(iRow);
                    try
                    {
                        if (chkSystemSpacing.Checked == true)
                        {
                            grdAlignment.Rows[iRow].Cells[1].Value = Convert.ToDouble(txtDx.Text);
                        }
                        fs.DataRow.BeginEdit();
                        fs.DataRow["spacing"] = grdAlignment.Rows[iRow].Cells[1].Value;
                        fs.DataRow["Remark"]  = grdAlignment.Rows[iRow].Cells[2].Value;
                        fs.DataRow.EndEdit();
                        Color pntColor = Color.Yellow;
                    }
                    catch { }
                }
            }
            double           xSpacing = 1;
            int              iLyr     = ProjectFile.LyrAlignment;// getLayerHdl(cmbAlignmentLyr.Text);
            IMapFeatureLayer bLineLyr = pvMap.Layers[iLyr] as IMapFeatureLayer;

            CratePvPole(xSpacing, bLineLyr);
        }
示例#9
0
        private void PrintLayer(IMapLayer layer, MapArgs args)
        {
            MapLabelLayer.ClearAllExistingLabels();  //need to do this or labels not drawn on refresh
            IMapGroup group = layer as IMapGroup;

            if (group != null)
            {
                foreach (IMapLayer subLayer in group.Layers)
                {
                    PrintLayer(subLayer, args);
                }
            }

            IMapLayer geoLayer = layer;

            if (geoLayer != null)
            {
                if (geoLayer.UseDynamicVisibility)
                {
                    if (ViewExtents.Width > geoLayer.DynamicVisibilityWidth)
                    {
                        return;  // skip the geoLayer if we are zoomed out too far.
                    }
                }

                if (geoLayer.IsVisible == false)
                {
                    return;
                }

                geoLayer.DrawRegions(args, new List <Extent> {
                    args.GeographicExtents
                });

                IMapFeatureLayer mfl = geoLayer as IMapFeatureLayer;
                if (mfl != null)
                {
                    if (mfl.UseDynamicVisibility)
                    {
                        if (ViewExtents.Width > mfl.DynamicVisibilityWidth)
                        {
                            return;
                        }
                    }
                    if (mfl.ShowLabels && mfl.LabelLayer != null)
                    {
                        if (mfl.LabelLayer.UseDynamicVisibility)
                        {
                            if (ViewExtents.Width > mfl.LabelLayer.DynamicVisibilityWidth)
                            {
                                return;
                            }
                        }
                        mfl.LabelLayer.DrawRegions(args, new List <Extent> {
                            args.GeographicExtents
                        });
                    }
                }
            }
        }
示例#10
0
 private void cmdUpdateShape_Click(object sender, EventArgs e)
 {
     if (ProjectFile.LyrBuilding != -1)
     {
         IMapFeatureLayer blgdFe = PvMap.Layers[ProjectFile.LyrBuilding] as IMapFeatureLayer;
         List <IFeature>  lstFe  = new List <IFeature>();
         ISelection       selFe  = blgdFe.Selection;
         lstFe = selFe.ToFeatureList();
         int iRow = 0;
         foreach (IFeature fs in lstFe)
         {
             try
             {
                 fs.DataRow.BeginEdit();
                 fs.DataRow["Height"] = grdBldg.Rows[iRow].Cells["Height"].Value;
                 fs.DataRow["Remark"] = grdBldg.Rows[iRow].Cells["Remark"].Value;
                 fs.DataRow.EndEdit();
                 iRow++;
             }
             catch { }
         }
         blgdFe.Selection.Clear();
         this.Close();
         Michael.drawBuildingShadow();
     }
 }
示例#11
0
文件: frmMain.cs 项目: respec/BASINS
 private void MakeYellowStars(IMapFeatureLayer alayer)
 {
     alayer.Symbolizer = new PointSymbolizer(Color.Yellow, DotSpatial.Symbology.PointShape.Star, 16);
     alayer.Symbolizer.SetOutline(Color.Black, 1);
     //alayer.Symbolizer = new PointSymbolizer('A', "Freestyle Script", Color.Blue, 16);
     //alayer.Symbolizer = new PointSymbolizer(Images.wiki, 36);
 }
示例#12
0
        private void AssignLayerSymbologies(IMapFrame mapFrame)
        {
            foreach (ILayer layer in mapFrame.GetAllLayers())
            {
                IMapLineLayer lineLayer = layer as IMapLineLayer;
                if (lineLayer != null)
                {
                    ILineScheme original = lineLayer.Symbology;
                    if (original != null)
                    {
                        ILineScheme newScheme = original.Clone() as ILineScheme;
                        original.CopyProperties(newScheme);
                        original.ResumeEvents();
                    }
                }

                //to correctly draw categories:
                IMapFeatureLayer featureLayer = layer as IMapFeatureLayer;
                if (featureLayer != null)
                {
                    if (featureLayer.Symbology.NumCategories > 1)
                    {
                        featureLayer.DataSet.FillAttributes();
                        featureLayer.ApplyScheme(featureLayer.Symbology);
                    }
                }
            }
        }
示例#13
0
        private DataTable GetDataFromCurrentLayer(ILayer iLayer)
        {
            IMapFeatureLayer mapFeatureLayer = iLayer as IMapFeatureLayer;

            if (mapFeatureLayer == null || mapFeatureLayer.DataSet == null || mapFeatureLayer.DataSet.Filename == null)
            {
                return(null);
            }
            return(mapFeatureLayer.DataSet.DataTable);
        }
示例#14
0
        private void CreateMap()
        {
            string basePath = Server.MapPath(@"~\Shape");

            WebMap1.Projection     = KnownCoordinateSystems.Projected.World.WebMercator;
            WebMap1.MapViewExtents = new Extent(-20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789);


            WebMapClient client = new WebMapClient();


            WMTClient wmt1 = new WMTClient();

            wmt1.Create(WebServiceType.BingHybrid);


            string    WMSServerWMS0 = "http://maps.ngdc.noaa.gov/soap/web_mercator/marine_geology/MapServer/WMSServer";
            WMSClient wms0          = new WMSClient();

            wms0.ReadCapabilities(WMSServerWMS0);
            wms0.CRS        = "EPSG:3857";
            wms0.Projection = KnownCoordinateSystems.Projected.World.WebMercator;


            string WMSServerWMS1 = "http://maps.ngdc.noaa.gov/soap/web_mercator/graticule/MapServer/WMSServer";

            WMSClient wms1 = new WMSClient();

            wms1.ReadCapabilities(WMSServerWMS1);
            wms1.CRS        = "EPSG:3857";
            wms1.Projection = KnownCoordinateSystems.Projected.World.WebMercator;


            client.AddService(wmt1);
            client.AddService(wms0);
            client.AddService(wms1);

            WebMap1.Back = client;


            IMapFeatureLayer  countriesLayer = (IMapFeatureLayer)WebMap1.AddLayer(basePath + @"\10m_admin_0_countries.shp");
            PolygonSymbolizer symbCountries  = new PolygonSymbolizer(Color.FromArgb(0, 191, 0));

            symbCountries.SetFillColor(Color.Transparent);
            symbCountries.OutlineSymbolizer = new LineSymbolizer(Color.Magenta, 1);
            countriesLayer.Symbolizer       = symbCountries;


            IMapFeatureLayer graticules30Layer = (IMapFeatureLayer)WebMap1.AddLayer(basePath + @"\10m_graticules_30.shp");
            LineSymbolizer   symbGratitules30  = new LineSymbolizer(Color.Red, 1);

            graticules30Layer.Symbolizer = symbGratitules30;

            graticules30Layer.IsVisible = false;
        }
示例#15
0
        private void DisableBasemapLayer()
        {
            RemoveBasemapLayer(_baseMapLayer);
            RemoveBasemapLayer(_featureSetLayer);

            _optionsAction.Enabled = false;
            _baseMapLayer          = null;
            _featureSetLayer       = null;

            App.Map.MapFrame.ViewExtentsChanged -= MapFrameExtentsChanged;
        }
示例#16
0
        /// <summary>
        ///
        /// </summary>
        private void DisableBasemapLayer()
        {
            RemoveBasemapLayer(_baseMapLayer);
            RemoveBasemapLayer(_featureSetLayer);

            _baseMapLayer    = null;
            _basemapImage    = null;
            _featureSetLayer = null;

            App.Map.MapFrame.ViewExtentsChanged -= MapFrameExtentsChanged;
        }
示例#17
0
        protected void ApplyScheme(IMapFeatureLayer gridLayer, string fieldName)
        {
            IFeatureScheme newScheme = gridLayer.Symbology;

            newScheme.EditorSettings.NumBreaks          = 5;
            newScheme.EditorSettings.UseGradient        = true;
            newScheme.EditorSettings.ClassificationType = ClassificationType.Quantities;
            newScheme.EditorSettings.FieldName          = fieldName;
            newScheme.CreateCategories(gridLayer.DataSet.DataTable);
            newScheme.ResumeEvents();
            gridLayer.ApplyScheme(newScheme);
        }
示例#18
0
        /// <summary>
        /// 导入数据(Excel)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnImprotData_Click(object sender, RoutedEventArgs e)
        {
            ImportExcelDlg f = new ImportExcelDlg();

            if (f.ShowDialog() == true)
            {
                IFeatureSet      pFeaSet = f.ResultFeaSet;
                IMapFeatureLayer layer   = MainWindow.m_DotMap.Layers.Add(pFeaSet);
                //底层有bug 这里再赋值一次 否则无法显示属性表
                layer.DataSet.DataTable = f.m_DataTable;
                MainWindow.m_DotMap.ZoomToMaxExtent();
            }
        }
示例#19
0
        private void cmdApplyAllPanel_Click(object sender, EventArgs e)
        {
            project.PvHeight = Convert.ToDouble(txtPvHeight.Text);
            project.PvWidth  = Convert.ToDouble(txtPvWidth.Text);
            Michael.CreatePvPanel();

            /*
             * List<IFeature> ls1 = new List<IFeature>();
             * FeatureLayer fl1 = pvMap.Layers[project.LyrPole] as FeatureLayer;
             * ISelection il1 = fl1.Selection;
             * FeatureSet FeSet = il1.ToFeatureSet();
             *
             *
             * for (int i = 0; i < FeSet.NumRows();i++ )
             * {
             *  IFeature fs = FeSet.GetFeature(i);
             *  try
             *  {
             *      fs.DataRow.BeginEdit();
             *      fs.DataRow["H"] = Convert.ToDouble(txtPvHeight.Text);
             *      fs.DataRow["W"] = Convert.ToDouble(txtPvWidth.Text);
             *      fs.DataRow.EndEdit();
             *  }
             *  catch { }
             * }
             */
            if (Project.LyrPole != -1)
            {
                IMapFeatureLayer pvPositionFe = PvMap.Layers[Project.LyrPole] as IMapFeatureLayer;
                List <IFeature>  lstFe        = new List <IFeature>();
                ISelection       selFe        = pvPositionFe.Selection;
                lstFe = selFe.ToFeatureList();
                int iRow = 0;
                foreach (IFeature fs in lstFe)
                {
                    try
                    {
                        fs.DataRow.BeginEdit();
                        fs.DataRow["h"] = Convert.ToDouble(txtPvHeight.Text);
                        fs.DataRow["W"] = Convert.ToDouble(txtPvWidth.Text);
                        fs.DataRow.EndEdit();
                        iRow++;
                    }
                    catch { }
                }
                this.Close();
            }
            MessageBox.Show("Data updated successfully");
            this.Close();
        }
示例#20
0
        private void cmdUpdateShape_Click(object sender, EventArgs e)
        {
            project.PvHeightEdit  = lblPvHeight.Text;
            project.PvWidthEdit   = lblPvWidth.Text;
            project.PvTiltEdit    = lblTilt.Text;
            project.PvAzimuthEdit = lblAzimuth.Text;

            /*
             * try
             * {
             *   tabControl1.SelectedTab = tabPage0;
             *   for (int iRow = 0; iRow < grdPvPoleSelected.RowCount; iRow++)
             *   {
             *       grdPvPoleSelected.Rows[iRow].Cells["Ele_Angle"].Value = lblTilt.Text;
             *       grdPvPoleSelected.Rows[iRow].Cells["Azimuth"].Value = lblAzimuth.Text;
             *       grdPvPoleSelected.Rows[iRow].Cells["w"].Value = lblPvWidth.Text;
             *       grdPvPoleSelected.Rows[iRow].Cells["h"].Value = lblPvHeight.Text;
             *   }
             * }
             * catch { }
             */
            if (Project.LyrPole != -1)
            {
                IMapFeatureLayer LocationFe = PvMap.Layers[Project.LyrPole] as IMapFeatureLayer;
                List <IFeature>  lstFe      = new List <IFeature>();
                ISelection       selFe      = LocationFe.Selection;
                lstFe = selFe.ToFeatureList();

                int iRow = 0;
                foreach (IFeature fs in lstFe)
                {
                    try
                    {
                        fs.DataRow.BeginEdit();
                        fs.DataRow["Ele_Angle"] = grdPvPoleSelected.Rows[iRow].Cells["Ele_Angle"].Value;
                        fs.DataRow["Azimuth"]   = grdPvPoleSelected.Rows[iRow].Cells["Azimuth"].Value;
                        fs.DataRow["h"]         = grdPvPoleSelected.Rows[iRow].Cells["h"].Value;
                        fs.DataRow["w"]         = grdPvPoleSelected.Rows[iRow].Cells["w"].Value;
                        fs.DataRow["x"]         = grdPvPoleSelected.Rows[iRow].Cells["x"].Value;
                        fs.DataRow["y"]         = grdPvPoleSelected.Rows[iRow].Cells["y"].Value;
                        fs.DataRow.EndEdit();
                        iRow++;
                    }
                    catch { }
                }
                this.Close();
            }
            Michael.CreatePvPanel();
        }
示例#21
0
        private void cmdGetLayer_Click(object sender, EventArgs e)
        {
            int activeLyr = getLayerID(mMap, cmbProjectLyr.Text);

            listBox2.Items.Clear();
            try
            {
                IMapFeatureLayer FeLyr = mMap.Layers[activeLyr] as IMapFeatureLayer;
                int nShp = FeLyr.DataSet.NumRows() - 1;

                listBox2.Items.Add("Layer Type:" + FeLyr.GetType().ToString());
                listBox2.Items.Add("Numner of shape:" + nShp.ToString());
            }
            catch { MessageBox.Show("Error! Please select a shapefile layer"); }
        }
 internal void ShowAllFeatures()
 {
     IMapFeatureLayer[] featureLayers = this._Map.GetFeatureLayers();
     for (int i = 0; i < (int)featureLayers.Length; i++)
     {
         IMapFeatureLayer mapFeatureLayer = featureLayers[i];
         if (mapFeatureLayer.DataSet.AttributesPopulated)
         {
             for (int j = 0; j < (int)mapFeatureLayer.DrawnStates.Length; j++)
             {
                 mapFeatureLayer.DrawnStates[j].Visible = true;
             }
         }
     }
     this._Map.MapFrame.ResetBuffer();
 }
示例#23
0
        private void cmdCreatePvPole_Click(object sender, EventArgs e)
        {
            saveAlignmentAttribute();
            double xSpacing = 1;

            int iLyr = ProjectFile.LyrAlignment;// getLayerHdl(cmbAlignmentLyr.Text);
            IMapFeatureLayer bLineLyr = pvMap.Layers[iLyr] as IMapFeatureLayer;

            CratePvPole(xSpacing, bLineLyr);

            //grpBLineInfo.Visible = false;
            //loadLayerList();
            //MessageBox.Show("Pv. ploe created complete (Total Panel: " + numPvPanel.ToString() + ")");
            //updateArea();

            //MainForm.pvVerify();
        }
示例#24
0
 private void cmdReloadAlignmentData_Click(object sender, EventArgs e)
 {
     if (ProjectFile.LyrAlignment != -1)
     {
         IMapFeatureLayer alingmentFe = pvMap.Layers[ProjectFile.LyrAlignment] as IMapFeatureLayer;
         int nShp = alingmentFe.DataSet.NumRows() - 1;
         grdAlignment.Rows.Clear();
         for (int i = 0; i < alingmentFe.DataSet.NumRows(); i++)
         {
             grdAlignment.Rows.Add();
             IFeature fs     = alingmentFe.DataSet.GetFeature(i);
             object   sp     = fs.DataRow["spacing"];
             object   remark = fs.DataRow["remark"];
             grdAlignment.Rows[i].Cells[0].Value = i;
             grdAlignment.Rows[i].Cells[1].Value = sp;
             grdAlignment.Rows[i].Cells[2].Value = remark;
         }
     }
 }
示例#25
0
 void Map_SelectionChanged(object sender, EventArgs e)
 {
     if (App.Map.MapFrame.IsSelected)
     {
         SelectionStatusPanel.Caption = "All Layers Selected";
     }
     else
     {
         if (App.Map.Layers.SelectedLayer != null)
         {
             string           layName = App.Map.Layers.SelectedLayer.LegendText;
             IMapFeatureLayer mfl     = App.Map.Layers.SelectedLayer as IMapFeatureLayer;
             if (mfl != null)
             {
                 SelectionStatusPanel.Caption = String.Format("layer: {0} Selected: {1}", layName, mfl.Selection.Count);
             }
         }
     }
 }
示例#26
0
        private bool TryGetMapLayer(string layerName, out IMapFeatureLayer mapFeatureLayer)
        {
            mapFeatureLayer = null;

            foreach (var layer in this.map.Layers)
            {
                if (layer.LegendText.ToLower() == layerName.ToLower())
                {
                    IMapFeatureLayer temp = layer as IMapFeatureLayer;
                    if (temp != null)
                    {
                        mapFeatureLayer = temp;
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#27
0
        //when clicking "OK"
        private void btnOK_Click(object sender, EventArgs e)
        {
            SpatiaLiteHelper slh = new SpatiaLiteHelper();

            foreach (DataGridViewRow r in dgGeometryColumns.Rows)
            {
                if (r.Selected)
                {
                    GeometryColumnInfo item = r.DataBoundItem as GeometryColumnInfo;
                    if (item != null)
                    {
                        IFeatureSet fs = slh.ReadFeatureSet(connString, item);

                        IMapFeatureLayer lay = mainMap.Layers.Add(fs);
                        //lay.EditMode = false;
                    }
                }
            }
        }
示例#28
0
        private void ForceMaxExtentZoom()
        {
            // special case when there are no other layers in the map. Set map projection to WebMercator and zoom to max ext.
            App.Map.MapFrame.ReprojectMapFrame(_webMercProj);

            // modifying the view extents didn't get the job done, so we are creating a new featureset.
            var fs = new FeatureSet(FeatureType.Point);

            fs.Features.Add(new Coordinate(TileCalculator.MinWebMercX, TileCalculator.MinWebMercY));
            fs.Features.Add(new Coordinate(TileCalculator.MaxWebMercX, TileCalculator.MaxWebMercY));

            fs.Projection    = App.Map.Projection;
            _featureSetLayer = App.Map.Layers.Add(fs);

            // hide the points that we are adding.
            _featureSetLayer.LegendItemVisible = false;

            App.Map.ZoomToMaxExtent();
        }
示例#29
0
        private void ForceMaxExtentZoom()
        {
            ProjectionInfo webMerc = KnownCoordinateSystems.Projected.World.WebMercator;

            //special case when there are no other layers in the map. Set map projection to WebMercator and zoom to max ext.
            MapFrameProjectionHelper.ReprojectMapFrame(App.Map.MapFrame, webMerc.ToEsriString());

            // modifying the view extents didn't get the job done, so we are creating a new featureset.
            // App.Map.ViewExtents = new Extent(TileCalculator.MinWebMercX, TileCalculator.MinWebMercY, TileCalculator.MaxWebMercX, TileCalculator.MaxWebMercY);
            var fs = new FeatureSet(FeatureType.Point);

            fs.Features.Add(new Coordinate(TileCalculator.MinWebMercX, TileCalculator.MinWebMercY));
            fs.Features.Add(new Coordinate(TileCalculator.MaxWebMercX, TileCalculator.MaxWebMercY));

            fs.Projection    = App.Map.Projection;
            _featureSetLayer = App.Map.Layers.Add(fs);

            // hide the points that we are adding.
            _featureSetLayer.LegendItemVisible = false;

            App.Map.ZoomToMaxExtent();
        }
示例#30
0
        private void NewButton_Click(object sender, EventArgs e)
        {
            FeatureTypeDialog dlg = new FeatureTypeDialog();

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            FeatureSet fs = new FeatureSet(dlg.FeatureType);

            if (_geoMap.Projection != null)
            {
                fs.Projection = _geoMap.Projection;
            }
            fs.CoordinateType = dlg.CoordinateType;
            fs.IndexMode      = false;

            IMapFeatureLayer layer = _geoMap.Layers.Add(fs);

            layer.EditMode = true;
            _geoMap.Layers.SelectedLayer = layer;
            layer.LegendText             = _geoMap.Layers.UnusedName("New Layer");
        }
        /// <summary>
        /// Creates a new Table editor control for editing a feature layer's attribute values. This allows interaction
        /// with the map. If a row is selected in the Table the corresponding row is selected in the map
        /// </summary>
        /// <param name="layer">The symbolizer on the map</param>
        public TableEditorControl(IMapFeatureLayer layer)
        {
            FeatureLayer = layer;
 
            Configure();
        }
 //when the parent form is closed
 void ParentFormFormClosed(object sender, FormClosedEventArgs e)
 {
     _featureLayer = null;
     _table = null;
     Dispose();
 }
示例#33
0
 public void ClearLayers()
 {
     spatialMap.ClearLayers();
     if (spatialDataLayer != null)
     {
         spatialDataLayer.Dispose();
         spatialDataLayer = null;
     }
 }
示例#34
0
        private IFeatureSet GetSpatialDataSet()
        {
            if (spatialDataLayer == null)
            {
                var dataset = new FeatureSet(FeatureType.Point)
                {
                    Projection = KnownCoordinateSystems.Geographic.World.WGS1984,
                };
                spatialDataLayer = spatialMap.Layers.Add(dataset);
            }

            return spatialDataLayer.DataSet;
        }
示例#35
0
        private void ForceMaxExtentZoom()
        {
            //special case when there are no other layers in the map. Set map projection to WebMercator and zoom to max ext.
            App.Map.MapFrame.ReprojectMapFrame(WebMercProj);

            // modifying the view extents didn't get the job done, so we are creating a new featureset.
            var fs = new FeatureSet(FeatureType.Point);
            fs.Features.Add(new Coordinate(TileCalculator.MinWebMercX, TileCalculator.MinWebMercY));
            fs.Features.Add(new Coordinate(TileCalculator.MaxWebMercX, TileCalculator.MaxWebMercY));

            fs.Projection = App.Map.Projection;
            _featureSetLayer = App.Map.Layers.Add(fs);

            // hide the points that we are adding.
            _featureSetLayer.LegendItemVisible = false;

            App.Map.ZoomToMaxExtent();
        }
示例#36
0
        /// <summary>
        ///
        /// </summary>
        private void DisableBasemapLayer()
        {
            RemoveBasemapLayer(_baseMapLayer);
            RemoveBasemapLayer(_featureSetLayer);

            _baseMapLayer = null;
            _featureSetLayer = null;

            App.Map.MapFrame.ViewExtentsChanged -= MapFrameExtentsChanged;
        }
示例#37
0
        private void ForceMaxExtentZoom()
        {
            ProjectionInfo webMerc = KnownCoordinateSystems.Projected.World.WebMercator;

            //special case when there are no other layers in the map. Set map projection to WebMercator and zoom to max ext.
            MapFrameProjectionHelper.ReprojectMapFrame(App.Map.MapFrame, webMerc.ToEsriString());

            // modifying the view extents didn't get the job done, so we are creating a new featureset.
            // App.Map.ViewExtents = new Extent(TileCalculator.MinWebMercX, TileCalculator.MinWebMercY, TileCalculator.MaxWebMercX, TileCalculator.MaxWebMercY);
            var fs = new FeatureSet(FeatureType.Point);
            fs.Features.Add(new Coordinate(TileCalculator.MinWebMercX, TileCalculator.MinWebMercY));
            fs.Features.Add(new Coordinate(TileCalculator.MaxWebMercX, TileCalculator.MaxWebMercY));

            fs.Projection = App.Map.Projection;
            _featureSetLayer = App.Map.Layers.Add(fs);

            // hide the points that we are adding.
            _featureSetLayer.LegendItemVisible = false;

            App.Map.ZoomToMaxExtent();
        }