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 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);
    }