Пример #1
0
        public override void OnMouseDown(int x, int y, System.Windows.Forms.MouseEventArgs e)
        {
            RgPoint P1 = mScreenDisplay.DisplayTransformation.ToUnit(new System.Drawing.PointF(x, y));

            Carto.FetureLayer featurelyr = mMapCtrl.Map.CurrentLayer as Carto.FetureLayer;
            if (featurelyr != null && featurelyr.ShapeType == RgEnumShapeType.RgPoint)
            {
                featurelyr.AddFeature(P1);
            }
            mMapCtrl.Refresh();
        }
Пример #2
0
        public override void OnMouseDown(int x, int y, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                n++;
                if (n <= 1)
                {
                    line = new LineString();
                    RgPoint pt = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(x, y));
                    line.Vertices.Add(pt);
                    lastPoint1Unit = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(x, y));
                    lastPoint2     = new PointF(x, y);
                }
                else
                {
                    RgPoint ptNext = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(x, y));
                    line.Vertices.Add(ptNext);
                    lastPoint1Unit = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(x, y));

                    lastPoint2 = new PointF(x, y);
                    mScreenDisplay.NewObject = line;
                    mMapCtrl.Refresh();
                }
            }
            else
            {
                Carto.FetureLayer featurelyr = mMapCtrl.Map.CurrentLayer as Carto.FetureLayer;
                if (featurelyr != null && featurelyr.ShapeType == RgEnumShapeType.RgLineString)
                {
                    featurelyr.AddFeature(line);
                }
                n = 0;
                mScreenDisplay.NewObject = null;
                mMapCtrl.Refresh();
            }
        }
Пример #3
0
        public override void OnMouseDown(int x, int y, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                n++;
                if (n == 1)
                {
                    RGeos.Geometries.RgPoint pt = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(x, y));
                    RGeos.Geometries.RgPoint P0 = new RGeos.Geometries.RgPoint(pt.X, pt.Y);
                    RGeos.Geometries.RgPoint P1 = new RGeos.Geometries.RgPoint(pt.X, pt.Y);
                    RGeos.Geometries.RgPoint P2 = new RGeos.Geometries.RgPoint(pt.X, pt.Y);
                    vertices.Add(P0);
                    vertices.Add(P1);
                    vertices.Add(P2);
                    line = new LinearRing(vertices);
                }
                else if (n == 2)
                {
                    PointF p2 = new PointF(x, y);
                    RGeos.Geometries.RgPoint pt1 = vertices[0];
                    RGeos.Geometries.RgPoint pt2 = mScreenDisplay.DisplayTransformation.ToUnit(p2);
                    vertices[1] = pt2;
                    mScreenDisplay.StartDrawing(mMapCtrl.CreateGraphics(), 1);
                    mScreenDisplayDraw.DrawLine(pt1, pt2, Pens.Blue);
                    mScreenDisplay.FinishDrawing();
                    //n = 0;
                }
                else if (n == 3)
                {
                    PointF p1 = new PointF(x, y);
                    RGeos.Geometries.RgPoint pt = mScreenDisplay.DisplayTransformation.ToUnit(p1);
                    vertices[2]          = pt;
                    polygon.ExteriorRing = line;
                    if (line != null)
                    {
                        SolidBrush brush = new SolidBrush(Color.Blue);
                        Pen        pen   = new Pen(brush);
                        mScreenDisplay.NewObject = polygon;
                        mMapCtrl.Refresh();
                    }
                }
                else
                {
                    PointF p1 = new PointF(x, y);
                    RGeos.Geometries.RgPoint pt = mScreenDisplay.DisplayTransformation.ToUnit(p1);
                    RGeos.Geometries.RgPoint P4 = pt;
                    vertices.Add(P4);
                    SolidBrush brush = new SolidBrush(Color.Blue);
                    Pen        pen   = new Pen(brush);
                    mScreenDisplay.NewObject = polygon;
                    mMapCtrl.Refresh();
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                Carto.FetureLayer featurelyr = mMapCtrl.Map.CurrentLayer as Carto.FetureLayer;
                if (featurelyr != null && featurelyr.ShapeType == RgEnumShapeType.RgPolygon)
                {
                    featurelyr.AddFeature(polygon);
                }

                vertices    = new List <RGeos.Geometries.RgPoint>();
                polygon     = new Polygon();
                tempPolygon = new Polygon();
                mScreenDisplay.NewObject = null;
                n = 0;
                mMapCtrl.Refresh();
            }
        }