SidebarLibrary.WinControls.OutlookBar.HitTest C# (CSharp) Метод

HitTest() публичный Метод

public HitTest ( Point point, int &index, bool doingDragging ) : HitTestType
point Point
index int
doingDragging bool
Результат HitTestType
		public HitTestType HitTest(Point point, out int index, bool doingDragging)
		{

			// If we don't have any bands just return
			index = 0;
			if ( bands.Count == 0 || currentBandIndex == -1 )	return HitTestType.Nothing;

			// Check if we hit the arrow buttons
			if (upArrowVisible && upArrowRect.Contains(point)) return HitTestType.UpScroll;
			if (downArrowVisible && downArrowRect.Contains(point)) return HitTestType.DownScroll;

			// Check to see if we hit a header
			for ( int i = 0; i < bands.Count; i++ )
			{
				Rectangle rc = GetHeaderRect(i);
				if ( rc.Contains(point) )
				{
					index = i;
					return HitTestType.Header;
				}
			}

			// Don't do any hit testing for items if
			// the current band has a child
			if ( HasChild() ) return HitTestType.Nothing;

			// Check to see if we hit an item
			int itemCount = bands[currentBandIndex].Items.Count;
			Rectangle viewPortRect = GetViewPortRect();
			Rectangle iconRect = Rectangle.Empty;
			Rectangle labelRect = Rectangle.Empty;
			for ( int i = firstItem; i < itemCount; i++ )
			{
				// Check if we hit the icon
				iconRect = GetIconRect(i);
				if ( iconRect.Contains(point) )
				{
					index = i;
					return HitTestType.Item;
				}
				else
					if ( iconRect.Bottom > viewPortRect.Bottom && !doingDragging) break;

				// Check to see if we hit the label
				labelRect = GetLabelRect(i);
				if ( labelRect.Contains(point) )
				{
					index = i;
					return HitTestType.Item;
				}
				else
					if ( labelRect.Bottom > viewPortRect.Bottom && !doingDragging) break;

				// If we are dragging, hit test for the drop line
				if ( doingDragging )
				{
					Rectangle dragRect = new Rectangle(viewPortRect.Left, iconRect.Top - Y_LARGEICON_SPACING,
						viewPortRect.Width, Y_LARGEICON_SPACING);

					if ( dragRect.Contains(point) )
					{
						index = i;
						return HitTestType.DropLine;
					}

					// if this is the last icon and the point is farther down the last item
					if ( (i == itemCount - 1) && point.Y > labelRect.Bottom )
					{
						index = itemCount - 1;
						return HitTestType.DropLineLastItem;
					}
				}
			}

			return HitTestType.Nothing;

		}