private void DrawArrowTo(ICity city, Graphics g) { PointF p0 = new PointF(_x, _y); PointF pEnd = new PointF(city.GetPositoin().X, city.GetPositoin().Y); float X = pEnd.X - p0.X; float Y = pEnd.Y - p0.Y; double lineLength = Math.Sqrt(X * X + Y * Y); double sin, cos; cos = X / lineLength; sin = Y / lineLength; PointF endPoint = new PointF((float)(p0.X + (cos * (lineLength - _rad))), (float)(p0.Y + (sin * (lineLength - _rad)))); PointF startPoint = new PointF((float)(p0.X + (cos * (_rad))), (float)(p0.Y + (sin * (_rad)))); PointF arrowPoint = new PointF((float)(p0.X + (cos * (lineLength - _rad - 10))), (float)(p0.Y + (sin * (lineLength - _rad - 10)))); PointF middlePoint = new PointF((float)(p0.X + (cos * (lineLength - lineLength / 2))), (float)(p0.Y + (sin * (lineLength - lineLength / 2)))); float vectorX, vectorY; if (X < 10 && X > -10) { vectorX = 1; vectorY = -X / Y; } else { vectorX = -Y / X; vectorY = 1; } int koef; if (_id < city.Id) { koef = 1; } else { koef = -1; } PointF normVector = new PointF(vectorX, vectorY); double NormLength = Math.Sqrt(normVector.X * normVector.X + normVector.Y * normVector.Y); double cosNorm = normVector.X / NormLength; double sinNorm = normVector.Y / NormLength; Pen linePen = new Pen(Color.Black, 2); g.DrawLine(linePen, startPoint, endPoint); if (koef > 0) { DrawWeightTo(_weights.GetInfo(city.Id), middlePoint, koef * sinNorm, koef * cosNorm, koef, g); } }