// handles connection's creation public override void DoCreationFixup(bool converted) { // get coords of intermediate points Point[] p = GuiPathFinder.polyline_quadric_DummyWay(conn.first, conn.second, conn.parent.active_objects); // fixup the number of points while (p.Length + 2 > conn.ipoints.Count) { if (converted) { conn.insert_point_child(0); } else { conn.insert_point(0); } } while (p.Length + 2 < conn.ipoints.Count) { if (converted) { conn.remove_point_child(1); } else { conn.remove_point(1); } } // change coords for (int i = 0; i < p.Length; i++) { (conn.ipoints[i + 1] as GuiIntermPoint).x = p[i].X; (conn.ipoints[i + 1] as GuiIntermPoint).y = p[i].Y; } }
// user moves conn_point private void fixup_quadric_endpoint_movement(GuiConnectionPoint conn_point) { GuiPoint neighbour; int x, y; if (conn.ipoints.Count == 2) { int dx = conn.first.x - conn.second.x, dy = conn.first.y - conn.second.y; GuiIntermPoint pt = null; if (dx != 0 && dy != 0) { pt = conn.insert_point(0); conn.add_child(pt, null); GuiPathFinder.select_pos_for_middle_point(conn.first, conn.second, out x, out y); pt.x = x; pt.y = y; } } else if (conn.ipoints.Count == 3) { GuiIntermPoint pt = conn.ipoints[1] as GuiIntermPoint; GuiPathFinder.select_pos_for_middle_point(conn.first, conn.second, out x, out y); pt.x = x; pt.y = y; } else if (conn.ipoints.Count >= 3) { bool vertical; if (conn_point == conn.first) { neighbour = conn.ipoints[1] as GuiPoint; vertical = neighbour.x - (conn.ipoints[2] as GuiPoint).x == 0; } else { neighbour = conn.ipoints[conn.ipoints.Count - 2] as GuiPoint; vertical = neighbour.x - (conn.ipoints[conn.ipoints.Count - 3] as GuiPoint).x == 0; } vertical = !vertical; // we have to invert the value to obtain the direction of the segment being moved if (vertical) { neighbour.x = conn_point.x; } else { neighbour.y = conn_point.y; } } }