コード例 #1
0
ファイル: ShpPolygon.cs プロジェクト: ntj/GravurGIS
 /// <summary>
 /// removes a point at a special position in a polygon and recalculates boundingBox
 /// </summary>
 /// <param name="index"></param>
 public override void RemovePoint(int index)
 {
     if (index == 0)
     {
         minX   = double.NaN;
         minY   = double.NaN;
         width  = double.NaN;
         height = double.NaN;
         points.RemoveAt(index);
     }
     else
     {
         ShpPoint tempPoint = points[index];
         points.RemoveAt(index);
         if (tempPoint.CenterX == minX || tempPoint.CenterX == minX + width ||
             tempPoint.CenterY == minY || tempPoint.CenterY == minY + height
             )
         {
             minX   = points[0].CenterX;
             minY   = points[0].CenterY;
             width  = 0;
             height = 0;
             checkBoundingBox();
         }
     }
 }
コード例 #2
0
ファイル: ShpPolygon.cs プロジェクト: ntj/GravurGIS
        public override int RemovePoint(ShpPoint point)
        {
            bool result = false;

            if (points.Count > 4) // since we save start and end points seperately
            {
                int index = points.IndexOf(point);

                result = points.Remove(point);

                if (result)
                {
                    if (index == 0) // did we delete the root point? Close the polygon again!
                    {
                        points[points.Count - 1].moveTo(
                            points[0].RootX,
                            points[0].RootY, false, true);
                    }

                    else if (index == points.Count) // did we delete the closing point? (since we removed one point we test against the now smaller list, hence Count can be used
                    {
                        points[0].moveTo(
                            points[points.Count - 1].RootX,
                            points[points.Count - 1].RootY, false, true);
                    }

                    checkBoundingBox();

                    return(index);
                }
            }
            return(-1);
        }
コード例 #3
0
ファイル: ShpPolygon.cs プロジェクト: ntj/GravurGIS
        public override void InsertPointAt(int index, double x, double y, double scale)
        {
            ShpPoint pointToAdd = new ShpPoint(x, y, scale);

            if (index == points.Count)
            {
                points.Add(pointToAdd);

                points[0].moveTo(
                    points[points.Count - 1].RootX,
                    points[points.Count - 1].RootY,
                    false,
                    true);
            }
            else
            {
                points.Insert(index, pointToAdd);


                if (index == 0) // did we delete the root point? Close the polygon again!
                {
                    points[points.Count - 1].moveTo(
                        points[0].RootX,
                        points[0].RootY,
                        false,
                        true);
                }
            }

            checkBoundingBox();

            pointToAdd.Changed += new PositionChangedDelegate(vertex_PositionChanged);
        }
コード例 #4
0
        public override int RemovePoint(ShpPoint point)
        {
            int index = points.IndexOf(point);

            bool result = points.Remove(point);

            if (points.Count == 0)
            {
                minX   = double.NaN;
                minY   = double.NaN;
                width  = double.NaN;
                height = double.NaN;
            }
            else
            {
                checkBoundingBox();
            }

            if (result)
            {
                return(index);
            }
            else
            {
                return(-1);
            }
        }
コード例 #5
0
ファイル: EditGeometryMenu.cs プロジェクト: ntj/GravurGIS
        public EditGeometryMenu(MainForm mainForm, IShape container, ShpPoint vertex)
            : base()
        {
            this.mainForm = mainForm;
            this.container = container;
            this.vertex = vertex;

            moveMenuItem = new MenuItem();
            moveMenuItem.Text = "verschieben";
            moveMenuItem.Checked = false;
            moveMenuItem.Click += new System.EventHandler(menuItemClick);

            //choosePositionMenuItem = new MenuItem();
            //choosePositionMenuItem.Text = "Position eingeben";
            //choosePositionMenuItem.Checked = false;
            //choosePositionMenuItem.Click += new System.EventHandler(menuItemClick);

            removeShapeMenuItem = new MenuItem();
            removeShapeMenuItem.Text = "löschen";
            removeShapeMenuItem.Checked = false;
            removeShapeMenuItem.Click += new System.EventHandler(menuItemClick);

            // you can not delete a point if there are less then three points in the polygon
            if ((container.PointCount <= 4 &&
                (container as ShpPolygon) != null)
                ||
                (container.PointCount <= 2 &&
                (container as ShpPolyline) != null))
                removeShapeMenuItem.Enabled = false;

            this.MenuItems.Add(moveMenuItem);
            //this.MenuItems.Add(choosePositionMenuItem);
            this.MenuItems.Add(removeShapeMenuItem);
        }
コード例 #6
0
ファイル: ShpPolygon.cs プロジェクト: ntj/GravurGIS
        public override void AddPoint(double x, double y, double scale)
        {
            ShpPoint pointToAdd = new ShpPoint(x, y, scale);

            points.Add(pointToAdd);
            checkBoundingBox();

            pointToAdd.Changed += new PositionChangedDelegate(vertex_PositionChanged);
        }
コード例 #7
0
        public override void InsertPointAt(int index, double x, double y, double scale)
        {
            ShpPoint pointToAdd = new ShpPoint(x, y, scale);

            points.Insert(index, pointToAdd);
            checkBoundingBox();

            pointToAdd.Changed += new PositionChangedDelegate(vertex_PositionChanged);
        }
コード例 #8
0
ファイル: RemoveGeometryAction.cs プロジェクト: ntj/GravurGIS
 public RemoveGeometryAction(ShpPoint shapeToRemove, IShape container,
     LayerManager layerManager)
 {
     this.layerManager = layerManager;
     this.d.x = this.layerManager.GetMainControler().MapPanel.DX;
     this.d.y = this.layerManager.GetMainControler().MapPanel.DY;
     this.scale = layerManager.Scale;
     this.shapeToDelete = shapeToRemove;
     this.container = container;
     this.pointSize = 2;
     deletedPoint.x = shapeToDelete.RootX;
     deletedPoint.y = shapeToDelete.RootY;
 }
コード例 #9
0
ファイル: ShpPoint.cs プロジェクト: ntj/GravurGIS
        /// <summary>
        /// Compares two points on coordinate basis. if they have the same coodinates they are considered equal
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            ShpPoint pnt = obj as ShpPoint;

            if (pnt != null)
            {
                if (this.CenterX == pnt.CenterX && pnt.CenterY == this.CenterY)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #10
0
ファイル: MainControler.cs プロジェクト: ntj/GravurGIS
 public void removeVertex(IShape container, ShpPoint vertex)
 {
     if (container != null && vertex != null)
     {
        DialogResult result = MessageBox.Show("Möchten Sie diesen Punkt wirklich löschen?", "Punkt löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation,
             MessageBoxDefaultButton.Button2);
        if (result == DialogResult.Yes)
        {
            if (PerformAction(new RemoveGeometryAction(vertex, container, layerManager)))
            {
                mainForm.setStatus_Timed("Punkt erfolgreich gelöscht.", 1000);
                mapPanel.Invalidate();
            }
            else
                mainForm.setStatus_Timed("Punkt nicht gelöscht.", 1000);
        }
     }
 }
コード例 #11
0
ファイル: ShpPoint.cs プロジェクト: ntj/GravurGIS
 public override int RemovePoint(ShpPoint point)
 {
     throw new Exception("A point can not delete itself.");
 }
コード例 #12
0
 public abstract int RemovePoint(ShpPoint point);
コード例 #13
0
        public ShpPoint addPoint(double x, double y, double scale)
        {
            ShpPoint pnt = new ShpPoint(x, y, scale);

            if (points.Count == 0)
            {
                _boundingBox.Left = pnt.RootX;
                _boundingBox.Bottom = pnt.RootY;
                _boundingBox.TopRight = _boundingBox.BottomLeft;
            }
            else
            {
                if (pnt.RootX < _boundingBox.Left)
                    _boundingBox.Left = pnt.RootX;
                if (pnt.RootY < _boundingBox.Bottom)
                    _boundingBox.Bottom = pnt.RootY;
                if (pnt.RootX > _boundingBox.Right)
                    _boundingBox.Right = pnt.RootX;
                if (pnt.RootY > _boundingBox.Top)
                    _boundingBox.Top = pnt.RootY;
            }

            points.Add(pnt);

            pnt.Changed += new IShape.PositionChangedDelegate(pnt_Changed);

            ElementAdded(pnt);
            return pnt;
        }
コード例 #14
0
ファイル: ShpPoint.cs プロジェクト: ntj/GravurGIS
 public override int RemovePoint(ShpPoint point)
 {
     throw new Exception("A point can not delete itself.");
 }
コード例 #15
0
ファイル: IShape.cs プロジェクト: ntj/GravurGIS
 public abstract int RemovePoint(ShpPoint point);