public void FocusFirstItem() { DefocusLastFocused(); var current = _iteratableList.GetCurrent(); if (current != null) { current.IsFocused = true; } }
private void SearchBox_OnOnKeyPressed(object sender, KeyEventArgs e) { switch (e.Key) { case Key.Up: case Key.Left: _iteratableList.GoToPrevious(); var current1 = (CheckBoxWithListDownMenu)_iteratableList.GetCurrent(); if (current1 == null) { return; } current1.Highlight(); if (_iteratableList.AtLast()) { ScrollViewer.ScrollToBottom(); } else if (!current1.IsVisibleToUser(ScrollViewer)) { ScrollViewer.PageUp(); } break; case Key.Down: case Key.Right: _iteratableList.GoToNext(); var current = (CheckBoxWithListDownMenu)_iteratableList.GetCurrent(); if (current == null) { return; } current.Highlight(); if (_iteratableList.AtFirst()) { ScrollViewer.ScrollToHome(); } else if (!current.IsVisibleToUser(ScrollViewer)) { ScrollViewer.PageDown(); } break; case Key.Enter: var current2 = (CheckBoxWithListDownMenu)_iteratableList.GetCurrent(); if (current2 == null) { return; } current2.IsChecked = !_iteratableList.GetCurrent().IsChecked; break; default: break; } }
public void Test_GoToPrevious() { var input = new CyclicIteratableList <int>(new List <int> { 1, 2, 3 }); input.GoToPrevious(); Assert.IsTrue(input.GetCurrent() == 3); input.GoToPrevious(); Assert.IsTrue(input.GetCurrent() == 2); input.GoToPrevious(); Assert.IsTrue(input.GetCurrent() == 1); }
private bool SearchForMatchingSubjectAndDisplayThem(string searchedText) { bool somethingFound = false; var found = new List <ICheckBoxWithListDownMenu>(); foreach (UIElement child in CheckerBoxStackPanel.Children) { if (child is ICheckBoxWithListDownMenu) { var target = child as ICheckBoxWithListDownMenu; string comparedString = target.SubjectName.ToLower() + target.SubjectCode.ToLower(); if (comparedString.Contains(searchedText)) { somethingFound = true; child.Visibility = Visible; found.Add(target); (child as ICheckBoxWithListDownMenu).HighlightText = searchedText; } else { child.Visibility = Collapsed; } } } _iteratableList = new CyclicIteratableList <ICheckBoxWithListDownMenu>(found); _iteratableList.GetCurrent()?.Highlight(); return(somethingFound); }
public void Test_InputHasNoElements_ReferenceTypes() { var input = new CyclicIteratableList <object>(new List <object>() { }); Assert.IsTrue(input.GetCurrent() == null); }
public void Test_InputHasNoElements_NumericTypes() { var input = new CyclicIteratableList <int>(new List <int>() { }); Assert.IsTrue(input.GetCurrent() == 0); }
public void Test_GetCurrent() { var input = new CyclicIteratableList <int>(new List <int>() { 1, 2, 3 }); Assert.IsTrue(input.GetCurrent() == 1); }