コード例 #1
0
        void JoinSegments(FreePoint point)
        {
            var dependents = point.Dependents.OfType <Segment>().ToArray();

            if (dependents.Length != 2)
            {
                return;
            }
            var line1 = dependents[0];
            var line2 = dependents[1];

            var otherPoint1 = line1.Dependencies.Without(point).FirstOrDefault();
            var otherPoint2 = line2.Dependencies.Without(point).FirstOrDefault();

            if (otherPoint1 == null || otherPoint2 == null)
            {
                return;
            }

            var segment = Factory.CreateSegment(Drawing, new[] { otherPoint1, otherPoint2 });

            using (Drawing.ActionManager.CreateTransaction())
            {
                RemovePointFromPolygons(point);
                Actions.Actions.Remove(line2);
                Actions.Actions.ReplaceWithNew(line1, segment);
                Actions.Actions.Remove(point);
            }
        }
コード例 #2
0
 void RemovePointFromPolygons(FreePoint point)
 {
     foreach (var polygon in point.Dependents.OfType <PolygonBase>().ToList())
     {
         if (polygon.Dependencies.Count > 3)
         {
             RemovePointFromPolygon(point, polygon);
         }
     }
 }
コード例 #3
0
        void JoinPolyLineSegments(FreePoint point)
        {
            var dependents = point.Dependents.OfType <Polyline>().ToArray();

            foreach (object obj in dependents)
            {
                if (obj is Polyline)
                {
                    var polyline = (Polyline)obj;

                    if (polyline.Dependencies.Count <= 3)
                    {
                        return;
                    }

                    var NewPolyLinePoints = new List <IFigure>();

                    // Eliminate deleted point
                    for (var i = 0; i < polyline.Dependencies.Count; i++)
                    {
                        var p1 = polyline.Dependencies[i] as IPoint;

                        if (p1.Coordinates.X != point.Coordinates.X &&
                            p1.Coordinates.Y != point.Coordinates.Y)
                        {
                            NewPolyLinePoints.Add(p1);
                        }
                    }

                    // create new polyline
                    var newPolyLine = Factory.CreatePolyline(Drawing, NewPolyLinePoints);
                    using (Drawing.ActionManager.CreateTransaction())
                    {
                        Actions.Actions.Remove(point);
                        Actions.Actions.ReplaceWithNew(polyline, newPolyLine);
                    }
                }
            }
        }
コード例 #4
0
 void RemovePointFromPolygon(FreePoint point, PolygonBase polygon)
 {
     Actions.Actions.RemoveDependency(polygon, point);
 }