예제 #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                }
                _axMap.ExtentsChanged -= OnMapExtentsChanged;
                _axMap.LayerRemoved   -= OnLayerRemoved;
                _axMap.LayerAdded     -= OnLayerAdded;
                _axMap = null;

                if (_sfGraticule != null)
                {
                    _sfGraticule.EditClear();
                }
                _sfGraticule = null;

                _geoProjection    = null;
                _graticuleExtents = null;
                _boundaryExtents  = null;
                _mapExtents       = null;
                _mapLayersHandler.OnLayerVisibilityChanged -= OnLayerVisibleChange;
                _mapLayersHandler.MapRedrawNeeded          -= OnRedrawNeeded;
                _mapLayersHandler.RemoveLayer("Mask");
                _mapLayersHandler.RemoveLayer(Name);
                _mapLayersHandler = null;
            }
        }
예제 #2
0
        private void UpdatePoint(AxMap Map, List <MapWinGIS.Point> PointsToUpdate)
        {
            var sf = new Shapefile();

            if (PointShapefileLayerHandle != -1)
            {
                sf = Map.get_Shapefile(PointShapefileLayerHandle);
            }

            if (PointShapefileLayerHandle == -1)
            {
                if (!sf.CreateNewWithShapeID("", ShpfileType.SHP_POINT))
                {
                    MessageBox.Show("Failed to create shapefile: " + sf.ErrorMsg[sf.LastErrorCode]);
                    return;
                }
                PointShapefileLayerHandle = Map.AddLayer(sf, true);
            }
            ShapeDrawingOptions options = sf.DefaultDrawingOptions;

            options.PointType        = tkPointSymbolType.ptSymbolStandard;
            options.PointShape       = tkPointShapeType.ptShapeCross;
            sf.DefaultDrawingOptions = options;
            sf.CollisionMode         = tkCollisionMode.AllowCollisions;
            sf.EditClear();

            foreach (MapWinGIS.Point PointToUpdate in PointsToUpdate)
            {
                Shape shp = new Shape();
                shp.Create(ShpfileType.SHP_POINT);
                MapWinGIS.Point pnt = PointToUpdate;

                int Index;
                Index = shp.NumPoints;

                shp.InsertPoint(pnt, ref Index);

                Index = sf.NumShapes;

                if (!sf.EditInsertShape(shp, Index))
                {
                    MessageBox.Show("Failed to insert shape: " + sf.ErrorMsg[sf.LastErrorCode]);
                    return;
                }

                Map.Redraw();
            }
            if (PointsToUpdate.Count == 0)
            {
                Map.Redraw();
            }
        }
예제 #3
0
        void ViewLine_AddLineEvent()
        {
            OpenFileDialog openLineDlg = new OpenFileDialog();

            openLineDlg.Filter = "矢量格式" + "|" + "*.shp";// + "|" + img.CdlgFilter;
            if (openLineDlg.ShowDialog() == DialogResult.OK)
            {
                String extention = Path.GetExtension(openLineDlg.FileName).ToLower();
                if (extention == ".shp")
                {
                    Shapefile lineShapefile = new Shapefile();
                    lineShapefile.Open(openLineDlg.FileName);
                    if (lineShapefile.ShapefileType != ShpfileType.SHP_POLYLINE)
                    {
                        return;
                    }

                    line = new Line(ref Map, lineShapefile, lineShapefileLayerHandle);
                    lineShapefileLayerHandle = line.LayerHandle;

                    var sf = new Shapefile();
                    if (PointShapefileLayerHandle != -1)
                    {
                        sf = Map.get_Shapefile(PointShapefileLayerHandle);
                        sf.EditClear();
                    }
                    foreach (MapWinGIS.Point pointFromLine in line.Points)
                    {
                        AddPoint(Map, pointFromLine.x, pointFromLine.y, pointFromLine.Key);
                    }

                    points = line.Points;

                    if (!(ViewLine == null || ViewLine.IsDisposed))
                    {
                        ViewLine.Close();
                    }
                    if (!(ViewPoint == null || ViewPoint.IsDisposed))
                    {
                        ViewPoint.Close();
                    }
                }
                else
                {
                    MessageBox.Show("罢工啦,亲~我只能识别.shp格式的线文件哦");
                }
            }
        }
예제 #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             _frameWidthDict.Clear();
             _frameWidthDict = null;
         }
         if (_shapeFileMask != null)
         {
             _shapeFileMask.EditClear();
             _shapeFileMask.Close();
             _shapeFileMask = null;
         }
         MapLayersHandler = null;
         _axMap           = null;
         _disposed        = true;
     }
 }
예제 #5
0
 public bool EditClear()
 {
     return(_shapefile.EditClear());
 }
예제 #6
0
 /// <summary>
 /// Rebuilds the graticule
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void Refresh()
 {
     _sfGraticule?.EditClear();
     _sfGraticule?.Labels.Clear();
     ShowGraticule();
 }
예제 #7
0
 /// <summary>
 /// removes all points from the shapefile and clears labels
 /// </summary>
 public void ClearLabels()
 {
     _shapeFileGrid25Labels.Labels.Clear();
     _shapeFileGrid25Labels.EditClear();
 }