示例#1
0
        /// <summary>
        /// Finish the shape.
        /// </summary>
        /// <param name="sender">The object sender.</param>
        /// <param name="e">An empty EventArgs class.</param>
        public void FinishShape(object sender, EventArgs e)
        {
            if (_featureSet != null && !_featureSet.IsDisposed)
            {
                Feature f = null;
                if (_featureSet.FeatureType == FeatureType.MultiPoint)
                {
                    f = new Feature(new MultiPoint(_coordinates));
                }
                if (_featureSet.FeatureType == FeatureType.Line || _featureSet.FeatureType == FeatureType.Polygon)
                {
                    FinishPart(sender, e);
                    Shape shp = new Shape(_featureSet.FeatureType);
                    foreach (List <Coordinate> part in _parts)
                    {
                        if (part.Count >= 2)
                        {
                            shp.AddPart(part, _featureSet.CoordinateType);
                        }
                    }
                    f = new Feature(shp);
                }
                if (f != null)
                {
                    _featureSet.Features.Add(f);
                }
                _featureSet.InvalidateVertices();
                _featureSet.UpdateExtent();
            }

            _coordinates = new List <Coordinate>();
            _parts       = new List <List <Coordinate> >();
        }
示例#2
0
        /// <summary>
        /// Finish the shape.
        /// </summary>
        /// <param name="sender">The object sender.</param>
        /// <param name="e">An empty EventArgs class.</param>
        public void FinishShape(object sender, EventArgs e)
        {
            if (_featureSet != null && !_featureSet.IsDisposed)
            {
                Feature f = null;
                if (_featureSet.FeatureType == FeatureType.MultiPoint)
                {
                    f = new Feature(new MultiPoint(_coordinates.CastToPointArray()));
                }

                if (_featureSet.FeatureType == FeatureType.Line || _featureSet.FeatureType == FeatureType.Polygon)
                {
                    // if (_coordinates == null || _coordinates.Count < 2) return;
                    FinishPart(sender, e);

                    if (_parts == null || _parts.Count <= 0)
                    {
                        return;
                    }
                    Shape shp = new Shape(_featureSet.FeatureType);
                    foreach (List <Coordinate> part in _parts)
                    {
                        // In order to avoid exceptions
                        if (part != null && part.Count >= 2)
                        {
                            shp.AddPart(part, _featureSet.CoordinateType);
                        }
                    }

                    f = new Feature(shp);
                }

                if (f != null)
                {
                    _featureSet.Features.Add(f);
                }

                _featureSet.ShapeIndices = null; // Reset shape indices
                _featureSet.UpdateExtent();
                _layer.AssignFastDrawnStates();
                _featureSet.InvalidateVertices();
            }

            _coordinates = new List <Coordinate>();
            _parts       = new List <List <Coordinate> >();
        }
示例#3
0
        /// <summary>
        /// Finish the shape.
        /// </summary>
        /// <param name="sender">The object sender.</param>
        /// <param name="e">An empty EventArgs class.</param>
        public void FinishShape(object sender, EventArgs e)
        {
            bool chk = true;

            if (_featureSet.FeatureType == FeatureType.Point)
            {
                if (_coordinates.Count < 1)
                {
                    MessageBox.Show("No assigned coordinate system cannot create point");
                    chk = false;
                    return;
                }
            }
            if (_featureSet.FeatureType == FeatureType.Line)
            {
                if (_coordinates.Count < 2)
                {
                    MessageBox.Show("The number of point for creating line must equal or greather than 2 point");
                    chk = false;
                    return;
                }
            }
            if (_featureSet.FeatureType == FeatureType.Polygon)
            {
                if (_coordinates.Count < 3)
                {
                    MessageBox.Show("The number of point for creating polygon must equal or greather than 3 point");
                    chk = false;
                    return;
                }
            }
            if (chk = true)
            {
                if (_featureSet != null && !_featureSet.IsDisposed)
                {
                    Feature f = null;
                    if (_featureSet.FeatureType == FeatureType.MultiPoint)
                    {
                        f = new Feature(new MultiPoint(_coordinates));
                    }
                    if (_featureSet.FeatureType == FeatureType.Line || _featureSet.FeatureType == FeatureType.Polygon)
                    {
                        FinishPart(sender, e);

                        Shape shp = new Shape(_featureSet.FeatureType);
                        foreach (List <Coordinate> part in _parts)
                        {
                            if (part.Count >= 2)
                            {
                                shp.AddPart(part, _featureSet.CoordinateType);
                            }
                        }
                        f = new Feature(shp);
                    }
                    if (f != null)
                    {
                        _featureSet.Features.Add(f);
                    }
                    _featureSet.InvalidateVertices();
                    _featureSet.UpdateExtent();
                }

                _coordinates = new List <Coordinate>();
                _parts       = new List <List <Coordinate> >();
            }
        }