public override Point GetLineAnchorLocation(DiagramItemBase toItem, Point toPoint, int toItemDiagramLinesCount, int toItemDiagramLinesNumber, bool isSelfStart) { Point p = new Point(); Point p2 = new Point(); Point pTo = new Point(); Point pRhombus1 = new Point(); Point pRhombus2 = new Point(); Line2D secondLine, firstLineSelf; if (toItem != null) { pTo.X = Canvas.GetLeft(toItem) + toItem.ActualWidth / 2; pTo.Y = Canvas.GetTop(toItem) + toItem.ActualHeight / 2; } else { pTo = toPoint; } double tX = Canvas.GetLeft(this) + this.ActualWidth / 2; double tY = Canvas.GetTop(this) + this.ActualHeight / 2; double testX = pTo.X - tX; double testY = pTo.Y - tY; if (testX == 0) { testX = 0.001; } if (testY == 0) { testY = 0.001; } if (toItemDiagramLinesCount > 1) { if (toItem == this) { if (isSelfStart) { p.X = Canvas.GetLeft(this) + ((((double)toItemDiagramLinesNumber) / 2 + 1) / ((double)toItemDiagramLinesCount + 1) * this.ActualWidth); p.Y = tY - this.ActualHeight / 2; p2.X = Canvas.GetLeft(this) + ((((double)toItemDiagramLinesNumber) / 2 + 1) / ((double)toItemDiagramLinesCount + 1) * this.ActualWidth); p2.Y = tY - this.ActualHeight; firstLineSelf = Geometry2D.GetLine2DFromPoints(p, p2); pRhombus1.X = Canvas.GetLeft(this); pRhombus1.Y = tY; pRhombus2.X = tX; pRhombus2.Y = Canvas.GetTop(this); } else { p.X = tX + this.ActualWidth / 2; p.Y = Canvas.GetTop(this) + (((double)(toItemDiagramLinesCount - ((double)toItemDiagramLinesNumber) / 2)) / ((double)toItemDiagramLinesCount + 1) * this.ActualHeight); p2.X = tX + this.ActualWidth; p2.Y = Canvas.GetTop(this) + (((double)(toItemDiagramLinesCount - ((double)toItemDiagramLinesNumber) / 2)) / ((double)toItemDiagramLinesCount + 1) * this.ActualHeight); firstLineSelf = Geometry2D.GetLine2DFromPoints(p, p2); pRhombus1.X = Canvas.GetLeft(this) + this.ActualWidth; pRhombus1.Y = tY; pRhombus2.X = tX; pRhombus2.Y = Canvas.GetTop(this) + this.ActualHeight; } secondLine = Geometry2D.GetLine2DFromPoints(pRhombus1, pRhombus2); return(Geometry2D.FindLineCross(firstLineSelf, secondLine)); } Point pFrom = new Point(); pFrom.X = tX; if (testY <= 0) { pFrom.Y = Canvas.GetTop(this) + (((double)toItemDiagramLinesNumber + 1) / ((double)toItemDiagramLinesCount + 1) * this.ActualHeight / 2); } else { pFrom.Y = tY + (((double)toItemDiagramLinesNumber + 1) / ((double)toItemDiagramLinesCount + 1) * this.ActualHeight / 2); } Line2D firstLine = Geometry2D.GetLine2DFromPoints(pTo, pFrom); // we have two lines: // - from pTo to pFrom (firstLine) // - from pRhombus1 to pRhombus2 (secondLine - depending on the rhombus side) if (testY <= 0 && testX <= 0) { pRhombus1.X = Canvas.GetLeft(this); pRhombus1.Y = tY; pRhombus2.X = tX; pRhombus2.Y = Canvas.GetTop(this); } if (testY <= 0 && testX >= 0) { pRhombus1.X = Canvas.GetLeft(this) + this.ActualWidth; pRhombus1.Y = tY; pRhombus2.X = tX; pRhombus2.Y = Canvas.GetTop(this); } if (testY >= 0 && testX >= 0) { pRhombus1.X = Canvas.GetLeft(this) + this.ActualWidth; pRhombus1.Y = tY; pRhombus2.X = tX; pRhombus2.Y = Canvas.GetTop(this) + this.ActualHeight; } if (testY >= 0 && testX <= 0) { pRhombus1.X = Canvas.GetLeft(this); pRhombus1.Y = tY; pRhombus2.X = tX; pRhombus2.Y = Canvas.GetTop(this) + this.ActualHeight; } secondLine = Geometry2D.GetLine2DFromPoints(pRhombus1, pRhombus2); return(Geometry2D.FindLineCross(firstLine, secondLine)); } else { if (toItem == this) { if (isSelfStart) { p.X = tX; p.Y = tY - this.ActualHeight / 2; return(p); } else { p.X = tX + this.ActualWidth / 2; p.Y = tY; return(p); } } Point pFrom = new Point(); pFrom.X = tX; pFrom.Y = tY; Line2D firstLine = Geometry2D.GetLine2DFromPoints(pTo, pFrom); pRhombus1 = new Point(); pRhombus2 = new Point(); // we have two lines: // - from pTo to pFrom (firstLine) // - from pRhombus1 to pRhombus2 (secondLine - depending on the rhombus side) if (testY <= 0 && testX <= 0) { pRhombus1.X = Canvas.GetLeft(this); pRhombus1.Y = tY; pRhombus2.X = tX; pRhombus2.Y = Canvas.GetTop(this); } if (testY <= 0 && testX >= 0) { pRhombus1.X = Canvas.GetLeft(this) + this.ActualWidth; pRhombus1.Y = tY; pRhombus2.X = tX; pRhombus2.Y = Canvas.GetTop(this); } if (testY >= 0 && testX >= 0) { pRhombus1.X = Canvas.GetLeft(this) + this.ActualWidth; pRhombus1.Y = tY; pRhombus2.X = tX; pRhombus2.Y = Canvas.GetTop(this) + this.ActualHeight; } if (testY >= 0 && testX <= 0) { pRhombus1.X = Canvas.GetLeft(this); pRhombus1.Y = tY; pRhombus2.X = tX; pRhombus2.Y = Canvas.GetTop(this) + this.ActualHeight; } secondLine = Geometry2D.GetLine2DFromPoints(pRhombus1, pRhombus2); return(Geometry2D.FindLineCross(firstLine, secondLine)); } return(p); }