|
| 1 | +// ----------------------------------------------------------------------- |
| 2 | +// ConsoleEx - A simple console window system for .NET Core |
| 3 | +// |
| 4 | +// Author: Nikolaos Protopapas |
| 5 | +// Email: nikolaos.protopapas@gmail.com |
| 6 | +// License: MIT |
| 7 | +// ----------------------------------------------------------------------- |
| 8 | + |
| 9 | +using SharpConsoleUI.Configuration; |
| 10 | + |
| 11 | +namespace SharpConsoleUI.Controls.StartMenu |
| 12 | +{ |
| 13 | + /// <summary> |
| 14 | + /// Provides formatting helpers for Start menu elements. |
| 15 | + /// Icon display is controlled by <see cref="Configuration.StartMenuOptions.ShowIcons"/>. |
| 16 | + /// </summary> |
| 17 | + internal static class StartMenuStyleHelper |
| 18 | + { |
| 19 | + /// <summary> |
| 20 | + /// Formats the application header with name and version. |
| 21 | + /// Returns multiple markup lines for MarkupControl. |
| 22 | + /// </summary> |
| 23 | + public static List<string> FormatAppHeaderLines(string appName, string version, bool showIcons, string headerIcon = "\u2630") |
| 24 | + { |
| 25 | + var icon = showIcons ? $"{headerIcon} " : ""; |
| 26 | + return new List<string> |
| 27 | + { |
| 28 | + $"{icon}[bold]{appName}[/]", |
| 29 | + $" v{version}", |
| 30 | + }; |
| 31 | + } |
| 32 | + |
| 33 | + /// <summary> |
| 34 | + /// Formats a section/category header label. |
| 35 | + /// </summary> |
| 36 | + public static string FormatCategoryHeader(string text, bool showIcons, string? icon = null) |
| 37 | + { |
| 38 | + var prefix = showIcons && icon != null ? $"{icon} " : ""; |
| 39 | + return $"{prefix}{text}"; |
| 40 | + } |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Formats the info strip with theme name, window count, and plugin count. |
| 44 | + /// Returns multiple markup lines for MarkupControl. |
| 45 | + /// </summary> |
| 46 | + public static List<string> FormatInfoStripLines(string themeName, int windowCount, int pluginCount) |
| 47 | + { |
| 48 | + var windowLabel = windowCount == 1 ? "Window" : "Windows"; |
| 49 | + var pluginLabel = pluginCount == 1 ? "Plugin" : "Plugins"; |
| 50 | + |
| 51 | + return new List<string> |
| 52 | + { |
| 53 | + $"Theme: {themeName}", |
| 54 | + $"{windowLabel}: {windowCount} {pluginLabel}: {pluginCount}", |
| 55 | + }; |
| 56 | + } |
| 57 | + |
| 58 | + /// <summary> |
| 59 | + /// Formats a window list item with state indicator and optional keyboard shortcut. |
| 60 | + /// </summary> |
| 61 | + public static string FormatWindowItem(string title, int index, bool isMinimized, bool isActive) |
| 62 | + { |
| 63 | + var indicator = isMinimized |
| 64 | + ? ControlDefaults.StartMenuMinimizedWindowIndicator |
| 65 | + : ControlDefaults.StartMenuActiveWindowIndicator; |
| 66 | + var shortcut = index < 9 ? $" Alt+{index + 1}" : ""; |
| 67 | + var dimStart = isMinimized ? "[dim]" : ""; |
| 68 | + var dimEnd = isMinimized ? "[/]" : ""; |
| 69 | + var activeStart = isActive ? "[bold]" : ""; |
| 70 | + var activeEnd = isActive ? "[/]" : ""; |
| 71 | + |
| 72 | + return $"{indicator} {dimStart}{activeStart}{title}{activeEnd}{dimEnd}{shortcut}"; |
| 73 | + } |
| 74 | + |
| 75 | + /// <summary> |
| 76 | + /// Formats the exit row text. |
| 77 | + /// </summary> |
| 78 | + public static string FormatExitRow(bool showIcons) |
| 79 | + { |
| 80 | + var icon = showIcons ? $"{ControlDefaults.StartMenuExitIcon} " : ""; |
| 81 | + return $"{icon}Exit Application"; |
| 82 | + } |
| 83 | + |
| 84 | + } |
| 85 | +} |
0 commit comments