/// <summary> /// Provides the center of the transition arrow /// </summary> /// <returns></returns> public Point getCenter() { // Set the start & end location of the arrow Point startLocation = StartLocation; Point targetLocation = TargetLocation; // Set the location of the text Span Xspan = new Span(startLocation.X, targetLocation.X); Span Yspan = new Span(startLocation.Y, targetLocation.Y); int x = Math.Min(startLocation.X, targetLocation.X) + Xspan.Center; int y = Math.Min(startLocation.Y, targetLocation.Y) + Yspan.Center; return new Point(x, y); }
/// <summary> /// Provides the intersection of two spans /// </summary> /// <param name="span1"></param> /// <param name="span2"></param> /// <returns></returns> public static Span Intersection(Span span1, Span span2) { Span retVal = null; if (span1.LowBound > span2.LowBound) { Span tmp = span1; span1 = span2; span2 = tmp; } // span1.LowBound <= span2.LowBound if (span1.HighBound < span2.LowBound) { retVal = null; } else { // span1.LowBound < span2.LowBound and span1.HighBound >= span2.LowBound int LowBound = span2.LowBound; int HighBound; if (span1.HighBound > span2.HighBound) { HighBound = span2.HighBound; } else { HighBound = span1.HighBound; } retVal = new Span(LowBound, HighBound); } return retVal; }