예제 #1
0
        public void TestSliderThumbResizing()
        {
            Screen      screen = new Screen();
            ListControl list   = new ListControl();

            list.Bounds         = new UniRectangle(10, 10, 100, 100);
            list.ListRowLocator = new DummyListRowLocator();
            screen.Desktop.Children.Add(list);

            RectangleF listBounds  = list.GetAbsoluteBounds();
            float      itemsInView = listBounds.Height;

            itemsInView /= list.ListRowLocator.GetRowHeight(listBounds);

            // Put 5 items in the list
            fillList(list, 5);
            Assert.AreEqual(1.0f, list.Slider.ThumbSize);

            // Put another 15 items in the list
            fillList(list, 15);
            Assert.AreEqual(itemsInView / 20.0f, list.Slider.ThumbSize);

            // Put another 15 items in the list
            list.Items.RemoveAt(19);
            list.Items.RemoveAt(18);
            list.Items.RemoveAt(17);
            list.Items.RemoveAt(16);
            list.Items.RemoveAt(15);
            Assert.AreEqual(itemsInView / 15.0f, list.Slider.ThumbSize);

            list.Items.Clear();
            Assert.AreEqual(1.0f, list.Slider.ThumbSize);
        }
예제 #2
0
        public void TestMouseWheel()
        {
            Screen      screen = new Screen();
            ListControl list   = new ListControl();

            list.Bounds         = new UniRectangle(10, 10, 100, 100);
            list.ListRowLocator = new DummyListRowLocator();
            screen.Desktop.Children.Add(list);

            // Put 20 items in the list
            fillList(list, 20);

            Assert.AreEqual(0.0f, list.Slider.ThumbPosition);
            list.ProcessMouseWheel(-1.0f);

            RectangleF listBounds  = list.GetAbsoluteBounds();
            float      totalitems  = list.Items.Count;
            float      itemsInView = listBounds.Height;

            itemsInView /= list.ListRowLocator.GetRowHeight(listBounds);
            float scrollableItems  = totalitems - itemsInView;
            float newThumbPosition = 1.0f / scrollableItems * 1.0f;

            Assert.AreEqual(newThumbPosition, list.Slider.ThumbPosition);
        }
예제 #3
0
    public void TestSliderThumbResizing() {
      Screen screen = new Screen();
      ListControl list = new ListControl();
      list.Bounds = new UniRectangle(10, 10, 100, 100);
      list.ListRowLocator = new DummyListRowLocator();
      screen.Desktop.Children.Add(list);

      RectangleF listBounds = list.GetAbsoluteBounds();
      float itemsInView = listBounds.Height;
      itemsInView /= list.ListRowLocator.GetRowHeight(listBounds);

      // Put 5 items in the list
      fillList(list, 5);
      Assert.AreEqual(1.0f, list.Slider.ThumbSize);

      // Put another 15 items in the list
      fillList(list, 15);
      Assert.AreEqual(itemsInView / 20.0f, list.Slider.ThumbSize);

      // Put another 15 items in the list
      list.Items.RemoveAt(19);
      list.Items.RemoveAt(18);
      list.Items.RemoveAt(17);
      list.Items.RemoveAt(16);
      list.Items.RemoveAt(15);
      Assert.AreEqual(itemsInView / 15.0f, list.Slider.ThumbSize);

      list.Items.Clear();
      Assert.AreEqual(1.0f, list.Slider.ThumbSize);
    }
예제 #4
0
    public void TestMouseWheel() {
      Screen screen = new Screen();
      ListControl list = new ListControl();
      list.Bounds = new UniRectangle(10, 10, 100, 100);
      list.ListRowLocator = new DummyListRowLocator();
      screen.Desktop.Children.Add(list);

      // Put 20 items in the list
      fillList(list, 20);

      Assert.AreEqual(0.0f, list.Slider.ThumbPosition);
      list.ProcessMouseWheel(-1.0f);

      RectangleF listBounds = list.GetAbsoluteBounds();
      float totalitems = list.Items.Count;
      float itemsInView = listBounds.Height;
      itemsInView /= list.ListRowLocator.GetRowHeight(listBounds);
      float scrollableItems = totalitems - itemsInView;
      float newThumbPosition = 1.0f / scrollableItems * 1.0f;
      
      Assert.AreEqual(newThumbPosition, list.Slider.ThumbPosition);
    }