public void TestMouseOverThumb()
        {
            Screen screen = new Screen(100, 100);
            HorizontalSliderControl slider = new HorizontalSliderControl();

            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 left         = movableRange * slider.ThumbPosition;
            float right        = left + slider.ThumbSize;

            left  *= slider.Bounds.Size.X.Offset;
            right *= slider.Bounds.Size.X.Offset;
            float thumbWidth = right - left;

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

            // Move the mouse over the thumb. The property should now return true.
            slider.ProcessMouseMove(100, 100, left + thumbWidth / 2.0f, 50);
            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, right + thumbWidth / 2.0f, 50);
            Assert.IsFalse(slider.MouseOverThumb);
        }
        public void TestMouseOverWithThumbLocator()
        {
            Screen screen = new Screen(100, 100);
            HorizontalSliderControl slider = new HorizontalSliderControl();

            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(66.6f, 0.0f, 33.3f, 100.0f)
                );

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

            // Move the mouse over the thumb. The property should now return true.
            slider.ProcessMouseMove(100, 100, 85, 50);
            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);
            HorizontalSliderControl slider = new HorizontalSliderControl();

            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, 60, 50);
            Assert.That(slider.ThumbPosition, Is.EqualTo(0.0f).Within(16).Ulps);
        }
        public void TestThumbDragging()
        {
            Screen screen = new Screen(100, 100);
            HorizontalSliderControl slider = new HorizontalSliderControl();

            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 left         = movableRange * slider.ThumbPosition;
            float right        = left + slider.ThumbSize;

            left  *= slider.Bounds.Size.X.Offset;
            right *= slider.Bounds.Size.X.Offset;
            float thumbWidth = right - left;

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

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

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

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

            slider.ProcessMouseMove(
                100, 100, slider.Bounds.Location.X.Offset + slider.Bounds.Size.X.Offset, 50
                );
            Assert.That(slider.ThumbPosition, Is.EqualTo(1.0f).Within(16).Ulps);
        }
    public void TestMouseOverThumb() {
      Screen screen = new Screen(100, 100);
      HorizontalSliderControl slider = new HorizontalSliderControl();
      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 left = movableRange * slider.ThumbPosition;
      float right = left + slider.ThumbSize;

      left *= slider.Bounds.Size.X.Offset;
      right *= slider.Bounds.Size.X.Offset;
      float thumbWidth = right - left;

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

      // Move the mouse over the thumb. The property should now return true.
      slider.ProcessMouseMove(100, 100, left + thumbWidth / 2.0f, 50);
      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, right + thumbWidth / 2.0f, 50);
      Assert.IsFalse(slider.MouseOverThumb);
    }
    public void TestFullSizeThumbDragging() {
      Screen screen = new Screen(100, 100);
      HorizontalSliderControl slider = new HorizontalSliderControl();
      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, 60, 50);
      Assert.That(slider.ThumbPosition, Is.EqualTo(0.0f).Within(16).Ulps);
    }
    public void TestThumbDragging() {
      Screen screen = new Screen(100, 100);
      HorizontalSliderControl slider = new HorizontalSliderControl();
      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 left = movableRange * slider.ThumbPosition;
      float right = left + slider.ThumbSize;

      left *= slider.Bounds.Size.X.Offset;
      right *= slider.Bounds.Size.X.Offset;
      float thumbWidth = right - left;

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

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

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

      slider.ProcessMouseMove(
        100, 100, slider.Bounds.Location.X.Offset + slider.Bounds.Size.X.Offset, 50
      );
      Assert.That(slider.ThumbPosition, Is.EqualTo(1.0f).Within(16).Ulps);
    }
    public void TestMouseOverWithThumbLocator() {
      Screen screen = new Screen(100, 100);
      HorizontalSliderControl slider = new HorizontalSliderControl();
      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(66.6f, 0.0f, 33.3f, 100.0f)
      );

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

      // Move the mouse over the thumb. The property should now return true.
      slider.ProcessMouseMove(100, 100, 85, 50);
      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);
    }