public void TestMouseOverThumb() {
      Screen screen = new Screen(100, 100);
      VerticalSliderControl slider = new VerticalSliderControl();
      slider.Bounds = new UniRectangle(10, 10, 100, 100);
      slider.ThumbSize = 0.33f;
      slider.ThumbPosition = 0.25f;
      screen.Desktop.Children.Add(slider);

      float movableRange = 1.0f - slider.ThumbSize;
      float top = movableRange * slider.ThumbPosition;
      float bottom = top + slider.ThumbSize;

      top *= slider.Bounds.Size.Y.Offset;
      bottom *= slider.Bounds.Size.Y.Offset;
      float thumbHeight = bottom - top;

      // Position above the thumb should be reported as outside of the thumb.
      slider.ProcessMouseMove(100, 100, 50, top - thumbHeight / 2.0f);
      Assert.IsFalse(slider.MouseOverThumb);

      // Move the mouse over the thumb. The property should now return true.
      slider.ProcessMouseMove(100, 100, 50, top + thumbHeight / 2.0f);
      Assert.IsTrue(slider.MouseOverThumb);

      // Move the mouse away from the thumb, but stay over the control.
      // The property should now return false again.      
      slider.ProcessMouseMove(100, 100, 50, bottom + thumbHeight / 2.0f);
      Assert.IsFalse(slider.MouseOverThumb);
    }
        public void TestMouseOverThumb()
        {
            Screen screen = new Screen(100, 100);
            VerticalSliderControl slider = new VerticalSliderControl();

            slider.Bounds        = new UniRectangle(10, 10, 100, 100);
            slider.ThumbSize     = 0.33f;
            slider.ThumbPosition = 0.25f;
            screen.Desktop.Children.Add(slider);

            float movableRange = 1.0f - slider.ThumbSize;
            float top          = movableRange * slider.ThumbPosition;
            float bottom       = top + slider.ThumbSize;

            top    *= slider.Bounds.Size.Y.Offset;
            bottom *= slider.Bounds.Size.Y.Offset;
            float thumbHeight = bottom - top;

            // Position above the thumb should be reported as outside of the thumb.
            slider.ProcessMouseMove(100, 100, 50, top - thumbHeight / 2.0f);
            Assert.IsFalse(slider.MouseOverThumb);

            // Move the mouse over the thumb. The property should now return true.
            slider.ProcessMouseMove(100, 100, 50, top + thumbHeight / 2.0f);
            Assert.IsTrue(slider.MouseOverThumb);

            // Move the mouse away from the thumb, but stay over the control.
            // The property should now return false again.
            slider.ProcessMouseMove(100, 100, 50, bottom + thumbHeight / 2.0f);
            Assert.IsFalse(slider.MouseOverThumb);
        }
        public void TestMouseOverWithThumbLocator()
        {
            Screen screen = new Screen(100, 100);
            VerticalSliderControl slider = new VerticalSliderControl();

            slider.Bounds        = new UniRectangle(10, 10, 100, 100);
            slider.ThumbSize     = 0.33f;
            slider.ThumbPosition = 0.0f;
            screen.Desktop.Children.Add(slider);

            // The thumb would normally be at the top of the control, but this
            // the thumb locator will tell the control that its thumb is at the bottom.
            slider.ThumbLocator = new DummyThumbLocator(
                new RectangleF(0.0f, 66.6f, 100.0f, 33.3f)
                );

            // Position above the thumb should be reported as outside of the thumb.
            slider.ProcessMouseMove(100, 100, 50, 15);
            Assert.IsFalse(slider.MouseOverThumb);

            // Move the mouse over the thumb. The property should now return true.
            slider.ProcessMouseMove(100, 100, 50, 85);
            Assert.IsTrue(slider.MouseOverThumb);

            // Move the mouse away from the thumb, but stay over the control.
            // The property should now return false again.
            slider.ProcessMouseMove(100, 100, 50, 50);
            Assert.IsFalse(slider.MouseOverThumb);
        }
        public void TestFullSizeThumbDragging()
        {
            Screen screen = new Screen(100, 100);
            VerticalSliderControl slider = new VerticalSliderControl();

            slider.Bounds    = new UniRectangle(10, 10, 100, 100);
            slider.ThumbSize = 1.0f;
            screen.Desktop.Children.Add(slider);

            // Move the mouse over the thumb, press the left mouse button and drag
            // it to a new location
            slider.ProcessMouseMove(100, 100, 50, 50);
            slider.ProcessMousePress(MouseButtons.Left);
            slider.ProcessMouseMove(100, 100, 50, 60);
            Assert.That(slider.ThumbPosition, Is.EqualTo(0.0f).Within(16).Ulps);
        }
        public void TestThumbDragging()
        {
            Screen screen = new Screen(100, 100);
            VerticalSliderControl slider = new VerticalSliderControl();

            slider.Bounds        = new UniRectangle(10, 10, 100, 100);
            slider.ThumbSize     = 0.33f;
            slider.ThumbPosition = 0.25f;
            screen.Desktop.Children.Add(slider);

            float movableRange = 1.0f - slider.ThumbSize;
            float top          = movableRange * slider.ThumbPosition;
            float bottom       = top + slider.ThumbSize;

            top    *= slider.Bounds.Size.Y.Offset;
            bottom *= slider.Bounds.Size.Y.Offset;
            float thumbHeight = bottom - top;

            float target = movableRange * (1.0f - slider.ThumbPosition);

            target *= slider.Bounds.Size.Y.Offset;

            // Move the mouse over the thumb, press the left mouse button and drag
            // it to a new location
            slider.ProcessMouseMove(100, 100, 50, top + thumbHeight / 2.0f);
            slider.ProcessMousePress(MouseButtons.Left);
            slider.ProcessMouseMove(100, 100, 50, target + thumbHeight / 2.0f);
            Assert.That(slider.ThumbPosition, Is.EqualTo(0.75f).Within(16).Ulps);

            slider.ProcessMouseMove(100, 100, 50, slider.Bounds.Location.Y.Offset);
            Assert.That(slider.ThumbPosition, Is.EqualTo(0.0f).Within(16).Ulps);

            slider.ProcessMouseMove(
                100, 100, 50, slider.Bounds.Location.Y.Offset + slider.Bounds.Size.Y.Offset
                );
            Assert.That(slider.ThumbPosition, Is.EqualTo(1.0f).Within(16).Ulps);
        }
    public void TestFullSizeThumbDragging() {
      Screen screen = new Screen(100, 100);
      VerticalSliderControl slider = new VerticalSliderControl();
      slider.Bounds = new UniRectangle(10, 10, 100, 100);
      slider.ThumbSize = 1.0f;
      screen.Desktop.Children.Add(slider);

      // Move the mouse over the thumb, press the left mouse button and drag
      // it to a new location
      slider.ProcessMouseMove(100, 100, 50, 50);
      slider.ProcessMousePress(MouseButtons.Left);
      slider.ProcessMouseMove(100, 100, 50, 60);
      Assert.That(slider.ThumbPosition, Is.EqualTo(0.0f).Within(16).Ulps);
    }
    public void TestThumbDragging() {
      Screen screen = new Screen(100, 100);
      VerticalSliderControl slider = new VerticalSliderControl();
      slider.Bounds = new UniRectangle(10, 10, 100, 100);
      slider.ThumbSize = 0.33f;
      slider.ThumbPosition = 0.25f;
      screen.Desktop.Children.Add(slider);

      float movableRange = 1.0f - slider.ThumbSize;
      float top = movableRange * slider.ThumbPosition;
      float bottom = top + slider.ThumbSize;

      top *= slider.Bounds.Size.Y.Offset;
      bottom *= slider.Bounds.Size.Y.Offset;
      float thumbHeight = bottom - top;

      float target = movableRange * (1.0f - slider.ThumbPosition);
      target *= slider.Bounds.Size.Y.Offset;

      // Move the mouse over the thumb, press the left mouse button and drag
      // it to a new location
      slider.ProcessMouseMove(100, 100, 50, top + thumbHeight / 2.0f);
      slider.ProcessMousePress(MouseButtons.Left);
      slider.ProcessMouseMove(100, 100, 50, target + thumbHeight / 2.0f);
      Assert.That(slider.ThumbPosition, Is.EqualTo(0.75f).Within(16).Ulps);

      slider.ProcessMouseMove(100, 100, 50, slider.Bounds.Location.Y.Offset);
      Assert.That(slider.ThumbPosition, Is.EqualTo(0.0f).Within(16).Ulps);

      slider.ProcessMouseMove(
        100, 100, 50, slider.Bounds.Location.Y.Offset + slider.Bounds.Size.Y.Offset
      );
      Assert.That(slider.ThumbPosition, Is.EqualTo(1.0f).Within(16).Ulps);
    }
    public void TestMouseOverWithThumbLocator() {
      Screen screen = new Screen(100, 100);
      VerticalSliderControl slider = new VerticalSliderControl();
      slider.Bounds = new UniRectangle(10, 10, 100, 100);
      slider.ThumbSize = 0.33f;
      slider.ThumbPosition = 0.0f;
      screen.Desktop.Children.Add(slider);

      // The thumb would normally be at the top of the control, but this
      // the thumb locator will tell the control that its thumb is at the bottom.
      slider.ThumbLocator = new DummyThumbLocator(
        new RectangleF(0.0f, 66.6f, 100.0f, 33.3f)
      );

      // Position above the thumb should be reported as outside of the thumb.
      slider.ProcessMouseMove(100, 100, 50, 15);
      Assert.IsFalse(slider.MouseOverThumb);

      // Move the mouse over the thumb. The property should now return true.
      slider.ProcessMouseMove(100, 100, 50, 85);
      Assert.IsTrue(slider.MouseOverThumb);

      // Move the mouse away from the thumb, but stay over the control.
      // The property should now return false again.      
      slider.ProcessMouseMove(100, 100, 50, 50);
      Assert.IsFalse(slider.MouseOverThumb);
    }