Example #1
0
        protected void OnMouseHover(object sender, EventArgs e)
        {
            var pos = Cursor.Position;

            if (CursorIsInRight())
            {
                if (timerHover.Enabled && ((CurrentHoverDirection & (MouseHoverDirection.Right | MouseHoverDirection.Far)) != 0))
                {
                    return;
                }
                else
                {
                    if (timerHover.Enabled && (CurrentHoverDirection & MouseHoverDirection.Right) == 0)
                    {
                        timerHover.Stop();
                    }

                    CurrentHoverDirection |= MouseHoverDirection.Right;
                    if (pos.X >= Width / 2 + 2 * ItemBoxSize.Width)
                    {
                        CurrentHoverDirection |= MouseHoverDirection.Far;
                    }

                    if (!timerHover.Enabled)
                    {
                        timerHover.Start();
                    }
                }
            }
            else if (CursorIsInLeft())
            {
                if (timerHover.Enabled && ((CurrentHoverDirection & (MouseHoverDirection.Left | MouseHoverDirection.Far)) != 0))
                {
                    return;
                }
                else
                {
                    if (timerHover.Enabled && (CurrentHoverDirection & MouseHoverDirection.Left) == 0)
                    {
                        timerHover.Stop();
                    }

                    CurrentHoverDirection |= MouseHoverDirection.Left;
                    if (pos.X <= Width / 2 + 2 * ItemBoxSize.Width)
                    {
                        CurrentHoverDirection |= MouseHoverDirection.Far;
                    }

                    if (!timerHover.Enabled)
                    {
                        timerHover.Start();
                    }
                }
            }
        }
Example #2
0
        protected void OnTimerHoverTick(object sender, EventArgs e)
        {
            if (CurrentHoverDirection != MouseHoverDirection.None)
            {
                if ((CurrentHoverDirection & MouseHoverDirection.Right) != 0)
                {
                    if (CursorIsInRight())
                    {
                        SelectedIndex++;
                    }
                }
                else
                {
                    if (CursorIsInLeft())
                    {
                        SelectedIndex--;
                    }
                }
                Refresh();

                CurrentHoverDirection = MouseHoverDirection.None;
                timerHover.Stop();
            }
        }