Beispiel #1
0
        public void MergeFeature(FeatureSet m_MergeFeaSet)
        {
            if (m_MergeFeaSet.Features.Count < 2 || m_CurrentFeaLyr == null)
            {
                return;
            }

            //确保目标图层只选中编辑的那一个要素,因为后面会把选中要素移除
            //m_CurrentFeaLyr.UnSelectAll();
            //m_CurrentFeaLyr.Selection.Clear();

            //merge
            IFeature MergeFea = m_MergeFeaSet.GetFeature(0);

            for (int i = 0; i < m_MergeFeaSet.Features.Count; i++)
            {
                var fea = m_MergeFeaSet.GetFeature(i);
                MergeFea = MergeFea.Union(fea.Geometry);
                if (MergeFea == null)
                {
                    break;
                }
            }
            lFeaM = m_InputFeaSet.AddFeature(MergeFea.Geometry);
            m_CurrentFeaLyr.RemoveSelectedFeatures();

            MainWindow.m_DotMap.ResetBuffer();
            MainWindow.m_DotMap.Refresh();


            if (MessageBox.Show("Save edit?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                m_CurrentFeaLyr.FeatureSet.Save();
                MessageBox.Show("Save successfully!");
            }
            //移除图层重新加载,因为底层bug 移动节点之后选择要素会报错。
            MainWindow.m_AddFeaType          = Enum.FeaType.None;
            MainWindow.m_DotMap.FunctionMode = FunctionMode.None;
            MainWindow.m_DotMap.Cursor       = System.Windows.Forms.Cursors.Default;
            string      shpPath = m_CurrentFeaLyr.FeatureSet.FilePath;
            string      name    = m_CurrentFeaLyr.LegendText;
            var         symbol  = m_CurrentFeaLyr.Symbolizer;
            var         extent  = m_CurrentFeaLyr.Extent;
            IFeatureSet s       = Shapefile.Open(shpPath);

            MainWindow.m_DotMap.Layers.Remove(m_CurrentFeaLyr as IMapLayer);
            var result = MainWindow.m_DotMap.Layers.Add(s);

            result.Symbolizer = symbol;
            result.Projection = MainWindow.m_DotMap.Projection;
            result.LegendText = name;
            //result.Select((result as FeatureLayer).FeatureSet.Features[(result as FeatureLayer).FeatureSet.Features.Count - 1]);
            this.Close();
        }
Beispiel #2
0
        /// <summary>
        /// Add the features from SourceFeatures to the TargetFeatures feature set.
        /// </summary>
        /// <param name="TargetFeatures">Feature set to which features will be added.</param>
        /// <param name="SourceFeatures">Source of features to add to the target feature set. </param>
        /// <returns>A point feature set with the randomly created features.</returns>
        public static FeatureSet AppendFeatures(FeatureSet TargetFeatures, FeatureSet SourceFeatures)
        {
            //Add the features from SourceFeatures to the TargetFeatures feature set
            //Note: we use the ShapeIndices here rather than for each feature in featureset.features as a memory management technique.
            //Dan Ames 2/27/2013
            IFeature SF;

            for (Int16 j = 0; j <= SourceFeatures.ShapeIndices.Count - 1; j++)
            {
                SF = SourceFeatures.GetFeature(j);                                                   //TODO jany_ why call get feature twice instead of using sf to copy attributes?
                TargetFeatures.AddFeature(SF.Geometry).CopyAttributes(SourceFeatures.GetFeature(j)); //by default this will try to copy attributes over that have the same name.
            }
            return(TargetFeatures);
        }
Beispiel #3
0
        /// <summary>
        /// Add the features from SourceFeatures to the TargetFeatures feature set.
        /// </summary>
        /// <param name="targetFeatures">Feature set to which features will be added.</param>
        /// <param name="sourceFeatures">Source of features to add to the target feature set. </param>
        /// <returns>A point feature set with the randomly created features.</returns>
        public static FeatureSet AppendFeatures(FeatureSet targetFeatures, FeatureSet sourceFeatures)
        {
            // Add the features from SourceFeatures to the TargetFeatures feature set
            // Note: we use the ShapeIndices here rather than for each feature in featureset.features as a memory management technique.
            // Dan Ames 2/27/2013
            for (short j = 0; j <= sourceFeatures.ShapeIndices.Count - 1; j++)
            {
                var sf = sourceFeatures.GetFeature(j);
                targetFeatures.AddFeature(sf.Geometry).CopyAttributes(sf); // by default this will try to copy attributes over that have the same name.
            }

            return(targetFeatures);
        }
        /// <summary>
        /// Get X,Y axis expressed by longitude and latitude
        /// </summary>
        /// <returns>mat[2][], mat[0] is longitude, mat[1] is latitude </returns>
        public float[][] GetLonLatAxis()
        {
            var lonlat = new float[2][];

            lonlat[0] = new float[ColumnCount];
            lonlat[1] = new float[RowCount];

            var         wgs84  = ProjectionInfo.FromEpsgCode(4326);
            IFeatureSet fs_lon = new FeatureSet(FeatureType.Point);

            fs_lon.Projection = this.Projection;
            for (int c = 0; c < ColumnCount; c++)
            {
                var   vertice = LocateCentroid(c + 1, 1);
                Point pt      = new Point(vertice);
                fs_lon.AddFeature(pt);
            }
            if (fs_lon.Projection != null)
            {
                fs_lon.Reproject(wgs84);
            }
            for (int c = 0; c < ColumnCount; c++)
            {
                var fea = fs_lon.GetFeature(c).Geometry.Coordinate;
                lonlat[0][c] = (float)fea.X;
            }


            IFeatureSet fs_lat = new FeatureSet(FeatureType.Point);

            fs_lat.Projection = this.Projection;
            for (int r = 0; r < RowCount; r++)
            {
                var   vertice = LocateCentroid(1, r + 1);
                Point pt      = new Point(vertice);
                fs_lat.AddFeature(pt);
            }
            if (fs_lat.Projection != null)
            {
                fs_lat.Reproject(wgs84);
            }
            for (int r = 0; r < RowCount; r++)
            {
                var fea = fs_lat.GetFeature(r).Geometry.Coordinate;
                lonlat[1][r] = (float)fea.Y;
            }

            return(lonlat);
        }
Beispiel #5
0
        private void mapMain_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (polygonmouseClick == true)
            {
                //get polygonGeomety instance of existing polygonFeature
                IFeature polygonFeature = polygonF.GetFeature(0);

                //add first coordinate
                Coordinate coord = polygonFeature.Coordinates[0];
                polygonFeature.Coordinates.Add(coord);

                polygonF.InitializeVertices();
                mapMain.ResetBuffer();

                //add first coordinate to the list
                xCoordinates.Add(coord.X);
                yCoordinates.Add(coord.Y);



                //we add new feature
                //Creat a list to contain the polygon coordinates
                List <Coordinate> polygonArray = new List <Coordinate>();
                for (int i = 0; i < xCoordinates.Count; i++)
                {
                    polygonArray.Add(new Coordinate(xCoordinates[i], yCoordinates[i]));
                }

                //Create an instance for LinearRing class.
                //We pass the polygon List to the constructor of this class
                LinearRing polygonGeometry          = new LinearRing(polygonArray);
                DotSpatial.Topology.Polygon polygon = new Polygon(polygonGeometry);

                //add polygonGeomety instance to polygonFeature
                IFeature polygonFeatureNew = polygonFNew.AddFeature(polygon);

                FeatureType ft = polygonFNew.FeatureType;

                polygonFNew.SaveAs("polygonF.shp", true);


                polygonmouseClick = false;
                mapMain.Cursor    = Cursors.Arrow;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Draws the labels for the given features.
        /// </summary>
        /// <param name="e">MapArgs to get Graphics object from.</param>
        /// <param name="features">Indizes of the features whose labels get drawn.</param>
        private void DrawFeatures(MapArgs e, IEnumerable <int> features)
        {
            // Check that exists at least one category with Expression
            if (Symbology.Categories.All(_ => string.IsNullOrEmpty(_.Expression)))
            {
                return;
            }

            Graphics g             = e.Device ?? Graphics.FromImage(BackBuffer);
            Matrix   origTransform = g.Transform;

            // Only draw features that are currently visible.
            if (FastDrawnStates == null)
            {
                CreateIndexedLabels();
            }

            FastLabelDrawnState[] drawStates = FastDrawnStates;
            if (drawStates == null)
            {
                return;
            }

            // Sets the graphics objects smoothing modes
            g.TextRenderingHint = TextRenderingHint.AntiAlias;
            g.SmoothingMode     = SmoothingMode.AntiAlias;

            Action <int, IFeature> drawFeature;

            switch (FeatureSet.FeatureType)
            {
            case FeatureType.Polygon:
                drawFeature = (fid, feature) => DrawPolygonFeature(e, g, feature, drawStates[fid].Category, drawStates[fid].Selected, ExistingLabels);
                break;

            case FeatureType.Line:
                drawFeature = (fid, feature) => DrawLineFeature(e, g, feature, drawStates[fid].Category, drawStates[fid].Selected, ExistingLabels);
                break;

            case FeatureType.Point:
            case FeatureType.MultiPoint:
                drawFeature = (fid, feature) => DrawPointFeature(e, g, feature, drawStates[fid].Category, drawStates[fid].Selected, ExistingLabels);
                break;

            default:
                return;     // Can't draw something else
            }

            foreach (var category in Symbology.Categories)
            {
                category.UpdateExpressionColumns(FeatureSet.DataTable.Columns);
                var catFeatures = new List <int>();
                foreach (int fid in features)
                {
                    if (drawStates[fid] == null || drawStates[fid].Category == null)
                    {
                        continue;
                    }
                    if (drawStates[fid].Category == category)
                    {
                        catFeatures.Add(fid);
                    }
                }

                // Now that we are restricted to a certain category, we can look at priority
                if (category.Symbolizer.PriorityField != "FID")
                {
                    Feature.ComparisonField = category.Symbolizer.PriorityField;
                    catFeatures.Sort();

                    // When preventing collisions, we want to do high priority first.
                    // Otherwise, do high priority last.
                    if (category.Symbolizer.PreventCollisions)
                    {
                        if (!category.Symbolizer.PrioritizeLowValues)
                        {
                            catFeatures.Reverse();
                        }
                    }
                    else
                    {
                        if (category.Symbolizer.PrioritizeLowValues)
                        {
                            catFeatures.Reverse();
                        }
                    }
                }

                foreach (var fid in catFeatures)
                {
                    if (!FeatureLayer.DrawnStates[fid].Visible)
                    {
                        continue;
                    }
                    var feature = FeatureSet.GetFeature(fid);
                    drawFeature(fid, feature);
                }
            }

            if (e.Device == null)
            {
                g.Dispose();
            }
            else
            {
                g.Transform = origTransform;
            }
        }
Beispiel #7
0
        public void RaiseCallbackEvent(String eventArgument)
//        public virtual void RaiseCallbackEvent(String eventArgument)  //to override in subclass
        {
//            returnCommand = "REFRESH";  //unsightly refresh when change legend selection
            returnCommand = "NOTHING";

//            string Nm = SessionName;  //not used

            GDIMap m = (GDIMap)System.Web.HttpContext.Current.Session[(string)ViewState[ClientID]];

            if (m == null)
            {
                return;
            }

            string[] arg = eventArgument.Split('|');

            string cmd = arg[0].ToUpper();

            switch (cmd)
            {
            case "ZOOMALL":
            {
                ZoomAll(ref m);
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "SELECT":
            {
                if (m.Layers.SelectedLayer != null)
                {
                    System.Drawing.Point pt1 = new System.Drawing.Point(Convert.ToInt32(arg[1]), Convert.ToInt32(arg[2]));
                    System.Drawing.Point pt2 = new System.Drawing.Point(Convert.ToInt32(arg[3]), Convert.ToInt32(arg[4]));

                    Coordinate pm1 = m.PixelToProj(pt1);
                    Coordinate pm2 = m.PixelToProj(pt2);

                    Extent ex = new Extent(Math.Min(pm1.X, pm2.X), Math.Min(pm1.Y, pm2.Y),
                                           Math.Max(pm1.X, pm2.X), Math.Max(pm1.Y, pm2.Y));

                    IEnvelope MapEnv = m.Extent.ToEnvelope();

                    m.Layers.SelectedLayer.ClearSelection(out MapEnv);


                    m.Layers.SelectedLayer.ClearSelection();

                    IEnvelope affectedarea = null;

//                                m.Layers.SelectedLayer.Select(m.ViewExtents.ToEnvelope(), ex.ToEnvelope(), Symbology.SelectionMode.IntersectsExtent, out affectedarea);
                    m.Layers.SelectedLayer.Select(ex.ToEnvelope(), ex.ToEnvelope(), Symbology.SelectionMode.Intersects, out affectedarea);

                    returnCommand = "STRUCTURE";
                }
                else
                {
                    returnValue   = "<table><tr><td>Select a layer first.<p></td></tr><table>";
                    returnCommand = "POPUP";
//                                returnValue = "Select a layer first.";
//                                returnCommand = "ALERT";
                }
            }
            break;

            case "INFO":
            {
                System.Drawing.Point pt = new System.Drawing.Point(Convert.ToInt32(arg[2]), Convert.ToInt32(arg[3]));
                Coordinate           pm = m.PixelToProj(pt);

                Extent ex = new Extent(pm.X, pm.Y, pm.X, pm.Y);

                if (m.Layers.SelectedLayer != null)
                {
                    FeatureSet fs = m.Layers.SelectedLayer.DataSet as FeatureSet;

//                                List<IFeature> flist = fs.Select(ex);  //returns empty list when IndexMode == false
                    List <int> flist = fs.SelectIndices(ex);

                    int n = flist.Count;

//                                returnValue = "<table border='1'>";  //looks goofy
                    returnValue = "<table>";

                    if (n > 0)
                    {
                        for (int i = 0; i < fs.DataTable.Columns.Count; i++)
                        {
                            returnValue += "<tr><td>" + fs.DataTable.Columns[i].ColumnName +
//                                                       "</td><td>" + flist[0].DataRow[i].ToString() + "</td></tr>";
                                           "</td><td>" + fs.GetFeature(flist[0]).DataRow[i].ToString() + "</td></tr>";
                        }

                        returnValue  += "</table>";
                        returnCommand = "POPUP";
                    }
                }
                else
                {
                    returnValue   = "<table><tr><td>Select a layer first.<p></td></tr><table>";
                    returnCommand = "POPUP";
//                                returnValue = "Select a layer first.";
//                                returnCommand = "ALERT";
                }
            }
            break;


            case "RESIZE":
            {
                Size NewSz    = new Size(Convert.ToInt32(arg[2]), Convert.ToInt32(arg[3]));
                Size ActualSz = ControlSize;

                if (ActualSz.Width == 0 || ActualSz.Height == 0)
                {
                    ControlSize = NewSz;

                    ZoomAll(ref m);

                    returnCommand = "STRUCTURE";
                }
                else
                {
                    if (NewSz != ActualSz)
                    {
                        ControlSize = NewSz;

                        returnCommand = "STRUCTURE";
                    }
                    else
                    {
                        returnCommand = "NOTHING";
                    }
                }
            }
            break;

            case "ZOOMRECT":
            {
                System.Drawing.Point pt1 = new System.Drawing.Point(Convert.ToInt32(arg[1]), Convert.ToInt32(arg[2]));
                System.Drawing.Point pt2 = new System.Drawing.Point(Convert.ToInt32(arg[3]), Convert.ToInt32(arg[4]));

                Coordinate pm1 = m.PixelToProj(pt1);
                Coordinate pm2 = m.PixelToProj(pt2);

                Extent x = new Extent(Math.Min(pm1.X, pm2.X),
                                      Math.Min(pm1.Y, pm2.Y),
                                      Math.Max(pm1.X, pm2.X),
                                      Math.Max(pm1.Y, pm2.Y));

                m.ViewExtents = x;
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "ZOOMIN":
            {
                int x = Convert.ToInt32(arg[1]);
                int y = Convert.ToInt32(arg[2]);

                System.Drawing.Point pntZoomAndCenter = new System.Drawing.Point((x - m.Size.Width / 2), (y - m.Size.Height / 2));
                m.MapFrame.Pan(pntZoomAndCenter);
                m.ZoomIn();
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "ZOOMOUT":
            {
                int x = Convert.ToInt32(arg[1]);
                int y = Convert.ToInt32(arg[2]);

                System.Drawing.Point pnt = new System.Drawing.Point((x - m.Size.Width / 2), (y - m.Size.Height / 2));

                m.MapFrame.Pan(pnt);
                m.ZoomOut();
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "PAN":
            {
                int x = Convert.ToInt32(arg[1]);
                int y = Convert.ToInt32(arg[2]);

// not used:                System.Drawing.Point pnt = new System.Drawing.Point((x - m.Size.Width / 2), (y - m.Size.Height / 2));

                m.MapFrame.Pan(new System.Drawing.Point(x, y));
                returnCommand = "REFRESH";
            }
            break;

            case "WHEELIN":
            {
                m.ZoomIn();
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "WHEELOUT":
            {
                m.ZoomOut();
                returnCommand = "REFRESHANDHIDEBUFFER";
            }
            break;

            case "DATAGRID":          //moved to here from RaisePostBackEvent
            {
                if (m.Layers.SelectedLayer != null)
                {
                    //string script=null;

                    IMapFeatureLayer MFL = (IMapFeatureLayer)m.Layers.SelectedLayer;

                    int n = MFL.Selection.Count;

                    FeatureSet fs;
                    DataTable  rs;
                    if (n > 0)
                    {
                        fs = MFL.Selection.ToFeatureSet();
                        rs = fs.DataTable;
                    }
                    else
                    {
                        fs = MFL.DataSet as FeatureSet;
                        rs = fs.DataTable;
                    }

                    if (DataOnGrid != null)              //Let event handler display grid?
                    {
                        DataGridEventArgs e = new DataGridEventArgs();
                        e.Recordsource = rs;
                        DataOnGrid(this, e);
                    }
                    else              //Display default HTML grid
                    {
                        returnValue = "<table border='1'><tr>";

                        for (int h = 0; h < rs.Columns.Count; h++)
                        {
                            returnValue += "<th>" + rs.Columns[h].ColumnName + "</th>";
                        }
                        returnValue += "</tr>";

                        string rowHtml;
                        for (int r = 0; r < rs.Rows.Count; r++)
                        {              //note: _much_ faster if build each row separately
                            rowHtml = "<tr>";
                            for (int c = 0; c < rs.Columns.Count; c++)
                            {
                                rowHtml += "<td>" + fs.GetFeature(r).DataRow[c].ToString() + "</td>";
                            }
                            rowHtml     += "</tr>";
                            returnValue += rowHtml;
                        }
                        returnValue  += "</table>";
                        returnCommand = "POPUP";
                    }
                }
                else
                {
                    returnValue   = "<table><tr><td>Select a layer first.<p></td></tr><table>";
                    returnCommand = "POPUP";
                }
            }
            break;

            case "ADDFEATURE":          //moved to here from RaisePostBackEvent
            {
                int num = Convert.ToInt32(arg[1]);

                System.Drawing.Point pt = new System.Drawing.Point();
                Coordinate[]         pm = new Coordinate[num];

                for (int i = 0; i < num; i++)
                {
                    pt.X = Convert.ToInt32(arg[(i + 1) * 2]);
                    pt.Y = Convert.ToInt32(arg[(i + 1) * 2 + 1]);

                    pm[i] = m.PixelToProj(pt);
                }

                if (m.Layers.SelectedLayer != null)
                {
                    FeatureSet  fs = m.Layers.SelectedLayer.DataSet as FeatureSet;
                    Feature     f;
                    FeatureType ft = FeatureType.Unspecified;

                    IMapFeatureLayer MFL = (IMapFeatureLayer)m.Layers.SelectedLayer;

                    if (MFL.GetType() == typeof(MapPointLayer))
                    {
                        ft = FeatureType.Point;
                    }
                    if (MFL.GetType() == typeof(MapLineLayer))
                    {
                        ft = FeatureType.Line;
                    }
                    if (MFL.GetType() == typeof(MapPolygonLayer))
                    {
                        ft = FeatureType.Polygon;
                    }

                    if (ft != FeatureType.Unspecified)
                    {
                        f = new Feature(ft, pm);

                        try
                        {
                            if (AddFeature != null)
                            {
                                AddFeature(this, fs, f);
                            }
                            else
                            {
                                try
                                {
                                    fs.AddFeature(f);
                                    fs.Save();
                                }
                                catch
                                {
                                    fs.Features.Remove(f);
                                    throw;              //re-throw exception
                                }
                                fs.InitializeVertices();
                            }
                            //Apparently have to force recreating labels when add feature.
                            if (MFL.LabelLayer != null)
                            {
                                // Recreating label layer works.
//                                            MapLabelLayer NewLabels = new MapLabelLayer();
//                                            NewLabels.Symbology = MFL.LabelLayer.Symbology;
//                                            NewLabels.Symbolizer = MFL.LabelLayer.Symbolizer;
//                                            MFL.LabelLayer = NewLabels;
                                // Recreating just labels also works.
                                MFL.LabelLayer.CreateLabels();
                            }
                            returnCommand = "FORCEREFRESH";
                        }
                        catch (Exception e)
                        {
                            returnValue   = "Unable to save feature.<p>" + e.Message;
                            returnCommand = "POPUPANDREFRESH";              //erase new shape too
                        }

//                                    fs.IndexMode = true;
                        //Adding a feature sets FeatureSet.IndexMode to false,
                        // causing fs.Select above in INFO case to return a list
                        // with Count == 0. One workaround is to set IndexMode
                        // back to true. This does cause all existing labels
                        // to disapper with refresh, but recreating label layer
                        // above fixed that. (Also tried InitializeVertices,
                        // InvalidateEnvelope, InvalidateVertices, UpdateExtents, etc.)
                        // Oops, setting IndexMode back to true corrupts shapes...
                    }
                }
            }
            break;
            }

            //ControlMap = m;
            System.Web.HttpContext.Current.Session[(string)ViewState[ClientID]] = m;

            if (returnCommand == "STRUCTURE")
            {
                returnValue = redraw(ref m);

                if (OnRedraw != null)
                {
                    OnRedraw(this);
                }
            }

            if (returnCommand == "REFRESH" | returnCommand == "REFRESHANDHIDEBUFFER")
            {
                returnValue = refresh(ref m);

                if (OnRedraw != null)
                {
                    OnRedraw(this);
                }
            }
        }
Beispiel #8
0
        // This draws the individual line features
        private void DrawFeatures(MapArgs e, IEnumerable <int> features)
        {
            Graphics g = e.Device ?? Graphics.FromImage(_backBuffer);

            // Only draw features that are currently visible.

            if (FastDrawnStates == null)
            {
                CreateIndexedLabels();
            }
            FastLabelDrawnState[] drawStates = FastDrawnStates;
            if (drawStates == null)
            {
                return;
            }
            //Sets the graphics objects smoothing modes
            g.TextRenderingHint = TextRenderingHint.AntiAlias;
            g.SmoothingMode     = SmoothingMode.AntiAlias;
            FeatureType type = FeatureSet.FeatureType;

            foreach (ILabelCategory category in Symbology.Categories)
            {
                List <int> catFeatures = new List <int>();
                foreach (int fid in features)
                {
                    if (drawStates[fid] == null || drawStates[fid].Category == null)
                    {
                        continue;
                    }
                    if (drawStates[fid].Category == category)
                    {
                        catFeatures.Add(fid);
                    }
                }
                // Now that we are restricted to a certain category, we can look at
                // priority
                if (category.Symbolizer.PriorityField != "FID")
                {
                    Feature.ComparisonField = category.Symbolizer.PriorityField;
                    catFeatures.Sort();
                    // When preventing collisions, we want to do high priority first.
                    // otherwise, do high priority last.
                    if (category.Symbolizer.PreventCollisions)
                    {
                        if (!category.Symbolizer.PrioritizeLowValues)
                        {
                            catFeatures.Reverse();
                        }
                    }
                    else
                    {
                        if (category.Symbolizer.PrioritizeLowValues)
                        {
                            catFeatures.Reverse();
                        }
                    }
                }
                foreach (int fid in catFeatures)
                {
                    IFeature feature = FeatureSet.GetFeature(fid);
                    switch (type)
                    {
                    case FeatureType.Polygon:
                        DrawPolygonFeature(e, g, feature, drawStates[fid].Category, drawStates[fid].Selected, ExistingLabels);
                        break;

                    case FeatureType.Line:
                        DrawLineFeature(e, g, feature, drawStates[fid].Category, drawStates[fid].Selected, ExistingLabels);
                        break;

                    case FeatureType.Point:
                        DrawPointFeature(e, g, feature, drawStates[fid].Category, drawStates[fid].Selected, ExistingLabels);
                        break;
                    }
                }
            }

            if (e.Device == null)
            {
                g.Dispose();
            }
        }