public void Test_FocusNavigator_Navigate_4()
        {
            var input          = GetMockData();
            var focusNavigator = new FocusNavigator(input);

            focusNavigator.NavigateToPrevious();
            Assert.IsTrue(input[input.Count - 1].IsFocused);
        }
        public void Test_FocusNavigator_Navigate_1()
        {
            var input          = GetMockData();
            var focusNavigator = new FocusNavigator(input);

            focusNavigator.NavigateToNext();
            Assert.IsTrue(input[1].IsFocused);
        }
        public void Test_FocusNavigator_FocusFirstItem()
        {
            var input          = GetMockData();
            var focusNavigator = new FocusNavigator(input);

            focusNavigator.FocusFirstItem();
            Assert.IsTrue(input[0].IsFocused);
        }
        public void Test_FocusNavigator_OnlyOneItemShouldBeFocusedAtATime()
        {
            var input          = GetMockData();
            var focusNavigator = new FocusNavigator(input);

            focusNavigator.NavigateToNext();
            focusNavigator.NavigateToNext();
            Assert.IsTrue(input.Count(x => x.IsFocused) == 1);
        }
Exemple #5
0
        private void OnFocusNavigatorChanged(FocusNavigator <TItem> oldFocusNavigator, FocusNavigator <TItem> newFocusNavigator)
        {
            if (oldFocusNavigator != null)
            {
                oldFocusNavigator.IsLogical = false;
            }

            if (newFocusNavigator != null)
            {
                newFocusNavigator.IsLogical = true;
            }
        }
 public SubjectListModel(List <SubjectModel> subjectModels, Func <Slot[], List <List <Slot> > > permutator = null,
                         ITaskRunnerWithProgressFeedback taskRunner = null)
 {
     _subjectModels           = subjectModels;
     _subjectSelectionManager = new SubjectSelectionManager(subjectModels, permutator, taskRunner);
     _subjectSelectionManager.SelectedSubjectCountChanged +=
         _subjectSelectionManager_SelectedSubjectCountChanged;
     _subjectSelectionManager.NewListOfTimetablesGenerated +=
         _subjectSelectionManager_NewListOfTimetablesGenerated;
     foreach (var subjectModel in _subjectModels)
     {
         _nameAndCodeOfAllSubjects.Add(subjectModel.Name);
         _nameAndCodeOfAllSubjects.Add(subjectModel.Code);
     }
     _focusNavigator = new FocusNavigator(new List <IFocusable>(_subjectModels));
     _focusNavigator.FocusFirstItem();
 }
Exemple #7
0
        /// <summary>
        /// Performs tab navigation while focus is within the drop down.
        /// </summary>
        private void PerformTabNavigation(Key key, ModifierKeys modifiers)
        {
            var shift = ((modifiers & ModifierKeys.Shift) == ModifierKeys.Shift);
            var ctrl  = ((modifiers & ModifierKeys.Control) == ModifierKeys.Control);

            var focused = Keyboard.GetFocusedElement(View) as UIElement;

            if (FocusNavigator.PerformNavigation(View, focused, shift ? FocusNavigationDirection.Previous : FocusNavigationDirection.Next, ctrl))
            {
                focused = Keyboard.GetFocusedElement(View) as UIElement;

                var container = (focused == null) ? null : ItemsControlUtil.FindContainer <ComboBoxItem>(this, focused);
                if (container != null)
                {
                    ItemsControlUtil.ScrollItemIntoView <ComboBoxItem>(this, PART_ScrollViewer, container);
                }
            }
        }
        private void OnIsDropDownOpenChangedSelector()
        {
            var selectorController = SelectorController;

            if (selectorController == null)
            {
                return;
            }

            if (IsDropDownOpen)
            {
                //selectorController.SuspendSelection();

                var selectedItem = selectorController.SelectedItem;

                if (selectedItem != null)
                {
                    ItemCollection.BringIntoViewInternal(new BringIntoViewRequest <TItem>(selectedItem, BringIntoViewMode.Top));

                    FocusNavigator.FocusedItem = selectedItem;
                    FocusHelper.QueryFocus(selectedItem);
                }
                else
                {
                    ItemCollection.BringIntoViewInternal(0);
                    FocusNavigator.ClearFocus();
                }
            }
            else
            {
                if (selectorController.IsSelectionSuspended)
                {
                    //selectorController.RestoreSelection();
                    //selectorController.ResumeSelection();
                }
            }
        }