BoxDiagrams.DiagramGestureAnalyzer.RecognizeBoxOrLines C# (CSharp) Method

RecognizeBoxOrLines() private method

private RecognizeBoxOrLines ( DragState state, bool &potentialSelection ) : Shape
state DragState
potentialSelection bool
return Shape
		Shape RecognizeBoxOrLines(DragState state, out bool potentialSelection)
		{
			// Okay so this is a rectangular recognizer that only sees things at 
			// 45-degree angles.
			List<Section> sections1 = BreakIntoSections(state);
			List<Section> sections2 = new List<Section>(sections1);

			// Figure out if a box or a line string is a better interpretation
			EliminateTinySections(sections1, 10);
			LineOrArrow line = InterpretAsPolyline(state, sections1);
			Shape shape = line;
			// Conditions to detect a box:
			// 0. If both endpoints are anchored, a box cannot be formed.
			// continued below...
			EliminateTinySections(sections2, 10 + (int)(sections1.Sum(s => s.LengthPx) * 0.05));
			if (line.ToAnchor == null || line.FromAnchor == null || line.FromAnchor.Equals(line.ToAnchor))
				shape = (Shape)TryInterpretAsBox(sections2, (line.FromAnchor ?? line.ToAnchor) != null, out potentialSelection) ?? line;
			else
				potentialSelection = false;
			return shape;
		}