/// <summary> /// Create instance of <see cref="HitTestInfo"/>. Use this to get the HitTest information. /// </summary> /// <param name="control"><see cref="SuperMarquee"/> for which HitTest is to be performed.</param> /// <param name="testPoint">HitTest Point</param> public HitTestInfo(SuperMarquee control, Point testPoint) { if (control != null) { HitTestInfo test = control.HitTest(testPoint); index = test.index; point = test.point; area = test.area; } else { index = -1; point = testPoint; area = HitTestArea.None; } }
/// <summary> /// Performs the HitTest. /// </summary> /// <param name="p">Point at which HitTest will be performed.</param> /// <returns>returm <see cref="HitTestInfo"/> object containing HitTest information.</returns> public HitTestInfo HitTest(Point p) { HitTestInfo info = new HitTestInfo { Area = HitTestArea.None, Point = p, Index = -1 }; for (int i = firstIndex; i < elements.Count; i++) { if (elements[i].TextRect.Contains(p)) { info.Area = HitTestArea.Item; info.Index = i; break; } if (elements[i].LeftRect.Contains(p)) { info.Area = HitTestArea.LeftImage; info.Index = i; break; } if (elements[i].RightRect.Contains(p)) { info.Area = HitTestArea.RightImage; info.Index = i; break; } } if (info.Area == HitTestArea.None) { if (bound.Contains(p)) { info.Area = HitTestArea.Strip; } else if (ClientRectangle.Contains(p)) { info.Area = HitTestArea.Control; } } return info; }