Exemplo n.º 1
0
        private void InitializeComponent()
        {
            EnableDragging = false;

            _dialogText = new LabelControl();
            _dialogText.Bounds = new UniRectangle(
                new UniScalar(0.0f, 15.0f), new UniScalar(0.0f, 15.0f),
                new UniScalar(1.0f, -30.0f), new UniScalar(1.0f, -85.0f)
            );
            Children.Add(_dialogText);

            _optionsList = new ListControl();
            _optionsList.Bounds = new UniRectangle(10, 10, new UniScalar(1, -20), 150);
            _optionsList.SelectionMode = ListSelectionMode.Single;

            _nextButton = new ButtonControl();
            _nextButton.Text = "Continue";
            _nextButton.Bounds = new UniRectangle(
                new UniScalar(1.0f, -110), new UniScalar(1.0f, -55f),
                new UniScalar(100), new UniScalar(45)
            );
            Children.Add(_nextButton);

            Bounds = new UniRectangle(
                new UniScalar(0.0f, 0.0f), new UniScalar(1.0f, -225.0f),
                new UniScalar(1.0f, 0.0f), new UniScalar(0.0f, 225.0f)
            );
        }
Exemplo n.º 2
0
 public void TestRowLocatorProperty() {
   ListControl list = new ListControl();
   DummyListRowLocator rowLocator = new DummyListRowLocator();
   list.ListRowLocator = rowLocator;
   Assert.AreSame(rowLocator, list.ListRowLocator);
 }
Exemplo n.º 3
0
 /// <summary>Fills a list control with dummy items</summary>
 /// <param name="list">List control that will be filled</param>
 /// <param name="itemCount">Number of dummy items to generate</param>
 private void fillList(ListControl list, int itemCount) {
   for(int index = 0; index < itemCount; ++index) {
     list.Items.Add("Item " + index.ToString());
   }
 }
Exemplo n.º 4
0
 public void TestConstructor() {
   ListControl list = new ListControl();
   Assert.IsNotNull(list); // nonsense; avoids compiler warning
 }
Exemplo n.º 5
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);
    }
Exemplo n.º 6
0
 /// <summary>Mocks a subscriber for the events of a list</summary>
 /// <param name="mockery">Mockery through which the mock will be created</param>
 /// <param name="list">List to mock an event subscriber for</param>
 /// <returns>The mocked event subscriber</returns>
 private static IListSubscriber mockSubscriber(Mockery mockery, ListControl list) {
   IListSubscriber mockedSubscriber = mockery.NewMock<IListSubscriber>();
   list.SelectionChanged += new EventHandler(mockedSubscriber.SelectionChanged);
   return mockedSubscriber;
 }
Exemplo n.º 7
0
    public void TestSelectionChangedEvent() {
      using(Mockery mockery = new Mockery()) {
        ListControl list = new ListControl();
        fillList(list, 20);

        IListSubscriber mockedSubscriber = mockSubscriber(mockery, list);

        Expect.Once.On(mockedSubscriber).Method("SelectionChanged").WithAnyArguments();
        list.SelectedItems.Add(1);

        Expect.Once.On(mockedSubscriber).Method("SelectionChanged").WithAnyArguments();
        list.SelectedItems.Remove(1);

        Expect.Once.On(mockedSubscriber).Method("SelectionChanged").WithAnyArguments();
        list.SelectedItems.Add(2);
        Expect.Once.On(mockedSubscriber).Method("SelectionChanged").WithAnyArguments();
        list.SelectedItems.Clear();

        mockery.VerifyAllExpectationsHaveBeenMet();
      }
    }
Exemplo n.º 8
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);
    }
Exemplo n.º 9
0
    public void TestSelectionModeProperty() {
      ListControl list = new ListControl();

      list.SelectionMode = ListSelectionMode.None;
      Assert.AreEqual(ListSelectionMode.None, list.SelectionMode);

      list.SelectionMode = ListSelectionMode.Single;
      Assert.AreEqual(ListSelectionMode.Single, list.SelectionMode);

      list.SelectionMode = ListSelectionMode.Multi;
      Assert.AreEqual(ListSelectionMode.Multi, list.SelectionMode);
    }
Exemplo n.º 10
0
 public void TestSliderProperty() {
   ListControl list = new ListControl();
   Assert.IsNotNull(list.Slider);
 }
Exemplo n.º 11
0
    public void TestMultiSelectionByMouse() {
      Screen screen = new Screen();
      ListControl list = new ListControl();
      list.Bounds = new UniRectangle(10, 10, 100, 100);
      list.SelectionMode = ListSelectionMode.Multi;
      list.ListRowLocator = new DummyListRowLocator();
      screen.Desktop.Children.Add(list);

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

      Assert.AreEqual(0, list.SelectedItems.Count);

      list.ProcessMouseMove(100, 100, 50, 35);
      list.ProcessMousePress(MouseButtons.Left);
      list.ProcessMouseRelease(MouseButtons.Left);

      Assert.AreEqual(1, list.SelectedItems.Count);
      Assert.AreEqual(2, list.SelectedItems[0]);

      list.ProcessMouseMove(100, 100, 50, 55);
      list.ProcessMousePress(MouseButtons.Left);
      list.ProcessMouseRelease(MouseButtons.Left);

      Assert.AreEqual(2, list.SelectedItems.Count);
      Assert.AreEqual(2, list.SelectedItems[0]);
      Assert.AreEqual(4, list.SelectedItems[1]);

      list.ProcessMouseMove(100, 100, 50, 35);
      list.ProcessMousePress(MouseButtons.Left);
      list.ProcessMouseRelease(MouseButtons.Left);

      Assert.AreEqual(1, list.SelectedItems.Count);
      Assert.AreEqual(4, list.SelectedItems[0]);
    }
Exemplo n.º 12
0
    public void TestSingleSelectionByMouse() {
      Screen screen = new Screen();
      ListControl list = new ListControl();
      list.Bounds = new UniRectangle(10, 10, 100, 100);
      list.SelectionMode = ListSelectionMode.Single;
      list.ListRowLocator = new DummyListRowLocator();
      screen.Desktop.Children.Add(list);

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

      // At the beginning, no items should be selected
      Assert.AreEqual(0, list.SelectedItems.Count);

      // Click on item 2 and verify that it is now selected
      list.ProcessMouseMove(100, 100, 50, 35);
      list.ProcessMousePress(MouseButtons.Left);
      list.ProcessMouseRelease(MouseButtons.Left);
      Assert.AreEqual(1, list.SelectedItems.Count);
      Assert.AreEqual(2, list.SelectedItems[0]);

      // Now click on item 4, which should unselect item 2 and select item 4
      list.ProcessMouseMove(100, 100, 50, 55);
      list.ProcessMousePress(MouseButtons.Left);
      list.ProcessMouseRelease(MouseButtons.Left);
      Assert.AreEqual(1, list.SelectedItems.Count);
      Assert.AreEqual(4, list.SelectedItems[0]);

      // Repeat the click on item 4, nothing should happen
      list.ProcessMouseMove(100, 100, 50, 55);
      list.ProcessMousePress(MouseButtons.Left);
      list.ProcessMouseRelease(MouseButtons.Left);
      Assert.AreEqual(1, list.SelectedItems.Count);
      Assert.AreEqual(4, list.SelectedItems[0]);
    }
Exemplo n.º 13
0
        public void TestConstructor()
        {
            ListControl list = new ListControl();

            Assert.IsNotNull(list); // nonsense; avoids compiler warning
        }
Exemplo n.º 14
0
        public void TestSliderProperty()
        {
            ListControl list = new ListControl();

            Assert.IsNotNull(list.Slider);
        }
Exemplo n.º 15
0
        private void CreateControls()
        {
            _pathLabel = new LabelControl("Select path for your .dll file:")
            {
                Bounds = new UniRectangle(new UniScalar(0f, 0), new UniScalar(0f, 0), 0, 0)
            };

            _pathBox = new InputControl
            {
                Name     = "path",
                IsHidden = false,
                Bounds   = new UniRectangle(new UniScalar(0, 0), new UniScalar(0f, 20), 300, 30),
                Text     = "",
                Enabled  = false
            };

            _browseButton = new ButtonControl
            {
                Text   = "Browse",
                Bounds =
                    new UniRectangle(
                        new UniScalar(0f, 310),
                        new UniScalar(0f, 20),
                        new UniScalar(0f, 100),
                        new UniScalar(0f, 30))
            };

            _uploadButton = new ButtonControl
            {
                Text   = "Upload",
                Bounds =
                    new UniRectangle(
                        new UniScalar(0f, 0),
                        new UniScalar(0f, 60),
                        new UniScalar(0f, 100),
                        new UniScalar(0f, 30))
            };
            _backButton = new ButtonControl
            {
                Text   = "Back",
                Bounds =
                    new UniRectangle(
                        new UniScalar(0f, 0),
                        new UniScalar(0f, 410),
                        new UniScalar(0f, 100),
                        new UniScalar(0f, 30))
            };

            _refreshButton = new ButtonControl
            {
                Text   = "Refresh",
                Bounds =
                    new UniRectangle(
                        new UniScalar(0f, 310),
                        new UniScalar(0f, 100),
                        new UniScalar(0f, 100),
                        new UniScalar(0f, 30))
            };
            _deleteButton = new ButtonControl
            {
                Text   = "Delete",
                Bounds =
                    new UniRectangle(
                        new UniScalar(0f, 310),
                        new UniScalar(0f, 135),
                        new UniScalar(0f, 100),
                        new UniScalar(0f, 30))
            };

            _intellectList = new Nuclex.UserInterface.Controls.Desktop.ListControl
            {
                SelectionMode = ListSelectionMode.Single,
                Bounds        =
                    new UniRectangle(
                        new UniScalar(0f, 0),
                        new UniScalar(0f, 100),
                        new UniScalar(0f, 300),
                        new UniScalar(0f, 300))
            };

            _intellectList.Slider.Bounds.Location.X.Offset -= 1.0f;
            _intellectList.Slider.Bounds.Location.Y.Offset += 1.0f;
            _intellectList.Slider.Bounds.Size.Y.Offset     -= 2.0f;
            _intellectList.SelectedItems.Add(0);
        }