@@ -33,6 +33,73 @@ internal class Menu : IMenu, IMenuPriorityExtension, INavigateBackMenuExtension
3333 public Menu ? Parent => Parents . Count > 0 ? Parents [ ^ 1 ] : null ;
3434 public DateTime OpenedAt { get ; set ; }
3535
36+ public int SelectionIndex { get ; set ; }
37+
38+ public int PrevSelectionIndex
39+ {
40+ get
41+ {
42+ var itemsVisible = Math . Min ( ItemsPerPage , Items . Count - ( CurrentPage * ItemsPerPage ) ) ;
43+ var buttonStates = GetButtonStates ( ) ;
44+
45+ if ( SelectionIndex > 8 && buttonStates . ShowNextButton )
46+ return 8 ;
47+ if ( SelectionIndex > 7 && ( buttonStates . ShowBackButton || buttonStates . ShowPrevButton ) )
48+ return 7 ;
49+ if ( SelectionIndex > itemsVisible - 1 )
50+ return itemsVisible - 1 ;
51+ if ( SelectionIndex > 0 )
52+ return SelectionIndex - 1 ;
53+
54+ if ( SelectionIndex == 0 )
55+ {
56+ if ( buttonStates . ShowExitButton )
57+ return 9 ;
58+ if ( buttonStates . ShowNextButton )
59+ return 8 ;
60+ if ( buttonStates . ShowBackButton || buttonStates . ShowPrevButton )
61+ return 7 ;
62+ if ( itemsVisible > 0 )
63+ return itemsVisible - 1 ;
64+ return SelectionIndex ;
65+ }
66+
67+ return SelectionIndex ;
68+ }
69+ }
70+ public int NextSelectionIndex
71+ {
72+ get
73+ {
74+ var itemsVisible = Math . Min ( ItemsPerPage , Items . Count - ( CurrentPage * ItemsPerPage ) ) ;
75+ var buttonStates = GetButtonStates ( ) ;
76+
77+ if ( SelectionIndex < itemsVisible - 1 )
78+ return SelectionIndex + 1 ;
79+ if ( SelectionIndex < 7 && ( buttonStates . ShowBackButton || buttonStates . ShowPrevButton ) )
80+ return 7 ;
81+ if ( SelectionIndex < 8 && buttonStates . ShowNextButton )
82+ return 8 ;
83+ if ( SelectionIndex < 9 && buttonStates . ShowExitButton )
84+ return 9 ;
85+
86+ if ( SelectionIndex == 9 )
87+ {
88+ if ( itemsVisible > 0 )
89+ return 0 ;
90+ if ( buttonStates . ShowBackButton || buttonStates . ShowPrevButton )
91+ return 7 ;
92+ if ( buttonStates . ShowNextButton )
93+ return 8 ;
94+ if ( buttonStates . ShowExitButton )
95+ return 9 ;
96+ return SelectionIndex ;
97+ }
98+
99+ return SelectionIndex ;
100+ }
101+ }
102+
36103 internal MenuButtonState GetButtonStates ( )
37104 {
38105 var ret = new MenuButtonState ( ) ;
0 commit comments