public TestSceneDropdown()
        {
            var testItems = new TestModel[10];
            int i         = 0;

            while (i < items_to_add)
            {
                testItems[i] = @"test " + i++;
            }

            Add(platformActionContainerKeyboardSelection = new PlatformActionContainer
            {
                Child = testDropdown = new TestDropdown
                {
                    Width    = 150,
                    Position = new Vector2(50, 50),
                    Items    = testItems
                }
            });

            Add(platformActionContainerKeyboardPreselection = new PlatformActionContainer
            {
                Child = testDropdownMenu = new TestDropdown
                {
                    Width    = 150,
                    Position = new Vector2(250, 50),
                    Items    = testItems
                }
            });
            testDropdownMenu.Menu.MaxHeight = explicit_height;

            Add(bindableDropdown = new TestDropdown
            {
                Width      = 150,
                Position   = new Vector2(450, 50),
                ItemSource = bindableList
            });

            Add(platformActionContainerEmptyDropdown = new PlatformActionContainer
            {
                Child = emptyDropdown = new TestDropdown
                {
                    Width    = 150,
                    Position = new Vector2(650, 50),
                }
            });

            Add(disabledDropdown = new TestDropdown
            {
                Width    = 150,
                Position = new Vector2(50, 350),
                Items    = testItems,
                Current  =
                {
                    Value    = testItems[3],
                    Disabled = true
                }
            });
        }
        private void performPlatformAction(PlatformAction action, PlatformActionContainer platformActionContainer, Drawable drawable)
        {
            var tempIsHovered = drawable.IsHovered;
            var tempHasFocus  = drawable.HasFocus;

            drawable.IsHovered = true;
            drawable.HasFocus  = true;

            platformActionContainer.TriggerPressed(action);
            platformActionContainer.TriggerReleased(action);

            drawable.IsHovered = tempIsHovered;
            drawable.HasFocus  = tempHasFocus;
        }
Ejemplo n.º 3
0
        public TestSceneDropdown()
        {
            var testItems = new string[10];
            int i         = 0;

            while (i < items_to_add)
            {
                testItems[i] = @"test " + i++;
            }

            Add(platformActionContainerKeyboardSelection = new PlatformActionContainer
            {
                Child = testDropdown = new TestDropdown
                {
                    Width    = 150,
                    Position = new Vector2(200, 70),
                    Items    = testItems
                }
            });

            Add(platformActionContainerKeyboardPreselection = new PlatformActionContainer
            {
                Child = testDropdownMenu = new TestDropdown
                {
                    Width    = 150,
                    Position = new Vector2(400, 70),
                    Items    = testItems
                }
            });
            testDropdownMenu.Menu.MaxHeight = explicit_height;

            Add(bindableDropdown = new TestDropdown
            {
                Width      = 150,
                Position   = new Vector2(600, 70),
                ItemSource = bindableList
            });

            Add(platformActionContainerEmptyDropdown = new PlatformActionContainer
            {
                Child = emptyDropdown = new TestDropdown
                {
                    Width    = 150,
                    Position = new Vector2(800, 70),
                }
            });
        }
Ejemplo n.º 4
0
        public TestCaseTabControl()
        {
            List <KeyValuePair <string, TestEnum> > items = new List <KeyValuePair <string, TestEnum> >();

            foreach (var val in (TestEnum[])Enum.GetValues(typeof(TestEnum)))
            {
                items.Add(new KeyValuePair <string, TestEnum>(val.GetDescription(), val));
            }

            StyledTabControl simpleTabcontrol = new StyledTabControl
            {
                Position = new Vector2(200, 50),
                Size     = new Vector2(200, 30),
            };

            items.AsEnumerable().ForEach(item => simpleTabcontrol.AddItem(item.Value));

            StyledTabControl pinnedAndAutoSort = new StyledTabControl
            {
                Position = new Vector2(200, 150),
                Size     = new Vector2(200, 30),
                AutoSort = true
            };

            items.GetRange(0, 7).AsEnumerable().ForEach(item => pinnedAndAutoSort.AddItem(item.Value));
            pinnedAndAutoSort.PinItem(TestEnum.Test5);

            StyledTabControl        switchingTabControl;
            PlatformActionContainer platformActionContainer = new PlatformActionContainer
            {
                Child = switchingTabControl = new StyledTabControl
                {
                    Position = new Vector2(200, 250),
                    Size     = new Vector2(200, 30),
                }
            };

            items.AsEnumerable().ForEach(item => switchingTabControl.AddItem(item.Value));

            StyledTabControl removeAllTabControl = new StyledTabControl
            {
                Position = new Vector2(200, 350),
                Size     = new Vector2(200, 30)
            };

            var withoutDropdownTabControl = new StyledTabControlWithoutDropdown
            {
                Position = new Vector2(200, 450),
                Size     = new Vector2(200, 30)
            };

            items.AsEnumerable().ForEach(item => withoutDropdownTabControl.AddItem(item.Value));

            Add(simpleTabcontrol);
            Add(pinnedAndAutoSort);
            Add(platformActionContainer);
            Add(removeAllTabControl);
            Add(withoutDropdownTabControl);

            var nextTest = new Func <TestEnum>(() => items.AsEnumerable()
                                               .Select(item => item.Value)
                                               .FirstOrDefault(test => !pinnedAndAutoSort.Items.Contains(test)));

            Stack <TestEnum> pinned = new Stack <TestEnum>();

            AddStep("AddItem", () =>
            {
                var item = nextTest.Invoke();
                if (!pinnedAndAutoSort.Items.Contains(item))
                {
                    pinnedAndAutoSort.AddItem(item);
                }
            });

            AddStep("RemoveItem", () =>
            {
                if (pinnedAndAutoSort.Items.Any())
                {
                    pinnedAndAutoSort.RemoveItem(pinnedAndAutoSort.Items.First());
                }
            });

            AddStep("PinItem", () =>
            {
                var item = nextTest.Invoke();

                if (!pinnedAndAutoSort.Items.Contains(item))
                {
                    pinned.Push(item);
                    pinnedAndAutoSort.AddItem(item);
                    pinnedAndAutoSort.PinItem(item);
                }
            });

            AddStep("UnpinItem", () =>
            {
                if (pinned.Count > 0)
                {
                    pinnedAndAutoSort.UnpinItem(pinned.Pop());
                }
            });

            AddStep("Set first tab", () => switchingTabControl.Current.Value = switchingTabControl.VisibleItems.First());
            AddStep("Switch forward", () => platformActionContainer.TriggerPressed(new PlatformAction(PlatformActionType.DocumentNext)));
            AddAssert("Ensure second tab", () => switchingTabControl.Current.Value == switchingTabControl.VisibleItems.ElementAt(1));

            AddStep("Switch backward", () => platformActionContainer.TriggerPressed(new PlatformAction(PlatformActionType.DocumentPrevious)));
            AddAssert("Ensure first Tab", () => switchingTabControl.Current.Value == switchingTabControl.VisibleItems.First());

            AddStep("Switch backward", () => platformActionContainer.TriggerPressed(new PlatformAction(PlatformActionType.DocumentPrevious)));
            AddAssert("Ensure last tab", () => switchingTabControl.Current.Value == switchingTabControl.VisibleItems.Last());

            AddStep("Switch forward", () => platformActionContainer.TriggerPressed(new PlatformAction(PlatformActionType.DocumentNext)));
            AddAssert("Ensure first tab", () => switchingTabControl.Current.Value == switchingTabControl.VisibleItems.First());

            AddStep("Add all items", () => items.AsEnumerable().ForEach(item => removeAllTabControl.AddItem(item.Value)));
            AddAssert("Ensure all items", () => removeAllTabControl.Items.Count() == items.Count);

            AddStep("Remove all items", () => removeAllTabControl.Clear());
            AddAssert("Ensure no items", () => !removeAllTabControl.Items.Any());

            AddAssert("Ensure any items", () => withoutDropdownTabControl.Items.Any());
            AddStep("Remove all items", () => withoutDropdownTabControl.Clear());
            AddAssert("Ensure no items", () => !withoutDropdownTabControl.Items.Any());
        }