Exemplo n.º 1
0
        public override void MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                this.IsMouseDown = false;

                // screen point to map point
                MG_LineString MapLineString = new MG_LineString();
                for (int i = 0; i < this.LineString.Count(); i++)
                {
                    MG_Point screenPoint = this.LineString.GetAt(i);
                    Point    screen      = new Point((int)screenPoint.x, (int)screenPoint.y);
                    MG_Point mapPoint    = MG_BaseRender.ToPoint(screen, this.MapView);
                    MapLineString.Add(mapPoint);
                }
                MG_LineString MapLineStringOther = new MG_LineString();
                for (int i = 0; i < this.LineStringOther.Count(); i++)
                {
                    MG_Point screenPoint = this.LineStringOther.GetAt(i);
                    Point    screen      = new Point((int)screenPoint.x, (int)screenPoint.y);
                    MG_Point mapPoint    = MG_BaseRender.ToPoint(screen, this.MapView);
                    MapLineStringOther.Add(mapPoint);
                }


                //1 create a feature
                // 1.1 set geometry
                this.Feature.SetGeometry(MapLineString);
                // 1.2 set field value
                for (int i = 0; i < this.Feature.GetFieldSet().Count(); i++)
                {
                    this.Feature.SetValue(i, null);
                }

                //2 create a new feature
                MG_Feature newFeature1 = new MG_Feature(this.Feature);
                //3 add new feature to layer
                this.Layer.AddFeature(newFeature1);

                //4 clear data to store the next linestring
                this.LineString.Clear();

                //1 create a feature
                // 1.1 set geometry
                this.Feature.SetGeometry(MapLineStringOther);
                // 1.2 set field value
                for (int i = 0; i < this.Feature.GetFieldSet().Count(); i++)
                {
                    this.Feature.SetValue(i, null);
                }

                //2 create a new feature
                MG_Feature newFeature2 = new MG_Feature(this.Feature);
                //3 add new feature to layer
                this.Layer.AddFeature(newFeature2);

                //4 clear data to store the next linestring
                this.LineStringOther.Clear();
            }
        }
Exemplo n.º 2
0
        private static MG_LineString AsLineString(Geometry g)
        {
            MG_LineString lineString = new MG_LineString();
            int           pointCount = g.GetPointCount();

            for (int i = 0; i < pointCount; i++)
            {
                MG_Point point = new MG_Point(g.GetX(i), g.GetY(i));
                lineString.Add(point);
            }
            return(lineString);
        }