Right now I am writing the same code. In short, the idea is: to
enumerate all connection points for each of the shapes and to test if
connection points of different shapes are coinciding.
A gives us the Point[] aPoints, B - Point[] bPoints. etc.
Then a simple loop:
for(int a = 0; a < aPoints.Length; a++)
for(int s = 0; s < bPoints.Length; s++)
if (aPoints[a] == bPoints)
// A and B have connected
;
where Point is the structure with fields of type double. Also the
structure should have overloaded operator == (and !=, in .NET).
And note what you have to take into account that rotation angle doesn't
affect the values of connection points you obtain from the shape using
CellsSRC(): you should calculate their new coordinates by yourself (use
formulas for transfer and rotation about pin point). Below is the code
in C# I wrote for obtaining the connection points and a method to test
if two shapes share connection point (i.e., connected)
public Point[] ConnectionPoints
{
get
{
short connPoints =
m_Inner.get_RowCount((short)Visio.VisSectionIndices.visSectionConnectionPts);
Point[] result = new Point[connPoints];
if (connPoints == 0)
return result;
Point leftBottom = LeftBottom;
double angle = m_Inner.get_CellsSRC(visSectionObject,
(short)Visio.VisRowIndices.visRowXFormOut,
(short)Visio.VisCellIndices.visXFormAngle).get_Result("radian");
double sin = Math.Sin(angle);
double cos = Math.Cos(angle);
Point center = Pin;
Point diff = new Point(center.X - leftBottom.X, center.Y -
leftBottom.Y);
for (short a = 0; a < connPoints; a++)
{
double x = 0;
double y = 0;
x =
m_Inner.get_CellsSRC((short)Visio.VisSectionIndices.visSectionConnectionPts,
a,
(short)Visio.VisCellIndices.visCnnctX).get_Result(Visio.VisMeasurementSystem.visMSMetric)
- diff.X;
y =
m_Inner.get_CellsSRC((short)Visio.VisSectionIndices.visSectionConnectionPts,
a,
(short)Visio.VisCellIndices.visCnnctY).get_Result(Visio.VisMeasurementSystem.visMSMetric)
- diff.Y;
result[a].X = x * cos - y * sin + leftBottom.X + diff.X;
result[a].Y = x * sin + y * cos + leftBottom.Y + diff.Y;
}
return result;
}
}
....
internal bool HasConnectionWith(VisioShape Shape, out Point[] Points)
{
Point[] sps = Shape.ConnectionPoints; // Shape is internal member of
corresponding class
Point[] ps = this.ConnectionPoints;
ArrayList points = new ArrayList();
for (int a = 0; a < sps.Length; a++)
for (int s = 0; s < ps.Length; s++)
if (ps == sps[a])
points.Add(ps);
Points = (Point[])points.ToArray(typeof(Point));
return points.Count != 0;
}
Hope this help.