├── .editorconfig
├── .gitignore
├── ConsoleMenu.sln
├── ConsoleMenu
├── CloseTrigger.cs
├── ConsoleMenu.cs
├── ConsoleMenu.csproj
├── ConsoleMenuDisplay.cs
├── Extensions.cs
├── IConsole.cs
├── ItemsCollection.cs
├── MenuConfig.cs
├── MenuItem.cs
├── Properties
│ └── PublishProfiles
│ │ └── FolderProfile.pubxml
├── PublicAPI.Shipped.txt
├── PublicAPI.Unshipped.txt
├── SystemConsole.cs
├── VisibilityManager.cs
└── stylecop.json
├── ConsoleMenuSampleApp
├── ConsoleMenuSampleApp.csproj
└── Program.cs
├── ConsoleMenuTests
├── BreadcrumbsScenarioTest.cs
├── ConsoleMenuTests.csproj
├── ExtensionsTest.cs
├── FilteringScenarioTest.cs
├── PreSelectionScenarioTest.cs
├── ReentrySubmenuScenarioTest.cs
├── SimpleScenarioTest.cs
├── TestConsole.cs
└── TestHelpers
│ ├── AssertHelper.cs
│ └── ConfigHelper.cs
├── LICENSE.txt
├── README.md
└── preview.gif
/.editorconfig:
--------------------------------------------------------------------------------
1 | # To learn more about .editorconfig see https://aka.ms/editorconfigdocs
2 | ###############################
3 | # Core EditorConfig Options #
4 | ###############################
5 | root = true
6 | # All files
7 | [*]
8 | indent_style = space
9 |
10 | # XML project files
11 | [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
12 | indent_size = 2
13 |
14 | # XML config files
15 | [*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
16 | indent_size = 2
17 |
18 | # Code files
19 | [*.{cs,csx,vb,vbx}]
20 | indent_size = 2
21 | insert_final_newline = true
22 | charset = utf-8-bom
23 | ###############################
24 | # .NET Coding Conventions #
25 | ###############################
26 | [*.{cs,vb}]
27 | # Organize usings
28 | dotnet_sort_system_directives_first = true
29 | # this. preferences
30 | dotnet_style_qualification_for_field = false:silent
31 | dotnet_style_qualification_for_property = false:silent
32 | dotnet_style_qualification_for_method = false:silent
33 | dotnet_style_qualification_for_event = false:silent
34 | # Language keywords vs BCL types preferences
35 | dotnet_style_predefined_type_for_locals_parameters_members = true:silent
36 | dotnet_style_predefined_type_for_member_access = true:silent
37 | # Parentheses preferences
38 | dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
39 | dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
40 | dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
41 | dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
42 | # Modifier preferences
43 | dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
44 | dotnet_style_readonly_field = true:suggestion
45 | # Expression-level preferences
46 | dotnet_style_object_initializer = true:suggestion
47 | dotnet_style_collection_initializer = true:suggestion
48 | dotnet_style_explicit_tuple_names = true:suggestion
49 | dotnet_style_null_propagation = true:suggestion
50 | dotnet_style_coalesce_expression = true:suggestion
51 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
52 | dotnet_style_prefer_inferred_tuple_names = true:suggestion
53 | dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
54 | dotnet_style_prefer_auto_properties = true:silent
55 | dotnet_style_prefer_conditional_expression_over_assignment = true:silent
56 | dotnet_style_prefer_conditional_expression_over_return = true:silent
57 | ###############################
58 | # Naming Conventions #
59 | ###############################
60 | # Style Definitions
61 | dotnet_naming_style.pascal_case_style.capitalization = pascal_case
62 | # Use PascalCase for constant fields
63 | dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
64 | dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
65 | dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
66 | dotnet_naming_symbols.constant_fields.applicable_kinds = field
67 | dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
68 | dotnet_naming_symbols.constant_fields.required_modifiers = const
69 | tab_width= 2
70 | dotnet_style_operator_placement_when_wrapping = beginning_of_line
71 | end_of_line = lf
72 | dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
73 | ###############################
74 | # C# Coding Conventions #
75 | ###############################
76 | [*.cs]
77 | # var preferences
78 | csharp_style_var_for_built_in_types = true:silent
79 | csharp_style_var_when_type_is_apparent = true:silent
80 | csharp_style_var_elsewhere = true:silent
81 | # Expression-bodied members
82 | csharp_style_expression_bodied_methods = false:silent
83 | csharp_style_expression_bodied_constructors = false:silent
84 | csharp_style_expression_bodied_operators = false:silent
85 | csharp_style_expression_bodied_properties = true:silent
86 | csharp_style_expression_bodied_indexers = true:silent
87 | csharp_style_expression_bodied_accessors = true:silent
88 | # Pattern matching preferences
89 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
90 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
91 | # Null-checking preferences
92 | csharp_style_throw_expression = true:suggestion
93 | csharp_style_conditional_delegate_call = true:suggestion
94 | # Modifier preferences
95 | csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
96 | # Expression-level preferences
97 | csharp_prefer_braces = true:silent
98 | csharp_style_deconstructed_variable_declaration = true:suggestion
99 | csharp_prefer_simple_default_expression = true:suggestion
100 | csharp_style_pattern_local_over_anonymous_function = true:suggestion
101 | csharp_style_inlined_variable_declaration = true:suggestion
102 | ###############################
103 | # C# Formatting Rules #
104 | ###############################
105 | # New line preferences
106 | csharp_new_line_before_open_brace = all
107 | csharp_new_line_before_else = true
108 | csharp_new_line_before_catch = true
109 | csharp_new_line_before_finally = true
110 | csharp_new_line_before_members_in_object_initializers = true
111 | csharp_new_line_before_members_in_anonymous_types = true
112 | csharp_new_line_between_query_expression_clauses = true
113 | # Indentation preferences
114 | csharp_indent_case_contents = true
115 | csharp_indent_switch_labels = true
116 | csharp_indent_labels = flush_left
117 | # Space preferences
118 | csharp_space_after_cast = false
119 | csharp_space_after_keywords_in_control_flow_statements = true
120 | csharp_space_between_method_call_parameter_list_parentheses = false
121 | csharp_space_between_method_declaration_parameter_list_parentheses = false
122 | csharp_space_between_parentheses = false
123 | csharp_space_before_colon_in_inheritance_clause = true
124 | csharp_space_after_colon_in_inheritance_clause = true
125 | csharp_space_around_binary_operators = before_and_after
126 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
127 | csharp_space_between_method_call_name_and_opening_parenthesis = false
128 | csharp_space_between_method_call_empty_parameter_list_parentheses = false
129 | # Wrapping preferences
130 | csharp_preserve_single_line_statements = true
131 | csharp_preserve_single_line_blocks = true
132 | csharp_style_namespace_declarations= file_scoped:warning
133 | csharp_using_directive_placement = outside_namespace:silent
134 | csharp_prefer_simple_using_statement = true:suggestion
135 | csharp_style_expression_bodied_lambdas = true:silent
136 | csharp_style_expression_bodied_local_functions = false:silent
137 | ###############################
138 | # VB Coding Conventions #
139 | ###############################
140 |
141 | # SA1633: File should have header
142 | dotnet_diagnostic.SA1633.severity = none
143 |
144 | # SA1122: Use string.Empty for empty strings
145 | dotnet_diagnostic.SA1122.severity = none
146 |
147 | # SA1405: Debug.Assert should provide message text
148 | dotnet_diagnostic.SA1405.severity = none
149 | csharp_style_prefer_method_group_conversion = true:silent
150 | csharp_style_prefer_top_level_statements = true:silent
151 |
152 | [*.vb]
153 | # Modifier preferences
154 | visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion
155 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/csharp,visualstudio,visualstudiocode
3 |
4 | ### Csharp ###
5 | ## Ignore Visual Studio temporary files, build results, and
6 | ## files generated by popular Visual Studio add-ons.
7 | ##
8 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
9 |
10 | # User-specific files
11 | *.suo
12 | *.user
13 | *.userosscache
14 | *.sln.docstates
15 |
16 | # User-specific files (MonoDevelop/Xamarin Studio)
17 | *.userprefs
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | bld/
27 | [Bb]in/
28 | [Oo]bj/
29 | [Ll]og/
30 |
31 | # Visual Studio 2015 cache/options directory
32 | .vs/
33 | # Uncomment if you have tasks that create the project's static files in wwwroot
34 | #wwwroot/
35 |
36 | # MSTest test Results
37 | [Tt]est[Rr]esult*/
38 | [Bb]uild[Ll]og.*
39 |
40 | # NUNIT
41 | *.VisualState.xml
42 | TestResult.xml
43 |
44 | # Build Results of an ATL Project
45 | [Dd]ebugPS/
46 | [Rr]eleasePS/
47 | dlldata.c
48 |
49 | # .NET Core
50 | project.lock.json
51 | project.fragment.lock.json
52 | artifacts/
53 | **/Properties/launchSettings.json
54 |
55 | *_i.c
56 | *_p.c
57 | *_i.h
58 | *.ilk
59 | *.meta
60 | *.obj
61 | *.pch
62 | *.pdb
63 | *.pgc
64 | *.pgd
65 | *.rsp
66 | *.sbr
67 | *.tlb
68 | *.tli
69 | *.tlh
70 | *.tmp
71 | *.tmp_proj
72 | *.log
73 | *.vspscc
74 | *.vssscc
75 | .builds
76 | *.pidb
77 | *.svclog
78 | *.scc
79 |
80 | # Chutzpah Test files
81 | _Chutzpah*
82 |
83 | # Visual C++ cache files
84 | ipch/
85 | *.aps
86 | *.ncb
87 | *.opendb
88 | *.opensdf
89 | *.sdf
90 | *.cachefile
91 | *.VC.db
92 | *.VC.VC.opendb
93 |
94 | # Visual Studio profiler
95 | *.psess
96 | *.vsp
97 | *.vspx
98 | *.sap
99 |
100 | # TFS 2012 Local Workspace
101 | $tf/
102 |
103 | # Guidance Automation Toolkit
104 | *.gpState
105 |
106 | # ReSharper is a .NET coding add-in
107 | _ReSharper*/
108 | *.[Rr]e[Ss]harper
109 | *.DotSettings.user
110 |
111 | # JustCode is a .NET coding add-in
112 | .JustCode
113 |
114 | # TeamCity is a build add-in
115 | _TeamCity*
116 |
117 | # DotCover is a Code Coverage Tool
118 | *.dotCover
119 |
120 | # Visual Studio code coverage results
121 | *.coverage
122 | *.coveragexml
123 |
124 | # NCrunch
125 | _NCrunch_*
126 | .*crunch*.local.xml
127 | nCrunchTemp_*
128 |
129 | # MightyMoose
130 | *.mm.*
131 | AutoTest.Net/
132 |
133 | # Web workbench (sass)
134 | .sass-cache/
135 |
136 | # Installshield output folder
137 | [Ee]xpress/
138 |
139 | # DocProject is a documentation generator add-in
140 | DocProject/buildhelp/
141 | DocProject/Help/*.HxT
142 | DocProject/Help/*.HxC
143 | DocProject/Help/*.hhc
144 | DocProject/Help/*.hhk
145 | DocProject/Help/*.hhp
146 | DocProject/Help/Html2
147 | DocProject/Help/html
148 |
149 | # Click-Once directory
150 | publish/
151 |
152 | # Publish Web Output
153 | *.[Pp]ublish.xml
154 | *.azurePubxml
155 | # TODO: Uncomment the next line to ignore your web deploy settings.
156 | # By default, sensitive information, such as encrypted password
157 | # should be stored in the .pubxml.user file.
158 | #*.pubxml
159 | *.pubxml.user
160 | *.publishproj
161 |
162 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
163 | # checkin your Azure Web App publish settings, but sensitive information contained
164 | # in these scripts will be unencrypted
165 | PublishScripts/
166 |
167 | # NuGet Packages
168 | *.nupkg
169 | # The packages folder can be ignored because of Package Restore
170 | **/packages/*
171 | # except build/, which is used as an MSBuild target.
172 | !**/packages/build/
173 | # Uncomment if necessary however generally it will be regenerated when needed
174 | #!**/packages/repositories.config
175 | # NuGet v3's project.json files produces more ignorable files
176 | *.nuget.props
177 | *.nuget.targets
178 |
179 | # Microsoft Azure Build Output
180 | csx/
181 | *.build.csdef
182 |
183 | # Microsoft Azure Emulator
184 | ecf/
185 | rcf/
186 |
187 | # Windows Store app package directories and files
188 | AppPackages/
189 | BundleArtifacts/
190 | Package.StoreAssociation.xml
191 | _pkginfo.txt
192 |
193 | # Visual Studio cache files
194 | # files ending in .cache can be ignored
195 | *.[Cc]ache
196 | # but keep track of directories ending in .cache
197 | !*.[Cc]ache/
198 |
199 | # Others
200 | ClientBin/
201 | ~$*
202 | *~
203 | *.dbmdl
204 | *.dbproj.schemaview
205 | *.jfm
206 | *.pfx
207 | *.publishsettings
208 | orleans.codegen.cs
209 |
210 | # Since there are multiple workflows, uncomment next line to ignore bower_components
211 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
212 | #bower_components/
213 |
214 | # RIA/Silverlight projects
215 | Generated_Code/
216 |
217 | # Backup & report files from converting an old project file
218 | # to a newer Visual Studio version. Backup files are not needed,
219 | # because we have git ;-)
220 | _UpgradeReport_Files/
221 | Backup*/
222 | UpgradeLog*.XML
223 | UpgradeLog*.htm
224 |
225 | # SQL Server files
226 | *.mdf
227 | *.ldf
228 | *.ndf
229 |
230 | # Business Intelligence projects
231 | *.rdl.data
232 | *.bim.layout
233 | *.bim_*.settings
234 |
235 | # Microsoft Fakes
236 | FakesAssemblies/
237 |
238 | # GhostDoc plugin setting file
239 | *.GhostDoc.xml
240 |
241 | # Node.js Tools for Visual Studio
242 | .ntvs_analysis.dat
243 | node_modules/
244 |
245 | # Typescript v1 declaration files
246 | typings/
247 |
248 | # Visual Studio 6 build log
249 | *.plg
250 |
251 | # Visual Studio 6 workspace options file
252 | *.opt
253 |
254 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
255 | *.vbw
256 |
257 | # Visual Studio LightSwitch build output
258 | **/*.HTMLClient/GeneratedArtifacts
259 | **/*.DesktopClient/GeneratedArtifacts
260 | **/*.DesktopClient/ModelManifest.xml
261 | **/*.Server/GeneratedArtifacts
262 | **/*.Server/ModelManifest.xml
263 | _Pvt_Extensions
264 |
265 | # Paket dependency manager
266 | .paket/paket.exe
267 | paket-files/
268 |
269 | # FAKE - F# Make
270 | .fake/
271 |
272 | # JetBrains Rider
273 | .idea/
274 | *.sln.iml
275 |
276 | # CodeRush
277 | .cr/
278 |
279 | # Python Tools for Visual Studio (PTVS)
280 | __pycache__/
281 | *.pyc
282 |
283 | # Cake - Uncomment if you are using it
284 | # tools/**
285 | # !tools/packages.config
286 |
287 | # Telerik's JustMock configuration file
288 | *.jmconfig
289 |
290 | # BizTalk build output
291 | *.btp.cs
292 | *.btm.cs
293 | *.odx.cs
294 | *.xsd.cs
295 |
296 | ### VisualStudioCode ###
297 | .vscode/*
298 | !.vscode/settings.json
299 | !.vscode/tasks.json
300 | !.vscode/launch.json
301 | !.vscode/extensions.json
302 | .history
303 |
304 | ### VisualStudio ###
305 | ## Ignore Visual Studio temporary files, build results, and
306 | ## files generated by popular Visual Studio add-ons.
307 | ##
308 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
309 |
310 | # User-specific files
311 |
312 | # User-specific files (MonoDevelop/Xamarin Studio)
313 |
314 | # Build results
315 |
316 | # Visual Studio 2015 cache/options directory
317 | # Uncomment if you have tasks that create the project's static files in wwwroot
318 | #wwwroot/
319 |
320 | # MSTest test Results
321 |
322 | # NUNIT
323 |
324 | # Build Results of an ATL Project
325 |
326 | # .NET Core
327 |
328 |
329 | # Chutzpah Test files
330 |
331 | # Visual C++ cache files
332 |
333 | # Visual Studio profiler
334 |
335 | # TFS 2012 Local Workspace
336 |
337 | # Guidance Automation Toolkit
338 |
339 | # ReSharper is a .NET coding add-in
340 |
341 | # JustCode is a .NET coding add-in
342 |
343 | # TeamCity is a build add-in
344 |
345 | # DotCover is a Code Coverage Tool
346 |
347 | # Visual Studio code coverage results
348 |
349 | # NCrunch
350 |
351 | # MightyMoose
352 |
353 | # Web workbench (sass)
354 |
355 | # Installshield output folder
356 |
357 | # DocProject is a documentation generator add-in
358 |
359 | # Click-Once directory
360 |
361 | # Publish Web Output
362 | # TODO: Uncomment the next line to ignore your web deploy settings.
363 | # By default, sensitive information, such as encrypted password
364 | # should be stored in the .pubxml.user file.
365 | #*.pubxml
366 |
367 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
368 | # checkin your Azure Web App publish settings, but sensitive information contained
369 | # in these scripts will be unencrypted
370 |
371 | # NuGet Packages
372 | # The packages folder can be ignored because of Package Restore
373 | # except build/, which is used as an MSBuild target.
374 | # Uncomment if necessary however generally it will be regenerated when needed
375 | #!**/packages/repositories.config
376 | # NuGet v3's project.json files produces more ignorable files
377 |
378 | # Microsoft Azure Build Output
379 |
380 | # Microsoft Azure Emulator
381 |
382 | # Windows Store app package directories and files
383 |
384 | # Visual Studio cache files
385 | # files ending in .cache can be ignored
386 | # but keep track of directories ending in .cache
387 |
388 | # Others
389 |
390 | # Since there are multiple workflows, uncomment next line to ignore bower_components
391 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
392 | #bower_components/
393 |
394 | # RIA/Silverlight projects
395 |
396 | # Backup & report files from converting an old project file
397 | # to a newer Visual Studio version. Backup files are not needed,
398 | # because we have git ;-)
399 |
400 | # SQL Server files
401 |
402 | # Business Intelligence projects
403 |
404 | # Microsoft Fakes
405 |
406 | # GhostDoc plugin setting file
407 |
408 | # Node.js Tools for Visual Studio
409 |
410 | # Typescript v1 declaration files
411 |
412 | # Visual Studio 6 build log
413 |
414 | # Visual Studio 6 workspace options file
415 |
416 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
417 |
418 | # Visual Studio LightSwitch build output
419 |
420 | # Paket dependency manager
421 |
422 | # FAKE - F# Make
423 |
424 | # JetBrains Rider
425 |
426 | # CodeRush
427 |
428 | # Python Tools for Visual Studio (PTVS)
429 |
430 | # Cake - Uncomment if you are using it
431 | # tools/**
432 | # !tools/packages.config
433 |
434 | # Telerik's JustMock configuration file
435 |
436 | # BizTalk build output
437 |
438 | ### VisualStudio Patch ###
439 | # By default, sensitive information, such as encrypted password
440 | # should be stored in the .pubxml.user file.
441 |
442 |
443 | # End of https://www.gitignore.io/api/csharp,visualstudio,visualstudiocode
--------------------------------------------------------------------------------
/ConsoleMenu.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.31919.166
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A114A1AF-445A-4014-B664-52FA8DFC5B9D}"
7 | ProjectSection(SolutionItems) = preProject
8 | .editorconfig = .editorconfig
9 | .gitignore = .gitignore
10 | preview.gif = preview.gif
11 | README.md = README.md
12 | EndProjectSection
13 | EndProject
14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleMenu", "ConsoleMenu\ConsoleMenu.csproj", "{A1653921-DC17-48FD-9C74-F62A0B23E742}"
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleMenuSampleApp", "ConsoleMenuSampleApp\ConsoleMenuSampleApp.csproj", "{6F5E57C6-45FE-4946-95FF-5B3259E08EB7}"
17 | EndProject
18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleMenuTests", "ConsoleMenuTests\ConsoleMenuTests.csproj", "{E8D9B8AB-FA77-4456-B1ED-B036231DBA22}"
19 | EndProject
20 | Global
21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
22 | Debug|Any CPU = Debug|Any CPU
23 | Release|Any CPU = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {A1653921-DC17-48FD-9C74-F62A0B23E742}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {A1653921-DC17-48FD-9C74-F62A0B23E742}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {A1653921-DC17-48FD-9C74-F62A0B23E742}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {A1653921-DC17-48FD-9C74-F62A0B23E742}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {6F5E57C6-45FE-4946-95FF-5B3259E08EB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {6F5E57C6-45FE-4946-95FF-5B3259E08EB7}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {6F5E57C6-45FE-4946-95FF-5B3259E08EB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {6F5E57C6-45FE-4946-95FF-5B3259E08EB7}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {E8D9B8AB-FA77-4456-B1ED-B036231DBA22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {E8D9B8AB-FA77-4456-B1ED-B036231DBA22}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {E8D9B8AB-FA77-4456-B1ED-B036231DBA22}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {E8D9B8AB-FA77-4456-B1ED-B036231DBA22}.Release|Any CPU.Build.0 = Release|Any CPU
38 | EndGlobalSection
39 | GlobalSection(SolutionProperties) = preSolution
40 | HideSolutionNode = FALSE
41 | EndGlobalSection
42 | GlobalSection(ExtensibilityGlobals) = postSolution
43 | SolutionGuid = {CA1BB767-870E-4B68-91ED-81C05D0D0F75}
44 | EndGlobalSection
45 | EndGlobal
46 |
--------------------------------------------------------------------------------
/ConsoleMenu/CloseTrigger.cs:
--------------------------------------------------------------------------------
1 | namespace ConsoleTools;
2 |
3 | internal sealed class CloseTrigger
4 | {
5 | private bool close;
6 |
7 | public void SetOn() => this.close = true;
8 |
9 | public void SetOff() => this.close = false;
10 |
11 | public bool IsOn() => this.close;
12 | }
13 |
--------------------------------------------------------------------------------
/ConsoleMenu/ConsoleMenu.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Runtime.CompilerServices;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | [assembly: InternalsVisibleTo("ConsoleMenuTests")]
9 |
10 | namespace ConsoleTools;
11 |
12 | ///
13 | /// A simple, highly customizable, DOS-like console menu.
14 | ///
15 | public class ConsoleMenu : IEnumerable
16 | {
17 | internal IConsole Console = new SystemConsole();
18 | private readonly ItemsCollection menuItems;
19 | private readonly CloseTrigger closeTrigger;
20 | private MenuConfig config = new MenuConfig();
21 | private ConsoleMenu? parent = null;
22 | private bool isShown = false;
23 |
24 | ///
25 | /// Initializes a new instance of the class.
26 | ///
27 | public ConsoleMenu()
28 | {
29 | this.menuItems = new ItemsCollection();
30 | this.closeTrigger = new CloseTrigger();
31 | }
32 |
33 | ///
34 | /// Initializes a new instance of the class
35 | /// with possibility to pre-select items via console parameter.
36 | ///
37 | /// args collection from Main.
38 | /// Level of whole menu.
39 | public ConsoleMenu(string[] args, int level)
40 | {
41 | if (args == null)
42 | {
43 | throw new ArgumentNullException(nameof(args));
44 | }
45 |
46 | if (level < 0)
47 | {
48 | throw new ArgumentException("Cannot be below 0", nameof(level));
49 | }
50 |
51 | this.menuItems = new ItemsCollection(args, level);
52 | this.closeTrigger = new CloseTrigger();
53 | }
54 |
55 | ///
56 | /// Gets menu items that can be modified.
57 | ///
58 | public IReadOnlyList