private double SegmentLength(int segmentNum) { // Get the length of just this line double thisLineLength = 0; // Is this a horizontal line? if (_points[segmentNum].X == _points[segmentNum + 1].X) { thisLineLength = Math.Abs(_points[segmentNum].Y - _points[segmentNum + 1].Y); } // Is this a vertical line? else if (_points[segmentNum].Y == _points[segmentNum + 1].Y) { thisLineLength = Math.Abs(_points[segmentNum].X - _points[segmentNum + 1].X); } else { // Find the length of the Hypotenuse of the right triangle double a = Math.Abs(_points[segmentNum].X - _points[segmentNum + 1].X); double b = Math.Abs(_points[segmentNum].Y - _points[segmentNum + 1].Y); thisLineLength = PreviewTools.TriangleHypotenuse(a, b); } return(thisLineLength); }