示例#1
0
        private void NavigateListLayout(string menuItem, MenuInputButton nextButton, MenuInputButton prevButton)
        {
            var        menu   = context.Desktop.ActiveWorkspace.ActiveWindow as Menu;
            ListLayout layout = menu.Layout as ListLayout;

            var target = layout.Items.SingleOrDefault(w => w.Name.Equals(menuItem, StringComparison.OrdinalIgnoreCase));

            if (target == null)
            {
                throw new InvalidOperationException($"Could not find {menuItem} in {menu.Name}. Active workspace: {context.Desktop.ActiveWorkspace}");
            }

            var targetIndex = layout.IndexOf(target);

            while (targetIndex > layout.FocusIndex)
            {
                Desktop.ClearAnimations();

                instructor.SendButtonPress(nextButton);
            }
            while (targetIndex < layout.FocusIndex)
            {
                instructor.SendButtonPress(prevButton);
            }
        }
        public void LL_ListBehavior()
        {
            var item = new Mock <IWidget>().Object;

            var item3 = ListLayout[3];

            ListLayout.IndexOf(item3).Should().Be(3);
            ListLayout.Contains(item).Should().BeFalse();

            ListLayout.Insert(3, item);
            ListLayout[3].Should().Be(item);
            ListLayout[4].Should().Be(item3);
            ListLayout.IndexOf(item).Should().Be(3);
            ListLayout.IndexOf(item3).Should().Be(4);

            ListLayout.Count.Should().Be(11);
            ListLayout.Contains(item).Should().BeTrue();

            ListLayout.Remove(item).Should().BeTrue();

            ListLayout[3].Should().Be(item3);
            ListLayout.Count.Should().Be(10);
            ListLayout.Contains(item).Should().BeFalse();

            ListLayout.RemoveAt(3);
            ListLayout.IndexOf(item3).Should().Be(-1);
            ListLayout.Contains(item3).Should().BeFalse();
            ListLayout.Count.Should().Be(9);

            IWidget[] array = new IWidget[9];
            ListLayout.CopyTo(array, 0);

            var index = 0;

            foreach (var listItem in ListLayout)
            {
                listItem.Should().Be(array[index]);
                index++;
            }
        }