77// -----------------------------------------------------------------------
88
99using SharpConsoleUI . Configuration ;
10- using SharpConsoleUI . Dialogs ;
1110using SharpConsoleUI . Logging ;
12- using SharpConsoleUI . Models ;
1311
1412namespace SharpConsoleUI . Core
1513{
1614 /// <summary>
17- /// Manages panel state, start menu actions, and panel visibility.
15+ /// Manages panel state and visibility.
1816 /// </summary>
1917 public class PanelStateService
2018 {
2119 private readonly ILogService _logService ;
2220 private readonly Func < ConsoleWindowSystem > _getWindowSystem ;
23- private readonly List < StartMenuAction > _startMenuActions = new ( ) ;
24-
25- // Start menu window tracking
26- private Window ? _startMenuWindow ;
2721
2822 // Panel references
2923 private Panel . Panel ? _topPanel ;
@@ -33,11 +27,6 @@ public class PanelStateService
3327 private bool _showTopPanel = true ;
3428 private bool _showBottomPanel = true ;
3529
36- // Start menu configuration
37- private StartMenuOptions _startMenuOptions = new ( ) ;
38- private ConsoleKey _startMenuShortcutKey = ConsoleKey . Spacebar ;
39- private ConsoleModifiers _startMenuShortcutModifiers = ConsoleModifiers . Control ;
40-
4130 /// <summary>
4231 /// Initializes a new instance of the PanelStateService class.
4332 /// </summary>
@@ -68,28 +57,6 @@ public PanelStateService(ILogService logService, Func<ConsoleWindowSystem> getWi
6857 ( _topPanel ? . IsDirty ?? false )
6958 || ( _bottomPanel ? . IsDirty ?? false ) ;
7059
71- /// <summary>
72- /// Gets the start menu options configuration.
73- /// </summary>
74- public StartMenuOptions StartMenuOptions => _startMenuOptions ;
75-
76- /// <summary>
77- /// Gets the shortcut key for toggling the start menu.
78- /// </summary>
79- public ConsoleKey StartMenuShortcutKey => _startMenuShortcutKey ;
80-
81- /// <summary>
82- /// Gets the shortcut modifier keys for toggling the start menu.
83- /// </summary>
84- public ConsoleModifiers StartMenuShortcutModifiers => _startMenuShortcutModifiers ;
85-
86- /// <summary>
87- /// Gets whether any panel contains a StartMenuElement.
88- /// </summary>
89- public bool HasStartMenu =>
90- ( _topPanel ? . HasElement < Panel . StartMenuElement > ( ) ?? false ) ||
91- ( _bottomPanel ? . HasElement < Panel . StartMenuElement > ( ) ?? false ) ;
92-
9360 /// <summary>
9461 /// Marks both panels as dirty, forcing a re-render on the next frame.
9562 /// </summary>
@@ -175,98 +142,6 @@ public string BottomStatus
175142
176143 #endregion
177144
178- #region Start Menu Actions
179-
180- /// <summary>
181- /// Registers a new action in the Start menu.
182- /// </summary>
183- /// <param name="name">Display name of the action.</param>
184- /// <param name="callback">Callback to execute when action is selected.</param>
185- /// <param name="category">Optional category for grouping actions.</param>
186- /// <param name="order">Display order (lower values appear first).</param>
187- public void RegisterStartMenuAction ( string name , Action callback , string ? category = null , int order = 0 )
188- {
189- _logService . LogDebug ( $ "Registering Start menu action: { name } ", category : "StartMenu" ) ;
190- var action = new StartMenuAction ( name , callback , category , order ) ;
191- _startMenuActions . Add ( action ) ;
192- }
193-
194- /// <summary>
195- /// Removes an action from the Start menu by name.
196- /// </summary>
197- /// <param name="name">Name of the action to remove.</param>
198- public void UnregisterStartMenuAction ( string name )
199- {
200- _logService . LogDebug ( $ "Unregistering Start menu action: { name } ", category : "StartMenu" ) ;
201- _startMenuActions . RemoveAll ( a => a . Name == name ) ;
202- }
203-
204- /// <summary>
205- /// Gets all registered Start menu actions.
206- /// </summary>
207- /// <returns>Read-only list of actions.</returns>
208- public IReadOnlyList < StartMenuAction > GetStartMenuActions ( ) => _startMenuActions . AsReadOnly ( ) ;
209-
210- #endregion
211-
212- #region Start Menu Display
213-
214- /// <summary>
215- /// Gets or sets the currently open Start menu window, if any.
216- /// Used for toggle behavior — if non-null, the Start menu is open.
217- /// </summary>
218- internal Window ? StartMenuWindow
219- {
220- get => _startMenuWindow ;
221- set => _startMenuWindow = value ;
222- }
223-
224- /// <summary>
225- /// Gets the screen bounds and panel location of the start menu element.
226- /// Returns null if no start menu element exists in any panel.
227- /// </summary>
228- internal ( System . Drawing . Rectangle bounds , bool isBottom ) ? GetStartMenuBounds ( )
229- {
230- var ws = _getWindowSystem ( ) ;
231- var screenHeight = ws . DesktopDimensions . Height
232- + ( _topPanel ? . Height ?? 0 )
233- + ( _bottomPanel ? . Height ?? 0 ) ;
234-
235- if ( _bottomPanel != null )
236- {
237- var b = _bottomPanel . GetElementBounds < Panel . StartMenuElement > ( ) ;
238- if ( b . HasValue )
239- return ( new System . Drawing . Rectangle ( b . Value . x , screenHeight - 1 , b . Value . width , 1 ) , true ) ;
240- }
241- if ( _topPanel != null )
242- {
243- var b = _topPanel . GetElementBounds < Panel . StartMenuElement > ( ) ;
244- if ( b . HasValue )
245- return ( new System . Drawing . Rectangle ( b . Value . x , 0 , b . Value . width , 1 ) , false ) ;
246- }
247- return null ;
248- }
249-
250- /// <summary>
251- /// Shows the Start menu dialog.
252- /// </summary>
253- public void ShowStartMenu ( )
254- {
255- _logService . LogDebug ( "Showing Start menu" , category : "StartMenu" ) ;
256- var windowSystem = _getWindowSystem ( ) ;
257-
258- if ( windowSystem is ConsoleWindowSystem consoleWindowSystem )
259- {
260- StartMenuDialog . Show ( consoleWindowSystem ) ;
261- }
262- else
263- {
264- _logService . LogWarning ( "Cannot show Start menu: window system is not ConsoleWindowSystem" , category : "StartMenu" ) ;
265- }
266- }
267-
268- #endregion
269-
270145 #region Panel Initialization
271146
272147 /// <summary>
@@ -279,12 +154,6 @@ public void InitializePanels(ConsoleWindowSystemOptions options)
279154 {
280155 var ws = _getWindowSystem ( ) ;
281156
282- // Apply start menu config
283- if ( options . StartMenu != null )
284- _startMenuOptions = options . StartMenu ;
285- _startMenuShortcutKey = options . StartMenuShortcutKey ;
286- _startMenuShortcutModifiers = options . StartMenuShortcutModifiers ;
287-
288157 // Top panel: user config or default (status text + clock)
289158 if ( options . TopPanelConfig != null )
290159 {
0 commit comments