private void HandleMouseMoved()
        {
            if (Cursor.Position.Equals(lastPosition))
            {
                return;
            }

            lastPosition = Cursor.Position;

            var screenRect = new Rectangle(0, 0, this.Width, this.Height);

            screenRect = this.RectangleToScreen(screenRect);

            if (IsMouseOverUs(lastPosition))
            {
                // The mouse moved, but not over us!
                MouseHider.Show();
            }

            if (screenRect.Contains(lastPosition))
            {
                MouseHider.Show();
                HideMouseTimer.Enabled = false;
                HideMouseTimer.Enabled = true;
            }
            else
            {
                HideMouseTimer.Enabled = false;
                MouseHider.Show();
            }
        }
 private void HideMouseTimer_Tick(object sender, EventArgs e)
 {
     HideMouseTimer.Enabled = false;
     if (IsMouseOverUs(lastPosition))
     {
         MouseHider.Hide();
     }
     else
     {
         MouseHider.Show();
     }
 }
        private bool IsMouseOverUs(Point mouseScreenPosition)
        {
            if (!this.IsHandleCreated ||
                this.childCanvas == null ||
                !this.childCanvas.IsHandleCreated)
            {
                return(false);
            }

            var overHandle = MouseHider.GetHWndAtPoint(mouseScreenPosition);

            if (this.Handle == overHandle ||
                this.childCanvas.Handle == overHandle)
            {
                return(true);
            }

            return(false);
        }