SidebarLibrary.Menus.MenuControl.OnMouseMove C# (CSharp) Method

OnMouseMove() protected method

protected OnMouseMove ( MouseEventArgs e ) : void
e MouseEventArgs
return void
		protected override void OnMouseMove(MouseEventArgs e)
		{
			// Sometimes we need to ignore this message
			if (_ignoreMouseMove)
				_ignoreMouseMove = false;
			else
			{
				// Is the first time we have noticed a mouse movement over our window
				if (!_mouseOver)
				{
					// Crea the structure needed for WindowsAPI call
					Win32.TRACKMOUSEEVENTS tme = new Win32.TRACKMOUSEEVENTS();

					// Fill in the structure
					tme.cbSize = 16;
					tme.dwFlags = (uint)Win32.TrackerEventFlags.TME_LEAVE;
					tme.hWnd = this.Handle;
					tme.dwHoverTime = 0;

					// Request that a message gets sent when mouse leaves this window
					WindowsAPI.TrackMouseEvent(ref tme);

					// Yes, we know the mouse is over window
					_mouseOver = true;
				}

				Form parentForm = this.FindForm();

				// Only hot track if this Form is active
				if ((parentForm != null) && parentForm.ContainsFocus)
				{
					Point pos = new Point(e.X, e.Y);

					int i = 0;

					for(i=0; i<_drawCommands.Count; i++)
					{
						DrawCommand dc = _drawCommands[i] as DrawCommand;

						// Find the DrawCommand this is over
						if (dc.DrawRect.Contains(pos))
						{
							// Is there a change in selected item?
							if (_trackItem != i)
							{
								// We we currently selecting an item
								if (_selected)
								{
									if (_popupMenu != null)
									{
										// Note that we are dismissing the submenu but not removing
										// the selection of items, this flag is tested by the routine
										// that will return because the submenu has been finished
										_dismissTransfer = true;

										// Dismiss the submenu
										_popupMenu.Dismiss();

										// Default to downward drawing
										_drawUpwards = false;
									}

									// Modify the display of the two items
									_trackItem = SwitchTrackingItem(_trackItem, i);

									// Does the newly selected item have a submenu?
									if (dc.Chevron || (dc.MenuCommand.MenuCommands.Count > 0))
										WindowsAPI.PostMessage(this.Handle, WM_OPERATEMENU, 1, 0);
								}
								else
								{
									// Modify the display of the two items
									_trackItem = SwitchTrackingItem(_trackItem, i);
								}
							}

							break;
						}
					}

					// If not in selected mode
					if (!_selected)
					{
						// None of the commands match?
						if (i == _drawCommands.Count)
						{
							// Modify the display of the two items
							_trackItem = SwitchTrackingItem(_trackItem, -1);
						}
					}
				}
			}

			base.OnMouseMove(e);
		}