Browse Source

Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop

Tig 5 months ago
parent
commit
639307248a
100 changed files with 1391 additions and 715 deletions
  1. 4 7
      .editorconfig
  2. 9 10
      .github/workflows/api-docs.yml
  3. 18 5
      .github/workflows/build-release.yml
  4. 10 14
      .github/workflows/publish.yml
  5. 4 30
      CONTRIBUTING.md
  6. 43 50
      Directory.Packages.props
  7. 1 1
      Examples/CommunityToolkitExample/CommunityToolkitExample.csproj
  8. 0 0
      Examples/CommunityToolkitExample/LoginActions.cs
  9. 3 1
      Examples/CommunityToolkitExample/LoginView.Designer.cs
  10. 9 8
      Examples/CommunityToolkitExample/LoginView.cs
  11. 5 4
      Examples/CommunityToolkitExample/LoginViewModel.cs
  12. 0 0
      Examples/CommunityToolkitExample/Message.cs
  13. 6 2
      Examples/CommunityToolkitExample/Program.cs
  14. 2 2
      Examples/CommunityToolkitExample/README.md
  15. 0 0
      Examples/DemoFiles/example_config.json
  16. 13 8
      Examples/Example/Example.cs
  17. 14 14
      Examples/Example/Example.csproj
  18. 0 0
      Examples/Example/README.md
  19. 0 0
      Examples/FSharpExample/.editorconfig
  20. 0 0
      Examples/FSharpExample/FSharpExample.fsproj
  21. 0 0
      Examples/FSharpExample/FSharpExample.sln
  22. 48 48
      Examples/FSharpExample/Program.fs
  23. 1 1
      Examples/NativeAot/NativeAot.csproj
  24. 7 3
      Examples/NativeAot/Program.cs
  25. 0 0
      Examples/NativeAot/Properties/PublishProfiles/FolderProfile_net8.0_win-x64_Debug.pubxml
  26. 0 0
      Examples/NativeAot/Properties/PublishProfiles/FolderProfile_net8.0_win-x64_Release.pubxml
  27. 0 0
      Examples/NativeAot/Properties/launchSettings.json
  28. 0 0
      Examples/NativeAot/Publish_linux-x64_Debug.sh
  29. 0 0
      Examples/NativeAot/Publish_linux-x64_Release.sh
  30. 0 0
      Examples/NativeAot/Publish_osx-x64_Debug.sh
  31. 0 0
      Examples/NativeAot/Publish_osx-x64_Release.sh
  32. 0 0
      Examples/NativeAot/README.md
  33. 6 3
      Examples/ReactiveExample/LoginView.cs
  34. 4 6
      Examples/ReactiveExample/LoginViewModel.cs
  35. 5 1
      Examples/ReactiveExample/Program.cs
  36. 0 0
      Examples/ReactiveExample/README.md
  37. 1 1
      Examples/ReactiveExample/ReactiveExample.csproj
  38. 1 1
      Examples/ReactiveExample/TerminalScheduler.cs
  39. 2 1
      Examples/ReactiveExample/ViewExtensions.cs
  40. 7 3
      Examples/SelfContained/Program.cs
  41. 0 0
      Examples/SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_linux-x64_Debug.pubxml
  42. 0 0
      Examples/SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_linux-x64_Release.pubxml
  43. 0 0
      Examples/SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_osx-x64_Debug.pubxml
  44. 0 0
      Examples/SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_osx-x64_Release.pubxml
  45. 0 0
      Examples/SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_win-x64_Debug.pubxml
  46. 0 0
      Examples/SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_win-x64_Release.pubxml
  47. 0 0
      Examples/SelfContained/README.md
  48. 1 1
      Examples/SelfContained/SelfContained.csproj
  49. 0 0
      Examples/UICatalog/.gitignore
  50. 0 0
      Examples/UICatalog/BenchmarkResults.cs
  51. 0 0
      Examples/UICatalog/Dockerfile
  52. 0 0
      Examples/UICatalog/NumberToWords.cs
  53. 29 4
      Examples/UICatalog/Properties/launchSettings.json
  54. 0 1
      Examples/UICatalog/README.md
  55. 21 32
      Examples/UICatalog/Resources/config.json
  56. 2 5
      Examples/UICatalog/Scenario.cs
  57. 0 0
      Examples/UICatalog/ScenarioCategory.cs
  58. 0 0
      Examples/UICatalog/ScenarioMetadata.cs
  59. 14 13
      Examples/UICatalog/Scenarios/Adornments.cs
  60. 36 73
      Examples/UICatalog/Scenarios/AllViewsTester.cs
  61. 0 2
      Examples/UICatalog/Scenarios/AnimationScenario/AnimationScenario.cs
  62. 0 0
      Examples/UICatalog/Scenarios/AnimationScenario/Spinning_globe_dark_small.gif
  63. 0 0
      Examples/UICatalog/Scenarios/AnimationScenario/spinning-globe-attribution.txt
  64. 9 10
      Examples/UICatalog/Scenarios/AnsiRequestsScenario.cs
  65. 45 62
      Examples/UICatalog/Scenarios/Arrangement.cs
  66. 19 20
      Examples/UICatalog/Scenarios/Bars.cs
  67. 29 28
      Examples/UICatalog/Scenarios/Buttons.cs
  68. 23 17
      Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs
  69. 1 2
      Examples/UICatalog/Scenarios/ChineseUI.cs
  70. 0 1
      Examples/UICatalog/Scenarios/ClassExplorer.cs
  71. 2 3
      Examples/UICatalog/Scenarios/Clipping.cs
  72. 2 3
      Examples/UICatalog/Scenarios/CollectionNavigatorTester.cs
  73. 20 19
      Examples/UICatalog/Scenarios/ColorPicker.cs
  74. 0 1
      Examples/UICatalog/Scenarios/CombiningMarks.cs
  75. 1 2
      Examples/UICatalog/Scenarios/ComboBoxIteration.cs
  76. 17 18
      Examples/UICatalog/Scenarios/ComputedLayout.cs
  77. 78 85
      Examples/UICatalog/Scenarios/ConfigurationEditor.cs
  78. 270 0
      Examples/UICatalog/Scenarios/ContextMenus.cs
  79. 0 1
      Examples/UICatalog/Scenarios/CsvEditor.cs
  80. 1 2
      Examples/UICatalog/Scenarios/DatePickers.cs
  81. 6 7
      Examples/UICatalog/Scenarios/Dialogs.cs
  82. 5 6
      Examples/UICatalog/Scenarios/DimAutoDemo.cs
  83. 18 18
      Examples/UICatalog/Scenarios/DynamicMenuBar.cs
  84. 4 5
      Examples/UICatalog/Scenarios/DynamicStatusBar.cs
  85. 31 10
      Examples/UICatalog/Scenarios/Editor.cs
  86. 9 9
      Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentEditor.cs
  87. 2 1
      Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentsEditor.cs
  88. 194 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/AllViewsView.cs
  89. 2 3
      Examples/UICatalog/Scenarios/EditorsAndHelpers/ArrangementEditor.cs
  90. 5 6
      Examples/UICatalog/Scenarios/EditorsAndHelpers/BorderEditor.cs
  91. 4 5
      Examples/UICatalog/Scenarios/EditorsAndHelpers/DimEditor.cs
  92. 7 6
      Examples/UICatalog/Scenarios/EditorsAndHelpers/EditorBase.cs
  93. 0 1
      Examples/UICatalog/Scenarios/EditorsAndHelpers/EventLog.cs
  94. 3 4
      Examples/UICatalog/Scenarios/EditorsAndHelpers/ExpanderButton.cs
  95. 0 1
      Examples/UICatalog/Scenarios/EditorsAndHelpers/LayoutEditor.cs
  96. 89 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/MarginEditor.cs
  97. 0 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/PaddingEditor.cs
  98. 3 4
      Examples/UICatalog/Scenarios/EditorsAndHelpers/PosEditor.cs
  99. 46 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/SchemeViewer.cs
  100. 120 0
      Examples/UICatalog/Scenarios/EditorsAndHelpers/ThemeViewer.cs

+ 4 - 7
.editorconfig

@@ -34,6 +34,8 @@ csharp_space_between_method_call_empty_parameter_list_parentheses = false
 csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
 csharp_space_between_parentheses = false
 csharp_space_between_square_brackets = false
+csharp_style_var_elsewhere = false:suggestion
+csharp_style_var_when_type_is_apparent = false:suggestion
 dotnet_diagnostic.bc40000.severity = warning
 dotnet_diagnostic.bc400005.severity = warning
 dotnet_diagnostic.bc40008.severity = warning
@@ -545,7 +547,7 @@ resharper_formatter_tags_enabled = false
 resharper_format_leading_spaces_decl = false
 resharper_for_built_in_types = use_var_when_evident
 resharper_for_other_types = use_explicit_type
-resharper_for_simple_types = use_var_when_evident
+resharper_for_simple_types = use_explicit_type
 resharper_ignore_space_preservation = false
 resharper_include_prefix_comment_in_indent = false
 resharper_indent_anonymous_method_block = true
@@ -864,7 +866,7 @@ resharper_arrange_default_value_when_type_evident_highlighting = suggestion
 resharper_arrange_default_value_when_type_not_evident_highlighting = suggestion
 resharper_arrange_local_function_body_highlighting = warning
 resharper_arrange_method_or_operator_body_highlighting = hint
-resharper_arrange_null_checking_pattern_highlighting = error
+resharper_arrange_null_checking_pattern_highlighting = hint
 resharper_arrange_object_creation_when_type_evident_highlighting = suggestion
 resharper_arrange_object_creation_when_type_not_evident_highlighting = warning
 resharper_arrange_redundant_parentheses_highlighting = warning
@@ -1879,8 +1881,3 @@ tab_width = 4
 indent_style = space
 indent_size = 2
 tab_width = 2
-
-[*.{appxmanifest,axaml,axml,build,config,cs,csproj,dbml,discomap,dtd,jsproj,lsproj,njsproj,nuspec,paml,proj,props,resw,resx,StyleCop,targets,tasks,vb,vbproj,xaml,xamlx,xml,xoml,xsd}]
-indent_style = space
-indent_size = 4
-tab_width = 4

+ 9 - 10
.github/workflows/api-docs.yml

@@ -17,7 +17,6 @@ jobs:
     runs-on: windows-latest
     steps:
     - name: Checkout
-      #if: github.ref_name == 'v1_release' ||  github.ref_name == 'v1_develop'
       uses: actions/checkout@v4
 
     - name: DocFX Build
@@ -41,17 +40,17 @@ jobs:
         path: docfx/_site
        
     - name: Deploy to GitHub Pages
-      if: github.ref_name == 'v1_release' ||  github.ref_name == 'v1_develop'
+      if: github.ref_name == 'v2_release' ||  github.ref_name == 'v2_develop'
       id: deployment
       uses: actions/deploy-pages@v4
       with:
         token: ${{ secrets.GITHUB_TOKEN }}
 
-    - name: v2_develop Repository Dispatch ${{ github.ref_name }}
-      if: github.ref_name == 'v2_develop'
-      uses: peter-evans/repository-dispatch@v3
-      with:
-        token: ${{ secrets.V2DOCS_TOKEN }}
-        repository: gui-cs/Terminal.GuiV2Docs
-        event-type: v2_develop_push
-        client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
+    # - name: v1_release Repository Dispatch ${{ github.ref_name }}
+    #   if: github.ref_name == 'v2_develop'
+    #   uses: peter-evans/repository-dispatch@v3
+    #   with:
+    #     token: ${{ secrets.V2DOCS_TOKEN }}
+    #     repository: gui-cs/Terminal.GuiV1Docs
+    #     event-type: v2_develop_push
+    #     client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

+ 18 - 5
.github/workflows/build-release.yml

@@ -1,4 +1,4 @@
-name: Ensure that Release builds are not broken
+name: Ensure that Release Build of Solution Builds Correctly
 
 on:
   push:
@@ -15,7 +15,7 @@ jobs:
     # Ensure that RELEASE builds are not broken
     runs-on: ubuntu-latest
     steps:
-    - name: Checkout code
+    - name: Checkout ${{ github.ref_name }}
       uses: actions/checkout@v4
 
     - name: Setup .NET Core
@@ -25,10 +25,23 @@ jobs:
         dotnet-quality: 'ga'
 
     - name: Build Release Terminal.Gui
-      run: dotnet build Terminal.Gui/Terminal.Gui.csproj --configuration Release
+      run: dotnet build Terminal.Gui/Terminal.Gui.csproj --no-incremental --nologo --force --configuration Release
 
     - name: Pack Release Terminal.Gui
       run: dotnet pack Terminal.Gui/Terminal.Gui.csproj --configuration Release --output ./local_packages
 
-    - name: Build Release Solution
-      run: dotnet build --configuration Release
+    - name: Restore AOT and Self-Contained projects
+      run: |
+        dotnet restore ./Examples/NativeAot/NativeAot.csproj -f
+        dotnet restore ./Examples/SelfContained/SelfContained.csproj -f
+
+    - name: Restore Solution Packages
+      run: dotnet restore
+
+    - name: Build Release AOT and Self-Contained
+      run: |
+        dotnet build ./Examples/NativeAot/NativeAot.csproj --configuration Release
+        dotnet build ./Examples/SelfContained/SelfContained.csproj --configuration Release
+
+    - name: Build Release Solution without restore
+      run: dotnet build --configuration Release --no-restore

+ 10 - 14
.github/workflows/publish.yml

@@ -1,8 +1,8 @@
-name: Publish Terminal.Gui
+name: Publish Terminal.Gui to Nuget
 
 on:
   push:
-    branches: [ v1_release, v1_develop, v2_release, v2_develop ]
+    branches: [ v2_release, v2_develop ]
     tags:
       - v*
     paths-ignore:
@@ -14,9 +14,10 @@ jobs:
     runs-on: ubuntu-latest
 
     steps:
-    - uses: actions/checkout@v4
+    - name: Checkout ${{ github.ref_name }}
+      uses: actions/checkout@v4
       with:
-        fetch-depth: 0 # fetch-depth is needed for GitVersion
+        fetch-depth: 0 # fetch-depth is needed for GitVersion https://github.com/GitTools/actions/blob/main/docs/cloning.md
 
     - name: Install GitVersion
       uses: gittools/actions/gitversion/[email protected]
@@ -33,18 +34,13 @@ jobs:
     - name: Setup dotnet
       uses: actions/setup-dotnet@v4
       with:
-        dotnet-version: 8.0
+        dotnet-version: 8.x
         dotnet-quality: 'ga'
-        
-    - name: Install dependencies
-      run: dotnet restore
 
-    - name: Build Release
-      run: |
-        dotnet build Terminal.Gui/Terminal.Gui.csproj --no-incremental --nologo --force --configuration Release
-        dotnet test Terminal.Gui/Terminal.Gui.csproj --configuration Release
+    - name: Build Release Terminal.Gui
+      run: dotnet build Terminal.Gui/Terminal.Gui.csproj --no-incremental --nologo --force --configuration Release
 
-    - name: Pack
+    - name: Pack Release Terminal.Gui ${{ steps.gitversion.outputs.SemVer }} for Nuget
       run: dotnet pack Terminal.Gui/Terminal.Gui.csproj -c Release --include-symbols -p:Version='${{ steps.gitversion.outputs.SemVer }}' 
 
     # - name: Test to generate Code Coverage Report
@@ -69,5 +65,5 @@ jobs:
     #     echo "Code coverage percentage: ${{steps.create_coverage_badge.outputs.percentage}}%"
     #     echo "Badge data: ${{steps.create_coverage_badge.outputs.badge}}"
         
-    - name: Publish to NuGet.org
+    - name: Publish Terminal.Gui.${{ steps.gitversion.outputs.SemVer }} to NuGet.org
       run: dotnet nuget push Terminal.Gui/bin/Release/Terminal.Gui.${{ steps.gitversion.outputs.SemVer }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} 

+ 4 - 30
CONTRIBUTING.md

@@ -10,8 +10,8 @@ We welcome contributions from the community. See [Issues](https://github.com/gui
 
 Terminal.Gui uses the [GitFlow](https://nvie.com/posts/a-successful-git-branching-model/) branching model. 
 
-* The `v1_release_` and `v2_release` branches are always stable, and always matches the most recently released Nuget package.
-* The `v1__develop` and `v2_develop` branches are where new development and bug-fixes happen. `v2_develop` is the default Github branch.
+* The `v1_release` and `v2_release` branches are always stable, and always match the most recently released Nuget package.
+* The `v1_develop` and `v2_develop` branches are where new development and bug-fixes happen. `v2_develop` is the default Github branch.
 
 ### Forking Terminal.Gui
 
@@ -141,34 +141,8 @@ Great care has been provided thus far in ensuring **Terminal.Gui** has great [AP
 
 ### Defining Events
 
-The [Microsoft .NET Framework Design Guidelines](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/) provides these guidelines for defining events:
-
-> Events always refer to some action, either one that is happening or one that has occurred. Therefore, as with methods, events are named with verbs, and verb tense is used to indicate the time when the event is raised.
->
-> ✔️ DO name events with a verb or a verb phrase.
-> 
-> Examples include Clicked, Painting, DroppedDown, and so on.
-> 
-> ✔️ DO give events names with a concept of before and after, using the present and past tenses.
-> 
-> For example, a close event that is raised before a window is closed would be called Closing, and one that is raised after the window is closed would be called Closed.
-> 
-> ❌ DO NOT use "Before" or "After" prefixes or postfixes to indicate pre- and post-events. Use present and past tenses as just described.
-> 
-> ✔️ DO name event handlers (delegates used as types of events) with the "EventHandler" suffix, as shown in the following example:
-> 
-> ✔️ DO name event argument classes with the "EventArgs" suffix.
-
-1. We follow the naming guidelines provided in https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-type-members?redirectedfrom=MSDN
-2. We use the `event EventHandler<T>` idiom.
-3. For public APIs, the class that can raise the event will implement:
-   - A `virtual` event raising function, named as `OnEventToRaise`. Typical implementations will simply do a `EventToRaise?.Invoke(this, eventArgs)`.
-   - An `event` as in `public event EventHandler<EventArgs> EventToRaise`
-   - Consumers of the event can do `theobject.EventToRaise += (sender, args) => {};`
-   - Sub-classes of the class implementing `EventToRaise` can override `OnEventToRaise` as needed.
-4. Where possible, a subclass of `EventArgs` should be provided and the old and new state should be included. By doing this, event handler methods do not have to query the sender for state.
-
-See also: https://www.codeproject.com../docs/20550/C-Event-Implementation-Fundamentals-Best-Practices
+See https://gui-cs.github.io/Terminal.Gui/docs/events.html
+
 
 ### Defining new `View` classes
 

+ 43 - 50
Directory.Packages.props

@@ -1,52 +1,45 @@
 <Project>
-	<PropertyGroup>
-		<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
-	</PropertyGroup>
-	<ItemGroup>
-		<!-- Enable Nuget Source Link for github -->
-		<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="[8,9)" />
-
-		<PackageVersion Include="ColorHelper" Version="[1.8.1,2)" />
-		<PackageVersion Include="JetBrains.Annotations" Version="[2024.3.0,)" />
-		<PackageVersion Include="Microsoft.CodeAnalysis" Version="[4.13,5)" />
-		<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="[4.13,5)" />
-		<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="[4.13,5)" />
-		<PackageVersion Include="Microsoft.Extensions.Logging" Version="[9.0.2,10)" />
-		<PackageVersion Include="System.IO.Abstractions" Version="[22.0.11,23)" />
-		<PackageVersion Include="System.Text.Json" Version="[8.0.5,9)" />
-		<PackageVersion Include="Wcwidth" Version="[2,3)" />
-
-		<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="[1.21.2,2)" />
-		<PackageVersion Include="Serilog" Version="4.2.0" />
-		<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.0" />
-		<PackageVersion Include="Serilog.Sinks.Debug" Version="3.0.0" />
-		<PackageVersion Include="Serilog.Sinks.File" Version="6.0.0" />
-		<PackageVersion Include="SixLabors.ImageSharp" Version="[3.1.7,4)" />
-		<PackageVersion Include="CsvHelper" Version="[33.0.1,34)" />
-		<PackageVersion Include="Microsoft.DotNet.PlatformAbstractions" Version="[3.1.6,4)" />
-		<PackageVersion Include="System.CommandLine" Version="[2.0.0-beta4.22272.1,3)" />
-
-		<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
-
-		<PackageVersion Include="CommunityToolkit.Mvvm" Version="[8.4.0,9)" />
-		<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="[9.0.2,10)" />	
-		<PackageVersion Include="ReactiveUI" Version="[20.1.63,21)" />
-		<PackageVersion Include="ReactiveMarbles.ObservableEvents.SourceGenerator" Version="[1.3.1,2)" />
-		<PackageVersion Include="ReactiveUI.SourceGenerators" Version="[2.1.8,3)"/>	
-
-		<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.13,18)" />
-		<PackageVersion Include="Moq" Version="[4.20.72,5)" />
-		<PackageVersion Include="ReportGenerator" Version="[5.4.4,6)" />
-		<PackageVersion Include="TestableIO.System.IO.Abstractions.TestingHelpers" Version="[22.0.11,23)" />
-		<PackageVersion Include="xunit" Version="[2.9.3,3)" />
-		<PackageVersion Include="Xunit.Combinatorial" Version="[1.6.24,2)" />
-		<PackageVersion Include="xunit.runner.visualstudio" Version="[2.8.2,3)"/> 
-		<PackageVersion Include="coverlet.collector" Version="[6.0.4,7)" />
-		
-	</ItemGroup>
-
-	<ItemGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
-        <PackageVersion Include="Terminal.Gui" Version="2.0.0" />
-	</ItemGroup>
-
+  <PropertyGroup>
+    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
+  </PropertyGroup>
+  <ItemGroup>
+    <!-- Enable Nuget Source Link for github -->
+    <PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
+    <PackageVersion Include="Microsoft.SourceLink.GitHub" Version="[8,9)" />
+    <PackageVersion Include="ColorHelper" Version="[1.8.1,2)" />
+    <PackageVersion Include="JetBrains.Annotations" Version="[2024.3.0,)" />
+    <PackageVersion Include="Microsoft.CodeAnalysis" Version="[4.11,4.12)" />
+    <PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="[4.11,4.12)" />
+    <PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
+    <PackageVersion Include="Microsoft.Extensions.Logging" Version="[9.0.2,10)" />
+    <PackageVersion Include="System.IO.Abstractions" Version="[22.0.11,23)" />
+    <PackageVersion Include="System.Text.Json" Version="[8.0.5,9)" />
+    <PackageVersion Include="Wcwidth" Version="[2,3)" />
+    <PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="[1.21.2,2)" />
+    <PackageVersion Include="Serilog" Version="4.2.0" />
+    <PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.0" />
+    <PackageVersion Include="Serilog.Sinks.Debug" Version="3.0.0" />
+    <PackageVersion Include="Serilog.Sinks.File" Version="6.0.0" />
+    <PackageVersion Include="SixLabors.ImageSharp" Version="[3.1.7,4)" />
+    <PackageVersion Include="CsvHelper" Version="[33.0.1,34)" />
+    <PackageVersion Include="Microsoft.DotNet.PlatformAbstractions" Version="[3.1.6,4)" />
+    <PackageVersion Include="System.CommandLine" Version="[2.0.0-beta4.22272.1,3)" />
+    <PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
+    <PackageVersion Include="CommunityToolkit.Mvvm" Version="[8.4.0,9)" />
+    <PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="[9.0.2,10)" />
+    <PackageVersion Include="ReactiveUI" Version="[20.1.63,21)" />
+    <PackageVersion Include="ReactiveMarbles.ObservableEvents.SourceGenerator" Version="[1.3.1,2)" />
+    <PackageVersion Include="ReactiveUI.SourceGenerators" Version="[2.1.8,3)" />
+    <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.13,18)" />
+    <PackageVersion Include="Moq" Version="[4.20.72,5)" />
+    <PackageVersion Include="ReportGenerator" Version="5.4.5" />
+    <PackageVersion Include="TestableIO.System.IO.Abstractions.TestingHelpers" Version="22.0.14" />
+    <PackageVersion Include="xunit" Version="[2.9.3,3)" />
+    <PackageVersion Include="Xunit.Combinatorial" Version="[1.6.24,2)" />
+    <PackageVersion Include="xunit.runner.visualstudio" Version="[2.8.2,3)" />
+    <PackageVersion Include="coverlet.collector" Version="[6.0.4,7)" />
+  </ItemGroup>
+  <ItemGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+    <PackageVersion Include="Terminal.Gui" Version="2.0.0" />
+  </ItemGroup>
 </Project>

+ 1 - 1
CommunityToolkitExample/CommunityToolkitExample.csproj → Examples/CommunityToolkitExample/CommunityToolkitExample.csproj

@@ -8,7 +8,7 @@
   <ItemGroup>
     <PackageReference Include="CommunityToolkit.Mvvm" />
     <PackageReference Include="Microsoft.Extensions.DependencyInjection" />
-    <ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" />
+    <ProjectReference Include="..\..\Terminal.Gui\Terminal.Gui.csproj" />
   </ItemGroup>
 
 </Project>

+ 0 - 0
CommunityToolkitExample/LoginActions.cs → Examples/CommunityToolkitExample/LoginActions.cs


+ 3 - 1
CommunityToolkitExample/LoginView.Designer.cs → Examples/CommunityToolkitExample/LoginView.Designer.cs

@@ -1,4 +1,6 @@
-using Terminal.Gui;
+
+using Terminal.Gui.ViewBase;
+using Terminal.Gui.Views;
 
 namespace CommunityToolkitExample;
 

+ 9 - 8
CommunityToolkitExample/LoginView.cs → Examples/CommunityToolkitExample/LoginView.cs

@@ -1,5 +1,6 @@
 using CommunityToolkit.Mvvm.Messaging;
-using Terminal.Gui;
+using Terminal.Gui.App;
+using Terminal.Gui.ViewBase;
 
 namespace CommunityToolkitExample;
 
@@ -23,15 +24,15 @@ internal partial class LoginView : IRecipient<Message<LoginActions>>
                               {
                                   if (!ViewModel.CanLogin) { return; }
                                   ViewModel.LoginCommand.Execute (null);
-                                  // Anytime Accepting is handled, make sure to set e.Cancel to false.
-                                  e.Cancel = false;
+                                  // When Accepting is handled, set e.Handled to true to prevent further processing.
+                                  e.Handled = true;
                               };
 
         clearButton.Accepting += (_, e) =>
                               {
                                   ViewModel.ClearCommand.Execute (null);
-                                  // Anytime Accepting is handled, make sure to set e.Cancel to false.
-                                  e.Cancel = false;
+                                  // When Accepting is handled, set e.Handled to true to prevent further processing.
+                                  e.Handled = true;
                               };
 
         Initialized += (_, _) => { ViewModel.Initialized (); };
@@ -47,7 +48,7 @@ internal partial class LoginView : IRecipient<Message<LoginActions>>
                 {
                     loginProgressLabel.Text = ViewModel.LoginProgressMessage;
                     validationLabel.Text = ViewModel.ValidationMessage;
-                    validationLabel.ColorScheme = ViewModel.ValidationColorScheme;
+                    validationLabel.SetScheme (ViewModel.ValidationScheme);
                     break;
                 }
             case LoginActions.LoginProgress:
@@ -58,11 +59,11 @@ internal partial class LoginView : IRecipient<Message<LoginActions>>
             case LoginActions.Validation:
                 {
                     validationLabel.Text = ViewModel.ValidationMessage;
-                    validationLabel.ColorScheme = ViewModel.ValidationColorScheme;
+                    validationLabel.SetScheme (ViewModel.ValidationScheme);
                     break;
                 }
         }
-        SetText();
+        SetText ();
         // BUGBUG: This should not be needed:
         Application.LayoutAndDraw ();
     }

+ 5 - 4
CommunityToolkitExample/LoginViewModel.cs → Examples/CommunityToolkitExample/LoginViewModel.cs

@@ -1,7 +1,8 @@
 using CommunityToolkit.Mvvm.ComponentModel;
 using CommunityToolkit.Mvvm.Input;
 using CommunityToolkit.Mvvm.Messaging;
-using Terminal.Gui;
+using Terminal.Gui.Configuration;
+using Terminal.Gui.Drawing;
 
 namespace CommunityToolkitExample;
 
@@ -29,7 +30,7 @@ internal partial class LoginViewModel : ObservableObject
     private string _usernameLengthMessage;
     
     [ObservableProperty]
-    private ColorScheme? _validationColorScheme;
+    private Scheme? _validationScheme;
 
     [ObservableProperty]
     private string _validationMessage;
@@ -107,14 +108,14 @@ internal partial class LoginViewModel : ObservableObject
              case LoginActions.Clear:
                 LoginProgressMessage = message;
                 ValidationMessage = INVALID_LOGIN_MESSAGE;
-                ValidationColorScheme = Colors.ColorSchemes ["Error"];
+                ValidationScheme = SchemeManager.GetScheme ("Error");
                 break;
             case LoginActions.LoginProgress:
                 LoginProgressMessage = message;
                 break;
             case LoginActions.Validation:
                 ValidationMessage = CanLogin ? VALID_LOGIN_MESSAGE : INVALID_LOGIN_MESSAGE;
-                ValidationColorScheme = CanLogin ? Colors.ColorSchemes ["Base"] : Colors.ColorSchemes ["Error"];
+                ValidationScheme = CanLogin ? SchemeManager.GetScheme ("Base") : SchemeManager.GetScheme("Error");
                 break;
         }
         WeakReferenceMessenger.Default.Send (new Message<LoginActions> { Value = loginAction });

+ 0 - 0
CommunityToolkitExample/Message.cs → Examples/CommunityToolkitExample/Message.cs


+ 6 - 2
CommunityToolkitExample/Program.cs → Examples/CommunityToolkitExample/Program.cs

@@ -1,5 +1,8 @@
 using Microsoft.Extensions.DependencyInjection;
-using Terminal.Gui;
+using Terminal.Gui.Configuration;
+using Terminal.Gui.App;
+using Terminal.Gui.ViewBase;
+
 
 namespace CommunityToolkitExample;
 
@@ -9,10 +12,11 @@ public static class Program
 
     private static void Main (string [] args)
     {
+        ConfigurationManager.Enable (ConfigLocations.All);
         Services = ConfigureServices ();
         Application.Init ();
         Application.Run (Services.GetRequiredService<LoginView> ());
-        Application.Top?.Dispose();
+        Application.Top?.Dispose ();
         Application.Shutdown ();
     }
 

+ 2 - 2
CommunityToolkitExample/README.md → Examples/CommunityToolkitExample/README.md

@@ -115,7 +115,7 @@ private void SendMessage (LoginAction loginAction, string message = "")
             break;
         case LoginAction.Validation:
             ValidationMessage = CanLogin ? VALID_LOGIN_MESSAGE : INVALID_LOGIN_MESSAGE;
-            ValidationColorScheme = CanLogin ? Colors.ColorSchemes ["Base"] : Colors.ColorSchemes ["Error"];
+            ValidationScheme = CanLogin ? Colors.Schemes ["Base"] : Colors.Schemes ["Error"];
             break;
     }
     WeakReferenceMessenger.Default.Send (new Message<LoginAction> { Value = loginAction });
@@ -144,7 +144,7 @@ public void Receive (Message<LoginAction> message)
         case LoginAction.Validation:
             {
                 validationLabel.Text = ViewModel.ValidationMessage;
-                validationLabel.ColorScheme = ViewModel.ValidationColorScheme;
+                validationLabel.Scheme = ViewModel.ValidationScheme;
                 break;
             }
     }

+ 0 - 0
DemoFiles/example_config.json → Examples/DemoFiles/example_config.json


+ 13 - 8
Example/Example.cs → Examples/Example/Example.cs

@@ -1,13 +1,18 @@
-// This is a simple example application.  For the full range of functionality
-// see the UICatalog project
+// A simple Terminal.Gui example in C# - using C# 9.0 Top-level statements
 
-// A simple Terminal.Gui example in C# - using C# 9.0 Top-level statements
+// This is a simple example application.  For the full range of functionality
+// see the UICatalog project
 
-using System;
-using Terminal.Gui;
+using Terminal.Gui.Configuration;
+using Terminal.Gui.App;
+using Terminal.Gui.Drawing;
+using Terminal.Gui.ViewBase;
+using Terminal.Gui.Views;
+using Attribute = Terminal.Gui.Drawing.Attribute;
 
 // Override the default configuration for the application to use the Light theme
 ConfigurationManager.RuntimeConfig = """{ "Theme": "Light" }""";
+ConfigurationManager.Enable(ConfigLocations.All);
 
 Application.Run<ExampleWindow> ().Dispose ();
 
@@ -21,7 +26,7 @@ Console.WriteLine ($@"Username: {ExampleWindow.UserName}");
 // Defines a top-level window with border and title
 public class ExampleWindow : Window
 {
-    public static string UserName;
+    public static string UserName { get; set; }
 
     public ExampleWindow ()
     {
@@ -78,8 +83,8 @@ public class ExampleWindow : Window
                                {
                                    MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
                                }
-                               // Anytime Accepting is handled, make sure to set e.Cancel to false.
-                               e.Cancel = false;
+                               // When Accepting is handled, set e.Handled to true to prevent further processing.
+                               e.Handled = true;
                            };
 
         // Add the views to the Window

+ 14 - 14
Example/Example.csproj → Examples/Example/Example.csproj

@@ -1,15 +1,15 @@
-<Project Sdk="Microsoft.NET.Sdk">
-  <PropertyGroup>
-    <OutputType>Exe</OutputType>
-    <!-- Version numbers are automatically updated by gitversion when a release is released -->
-    <!-- In the source tree the version will always be 1.0 for all projects. -->
-    <!-- Do not modify these. -->
-    <AssemblyVersion>2.0</AssemblyVersion>
-    <FileVersion>2.0</FileVersion>
-    <Version>2.0</Version>
-    <InformationalVersion>2.0</InformationalVersion>
-  </PropertyGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" />
-  </ItemGroup>
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <!-- Version numbers are automatically updated by gitversion when a release is released -->
+    <!-- In the source tree the version will always be 1.0 for all projects. -->
+    <!-- Do not modify these. -->
+    <AssemblyVersion>2.0</AssemblyVersion>
+    <FileVersion>2.0</FileVersion>
+    <Version>2.0</Version>
+    <InformationalVersion>2.0</InformationalVersion>
+  </PropertyGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Terminal.Gui\Terminal.Gui.csproj" />
+  </ItemGroup>
 </Project>

+ 0 - 0
Example/README.md → Examples/Example/README.md


+ 0 - 0
FSharpExample/.editorconfig → Examples/FSharpExample/.editorconfig


+ 0 - 0
FSharpExample/FSharpExample.fsproj → Examples/FSharpExample/FSharpExample.fsproj


+ 0 - 0
FSharpExample/FSharpExample.sln → Examples/FSharpExample/FSharpExample.sln


+ 48 - 48
FSharpExample/Program.fs → Examples/FSharpExample/Program.fs

@@ -1,48 +1,48 @@
-open Terminal.Gui
-
-type ExampleWindow() as this =
-    inherit Window()
-    
-    do
-        this.Title <- sprintf "Example App (%O to quit)" Application.QuitKey
-
-        // Create input components and labels
-        let usernameLabel = new Label(Text = "Username:")
-
-        let userNameText = new TextField(X = Pos.Right(usernameLabel) + Pos.op_Implicit(1), Width = Dim.Fill())
-
-        let passwordLabel = new Label(Text = "Password:", X = Pos.Left(usernameLabel), Y = Pos.Bottom(usernameLabel) +  Pos.op_Implicit(1))
-
-        let passwordText = new TextField(Secret = true, X = Pos.Left(userNameText), Y = Pos.Top(passwordLabel), Width = Dim.Fill())
-
-        // Create login button
-        let btnLogin = new Button(Text = "Login", Y = Pos.Bottom(passwordLabel) +  Pos.op_Implicit(1), X = Pos.Center(), IsDefault = true)
-
-        // When login button is clicked display a message popup
-        btnLogin.Accepting.Add(fun _ ->
-            if userNameText.Text = "admin" && passwordText.Text = "password" then
-                MessageBox.Query("Logging In", "Login Successful", "Ok") |> ignore
-                ExampleWindow.UserName <- userNameText.Text.ToString()
-                Application.RequestStop()
-            else
-                MessageBox.ErrorQuery("Logging In", "Incorrect username or password", "Ok") |> ignore
-        )
-
-        // Add the views to the Window
-        this.Add(usernameLabel, userNameText, passwordLabel, passwordText, btnLogin)
-
-    static member val UserName = "" with get, set
-
-[<EntryPoint>]
-let main argv =
-    Application.Init()
-    Application.Run<ExampleWindow>().Dispose()
-    
-    // Before the application exits, reset Terminal.Gui for clean shutdown
-    Application.Shutdown()
-    
-    // To see this output on the screen it must be done after shutdown,
-    // which restores the previous screen.
-    printfn "Username: %s" ExampleWindow.UserName
-    
-    0 // return an integer exit code
+open Terminal.Gui
+
+type ExampleWindow() as this =
+    inherit Window()
+    
+    do
+        this.Title <- sprintf "Example App (%O to quit)" Application.QuitKey
+
+        // Create input components and labels
+        let usernameLabel = new Label(Text = "Username:")
+
+        let userNameText = new TextField(X = Pos.Right(usernameLabel) + Pos.op_Implicit(1), Width = Dim.Fill())
+
+        let passwordLabel = new Label(Text = "Password:", X = Pos.Left(usernameLabel), Y = Pos.Bottom(usernameLabel) +  Pos.op_Implicit(1))
+
+        let passwordText = new TextField(Secret = true, X = Pos.Left(userNameText), Y = Pos.Top(passwordLabel), Width = Dim.Fill())
+
+        // Create login button
+        let btnLogin = new Button(Text = "Login", Y = Pos.Bottom(passwordLabel) +  Pos.op_Implicit(1), X = Pos.Center(), IsDefault = true)
+
+        // When login button is clicked display a message popup
+        btnLogin.Accepting.Add(fun _ ->
+            if userNameText.Text = "admin" && passwordText.Text = "password" then
+                MessageBox.Query("Logging In", "Login Successful", "Ok") |> ignore
+                ExampleWindow.UserName <- userNameText.Text.ToString()
+                Application.RequestStop()
+            else
+                MessageBox.ErrorQuery("Logging In", "Incorrect username or password", "Ok") |> ignore
+        )
+
+        // Add the views to the Window
+        this.Add(usernameLabel, userNameText, passwordLabel, passwordText, btnLogin)
+
+    static member val UserName = "" with get, set
+
+[<EntryPoint>]
+let main argv =
+    Application.Init()
+    Application.Run<ExampleWindow>().Dispose()
+    
+    // Before the application exits, reset Terminal.Gui for clean shutdown
+    Application.Shutdown()
+    
+    // To see this output on the screen it must be done after shutdown,
+    // which restores the previous screen.
+    printfn "Username: %s" ExampleWindow.UserName
+    
+    0 // return an integer exit code

+ 1 - 1
NativeAot/NativeAot.csproj → Examples/NativeAot/NativeAot.csproj

@@ -8,7 +8,7 @@
   </PropertyGroup>
 
   <ItemGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
-    <ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" />
+    <ProjectReference Include="..\..\Terminal.Gui\Terminal.Gui.csproj" />
     <TrimmerRootAssembly Include="Terminal.Gui" />
   </ItemGroup>
 

+ 7 - 3
NativeAot/Program.cs → Examples/NativeAot/Program.cs

@@ -3,7 +3,10 @@
 using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
-using Terminal.Gui;
+using Terminal.Gui.Configuration;
+using Terminal.Gui.Views;
+using Terminal.Gui.App;
+using Terminal.Gui.ViewBase;
 
 namespace NativeAot;
 
@@ -13,6 +16,7 @@ public static class Program
     [RequiresDynamicCode ("Calls Terminal.Gui.Application.Init(IConsoleDriver, String)")]
     private static void Main (string [] args)
     {
+        ConfigurationManager.Enable(ConfigLocations.All);
         Application.Init ();
 
         #region The code in this region is not intended for use in a native Aot self-contained. It's just here to make sure there is no functionality break with localization in Terminal.Gui using self-contained
@@ -105,8 +109,8 @@ public class ExampleWindow : Window
             {
                 MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
             }
-            // Anytime Accepting is handled, make sure to set e.Cancel to false.
-            e.Cancel = false;
+            // Anytime Accepting is handled, make sure to set e.Handled to true.
+            e.Handled = true;
         };
 
         // Add the views to the Window

+ 0 - 0
NativeAot/Properties/PublishProfiles/FolderProfile_net8.0_win-x64_Debug.pubxml → Examples/NativeAot/Properties/PublishProfiles/FolderProfile_net8.0_win-x64_Debug.pubxml


+ 0 - 0
NativeAot/Properties/PublishProfiles/FolderProfile_net8.0_win-x64_Release.pubxml → Examples/NativeAot/Properties/PublishProfiles/FolderProfile_net8.0_win-x64_Release.pubxml


+ 0 - 0
NativeAot/Properties/launchSettings.json → Examples/NativeAot/Properties/launchSettings.json


+ 0 - 0
NativeAot/Publish_linux-x64_Debug.sh → Examples/NativeAot/Publish_linux-x64_Debug.sh


+ 0 - 0
NativeAot/Publish_linux-x64_Release.sh → Examples/NativeAot/Publish_linux-x64_Release.sh


+ 0 - 0
NativeAot/Publish_osx-x64_Debug.sh → Examples/NativeAot/Publish_osx-x64_Debug.sh


+ 0 - 0
NativeAot/Publish_osx-x64_Release.sh → Examples/NativeAot/Publish_osx-x64_Release.sh


+ 0 - 0
NativeAot/README.md → Examples/NativeAot/README.md


+ 6 - 3
ReactiveExample/LoginView.cs → Examples/ReactiveExample/LoginView.cs

@@ -2,7 +2,10 @@ using System.Reactive.Disposables;
 using System.Reactive.Linq;
 using ReactiveMarbles.ObservableEvents;
 using ReactiveUI;
-using Terminal.Gui;
+using Terminal.Gui.Configuration;
+using Terminal.Gui.Views;
+using Terminal.Gui.App;
+using Terminal.Gui.ViewBase;
 
 namespace ReactiveExample;
 
@@ -96,8 +99,8 @@ public class LoginView : Window, IViewFor<LoginViewModel>
 
                 ViewModel
                     .WhenAnyValue (x => x.IsValid)
-                    .Select (valid => valid ? Colors.ColorSchemes ["Base"] : Colors.ColorSchemes ["Error"])
-                    .BindTo (validation, x => x.ColorScheme)
+                    .Select (valid => valid ? SchemeManager.GetScheme ("Base") : SchemeManager.GetScheme ("Error"))
+                    .Subscribe (scheme => validation.SetScheme (scheme))
                     .DisposeWith (_disposable);
             })
             .AddControlAfter<Button> ((previous, login) =>

+ 4 - 6
ReactiveExample/LoginViewModel.cs → Examples/ReactiveExample/LoginViewModel.cs

@@ -1,11 +1,9 @@
-using System;
-using System.ComponentModel;
 using System.Reactive;
 using System.Reactive.Linq;
 using System.Runtime.Serialization;
-using System.Threading.Tasks;
 using ReactiveUI;
 using ReactiveUI.SourceGenerators;
+using Terminal.Gui.Input;
 
 namespace ReactiveExample;
 
@@ -50,7 +48,7 @@ public partial class LoginViewModel : ReactiveObject
 
         _isValidHelper = canLogin.ToProperty (this, x => x.IsValid);
 
-        Login = ReactiveCommand.CreateFromTask<HandledEventArgs>
+        Login = ReactiveCommand.CreateFromTask<CommandEventArgs>
             (
                 e => Task.Delay (TimeSpan.FromSeconds (1)),
                 canLogin
@@ -76,8 +74,8 @@ public partial class LoginViewModel : ReactiveObject
     }
 
     [ReactiveCommand]
-    public void Clear (HandledEventArgs args) { }
+    public void Clear (CommandEventArgs args) { }
 
     [IgnoreDataMember]
-    public ReactiveCommand<HandledEventArgs, Unit> Login { get; }
+    public ReactiveCommand<CommandEventArgs, Unit> Login { get; }
 }

+ 5 - 1
ReactiveExample/Program.cs → Examples/ReactiveExample/Program.cs

@@ -1,6 +1,9 @@
 using System.Reactive.Concurrency;
 using ReactiveUI;
-using Terminal.Gui;
+using ReactiveUI.SourceGenerators;
+using Terminal.Gui.Configuration;
+using Terminal.Gui.App;
+using Terminal.Gui.ViewBase;
 
 namespace ReactiveExample;
 
@@ -8,6 +11,7 @@ public static class Program
 {
     private static void Main (string [] args)
     {
+        ConfigurationManager.Enable (ConfigLocations.All);
         Application.Init ();
         RxApp.MainThreadScheduler = TerminalScheduler.Default;
         RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;

+ 0 - 0
ReactiveExample/README.md → Examples/ReactiveExample/README.md


+ 1 - 1
ReactiveExample/ReactiveExample.csproj → Examples/ReactiveExample/ReactiveExample.csproj

@@ -15,6 +15,6 @@
     <PackageReference Include="ReactiveUI.SourceGenerators" PrivateAssets="all" />
   </ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" />
+    <ProjectReference Include="..\..\Terminal.Gui\Terminal.Gui.csproj" />
   </ItemGroup>
 </Project>

+ 1 - 1
ReactiveExample/TerminalScheduler.cs → Examples/ReactiveExample/TerminalScheduler.cs

@@ -1,7 +1,7 @@
 using System;
 using System.Reactive.Concurrency;
 using System.Reactive.Disposables;
-using Terminal.Gui;
+using Terminal.Gui.App;
 
 namespace ReactiveExample;
 

+ 2 - 1
ReactiveExample/ViewExtensions.cs → Examples/ReactiveExample/ViewExtensions.cs

@@ -1,5 +1,6 @@
 using System;
-using Terminal.Gui;
+using Terminal.Gui.ViewBase;
+using Terminal.Gui.Views;
 
 namespace ReactiveExample;
 public static class ViewExtensions

+ 7 - 3
SelfContained/Program.cs → Examples/SelfContained/Program.cs

@@ -3,7 +3,10 @@
 using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
-using Terminal.Gui;
+using Terminal.Gui.Configuration;
+using Terminal.Gui.App;
+using Terminal.Gui.ViewBase;
+using Terminal.Gui.Views;
 
 namespace SelfContained;
 
@@ -12,6 +15,7 @@ public static class Program
     [RequiresUnreferencedCode ("Calls Terminal.Gui.Application.Run<T>(Func<Exception, Boolean>, IConsoleDriver)")]
     private static void Main (string [] args)
     {
+        ConfigurationManager.Enable (ConfigLocations.All);
         Application.Init ();
 
         #region The code in this region is not intended for use in a self-contained single-file. It's just here to make sure there is no functionality break with localization in Terminal.Gui using single-file
@@ -104,8 +108,8 @@ public class ExampleWindow : Window
                                {
                                    MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
                                }
-                               // Anytime Accepting is handled, make sure to set e.Cancel to false.
-                               e.Cancel = false;
+                               // When Accepting is handled, set e.Handled to true to prevent further processing.
+                               e.Handled = true;
                            };
 
         // Add the views to the Window

+ 0 - 0
SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_linux-x64_Debug.pubxml → Examples/SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_linux-x64_Debug.pubxml


+ 0 - 0
SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_linux-x64_Release.pubxml → Examples/SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_linux-x64_Release.pubxml


+ 0 - 0
SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_osx-x64_Debug.pubxml → Examples/SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_osx-x64_Debug.pubxml


+ 0 - 0
SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_osx-x64_Release.pubxml → Examples/SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_osx-x64_Release.pubxml


+ 0 - 0
SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_win-x64_Debug.pubxml → Examples/SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_win-x64_Debug.pubxml


+ 0 - 0
SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_win-x64_Release.pubxml → Examples/SelfContained/Properties/PublishProfiles/FolderProfile_net8.0_win-x64_Release.pubxml


+ 0 - 0
SelfContained/README.md → Examples/SelfContained/README.md


+ 1 - 1
SelfContained/SelfContained.csproj → Examples/SelfContained/SelfContained.csproj

@@ -11,7 +11,7 @@
   </PropertyGroup>
 
   <ItemGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
-    <ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" />
+    <ProjectReference Include="..\..\Terminal.Gui\Terminal.Gui.csproj" />
     <TrimmerRootAssembly Include="Terminal.Gui" />
   </ItemGroup>
 

+ 0 - 0
UICatalog/.gitignore → Examples/UICatalog/.gitignore


+ 0 - 0
UICatalog/BenchmarkResults.cs → Examples/UICatalog/BenchmarkResults.cs


+ 0 - 0
UICatalog/Dockerfile → Examples/UICatalog/Dockerfile


+ 0 - 0
UICatalog/NumberToWords.cs → Examples/UICatalog/NumberToWords.cs


+ 29 - 4
UICatalog/Properties/launchSettings.json → Examples/UICatalog/Properties/launchSettings.json

@@ -1,7 +1,8 @@
 {
   "profiles": {
     "UICatalog": {
-      "commandName": "Project"
+      "commandName": "Project",
+      "commandLineArgs": "--debug-log-level Debug"
     },
     "UICatalog --driver NetDriver": {
       "commandName": "Project",
@@ -11,9 +12,13 @@
       "commandName": "Project",
       "commandLineArgs": "--driver WindowsDriver"
     },
+    "UICatalog --driver v2": {
+      "commandName": "Project",
+      "commandLineArgs": "--driver v2 -dl Trace"
+    },
     "UICatalog --driver v2win": {
       "commandName": "Project",
-      "commandLineArgs": "--driver v2win"
+      "commandLineArgs": "--driver v2win -dl Trace"
     },
     "UICatalog --driver v2net": {
       "commandName": "Project",
@@ -31,6 +36,18 @@
       "commandLineArgs": "dotnet UICatalog.dll --driver NetDriver",
       "distributionName": ""
     },
+    "WSL: UICatalog --driver v2": {
+      "commandName": "Executable",
+      "executablePath": "wsl",
+      "commandLineArgs": "dotnet UICatalog.dll --driver v2",
+      "distributionName": ""
+    },
+    "WSL: UICatalog --driver v2net": {
+      "commandName": "Executable",
+      "executablePath": "wsl",
+      "commandLineArgs": "dotnet UICatalog.dll --driver v2net",
+      "distributionName": ""
+    },
     "Benchmark All": {
       "commandName": "Project",
       "commandLineArgs": "--benchmark"
@@ -60,9 +77,17 @@
       "commandName": "Project",
       "commandLineArgs": "\"All Views Tester\" -b -t 5000"
     },
-    "Charmap": {
+    "UICatalog --disable-cm": {
+      "commandName": "Project",
+      "commandLineArgs": "--disable-cm\r\n"
+    },
+    "UICatalog --disable-cm --driver v2win": {
+      "commandName": "Project",
+      "commandLineArgs": "--disable-cm --driver v2win"
+    },
+    "Themes": {
       "commandName": "Project",
-      "commandLineArgs": "Bars -b"
+      "commandLineArgs": "Themes"
     }
   }
 }

+ 0 - 1
UICatalog/README.md → Examples/UICatalog/README.md

@@ -55,7 +55,6 @@ To add a new **Scenario** simply:
 The sample below is provided in the `.\UICatalog\Scenarios` directory as a generic sample that can be copied and re-named:
 
 ```csharp
-using Terminal.Gui;
 
 namespace UICatalog {
 	[ScenarioMetadata (Name: "Generic", Description: "Generic sample - A template for creating new Scenarios")]

+ 21 - 32
UICatalog/Resources/config.json → Examples/UICatalog/Resources/config.json

@@ -1,40 +1,15 @@
 {
-  "$schema": "https://gui-cs.github.io/Terminal.GuiV2Docs/schemas/tui-config-schema.json",
+  "$schema": "https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json",
   "FileDialog.MaxSearchResults": 10000,
   "FileDialogStyle.DefaultUseColors": false,
   "FileDialogStyle.DefaultUseUnicodeCharacters": false,
   "AppSettings": {
-    "UICatalog.StatusBar": true,
-    "ConfigurationEditor.EditorColorScheme": {
-      "Normal": {
-        "Foreground": "Red",
-        "Background": "White"
-      },
-      "Focus": {
-        "Foreground": "Green",
-        "Background": "White"
-      },
-      "HotNormal": {
-        "Foreground": "Black",
-        "Background": "White"
-      },
-      "HotFocus": {
-        "Foreground": "White",
-        "Background": "BrightRed"
-      },
-      "Disabled": {
-        "Foreground": "DarkGray",
-        "Background": "White"
-      }
-    }
+    "UICatalog.StatusBar": true
   },
   "Themes": [
     {
       "Hot Dog Stand": {
-        "Button.DefaultShadow": "Opaque",
-        "Dialog.DefaultShadow": "Transparent",
-        "Dialog.DefaultButtonAlignment": "Center",
-        "ColorSchemes": [
+        "Schemes": [
           {
             "Toplevel": {
               "Normal": {
@@ -160,10 +135,24 @@
     },
     {
       "UI Catalog Theme": {
-        "Button.DefaultShadow": "Opaque",
-        "Dialog.DefaultShadow": "Transparent",
-        "Dialog.DefaultButtonAlignment": "Center",
-        "ColorSchemes": [
+        "Window.DefaultShadow": "Transparent",
+        "CheckBox.DefaultHighlightStates": "In, Pressed, PressedOutside",
+        "MessageBox.DefaultButtonAlignment": "Start",
+        "StatusBar.DefaultSeparatorLineStyle": "Single",
+        "Dialog.DefaultMinimumWidth": 80,
+        "MessageBox.DefaultBorderStyle": "Dotted",
+        "NerdFonts.Enable": false,
+        "MessageBox.DefaultMinimumWidth": 0,
+        "Window.DefaultBorderStyle": "Double",
+        "Dialog.DefaultShadow": "Opaque",
+        "Dialog.DefaultButtonAlignment": "Start",
+        "Button.DefaultShadow": "Transparent",
+        "FrameView.DefaultBorderStyle": "Double",
+        "MessageBox.DefaultMinimumHeight": 0,
+        "Button.DefaultHighlightStates": "In, Pressed",
+        "Menuv2.DefaultBorderStyle": "Heavy",
+        "MenuBarv2.DefaultBorderStyle": "Heavy",
+        "Schemes": [
           {
             "UI Catalog Scheme": {
               "Normal": {

+ 2 - 5
UICatalog/Scenario.cs → Examples/UICatalog/Scenario.cs

@@ -4,7 +4,6 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Diagnostics;
 using System.Linq;
-using Terminal.Gui;
 
 namespace UICatalog;
 
@@ -84,8 +83,6 @@ namespace UICatalog;
 public class Scenario : IDisposable
 {
     private static int _maxScenarioNameLen = 30;
-    public string TopLevelColorScheme { get; set; } = "Base";
-
     public BenchmarkResults BenchmarkResults
     {
         get { return _benchmarkResults; }
@@ -184,7 +181,7 @@ public class Scenario : IDisposable
 
     private void OnApplicationOnInitializedChanged (object? s, EventArgs<bool> a)
     {
-        if (a.CurrentValue)
+        if (a.Value)
         {
             lock (_timeoutLock!)
             {
@@ -199,7 +196,7 @@ public class Scenario : IDisposable
                 cd.Refreshed += (sender, args) =>
                                                  {
                                                      BenchmarkResults.RefreshedCount++;
-                                                     if (args.CurrentValue)
+                                                     if (args.Value)
                                                      {
                                                          BenchmarkResults.UpdatedCount++;
                                                      }

+ 0 - 0
UICatalog/ScenarioCategory.cs → Examples/UICatalog/ScenarioCategory.cs


+ 0 - 0
UICatalog/ScenarioMetadata.cs → Examples/UICatalog/ScenarioMetadata.cs


+ 14 - 13
UICatalog/Scenarios/Adornments.cs → Examples/UICatalog/Scenarios/Adornments.cs

@@ -1,5 +1,4 @@
 using System;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -36,7 +35,7 @@ public class Adornments : Scenario
             Title = "The _Window",
             Arrangement = ViewArrangement.Overlapped | ViewArrangement.Movable,
 
-            Width = Dim.Fill (Dim.Func (() => editor.Frame.Width )),
+            Width = Dim.Fill (Dim.Func (() => editor.Frame.Width)),
             Height = Dim.Fill ()
         };
         app.Add (window);
@@ -47,13 +46,15 @@ public class Adornments : Scenario
 
         color.ColorChanged += (s, e) =>
                               {
-                                  color.SuperView.ColorScheme = new (color.SuperView.ColorScheme)
-                                  {
-                                      Normal = new (
-                                                    color.SuperView.ColorScheme.Normal.Foreground,
-                                                    e.CurrentValue
-                                                   )
-                                  };
+                                  color.SuperView!.SetScheme (
+                                                             new (color.SuperView.GetScheme ())
+                                                             {
+                                                                 Normal = new (
+                                                                               color.SuperView.GetAttributeForRole (VisualRole.Normal).Foreground,
+                                                                               e.Result,
+                                                                               color.SuperView.GetAttributeForRole (VisualRole.Normal).Style
+                                                                              )
+                                                             });
                               };
 
         var button = new Button { X = Pos.Center (), Y = Pos.Center (), Text = "Press me!" };
@@ -80,7 +81,7 @@ public class Adornments : Scenario
             Width = 40,
             Height = Dim.Percent (20),
             Text = "Label\nY=AnchorEnd(),Height=Dim.Percent(10)",
-            ColorScheme = Colors.ColorSchemes ["Dialog"]
+            SchemeName = "Dialog"
         };
 
         window.Margin.Data = "Margin";
@@ -94,7 +95,7 @@ public class Adornments : Scenario
         window.Padding.Data = "Padding";
         window.Padding.Text = "Padding Text line 1\nPadding Text line 3\nPadding Text line 3\nPadding Text line 4\nPadding Text line 5";
         window.Padding.Thickness = new (3);
-        window.Padding.ColorScheme = Colors.ColorSchemes ["Error"];
+        window.Padding.SchemeName = "Error";
         window.Padding.CanFocus = true;
 
         var longLabel = new Label
@@ -129,7 +130,7 @@ public class Adornments : Scenario
                                       Y = 1,
                                       Text = "_Button in Padding Y = 1",
                                       CanFocus = true,
-                                      HighlightStyle = HighlightStyle.None,
+                                      HighlightStates = MouseState.None,
                                   };
                                   btnButtonInPadding.Accepting += (s, e) => MessageBox.Query (20, 7, "Hi", "Button in Padding Pressed!", "Ok");
                                   btnButtonInPadding.BorderStyle = LineStyle.Dashed;
@@ -143,7 +144,7 @@ public class Adornments : Scenario
                                 view.Border.CloseButton.Accept += (s, e) =>
                                                                   {
                                                                       MessageBox.Query (20, 7, "Hi", "Window Close Button Pressed!", "Ok");
-                                                                      e.Cancel = true;
+                                                                      e.Handled = true;
                                                                   };
 
                                 view.Accept += (s, e) => MessageBox.Query (20, 7, "Hi", "Window Close Button Pressed!", "Ok");

+ 36 - 73
UICatalog/Scenarios/AllViewsTester.cs → Examples/UICatalog/Scenarios/AllViewsTester.cs

@@ -3,7 +3,6 @@ using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -21,10 +20,7 @@ public class AllViewsTester : Scenario
     private ArrangementEditor? _arrangementEditor;
     private LayoutEditor? _layoutEditor;
     private ViewportSettingsEditor? _viewportSettingsEditor;
-    private FrameView? _settingsPane;
-    private RadioGroup? _orientation;
-    private string _demoText = "This, that, and the other thing.";
-    private TextView? _demoTextView;
+    private ViewPropertiesEditor? _propertiesEditor;
 
     private FrameView? _hostPane;
     private View? _curView;
@@ -38,13 +34,13 @@ public class AllViewsTester : Scenario
         var app = new Window
         {
             Title = GetQuitKeyAndName (),
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
         };
 
         // Set the BorderStyle we use for all subviews, but disable the app border thickness
         app.Border!.LineStyle = LineStyle.Heavy;
         app.Border.Thickness = new (0);
 
+
         _viewClasses = GetAllViewClassesCollection ()
                        .OrderBy (t => t.Name)
                        .Select (t => new KeyValuePair<string, Type> (t.Name, t))
@@ -83,7 +79,7 @@ public class AllViewsTester : Scenario
         _classListView.Accepting += (sender, args) =>
                                     {
                                         _curView?.SetFocus ();
-                                        args.Cancel = true;
+                                        args.Handled = true;
                                     };
 
         _adornmentsEditor = new ()
@@ -148,9 +144,9 @@ public class AllViewsTester : Scenario
         };
         _viewportSettingsEditor.Border!.Thickness = new (1, 1, 1, 1);
 
-        _settingsPane = new ()
+        _propertiesEditor = new ()
         {
-            Title = "Misc Settings [_6]",
+            Title = "View Properties [_6]",
             X = Pos.Right (_adornmentsEditor) - 1,
             Y = Pos.Bottom (_viewportSettingsEditor) - Pos.Func (() => _viewportSettingsEditor.Frame.Height == 1 ? 0 : 1),
             Width = Dim.Width (_layoutEditor),
@@ -158,49 +154,7 @@ public class AllViewsTester : Scenario
             CanFocus = true,
             SuperViewRendersLineCanvas = true
         };
-        _settingsPane.Border!.Thickness = new (1, 1, 1, 0);
-
-        Label label = new () { X = 0, Y = 0, Text = "_Orientation:" };
-
-        _orientation = new ()
-        {
-            X = Pos.Right (label) + 1,
-            Y = Pos.Top (label),
-            RadioLabels = new [] { "Horizontal", "Vertical" },
-            Orientation = Orientation.Horizontal
-        };
-
-        _orientation.SelectedItemChanged += (s, selected) =>
-                                            {
-                                                if (_curView is IOrientation orientatedView)
-                                                {
-                                                    orientatedView.Orientation = (Orientation)_orientation.SelectedItem;
-                                                }
-                                            };
-        _settingsPane.Add (label, _orientation);
-
-        label = new () { X = 0, Y = Pos.Bottom (_orientation), Text = "_Text:" };
-
-        _demoTextView = new ()
-        {
-            X = Pos.Right (label) + 1,
-            Y = Pos.Top (label),
-            Width = Dim.Fill (),
-            Height = Dim.Auto (minimumContentDim: 2),
-            Text = _demoText
-        };
-
-        _demoTextView.ContentsChanged += (s, e) =>
-                                         {
-                                             _demoText = _demoTextView.Text;
-
-                                             if (_curView is { })
-                                             {
-                                                 _curView.Text = _demoText;
-                                             }
-                                         };
-
-        _settingsPane.Add (label, _demoTextView);
+        _propertiesEditor.Border!.Thickness = new (1, 1, 1, 0);
 
         _eventLog = new ()
         {
@@ -235,22 +189,22 @@ public class AllViewsTester : Scenario
         {
             Id = "_hostPane",
             X = Pos.Right (_adornmentsEditor),
-            Y = Pos.Bottom (_settingsPane),
+            Y = Pos.Bottom (_propertiesEditor),
             Width = Dim.Width (_layoutEditor) - 2,
             Height = Dim.Fill (),
             CanFocus = true,
             TabStop = TabBehavior.TabStop,
-            ColorScheme = Colors.ColorSchemes ["Base"],
+            //SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Base),
             Arrangement = ViewArrangement.LeftResizable | ViewArrangement.BottomResizable | ViewArrangement.RightResizable,
             BorderStyle = LineStyle.Double,
             SuperViewRendersLineCanvas = true
         };
-        _hostPane.Border!.ColorScheme = app.ColorScheme;
+        _hostPane.Border!.SetScheme (app.GetScheme ());
         _hostPane.Padding!.Thickness = new (1);
         _hostPane.Padding.Diagnostics = ViewDiagnosticFlags.Ruler;
-        _hostPane.Padding.ColorScheme = app.ColorScheme;
+        _hostPane.Padding.SetScheme (app.GetScheme ());
 
-        app.Add (_classListView, _adornmentsEditor, _arrangementEditor, _layoutEditor, _viewportSettingsEditor, _settingsPane, _eventLog, _hostPane);
+        app.Add (_classListView, _adornmentsEditor, _arrangementEditor, _layoutEditor, _viewportSettingsEditor, _propertiesEditor, _eventLog, _hostPane);
 
         app.Initialized += App_Initialized;
 
@@ -276,54 +230,62 @@ public class AllViewsTester : Scenario
             // For each of the <T> arguments
             List<Type> typeArguments = new ();
 
-            // use <object>
+            // use <object> or the original type if applicable
             foreach (Type arg in type.GetGenericArguments ())
             {
-                typeArguments.Add (typeof (object));
+                if (arg.IsValueType && Nullable.GetUnderlyingType (arg) == null)
+                {
+                    typeArguments.Add (arg);
+                }
+                else
+                {
+                    typeArguments.Add (typeof (object));
+                }
             }
 
-            // And change what type we are instantiating from MyClass<T> to MyClass<object>
+            // And change what type we are instantiating from MyClass<T> to MyClass<object> or MyClass<T>
             type = type.MakeGenericType (typeArguments.ToArray ());
         }
 
+        // Ensure the type does not contain any generic parameters
+        if (type.ContainsGenericParameters)
+        {
+            Logging.Warning ($"Cannot create an instance of {type} because it contains generic parameters.");
+            //throw new ArgumentException ($"Cannot create an instance of {type} because it contains generic parameters.");
+            return;
+        }
+
         // Instantiate view
         var view = (View)Activator.CreateInstance (type)!;
         _eventLog!.ViewToLog = view;
 
         if (view is IDesignable designable)
         {
-            designable.EnableForDesign (ref _demoText);
+            string settingsEditorDemoText = _propertiesEditor!.DemoText;
+            designable.EnableForDesign (ref settingsEditorDemoText);
         }
         else
         {
-            view.Text = _demoText;
+            view.Text = _propertiesEditor!.DemoText;
             view.Title = "_Test Title";
         }
 
-        if (view is IOrientation orientatedView)
-        {
-            _orientation!.SelectedItem = (int)orientatedView.Orientation;
-            _orientation.Enabled = true;
-        }
-        else
-        {
-            _orientation!.Enabled = false;
-        }
 
         view.Initialized += CurrentView_Initialized;
         view.SubViewsLaidOut += CurrentView_LayoutComplete;
 
         view.Id = "_curView";
         _curView = view;
-        _curView = view;
 
         _hostPane!.Add (_curView);
         _layoutEditor!.ViewToEdit = _curView;
         _viewportSettingsEditor!.ViewToEdit = _curView;
         _arrangementEditor!.ViewToEdit = _curView;
+        _propertiesEditor!.ViewToEdit = _curView;
         _curView.SetNeedsLayout ();
     }
 
+
     private void DisposeCurrentView ()
     {
         if (_curView != null)
@@ -334,6 +296,7 @@ public class AllViewsTester : Scenario
             _layoutEditor!.ViewToEdit = null;
             _viewportSettingsEditor!.ViewToEdit = null;
             _arrangementEditor!.ViewToEdit = null;
+            _propertiesEditor!.ViewToEdit = null;
 
             _curView.Dispose ();
             _curView = null;
@@ -364,7 +327,7 @@ public class AllViewsTester : Scenario
             return;
         }
 
-        if (view.Width == Dim.Absolute(0) || view.Width is null)
+        if (view.Width == Dim.Absolute (0) || view.Width is null)
         {
             view.Width = Dim.Fill ();
         }

+ 0 - 2
UICatalog/Scenarios/AnimationScenario/AnimationScenario.cs → Examples/UICatalog/Scenarios/AnimationScenario/AnimationScenario.cs

@@ -8,7 +8,6 @@ using System.Threading.Tasks;
 using SixLabors.ImageSharp;
 using SixLabors.ImageSharp.PixelFormats;
 using SixLabors.ImageSharp.Processing;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -51,7 +50,6 @@ public class AnimationScenario : Scenario
         Application.Run (win);
         win.Dispose ();
         Application.Shutdown ();
-        Debug.Assert (!Application.Initialized);
     }
 
 

+ 0 - 0
UICatalog/Scenarios/AnimationScenario/Spinning_globe_dark_small.gif → Examples/UICatalog/Scenarios/AnimationScenario/Spinning_globe_dark_small.gif


+ 0 - 0
UICatalog/Scenarios/AnimationScenario/spinning-globe-attribution.txt → Examples/UICatalog/Scenarios/AnimationScenario/spinning-globe-attribution.txt


+ 9 - 10
UICatalog/Scenarios/AnsiRequestsScenario.cs → Examples/UICatalog/Scenarios/AnsiRequestsScenario.cs

@@ -2,12 +2,11 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
 [ScenarioMetadata ("AnsiEscapeSequenceRequest", "Ansi Escape Sequence Request")]
-[ScenarioCategory ("Ansi Escape Sequence")]
+[ScenarioCategory ("Tests")]
 public sealed class AnsiEscapeSequenceRequests : Scenario
 {
     private GraphView _graphView;
@@ -169,8 +168,8 @@ public sealed class AnsiEscapeSequenceRequests : Scenario
                                                                           {
                                                                               Request = ansiEscapeSequenceRequest.Request,
                                                                               Terminator = ansiEscapeSequenceRequest.Terminator,
-                                                                              ResponseReceived = (s)=>OnSuccess(s, tvResponse, tvError, tvValue, tvTerminator,lblSuccess),
-                                                                              Abandoned =()=> OnFail (tvResponse, tvError, tvValue, tvTerminator, lblSuccess)
+                                                                              ResponseReceived = (s) => OnSuccess (s, tvResponse, tvError, tvValue, tvTerminator, lblSuccess),
+                                                                              Abandoned = () => OnFail (tvResponse, tvError, tvValue, tvTerminator, lblSuccess)
                                                                           });
                                  };
 
@@ -181,15 +180,15 @@ public sealed class AnsiEscapeSequenceRequests : Scenario
         return w;
     }
 
-    private void OnSuccess (string response, TextView tvResponse, TextView tvError, TextView tvValue, TextView tvTerminator,Label lblSuccess)
+    private void OnSuccess (string response, TextView tvResponse, TextView tvError, TextView tvValue, TextView tvTerminator, Label lblSuccess)
     {
         tvResponse.Text = response;
         tvError.Text = string.Empty;
         tvValue.Text = string.Empty;
         tvTerminator.Text = string.Empty;
 
-            lblSuccess.ColorScheme = Colors.ColorSchemes ["Base"];
-            lblSuccess.Text = "Successful";
+        lblSuccess.SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Base);
+        lblSuccess.Text = "Successful";
     }
 
     private void OnFail (TextView tvResponse, TextView tvError, TextView tvValue, TextView tvTerminator, Label lblSuccess)
@@ -199,7 +198,7 @@ public sealed class AnsiEscapeSequenceRequests : Scenario
         tvValue.Text = string.Empty;
         tvTerminator.Text = string.Empty;
 
-        lblSuccess.ColorScheme = Colors.ColorSchemes ["Error"];
+        lblSuccess.SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Error);
         lblSuccess.Text = "Error";
     }
 
@@ -320,7 +319,7 @@ public sealed class AnsiEscapeSequenceRequests : Scenario
     private void UpdateResponses ()
     {
         _lblSummary.Text = GetSummary ();
-        _lblSummary.SetNeedsDraw();
+        _lblSummary.SetNeedsDraw ();
     }
 
     private string GetSummary ()
@@ -369,7 +368,7 @@ public sealed class AnsiEscapeSequenceRequests : Scenario
                                         .Select (g => new PointF (g.Key, g.Count ()))
                                         .ToList ();
         //  _graphView.ScrollOffset  = new PointF(,0);
-        _graphView.SetNeedsDraw();
+        _graphView.SetNeedsDraw ();
 
     }
 

+ 45 - 62
UICatalog/Scenarios/Arrangement.cs → Examples/UICatalog/Scenarios/Arrangement.cs

@@ -1,5 +1,4 @@
 using System.Collections.Generic;
-using Terminal.Gui;
 using Timer = System.Timers.Timer;
 
 namespace UICatalog.Scenarios;
@@ -19,7 +18,8 @@ public class Arrangement : Scenario
         Window app = new ()
         {
             Title = GetQuitKeyAndName (),
-            TabStop = TabBehavior.TabGroup
+            TabStop = TabBehavior.TabGroup,
+            ShadowStyle = ShadowStyle.None
         };
 
         var adornmentsEditor = new AdornmentsEditor
@@ -33,7 +33,7 @@ public class Arrangement : Scenario
 
         app.Add (adornmentsEditor);
 
-        adornmentsEditor.ExpanderButton.Orientation = Orientation.Horizontal;
+        adornmentsEditor!.ExpanderButton!.Orientation = Orientation.Horizontal;
 
         //  adornmentsEditor.ExpanderButton!.Collapsed = true;
 
@@ -165,8 +165,8 @@ public class Arrangement : Scenario
         };
         colorPicker.ApplyStyleChanges ();
 
-        colorPicker.SelectedColor = testFrame.ColorScheme!.Normal.Background;
-        colorPicker.ColorChanged += ColorPicker_ColorChanged;
+        colorPicker.SelectedColor = testFrame.GetAttributeForRole (VisualRole.Normal).Background;
+        colorPicker.ColorChanged += ColorPickerColorChanged;
         overlappedView2.Add (colorPicker);
         overlappedView2.Width = 50;
 
@@ -176,16 +176,22 @@ public class Arrangement : Scenario
             Y = 17,
             Id = "datePicker",
             Title = "Not _Sizeable",
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
             ShadowStyle = ShadowStyle.Transparent,
             BorderStyle = LineStyle.Double,
             TabStop = TabBehavior.TabGroup,
             Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped
         };
 
+        datePicker.SetScheme (new Scheme (
+                                          new Attribute (
+                                                         SchemeManager.GetScheme (Schemes.Toplevel).Normal.Foreground.GetBrighterColor (),
+                                                         SchemeManager.GetScheme (Schemes.Toplevel).Normal.Background.GetBrighterColor (),
+                                                         SchemeManager.GetScheme (Schemes.Toplevel).Normal.Style)));
+
         TransparentView transparentView = new ()
         {
-            Id = "transparentView",
+            Title = "Transparent",
+            ViewportSettings = Terminal.Gui.ViewBase.ViewportSettingsFlags.Transparent,
             X = 30,
             Y = 5,
             Width = 35,
@@ -198,6 +204,13 @@ public class Arrangement : Scenario
         testFrame.Add (movableSizeableWithProgress);
         testFrame.Add (transparentView);
 
+
+        testFrame.Add (new TransparentView ()
+        {
+            Title = "Transparent|TransparentMouse",
+            ViewportSettings = Terminal.Gui.ViewBase.ViewportSettingsFlags.TransparentMouse | Terminal.Gui.ViewBase.ViewportSettingsFlags.Transparent
+        });
+
         adornmentsEditor.AutoSelectSuperView = testFrame;
         arrangementEditor.AutoSelectSuperView = testFrame;
 
@@ -210,9 +223,9 @@ public class Arrangement : Scenario
 
         return;
 
-        void ColorPicker_ColorChanged (object sender, ColorEventArgs e)
+        void ColorPickerColorChanged (object sender, ResultEventArgs<Color> e)
         {
-            testFrame.ColorScheme = testFrame.ColorScheme! with { Normal = new (testFrame.ColorScheme.Normal.Foreground, e.CurrentValue) };
+            testFrame.SetScheme (testFrame.GetScheme () with { Normal = new (testFrame.GetAttributeForRole (VisualRole.Normal).Foreground, e.Result) });
         }
     }
 
@@ -225,7 +238,7 @@ public class Arrangement : Scenario
             Width = Dim.Auto (minimumContentDim: 15),
             Height = Dim.Auto (minimumContentDim: 3),
             Title = $"Overlapped{id} _{GetNextHotKey ()}",
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Toplevel),
             Id = $"Overlapped{id}",
             ShadowStyle = ShadowStyle.Transparent,
             BorderStyle = LineStyle.Double,
@@ -251,8 +264,6 @@ public class Arrangement : Scenario
             CanFocus = true,
             TabStop = TabBehavior.TabStop,
             Arrangement = ViewArrangement.Resizable
-
-            //            SuperViewRendersLineCanvas = true
         };
 
         return tiled;
@@ -312,58 +323,30 @@ public class Arrangement : Scenario
 
         return keys;
     }
-}
 
-public class TransparentView : FrameView
-{
-    public TransparentView ()
+    public class TransparentView : FrameView
     {
-        Title = "Transparent View";
-        base.Text = "View.Text.\nThis should be opaque.\nNote how clipping works?";
-        TextFormatter.Alignment = Alignment.Center;
-        TextFormatter.VerticalAlignment = Alignment.Center;
-        Arrangement = ViewArrangement.Overlapped | ViewArrangement.Resizable | ViewArrangement.Movable;
-        ViewportSettings |= Terminal.Gui.ViewportSettings.Transparent | Terminal.Gui.ViewportSettings.TransparentMouse;
-        BorderStyle = LineStyle.RoundedDotted;
-        base.ColorScheme = Colors.ColorSchemes ["Menu"];
-
-        var transparentSubView = new View ()
-        {
-            Text = "Sizable/Movable View with border. Should be opaque. The shadow should be semi-opaque.",
-            Id = "transparentSubView",
-            X = 4,
-            Y = 8,
-            Width = 20,
-            Height = 8,
-            BorderStyle = LineStyle.Dashed,
-            Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable,
-            ShadowStyle = ShadowStyle.Transparent,
-            //ViewportSettings = Terminal.Gui.ViewportSettings.Transparent
-        };
-        transparentSubView.Border.Thickness = new (1, 1, 1, 1);
-        transparentSubView.ColorScheme = Colors.ColorSchemes ["Dialog"];
-
-        Button button = new Button ()
+        public TransparentView ()
         {
-            Title = "_Opaque Shadows No Worky",
-            X = Pos.Center (),
-            Y = 4,
-            ColorScheme = Colors.ColorSchemes ["Dialog"],
-        };
-
-        button.ClearingViewport += (sender, args) =>
-                                   {
-                                       args.Cancel = true;
-                                   };
-
-
-        base.Add (button);
-        base.Add (transparentSubView);
+            Title = "Transparent";
+            Text = "TransparentView Text";
+            X = 0;
+            Y = 0;
+            Width = 30;
+            Height = 10;
+            Arrangement = ViewArrangement.Overlapped | ViewArrangement.Resizable | ViewArrangement.Movable;
+            ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.Transparent | Terminal.Gui.ViewBase.ViewportSettingsFlags.TransparentMouse;
+
+            Padding!.Thickness = new Thickness (1);
+
+            Add (
+                 new Button ()
+                 {
+                     Title = "_Hi",
+                     X = Pos.Center (),
+                     Y = Pos.Center ()
+                 });
+        }
     }
-
-    /// <inheritdoc />
-    protected override bool OnClearingViewport () { return false; }
-
-    /// <inheritdoc />
-    protected override bool OnMouseEvent (MouseEventArgs mouseEvent) { return false; }
 }
+

+ 19 - 20
UICatalog/Scenarios/Bars.cs → Examples/UICatalog/Scenarios/Bars.cs

@@ -4,7 +4,6 @@ using System.Collections.ObjectModel;
 using System.ComponentModel;
 using System.Linq;
 using System.Text;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -38,7 +37,7 @@ public class Bars : Scenario
             X = Pos.AnchorEnd (),
             Width = Dim.Auto (),
             Height = Dim.Fill (), // Make room for some wide things
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            SchemeName = "Toplevel",
             Source = new ListWrapper<string> (eventSource)
         };
         eventLog.Border.Thickness = new (0, 1, 0, 0);
@@ -81,15 +80,15 @@ public class Bars : Scenario
         };
         menuBarLikeExamples.Add (label);
 
-        bar = new MenuBarv2
-        {
-            Id = "menuBar",
-            X = Pos.Right (label),
-            Y = Pos.Top (label),
-        };
+        //bar = new MenuBarv2
+        //{
+        //    Id = "menuBar",
+        //    X = Pos.Right (label),
+        //    Y = Pos.Top (label),
+        //};
 
-        ConfigMenuBar (bar);
-        menuBarLikeExamples.Add (bar);
+        //ConfigMenuBar (bar);
+        //menuBarLikeExamples.Add (bar);
 
         FrameView menuLikeExamples = new ()
         {
@@ -416,7 +415,7 @@ public class Bars : Scenario
             Title = "_File",
             HelpText = "File Menu",
             Key = Key.D0.WithAlt,
-            HighlightStyle = HighlightStyle.Hover
+            HighlightStates = MouseState.In
         };
 
         var editMenuBarItem = new Shortcut
@@ -424,7 +423,7 @@ public class Bars : Scenario
             Title = "_Edit",
             HelpText = "Edit Menu",
             Key = Key.D1.WithAlt,
-            HighlightStyle = HighlightStyle.Hover
+            HighlightStates = MouseState.In
         };
 
         var helpMenuBarItem = new Shortcut
@@ -432,7 +431,7 @@ public class Bars : Scenario
             Title = "_Help",
             HelpText = "Halp Menu",
             Key = Key.D2.WithAlt,
-            HighlightStyle = HighlightStyle.Hover
+            HighlightStates = MouseState.In
         };
 
         bar.Add (fileMenuBarItem, editMenuBarItem, helpMenuBarItem);
@@ -446,7 +445,7 @@ public class Bars : Scenario
             Title = "Z_igzag",
             Key = Key.I.WithCtrl,
             Text = "Gonna zig zag",
-            HighlightStyle = HighlightStyle.Hover
+            HighlightStates = MouseState.In
         };
 
         var shortcut2 = new Shortcut
@@ -454,7 +453,7 @@ public class Bars : Scenario
             Title = "Za_G",
             Text = "Gonna zag",
             Key = Key.G.WithAlt,
-            HighlightStyle = HighlightStyle.Hover
+            HighlightStates = MouseState.In
         };
 
         var shortcut3 = new Shortcut
@@ -462,7 +461,7 @@ public class Bars : Scenario
             Title = "_Three",
             Text = "The 3rd item",
             Key = Key.D3.WithAlt,
-            HighlightStyle = HighlightStyle.Hover
+            HighlightStates = MouseState.In
         };
 
         var line = new Line ()
@@ -476,17 +475,17 @@ public class Bars : Scenario
             Title = "_Four",
             Text = "Below the line",
             Key = Key.D3.WithAlt,
-            HighlightStyle = HighlightStyle.Hover
+            HighlightStates = MouseState.In
         };
 
         shortcut4.CommandView = new CheckBox ()
         {
             Title = shortcut4.Title,
-            HighlightStyle = HighlightStyle.None,
+            HighlightStates = MouseState.None,
             CanFocus = false
         };
         // This ensures the checkbox state toggles when the hotkey of Title is pressed.
-        shortcut4.Accepting += (sender, args) => args.Cancel = true;
+        shortcut4.Accepting += (sender, args) => args.Handled = true;
 
         bar.Add (shortcut1, shortcut2, shortcut3, line, shortcut4);
     }
@@ -536,7 +535,7 @@ public class Bars : Scenario
                                                     {
                                                         button1.Visible = !button1.Visible;
                                                         button1.Enabled = button1.Visible;
-                                                        e.Cancel = false;
+                                                        e.Handled = true;
                                                     };
 
         bar.Add (new Label

+ 29 - 28
UICatalog/Scenarios/Buttons.cs → Examples/UICatalog/Scenarios/Buttons.cs

@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.ComponentModel;
 using System.Text;
 using JetBrains.Annotations;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -44,21 +43,21 @@ public class Buttons : Scenario
             Width = 45,
             Height = 3,
             Text = "S_wap Default (Size = 45, 3)",
-            ColorScheme = Colors.ColorSchemes ["Error"]
+            SchemeName = "Error"
         };
 
         swapButton.Accepting += (s, e) =>
                              {
-                                 e.Cancel = !swapButton.IsDefault;
+                                 e.Handled = !swapButton.IsDefault;
                                  defaultButton.IsDefault = !defaultButton.IsDefault;
                                  swapButton.IsDefault = !swapButton.IsDefault;
                              };
 
         defaultButton.Accepting += (s, e) =>
                                 {
-                                    e.Cancel = !defaultButton.IsDefault;
+                                    e.Handled = !defaultButton.IsDefault;
 
-                                    if (e.Cancel)
+                                    if (e.Handled)
                                     {
                                         MessageBox.ErrorQuery ("Error", "This button is no longer the Quit button; the Swap Default button is.", "_Ok");
                                     }
@@ -71,7 +70,7 @@ public class Buttons : Scenario
                              {
                                  string btnText = button.Text;
                                  MessageBox.Query ("Message", $"Did you click {txt}?", "Yes", "No");
-                                 e.Cancel = true;
+                                 e.Handled = true;
                              };
         }
 
@@ -80,14 +79,14 @@ public class Buttons : Scenario
 
         View prev = colorButtonsLabel;
 
-        foreach (KeyValuePair<string, ColorScheme> colorScheme in Colors.ColorSchemes)
+        foreach (KeyValuePair<string, Scheme> scheme in SchemeManager.GetSchemesForCurrentTheme ())
         {
             var colorButton = new Button
             {
                 X = Pos.Right (prev),
                 Y = Pos.Y (colorButtonsLabel),
-                Text = $"_{colorScheme.Key}",
-                ColorScheme = colorScheme.Value,
+                Text = $"_{scheme.Key}",
+                SchemeName = scheme.Key,
             };
             DoMessage (colorButton, colorButton.Text);
             main.Add (colorButton);
@@ -114,7 +113,7 @@ public class Buttons : Scenario
         button.Accepting += (s, e) =>
                          {
                              MessageBox.Query ("Message", "Question?", "Yes", "No");
-                             e.Cancel = true;
+                             e.Handled = true;
                          };
 
         var textChanger = new Button { X = 2, Y = Pos.Bottom (button) + 1, Text = "Te_xt Changer" };
@@ -122,7 +121,7 @@ public class Buttons : Scenario
         textChanger.Accepting += (s, e) =>
                               {
                                   textChanger.Text += "!";
-                                  e.Cancel = true;
+                                  e.Handled = true;
                               };
 
         main.Add (
@@ -133,12 +132,13 @@ public class Buttons : Scenario
                       Text = "Lets see if this will move as \"Text Changer\" grows"
                   }
                  );
-        button.Accepting += (sender, args) => { args.Cancel = true; };
+        button.Accepting += (sender, args) => { args.Handled = true; };
 
         var removeButton = new Button
         {
             X = 2, Y = Pos.Bottom (button) + 1,
-            ColorScheme = Colors.ColorSchemes ["Error"], Text = "Remove this button"
+            SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Error),
+            Text = "Remove this button"
         };
         main.Add (removeButton);
 
@@ -146,7 +146,7 @@ public class Buttons : Scenario
         removeButton.Accepting += (s, e) =>
                                {
                                    removeButton.Visible = false;
-                                   e.Cancel = true;
+                                   e.Handled = true;
                                };
 
         var computedFrame = new FrameView
@@ -165,14 +165,14 @@ public class Buttons : Scenario
             X = 0,
             Y = Pos.Center () - 1,
             Width = 30,
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Text = "Move This \u263b Button v_ia Pos"
         };
 
         moveBtn.Accepting += (s, e) =>
                           {
                               moveBtn.X = moveBtn.Frame.X + 5;
-                              e.Cancel = true;
+                              e.Handled = true;
                           };
         computedFrame.Add (moveBtn);
 
@@ -183,13 +183,13 @@ public class Buttons : Scenario
             X = 0,
             Width = 30,
             Text = "Grow This \u263a Button _via Pos",
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
         };
 
         sizeBtn.Accepting += (s, e) =>
                           {
                               sizeBtn.Width = sizeBtn.Frame.Width + 5;
-                              e.Cancel = true;
+                              e.Handled = true;
                           };
         computedFrame.Add (sizeBtn);
 
@@ -204,7 +204,7 @@ public class Buttons : Scenario
         main.Add (absoluteFrame);
 
         // Demonstrates how changing the View.Frame property can move Views
-        var moveBtnA = new Button { ColorScheme = Colors.ColorSchemes ["Error"], Text = "Move This Button via Frame" };
+        var moveBtnA = new Button { SchemeName = "Error", Text = "Move This Button via Frame" };
 
         moveBtnA.Accepting += (s, e) =>
                            {
@@ -214,14 +214,14 @@ public class Buttons : Scenario
                                                      moveBtnA.Frame.Width,
                                                      moveBtnA.Frame.Height
                                                     );
-                               e.Cancel = true;
+                               e.Handled = true;
                            };
         absoluteFrame.Add (moveBtnA);
 
         // Demonstrates how changing the View.Frame property can SIZE Views (#583)
         var sizeBtnA = new Button
         {
-            Y = 2, ColorScheme = Colors.ColorSchemes ["Error"], Text = " ~  s  gui.cs   master ↑_10 = Сохранить"
+            Y = 2, SchemeName = "Error", Text = " ~  s  gui.cs   master ↑_10 = Сохранить"
         };
 
         sizeBtnA.Accepting += (s, e) =>
@@ -232,7 +232,7 @@ public class Buttons : Scenario
                                                      sizeBtnA.Frame.Width + 5,
                                                      sizeBtnA.Frame.Height
                                                     );
-                               e.Cancel = true;
+                               e.Handled = true;
                            };
         absoluteFrame.Add (sizeBtnA);
 
@@ -294,13 +294,13 @@ public class Buttons : Scenario
             X = 2,
             Y = Pos.Bottom (radioGroup) + 1,
             Width = Dim.Width (computedFrame) - 2,
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            SchemeName = "TopLevel",
             Text = mhkb
         };
         moveHotKeyBtn.Accepting += (s, e) =>
                                 {
                                     moveHotKeyBtn.Text = MoveHotkey (moveHotKeyBtn.Text);
-                                    e.Cancel = true;
+                                    e.Handled = true;
                                 };
         main.Add (moveHotKeyBtn);
 
@@ -311,13 +311,13 @@ public class Buttons : Scenario
             X = Pos.Left (absoluteFrame) + 1,
             Y = Pos.Bottom (radioGroup) + 1,
             Width = Dim.Width (absoluteFrame) - 2,
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            SchemeName = "TopLevel",
             Text = muhkb
         };
         moveUnicodeHotKeyBtn.Accepting += (s, e) =>
                                        {
                                            moveUnicodeHotKeyBtn.Text = MoveHotkey (moveUnicodeHotKeyBtn.Text);
-                                           e.Cancel = true;
+                                           e.Handled = true;
                                        };
         main.Add (moveUnicodeHotKeyBtn);
 
@@ -401,7 +401,7 @@ public class Buttons : Scenario
         noRepeatButton.Accepting += (s, e) =>
                                  {
                                      noRepeatButton.Title = $"Accept Cou_nt: {++noRepeatAcceptCount}";
-                                     e.Cancel = true;
+                                     e.Handled = true;
                                  };
         main.Add (label, noRepeatButton);
 
@@ -415,6 +415,7 @@ public class Buttons : Scenario
 
         var repeatButton = new Button
         {
+            Id = "repeatButton",
             X = Pos.Right (label) + 1,
             Y = Pos.Top (label),
             Title = $"Accept Co_unt: {acceptCount}",
@@ -423,7 +424,7 @@ public class Buttons : Scenario
         repeatButton.Accepting += (s, e) =>
                                {
                                    repeatButton.Title = $"Accept Co_unt: {++acceptCount}";
-                                   e.Cancel = true;
+                                   e.Handled = true;
                                };
 
         var enableCB = new CheckBox

+ 23 - 17
UICatalog/Scenarios/CharacterMap/CharacterMap.cs → Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs

@@ -5,7 +5,6 @@ using System.Collections.Generic;
 using System.Globalization;
 using System.Linq;
 using System.Text;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -41,7 +40,9 @@ public class CharacterMap : Scenario
             X = 0,
             Y = 1,
             Width = Dim.Fill (Dim.Func (() => _categoryList!.Frame.Width)),
-            Height = Dim.Fill ()
+            Height = Dim.Fill (),
+           // SchemeName = "Base"
+
         };
         top.Add (_charMap);
 
@@ -50,7 +51,8 @@ public class CharacterMap : Scenario
             X = Pos.Right (_charMap) + 1,
             Y = Pos.Y (_charMap),
             HotKeySpecifier = (Rune)'_',
-            Text = "_Jump To:"
+            Text = "_Jump To:",
+            //SchemeName = "Dialog"
         };
         top.Add (jumpLabel);
 
@@ -60,18 +62,19 @@ public class CharacterMap : Scenario
             Y = Pos.Y (_charMap),
             Width = 17,
             Caption = "e.g. 01BE3 or ✈",
+            //SchemeName = "Dialog"
         };
         top.Add (jumpEdit);
 
         _charMap.SelectedCodePointChanged += (sender, args) =>
                                              {
-                                                 if (Rune.IsValid (args.CurrentValue))
+                                                 if (Rune.IsValid (args.Value))
                                                  {
-                                                     jumpEdit.Text = ((Rune)args.CurrentValue).ToString ();
+                                                     jumpEdit.Text = ((Rune)args.Value).ToString ();
                                                  }
                                                  else
                                                  {
-                                                     jumpEdit.Text = $"U+{args.CurrentValue:x5}";
+                                                     jumpEdit.Text = $"U+{args.Value:x5}";
                                                  }
                                              };
 
@@ -79,10 +82,9 @@ public class CharacterMap : Scenario
         {
             X = Pos.Right (jumpEdit) + 1,
             Y = Pos.Y (_charMap),
-            ColorScheme = Colors.ColorSchemes ["error"],
+            SchemeName = "error",
             Text = "err",
             Visible = false
-
         };
         top.Add (_errorLabel);
 
@@ -92,6 +94,7 @@ public class CharacterMap : Scenario
             X = Pos.Right (_charMap), 
             Y = Pos.Bottom (jumpLabel), 
             Height = Dim.Fill (),
+            //SchemeName = "Dialog"
         };
         _categoryList.FullRowSelect = true;
         _categoryList.MultiSelect = false;
@@ -146,13 +149,13 @@ public class CharacterMap : Scenario
 
         top.Add (_categoryList);
 
-        var menu = new MenuBar
+        var menu = new MenuBarv2
         {
             Menus =
             [
                 new (
                      "_File",
-                     new MenuItem []
+                     new MenuItemv2 []
                      {
                          new (
                               "_Quit",
@@ -163,7 +166,7 @@ public class CharacterMap : Scenario
                     ),
                 new (
                      "_Options",
-                     new [] { CreateMenuShowWidth () }
+                     new MenuItemv2 [] { CreateMenuShowWidth () }
                     )
             ]
         };
@@ -256,7 +259,7 @@ public class CharacterMap : Scenario
             _charMap.SetFocus ();
 
             // Cancel the event to prevent ENTER from being handled elsewhere
-            e.Cancel = true;
+            e.Handled = true;
         }
     }
 
@@ -305,16 +308,19 @@ public class CharacterMap : Scenario
                    );
     }
 
-    private MenuItem CreateMenuShowWidth ()
+    private MenuItemv2 CreateMenuShowWidth ()
     {
-        var item = new MenuItem { Title = "_Show Glyph Width" };
-        item.CheckType |= MenuItemCheckStyle.Checked;
-        item.Checked = _charMap?.ShowGlyphWidths;
+        CheckBox cb = new ()
+        {
+            Title = "_Show Glyph Width",
+            CheckedState = _charMap!.ShowGlyphWidths ? CheckState.Checked : CheckState.None
+        };
+        var item = new MenuItemv2 { CommandView = cb };
         item.Action += () =>
                        {
                            if (_charMap is { })
                            {
-                               _charMap.ShowGlyphWidths = (bool)(item.Checked = !item.Checked)!;
+                               _charMap.ShowGlyphWidths = cb.CheckedState == CheckState.Checked;
                            }
                        };
 

+ 1 - 2
UICatalog/Scenarios/ChineseUI.cs → Examples/UICatalog/Scenarios/ChineseUI.cs

@@ -1,5 +1,4 @@
-using Terminal.Gui;
-
+
 namespace UICatalog.Scenarios;
 
 [ScenarioMetadata ("ChineseUI", "Chinese UI")]

+ 0 - 1
UICatalog/Scenarios/ClassExplorer.cs → Examples/UICatalog/Scenarios/ClassExplorer.cs

@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Reflection;
 using System.Text;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 

+ 2 - 3
UICatalog/Scenarios/Clipping.cs → Examples/UICatalog/Scenarios/Clipping.cs

@@ -1,5 +1,4 @@
-using Terminal.Gui;
-using Timer = System.Timers.Timer;
+using Timer = System.Timers.Timer;
 
 namespace UICatalog.Scenarios;
 
@@ -120,7 +119,7 @@ public class Clipping : Scenario
             Height = Dim.Auto (minimumContentDim: 4),
             Width = Dim.Auto (minimumContentDim: 14),
             Title = $"Overlapped{id} _{GetNextHotKey ()}",
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            SchemeName = SchemeManager.SchemesToSchemeName(Schemes.Toplevel),
             Id = $"Overlapped{id}",
             ShadowStyle = ShadowStyle.Transparent,
             BorderStyle = LineStyle.Double,

+ 2 - 3
UICatalog/Scenarios/CollectionNavigatorTester.cs → Examples/UICatalog/Scenarios/CollectionNavigatorTester.cs

@@ -2,7 +2,6 @@
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Linq;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -58,7 +57,7 @@ public class CollectionNavigatorTester : Scenario
         "$200.00",
         "$210.99",
         "$$",
-        "appricot",
+        "apricot",
         "arm",
         "丗丙业丞",
         "丗丙丛",
@@ -82,7 +81,7 @@ public class CollectionNavigatorTester : Scenario
     public override void Main ()
     {
         Application.Init ();
-        top = new Toplevel { ColorScheme = Colors.ColorSchemes ["Base"] };
+        top = new Toplevel { SchemeName = "Base" };
 
         var allowMarking = new MenuItem ("Allow _Marking", "", null)
         {

+ 20 - 19
UICatalog/Scenarios/ColorPicker.cs → Examples/UICatalog/Scenarios/ColorPicker.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -45,7 +44,8 @@ public class ColorPickers : Scenario
         ///////////////////////////////////////
 
         // Foreground ColorPicker.
-        foregroundColorPicker = new ColorPicker {
+        foregroundColorPicker = new ColorPicker
+        {
             Title = "_Foreground Color",
             BorderStyle = LineStyle.Single,
             Width = Dim.Percent (50)
@@ -154,7 +154,7 @@ public class ColorPickers : Scenario
                                                     backgroundColorPicker.Visible = false;
 
                                                     // Switching to 16 colors
-                                                    ForegroundColor_ColorChanged (null,null);
+                                                    ForegroundColor_ColorChanged (null, null);
                                                     BackgroundColor_ColorChanged (null, null);
                                                 }
                                                 else
@@ -182,17 +182,17 @@ public class ColorPickers : Scenario
         var cbShowTextFields = new CheckBox ()
         {
             Text = "Show _Text Fields",
-            Y = Pos.Bottom (rgColorModel)+1,
+            Y = Pos.Bottom (rgColorModel) + 1,
             Width = Dim.Auto (),
             Height = Dim.Auto (),
-            CheckedState = foregroundColorPicker.Style.ShowTextFields ? CheckState.Checked: CheckState.UnChecked,
+            CheckedState = foregroundColorPicker.Style.ShowTextFields ? CheckState.Checked : CheckState.UnChecked,
         };
 
         cbShowTextFields.CheckedStateChanging += (_, e) =>
                                                 {
-                                                    foregroundColorPicker.Style.ShowTextFields = e.NewValue == CheckState.Checked;
+                                                    foregroundColorPicker.Style.ShowTextFields = e.Result == CheckState.Checked;
                                                     foregroundColorPicker.ApplyStyleChanges ();
-                                                    backgroundColorPicker.Style.ShowTextFields = e.NewValue == CheckState.Checked;
+                                                    backgroundColorPicker.Style.ShowTextFields = e.Result == CheckState.Checked;
                                                     backgroundColorPicker.ApplyStyleChanges ();
                                                 };
         app.Add (cbShowTextFields);
@@ -209,16 +209,16 @@ public class ColorPickers : Scenario
 
         cbShowName.CheckedStateChanging += (_, e) =>
                                            {
-                                               foregroundColorPicker.Style.ShowColorName = e.NewValue == CheckState.Checked;
+                                               foregroundColorPicker.Style.ShowColorName = e.Result == CheckState.Checked;
                                                foregroundColorPicker.ApplyStyleChanges ();
-                                               backgroundColorPicker.Style.ShowColorName = e.NewValue == CheckState.Checked;
+                                               backgroundColorPicker.Style.ShowColorName = e.Result == CheckState.Checked;
                                                backgroundColorPicker.ApplyStyleChanges ();
                                            };
         app.Add (cbShowName);
 
         // Set default colors.
-        foregroundColorPicker.SelectedColor = _demoView.SuperView.ColorScheme.Normal.Foreground.GetClosestNamedColor16 ();
-        backgroundColorPicker.SelectedColor = _demoView.SuperView.ColorScheme.Normal.Background.GetClosestNamedColor16 ();
+        foregroundColorPicker.SelectedColor = _demoView.SuperView!.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ();
+        backgroundColorPicker.SelectedColor = _demoView.SuperView.GetAttributeForRole (VisualRole.Normal).Background.GetClosestNamedColor16 ();
 
         Application.Run (app);
         app.Dispose ();
@@ -226,7 +226,7 @@ public class ColorPickers : Scenario
     }
 
     /// <summary>Fired when background color is changed.</summary>
-    private void BackgroundColor_ColorChanged (object sender, EventArgs e)
+    private void BackgroundColor_ColorChanged (object sender, ResultEventArgs<Color> e)
     {
         UpdateColorLabel (_backgroundColorLabel,
                           backgroundColorPicker.Visible ?
@@ -237,7 +237,7 @@ public class ColorPickers : Scenario
     }
 
     /// <summary>Fired when foreground color is changed.</summary>
-    private void ForegroundColor_ColorChanged (object sender, EventArgs e)
+    private void ForegroundColor_ColorChanged (object sender, ResultEventArgs<Color> e)
     {
         UpdateColorLabel (_foregroundColorLabel,
                           foregroundColorPicker.Visible ?
@@ -250,7 +250,7 @@ public class ColorPickers : Scenario
     /// <summary>Update a color label from his ColorPicker.</summary>
     private void UpdateColorLabel (Label label, Color color)
     {
-        label.ClearViewport ();
+        label.ClearViewport (null);
 
         label.Text =
             $"{color} ({(int)color}) #{color.R:X2}{color.G:X2}{color.B:X2}";
@@ -259,7 +259,7 @@ public class ColorPickers : Scenario
     /// <summary>Update Demo Label.</summary>
     private void UpdateDemoLabel ()
     {
-        _demoView.ColorScheme = new ColorScheme
+        _demoView.SetScheme (new Scheme
         {
             Normal = new Attribute (
                                     foregroundColorPicker.Visible ?
@@ -269,14 +269,15 @@ public class ColorPickers : Scenario
                                         backgroundColorPicker.SelectedColor :
                                         backgroundColorPicker16.SelectedColor
                                    )
-        };
+        });
     }
 
     public override List<Key> GetDemoKeyStrokes ()
     {
-        var keys = new List<Key> ();
-
-        keys.Add (Key.B.WithAlt);
+        List<Key> keys =
+        [
+            Key.B.WithAlt
+        ];
 
         for (int i = 0; i < 200; i++)
         {

+ 0 - 1
UICatalog/Scenarios/CombiningMarks.cs → Examples/UICatalog/Scenarios/CombiningMarks.cs

@@ -1,4 +1,3 @@
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 

+ 1 - 2
UICatalog/Scenarios/ComboBoxIteration.cs → Examples/UICatalog/Scenarios/ComboBoxIteration.cs

@@ -1,6 +1,5 @@
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -26,7 +25,7 @@ public class ComboBoxIteration : Scenario
 
         var lbComboBox = new Label
         {
-            ColorScheme = Colors.ColorSchemes ["TopLevel"],
+            SchemeName = "TopLevel",
             X = Pos.Right (lbListView) + 1,
             Width = Dim.Percent (40)
         };

+ 17 - 18
UICatalog/Scenarios/ComputedLayout.cs → Examples/UICatalog/Scenarios/ComputedLayout.cs

@@ -1,7 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -30,7 +29,7 @@ public class ComputedLayout : Scenario
             Y = 0,
             Width = Dim.Fill (),
             Height = 1,
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Text = rule
         };
 
@@ -45,7 +44,7 @@ public class ComputedLayout : Scenario
             Y = 0,
             Width = 1,
             Height = Dim.Fill (),
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Text = vrule
         };
 
@@ -103,7 +102,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -115,7 +114,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -127,7 +126,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -139,7 +138,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -165,7 +164,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -177,7 +176,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -189,7 +188,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -201,7 +200,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -231,7 +230,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -243,7 +242,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -255,7 +254,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -267,7 +266,7 @@ public class ComputedLayout : Scenario
                            Width = Dim.Fill (),
                            X = 0,
                            Y = Pos.Bottom (labelList.LastOrDefault ()),
-                           ColorScheme = Colors.ColorSchemes ["Dialog"],
+                           SchemeName = "Dialog",
                            Text = $"{i++}-{txt}"
                        }
                       );
@@ -281,7 +280,7 @@ public class ComputedLayout : Scenario
             Y = Pos.Percent (50),
             Width = Dim.Percent (80),
             Height = Dim.Percent (10),
-            ColorScheme = Colors.ColorSchemes ["TopLevel"]
+            SchemeName = "TopLevel"
         };
 
         textView.Text =
@@ -384,7 +383,7 @@ public class ComputedLayout : Scenario
         {
             Text = "This Label should be the 3rd to last line (AnchorEnd (3)).",
             TextAlignment = Alignment.Center,
-            ColorScheme = Colors.ColorSchemes ["Menu"],
+            SchemeName = "Menu",
             Width = Dim.Fill (5),
             X = 5,
             Y = Pos.AnchorEnd (3)
@@ -398,7 +397,7 @@ public class ComputedLayout : Scenario
             Text =
                 "This TextField should be the 4th to last line (AnchorEnd (3) - 1).",
             TextAlignment = Alignment.Start,
-            ColorScheme = Colors.ColorSchemes ["Menu"],
+            SchemeName = "Menu",
             Width = Dim.Fill (5),
             X = 5,
             Y = Pos.AnchorEnd (3) - 1 // Pos.Combine

+ 78 - 85
UICatalog/Scenarios/ConfigurationEditor.cs → Examples/UICatalog/Scenarios/ConfigurationEditor.cs

@@ -1,75 +1,56 @@
 #nullable enable
-using System;
-using System.IO;
-using System.Linq;
 using System.Reflection;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
-[ScenarioMetadata ("Configuration Editor", "Edits Terminal.Gui Config Files.")]
+[ScenarioMetadata ("Configuration Editor", "Edits of Terminal.Gui Config Files")]
 [ScenarioCategory ("TabView")]
 [ScenarioCategory ("Colors")]
 [ScenarioCategory ("Files and IO")]
 [ScenarioCategory ("TextView")]
+[ScenarioCategory ("Configuration")]
 public class ConfigurationEditor : Scenario
 {
-    private static ColorScheme _editorColorScheme = new ()
-    {
-        Normal = new Attribute (Color.Red, Color.White),
-        Focus = new Attribute (Color.Red, Color.Black),
-        HotFocus = new Attribute (Color.BrightRed, Color.Black),
-        HotNormal = new Attribute (Color.Magenta, Color.White)
-    };
-
-    private static Action? _editorColorSchemeChanged;
     private TabView? _tabView;
     private Shortcut? _lenShortcut;
 
-    [SerializableConfigurationProperty (Scope = typeof (AppScope))]
-    public static ColorScheme EditorColorScheme
-    {
-        get => _editorColorScheme;
-        set
-        {
-            _editorColorScheme = value;
-            _editorColorSchemeChanged?.Invoke ();
-        }
-    }
-
     public override void Main ()
     {
         Application.Init ();
 
-        Toplevel top = new ();
+        Window? win = new ();
 
-        _lenShortcut = new Shortcut ()
+        _lenShortcut = new ()
         {
             Title = "",
         };
 
-        var quitShortcut = new Shortcut ()
+        Shortcut quitShortcut = new ()
         {
             Key = Application.QuitKey,
             Title = $"Quit",
             Action = Quit
         };
 
-        var reloadShortcut = new Shortcut ()
+        Shortcut reloadShortcut = new  ()
         {
             Key = Key.F5.WithShift,
             Title = "Reload",
         };
-        reloadShortcut.Accepting += (s, e) => { Reload (); };
+        reloadShortcut.Accepting += (s, e) =>
+                                    {
+                                        Reload ();
+                                        e.Handled = true;
+                                    };
 
-        var saveShortcut = new Shortcut ()
+        Shortcut saveShortcut = new  ()
         {
             Key = Key.F4,
             Title = "Save",
             Action = Save
         };
 
-        var statusBar = new StatusBar ([quitShortcut, reloadShortcut, saveShortcut, _lenShortcut]);
+        StatusBar statusBar = new ([quitShortcut, reloadShortcut, saveShortcut, _lenShortcut]);
 
         _tabView = new ()
         {
@@ -77,34 +58,25 @@ public class ConfigurationEditor : Scenario
             Height = Dim.Fill (Dim.Func (() => statusBar.Frame.Height))
         };
 
-        top.Add (_tabView, statusBar);
+        win.Add (_tabView, statusBar);
 
-        top.Loaded += (s, a) =>
+        win.Loaded += (s, a) =>
                       {
                           Open ();
-                          _editorColorSchemeChanged?.Invoke ();
                       };
 
-        void OnEditorColorSchemeChanged ()
-        {
-            if (Application.Top is { })
-            {
-                return;
-            }
+        ConfigurationManager.Applied += ConfigurationManagerOnApplied;
 
-            foreach (ConfigTextView t in _tabView.SubViews.Where (v => v is ConfigTextView).Cast<ConfigTextView> ())
-            {
-                t.ColorScheme = EditorColorScheme;
-            }
-        }
-
-        _editorColorSchemeChanged += OnEditorColorSchemeChanged;
+        Application.Run (win);
+        win.Dispose ();
+        Application.Shutdown ();
 
-        Application.Run (top);
-        _editorColorSchemeChanged -= OnEditorColorSchemeChanged;
-        top.Dispose ();
+        return;
 
-        Application.Shutdown ();
+        void ConfigurationManagerOnApplied (object? sender, ConfigurationManagerEventArgs e)
+        {
+            Application.Top?.SetNeedsDraw ();
+        }
     }
     public void Save ()
     {
@@ -116,7 +88,7 @@ public class ConfigurationEditor : Scenario
 
     private void Open ()
     {
-        foreach (var config in ConfigurationManager.Settings!.Sources)
+        foreach (KeyValuePair<ConfigLocations, string> config in ConfigurationManager.SourcesManager!.Sources)
         {
             var homeDir = $"{Environment.GetFolderPath (Environment.SpecialFolder.UserProfile)}";
             var fileInfo = new FileInfo (config.Value.Replace ("~", homeDir));
@@ -125,11 +97,17 @@ public class ConfigurationEditor : Scenario
             {
                 Title = config.Value.StartsWith ("resource://") ? fileInfo.Name : config.Value,
                 Width = Dim.Fill (),
-                Height = Dim.Fill(),
+                Height = Dim.Fill (),
                 FileInfo = fileInfo,
             };
 
-            Tab tab = new Tab ()
+            if (config.Value == "HardCoded")
+            {
+                editor.Title = "HardCoded";
+
+            }
+
+            Tab tab = new ()
             {
                 View = editor,
                 DisplayText = config.Key.ToString ()
@@ -160,7 +138,7 @@ public class ConfigurationEditor : Scenario
 
     private void Quit ()
     {
-        foreach (ConfigTextView editor in _tabView!.Tabs.Select(v =>
+        foreach (ConfigTextView editor in _tabView!.Tabs.Select (v =>
                                                                 {
                                                                     if (v.View is ConfigTextView ctv)
                                                                     {
@@ -170,32 +148,39 @@ public class ConfigurationEditor : Scenario
                                                                     return null;
                                                                 }).Cast<ConfigTextView> ())
         {
-            if (editor.IsDirty)
+            if (!editor.IsDirty)
             {
-                int result = MessageBox.Query (
-                                               "Save Changes",
-                                               $"Save changes to {editor.FileInfo!.Name}",
-                                               "_Yes",
-                                               "_No",
-                                               "_Cancel"
-                                              );
-
-                if (result == -1 || result == 2)
-                {
-                    // user cancelled
-                }
+                continue;
+            }
 
-                if (result == 0)
-                {
+            int result = MessageBox.Query (
+                                           "Save Changes",
+                                           $"Save changes to {editor.FileInfo!.Name}",
+                                           "_Yes",
+                                           "_No",
+                                           "_Cancel"
+                                          );
+
+            switch (result)
+            {
+                case 0:
                     editor.Save ();
-                }
+
+                    break;
+
+                case 1:
+                    // user decided not save changes
+                    break;
+                case -1 or 2:
+                    // user cancelled
+                    return;
             }
         }
 
         Application.RequestStop ();
     }
 
-    private void Reload ()
+    private static void Reload ()
     {
         if (Application.Navigation?.GetFocused () is ConfigTextView editor)
         {
@@ -210,7 +195,7 @@ public class ConfigurationEditor : Scenario
             TabStop = TabBehavior.TabGroup;
         }
 
-        internal FileInfo? FileInfo { get; set; }
+        internal FileInfo? FileInfo { get; init; }
 
         internal void Read ()
         {
@@ -231,27 +216,35 @@ public class ConfigurationEditor : Scenario
                 string? name = assembly
                                .GetManifestResourceNames ()
                                .FirstOrDefault (x => x.EndsWith ("config.json"));
-                if (!string.IsNullOrEmpty (name))
-                {
 
-                    using Stream? stream = assembly.GetManifestResourceStream (name);
-                    using var reader = new StreamReader (stream!);
-                    Text = reader.ReadToEnd ();
-                    ReadOnly = true;
-                    Enabled = true;
+                if (string.IsNullOrEmpty (name))
+                {
+                    return;
                 }
 
+                using Stream? stream = assembly.GetManifestResourceStream (name);
+                using var reader = new StreamReader (stream!);
+                Text = reader.ReadToEnd ();
+                ReadOnly = true;
+                Enabled = true;
+
                 return;
             }
 
-            if (FileInfo!.FullName.Contains ("RuntimeConfig"))
+            if (FileInfo!.FullName.Contains ("HardCoded"))
+            {
+                Text = ConfigurationManager.GetHardCodedConfig ()!;
+                ReadOnly = true;
+                Enabled = true;
+            }
+            else if (FileInfo!.FullName.Contains ("RuntimeConfig"))
             {
                 Text = ConfigurationManager.RuntimeConfig!;
-
-            } else if (!FileInfo.Exists)
+            }
+            else if (!FileInfo.Exists)
             {
                 // Create empty config file
-                Text = ConfigurationManager.GetEmptyJson ();
+                Text = ConfigurationManager.GetEmptyConfig ();
             }
             else
             {

+ 270 - 0
Examples/UICatalog/Scenarios/ContextMenus.cs

@@ -0,0 +1,270 @@
+using System.Globalization;
+using JetBrains.Annotations;
+
+namespace UICatalog.Scenarios;
+
+[ScenarioMetadata ("ContextMenus", "Context Menu Sample.")]
+[ScenarioCategory ("Menus")]
+public class ContextMenus : Scenario
+{
+    [CanBeNull]
+    private PopoverMenu _winContextMenu;
+    private TextField _tfTopLeft, _tfTopRight, _tfMiddle, _tfBottomLeft, _tfBottomRight;
+    private readonly List<CultureInfo> _cultureInfos = Application.SupportedCultures;
+    private readonly Key _winContextMenuKey = Key.Space.WithCtrl;
+
+    public override void Main ()
+    {
+        // Init
+        Application.Init ();
+
+        // Setup - Create a top-level application window and configure it.
+        Window appWindow = new ()
+        {
+            Title = GetQuitKeyAndName (),
+            Arrangement = ViewArrangement.Fixed,
+            SchemeName = "Toplevel"
+        };
+
+        var text = "Context Menu";
+        var width = 20;
+
+        CreateWinContextMenu ();
+
+        var label = new Label
+        {
+            X = Pos.Center (), Y = 1, Text = $"Press '{_winContextMenuKey}' to open the Window context menu."
+        };
+        appWindow.Add (label);
+
+        label = new ()
+        {
+            X = Pos.Center (),
+            Y = Pos.Bottom (label),
+            Text = $"Press '{PopoverMenu.DefaultKey}' to open the TextField context menu."
+        };
+        appWindow.Add (label);
+
+        _tfTopLeft = new () { Id = "_tfTopLeft", Width = width, Text = text };
+        appWindow.Add (_tfTopLeft);
+
+        _tfTopRight = new () { Id = "_tfTopRight", X = Pos.AnchorEnd (width), Width = width, Text = text };
+        appWindow.Add (_tfTopRight);
+
+        _tfMiddle = new () { Id = "_tfMiddle", X = Pos.Center (), Y = Pos.Center (), Width = width, Text = text };
+        appWindow.Add (_tfMiddle);
+
+        _tfBottomLeft = new () { Id = "_tfBottomLeft", Y = Pos.AnchorEnd (1), Width = width, Text = text };
+        appWindow.Add (_tfBottomLeft);
+
+        _tfBottomRight = new () { Id = "_tfBottomRight", X = Pos.AnchorEnd (width), Y = Pos.AnchorEnd (1), Width = width, Text = text };
+        appWindow.Add (_tfBottomRight);
+
+        appWindow.KeyDown += OnAppWindowOnKeyDown;
+        appWindow.MouseClick += OnAppWindowOnMouseClick;
+
+        CultureInfo originalCulture = Thread.CurrentThread.CurrentUICulture;
+        appWindow.Closed += (s, e) => { Thread.CurrentThread.CurrentUICulture = originalCulture; };
+
+        // Run - Start the application.
+        Application.Run (appWindow);
+        appWindow.Dispose ();
+        appWindow.KeyDown -= OnAppWindowOnKeyDown;
+        appWindow.MouseClick -= OnAppWindowOnMouseClick;
+        _winContextMenu?.Dispose ();
+
+        // Shutdown - Calling Application.Shutdown is required.
+        Application.Shutdown ();
+
+        return;
+
+        void OnAppWindowOnMouseClick (object s, MouseEventArgs e)
+        {
+            if (e.Flags == MouseFlags.Button3Clicked)
+            {
+                // ReSharper disable once AccessToDisposedClosure
+                _winContextMenu?.MakeVisible (e.ScreenPosition);
+                e.Handled = true;
+            }
+        }
+
+        void OnAppWindowOnKeyDown (object s, Key e)
+        {
+            if (e == _winContextMenuKey)
+            {
+                // ReSharper disable once AccessToDisposedClosure
+                _winContextMenu?.MakeVisible ();
+                e.Handled = true;
+            }
+        }
+    }
+
+    private void CreateWinContextMenu ()
+    {
+        if (_winContextMenu is { })
+        {
+            _winContextMenu.Dispose ();
+            _winContextMenu = null;
+        }
+
+        _winContextMenu = new (
+                               [
+                                   new MenuItemv2
+                                   {
+                                       Title = "C_ultures",
+                                       SubMenu = GetSupportedCultureMenu (),
+                                   },
+                                   new Line (),
+                                   new MenuItemv2
+                                   {
+                                       Title = "_Configuration...",
+                                       HelpText = "Show configuration",
+                                       Action = () => MessageBox.Query (
+                                                                        50,
+                                                                        10,
+                                                                        "Configuration",
+                                                                        "This would be a configuration dialog",
+                                                                        "Ok"
+                                                                       )
+                                   },
+                                   new MenuItemv2
+                                   {
+                                       Title = "M_ore options",
+                                       SubMenu = new (
+                                                      [
+                                                          new MenuItemv2
+                                                          {
+                                                              Title = "_Setup...",
+                                                              HelpText = "Perform setup",
+                                                              Action = () => MessageBox
+                                                                           .Query (
+                                                                                   50,
+                                                                                   10,
+                                                                                   "Setup",
+                                                                                   "This would be a setup dialog",
+                                                                                   "Ok"
+                                                                                  ),
+                                                              Key = Key.T.WithCtrl
+                                                          },
+                                                          new MenuItemv2
+                                                          {
+                                                              Title = "_Maintenance...",
+                                                              HelpText = "Maintenance mode",
+                                                              Action = () => MessageBox
+                                                                           .Query (
+                                                                                   50,
+                                                                                   10,
+                                                                                   "Maintenance",
+                                                                                   "This would be a maintenance dialog",
+                                                                                   "Ok"
+                                                                                  )
+                                                          }
+                                                      ])
+                                   },
+                                   new Line (),
+                                   new MenuItemv2
+                                   {
+                                       Title = "_Quit",
+                                       Action = () => Application.RequestStop ()
+                                   }
+                               ])
+        {
+            Key = _winContextMenuKey
+        };
+    }
+
+    private Menuv2 GetSupportedCultureMenu ()
+    {
+        List<MenuItemv2> supportedCultures = [];
+        int index = -1;
+
+        foreach (CultureInfo c in _cultureInfos)
+        {
+            MenuItemv2 culture = new ();
+
+            culture.CommandView = new CheckBox { CanFocus = false };
+
+            if (index == -1)
+            {
+                // Create English because GetSupportedCutures doesn't include it
+                culture.Id = "_English";
+                culture.Title = "_English";
+                culture.HelpText = "en-US";
+
+                ((CheckBox)culture.CommandView).CheckedState =
+                    Thread.CurrentThread.CurrentUICulture.Name == "en-US" ? CheckState.Checked : CheckState.UnChecked;
+                CreateAction (supportedCultures, culture);
+                supportedCultures.Add (culture);
+
+                index++;
+                culture = new ();
+                culture.CommandView = new CheckBox { CanFocus = false };
+            }
+
+            culture.Id = $"_{c.Parent.EnglishName}";
+            culture.Title = $"_{c.Parent.EnglishName}";
+            culture.HelpText = c.Name;
+
+            ((CheckBox)culture.CommandView).CheckedState =
+                Thread.CurrentThread.CurrentUICulture.Name == culture.HelpText ? CheckState.Checked : CheckState.UnChecked;
+            CreateAction (supportedCultures, culture);
+            supportedCultures.Add (culture);
+        }
+
+        Menuv2 menu = new (supportedCultures.ToArray ());
+
+        return menu;
+
+        void CreateAction (List<MenuItemv2> cultures, MenuItemv2 culture)
+        {
+            culture.Action += () =>
+                              {
+                                  Thread.CurrentThread.CurrentUICulture = new (culture.HelpText);
+
+                                  foreach (MenuItemv2 item in cultures)
+                                  {
+                                      ((CheckBox)item.CommandView).CheckedState =
+                                          Thread.CurrentThread.CurrentUICulture.Name == item.HelpText ? CheckState.Checked : CheckState.UnChecked;
+                                  }
+                              };
+        }
+    }
+
+    public override List<Key> GetDemoKeyStrokes ()
+    {
+        List<Key> keys = new ();
+
+        keys.Add (Key.F10.WithShift);
+        keys.Add (Key.Esc);
+
+        keys.Add (Key.Space.WithCtrl);
+        keys.Add (Key.CursorDown);
+        keys.Add (Key.Enter);
+
+        keys.Add (Key.F10.WithShift);
+        keys.Add (Key.Esc);
+
+        keys.Add (Key.Tab);
+
+        keys.Add (Key.Space.WithCtrl);
+        keys.Add (Key.CursorDown);
+        keys.Add (Key.CursorDown);
+        keys.Add (Key.Enter);
+
+        keys.Add (Key.F10.WithShift);
+        keys.Add (Key.Esc);
+
+        keys.Add (Key.Tab);
+
+        keys.Add (Key.Space.WithCtrl);
+        keys.Add (Key.CursorDown);
+        keys.Add (Key.CursorDown);
+        keys.Add (Key.CursorDown);
+        keys.Add (Key.Enter);
+
+        keys.Add (Key.F10.WithShift);
+        keys.Add (Key.Esc);
+
+        return keys;
+    }
+}

+ 0 - 1
UICatalog/Scenarios/CsvEditor.cs → Examples/UICatalog/Scenarios/CsvEditor.cs

@@ -5,7 +5,6 @@ using System.IO;
 using System.Linq;
 using System.Text.RegularExpressions;
 using CsvHelper;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 

+ 1 - 2
UICatalog/Scenarios/DatePickers.cs → Examples/UICatalog/Scenarios/DatePickers.cs

@@ -1,5 +1,4 @@
-using Terminal.Gui;
-
+
 namespace UICatalog.Scenarios;
 
 [ScenarioMetadata ("Date Picker", "Demonstrates how to use DatePicker class")]

+ 6 - 7
UICatalog/Scenarios/Dialogs.cs → Examples/UICatalog/Scenarios/Dialogs.cs

@@ -1,7 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -177,7 +176,7 @@ public class Dialogs : Scenario
 
         var buttonPressedLabel = new Label
         {
-            X = Pos.Center (), Y = Pos.Bottom (frame) + 5, ColorScheme = Colors.ColorSchemes ["Error"], Text = " "
+            X = Pos.Center (), Y = Pos.Bottom (frame) + 5, SchemeName = "Error", Text = " "
         };
 
         var showDialogButton = new Button
@@ -198,7 +197,7 @@ public class Dialogs : Scenario
                                                                      );
                                        Application.Run (dlg);
                                        dlg.Dispose ();
-                                       e.Cancel = true;
+                                       e.Handled = true;
                                    };
 
         app.Add (showDialogButton);
@@ -258,7 +257,7 @@ public class Dialogs : Scenario
                 button.Accepting += (s, e) =>
                                  {
                                      clicked = buttonId;
-                                     e.Cancel = true;
+                                     e.Handled = true;
                                      Application.RequestStop ();
                                  };
                 buttons.Add (button);
@@ -313,7 +312,7 @@ public class Dialogs : Scenario
                                                {
                                                    clicked = buttonId;
                                                    Application.RequestStop ();
-                                                   e.Cancel = true;
+                                                   e.Handled = true;
                                                };
                               buttons.Add (button);
                               dialog.AddButton (button);
@@ -322,7 +321,7 @@ public class Dialogs : Scenario
                               //{
                               //    button.TabIndex = buttons [buttons.Count - 2].TabIndex + 1;
                               //}
-                              e.Cancel = true;
+                              e.Handled = true;
                           };
             dialog.Add (add);
 
@@ -340,7 +339,7 @@ public class Dialogs : Scenario
                                       button.Text += char.ConvertFromUtf32 (CODE_POINT);
                                   }
 
-                                  e.Cancel = true;
+                                  e.Handled = true;
                               };
             dialog.Add (addChar);
 

+ 5 - 6
UICatalog/Scenarios/DimAutoDemo.cs → Examples/UICatalog/Scenarios/DimAutoDemo.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -74,7 +73,7 @@ public class DimAutoDemo : Scenario
             Y = Pos.Bottom (textEdit) + 1,
             Width = Dim.Auto (DimAutoStyle.Text, 1),
             Height = Dim.Auto (DimAutoStyle.Text, 8),
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             TextDirection = TextDirection.TopBottom_LeftRight
         };
         vlabel.Id = "vlabel";
@@ -87,7 +86,7 @@ public class DimAutoDemo : Scenario
             Y = Pos.Bottom (textEdit),
             Width = Dim.Auto (DimAutoStyle.Text, 20),
             Height = Dim.Auto (DimAutoStyle.Text, 1),
-            ColorScheme = Colors.ColorSchemes ["Error"]
+            SchemeName = "Error"
         };
         hlabel.Id = "hlabel";
         dimAutoFrameView.Add (hlabel);
@@ -98,7 +97,7 @@ public class DimAutoDemo : Scenario
             Y = Pos.Bottom (hlabel) + 1,
             Width = 20,
             Height = Dim.Auto (),
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Title = "W: 20, H: Auto",
             BorderStyle = LineStyle.Rounded
         };
@@ -111,7 +110,7 @@ public class DimAutoDemo : Scenario
             Y = Pos.Bottom (hlabel) + 1,
             Width = Dim.Auto (),
             Height = 5,
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Title = "W: Auto, H: 5",
             BorderStyle = LineStyle.Rounded
         };
@@ -124,7 +123,7 @@ public class DimAutoDemo : Scenario
             Y = Pos.Bottom (hlabel) + 1,
             Width = Dim.Auto (),
             Height = Dim.Auto (),
-            ColorScheme = Colors.ColorSchemes ["Error"],
+            SchemeName = "Error",
             Title = "W: Auto, H: Auto",
             BorderStyle = LineStyle.Rounded
         };

+ 18 - 18
UICatalog/Scenarios/DynamicMenuBar.cs → Examples/UICatalog/Scenarios/DynamicMenuBar.cs

@@ -1,10 +1,10 @@
-using System;
-using System.Collections.ObjectModel;
+using System.Collections.ObjectModel;
 using System.ComponentModel;
 using System.Reflection;
 using System.Runtime.CompilerServices;
 using System.Text;
-using Terminal.Gui;
+
+#pragma warning disable CS0618 // Type or member is obsolete
 
 namespace UICatalog.Scenarios;
 
@@ -142,9 +142,9 @@ public class DynamicMenuBar : Scenario
 
             TextHotKey.TextChanging += (s, e) =>
                                        {
-                                           if (!string.IsNullOrEmpty (e.NewValue) && char.IsLower (e.NewValue [0]))
+                                           if (!string.IsNullOrEmpty (e.Result) && char.IsLower (e.Result [0]))
                                            {
-                                               e.NewValue = e.NewValue.ToUpper ();
+                                               e.Result = e.Result.ToUpper ();
                                            }
                                        };
             TextHotKey.TextChanged += (s, _) => TextHotKey.SelectAll ();
@@ -208,20 +208,20 @@ public class DynamicMenuBar : Scenario
 
             CkbIsTopLevel.CheckedStateChanging += (s, e) =>
                                      {
-                                         if ((_menuItem != null && _menuItem.Parent != null && e.NewValue == CheckState.Checked)
-                                             || (_menuItem == null && _hasParent && e.NewValue == CheckState.Checked))
+                                         if ((_menuItem != null && _menuItem.Parent != null && e.Result == CheckState.Checked)
+                                             || (_menuItem == null && _hasParent && e.Result == CheckState.Checked))
                                          {
                                              MessageBox.ErrorQuery (
                                                                     "Invalid IsTopLevel",
                                                                     "Only menu bar can have top level menu item!",
                                                                     "Ok"
                                                                    );
-                                             e.Cancel = true;
+                                             e.Handled = true;
 
                                              return;
                                          }
 
-                                         if (e.NewValue == CheckState.Checked)
+                                         if (e.Result == CheckState.Checked)
                                          {
                                              CkbSubMenu.CheckedState = CheckState.UnChecked;
                                              CkbSubMenu.SetNeedsDraw ();
@@ -243,13 +243,13 @@ public class DynamicMenuBar : Scenario
                                              TextAction.Text = "";
 
                                              TextShortcutKey.Enabled =
-                                                 e.NewValue == CheckState.Checked && CkbSubMenu.CheckedState == CheckState.UnChecked;
+                                                 e.Result == CheckState.Checked && CkbSubMenu.CheckedState == CheckState.UnChecked;
                                          }
                                      };
 
             CkbSubMenu.CheckedStateChanged += (s, e) =>
                                   {
-                                      if (e.CurrentValue == CheckState.Checked)
+                                      if (e.Value == CheckState.Checked)
                                       {
                                           CkbIsTopLevel.CheckedState = CheckState.UnChecked;
                                           CkbIsTopLevel.SetNeedsDraw ();
@@ -275,7 +275,7 @@ public class DynamicMenuBar : Scenario
                                           if (_hasParent)
                                           {
                                               TextShortcutKey.Enabled = CkbIsTopLevel.CheckedState == CheckState.UnChecked
-                                                                     && e.CurrentValue == CheckState.UnChecked;
+                                                                     && e.Value == CheckState.UnChecked;
                                           }
                                       }
                                   };
@@ -284,7 +284,7 @@ public class DynamicMenuBar : Scenario
                                     {
                                         if (_menuItem != null)
                                         {
-                                            _menuItem.AllowNullChecked = e.CurrentValue == CheckState.Checked;
+                                            _menuItem.AllowNullChecked = e.Value == CheckState.Checked;
                                         }
                                     };
 
@@ -593,7 +593,7 @@ public class DynamicMenuBar : Scenario
 
             var lblMenuBar = new Label
             {
-                ColorScheme = Colors.ColorSchemes ["Dialog"],
+                SchemeName = "Dialog",
                 TextAlignment = Alignment.Center,
                 X = Pos.Right (btnPrevious) + 1,
                 Y = Pos.Top (btnPrevious),
@@ -631,7 +631,7 @@ public class DynamicMenuBar : Scenario
 
             _lstMenus = new ()
             {
-                ColorScheme = Colors.ColorSchemes ["Dialog"],
+                SchemeName = "Dialog",
                 X = Pos.Right (btnPrevious) + 1,
                 Y = Pos.Top (btnPrevious) + 2,
                 Width = lblMenuBar.Width,
@@ -792,13 +792,13 @@ public class DynamicMenuBar : Scenario
 
             txtDelimiter.TextChanging += (s, e) =>
                                           {
-                                              if (!string.IsNullOrEmpty (e.NewValue))
+                                              if (!string.IsNullOrEmpty (e.Result))
                                               {
-                                                  Key.Separator = e.NewValue.ToRunes () [0];
+                                                  Key.Separator = e.Result.ToRunes () [0];
                                               }
                                               else
                                               {
-                                                  e.Cancel = true;
+                                                  e.Handled = true;
                                                   txtDelimiter.SelectAll ();
                                               }
                                           };

+ 4 - 5
UICatalog/Scenarios/DynamicStatusBar.cs → Examples/UICatalog/Scenarios/DynamicStatusBar.cs

@@ -5,7 +5,6 @@ using System.Linq;
 using System.Reflection;
 using System.Runtime.CompilerServices;
 using System.Text;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -282,7 +281,7 @@ public class DynamicStatusBar : Scenario
 
             _lstItems = new ListView
             {
-                ColorScheme = Colors.ColorSchemes ["Dialog"],
+                SchemeName = "Dialog",
                 Y = Pos.Top (btnAddStatusBar) + 2,
                 Width = Dim.Fill () - Dim.Width (btnAdd) - 1,
                 Height = Dim.Fill (),
@@ -318,7 +317,7 @@ public class DynamicStatusBar : Scenario
 
                                   if (statusItem != null)
                                   {
-                                      Shortcut [] items = _statusBar.SubViews.Cast<Shortcut> ().ToArray ();
+                                      Shortcut [] items = _statusBar.SubViews.OfType<Shortcut> ().ToArray ();
 
                                       if (i > 0)
                                       {
@@ -341,7 +340,7 @@ public class DynamicStatusBar : Scenario
 
                                     if (statusItem != null)
                                     {
-                                        Shortcut [] items = _statusBar.SubViews.Cast<Shortcut> ().ToArray ();
+                                        Shortcut [] items = _statusBar.SubViews.OfType<Shortcut> ().ToArray ();
 
                                         if (i < items.Length - 1)
                                         {
@@ -521,7 +520,7 @@ public class DynamicStatusBar : Scenario
 
                 if (statusItem != null)
                 {
-                    foreach (Shortcut si in _statusBar.SubViews.Cast<Shortcut> ())
+                    foreach (Shortcut si in _statusBar.SubViews.OfType<Shortcut> ())
                     {
                         DataContext.Items.Add (new DynamicStatusItemList (si.Title, si));
                     }

+ 31 - 10
UICatalog/Scenarios/Editor.cs → Examples/UICatalog/Scenarios/Editor.cs

@@ -7,7 +7,6 @@ using System.Linq;
 using System.Text;
 using System.Text.RegularExpressions;
 using System.Threading;
-using Terminal.Gui;
 using static UICatalog.Scenarios.DynamicMenuBar;
 
 namespace UICatalog.Scenarios;
@@ -202,6 +201,8 @@ public class Editor : Scenario
                          CreateAutocomplete (),
                          CreateAllowsTabChecked (),
                          CreateReadOnlyChecked (),
+                         CreateUseSameRuneTypeForWords (),
+                         CreateSelectWordOnlyOnDoubleClick (),
                          new MenuItem (
                                        "Colors",
                                        "",
@@ -225,12 +226,12 @@ public class Editor : Scenario
                                                          "",
                                                          () =>
                                                          {
-                                                             _miForceMinimumPosToZero.Checked =
-                                                                 _forceMinimumPosToZero =
-                                                                     !_forceMinimumPosToZero;
+                                                             //_miForceMinimumPosToZero.Checked =
+                                                             //    _forceMinimumPosToZero =
+                                                             //        !_forceMinimumPosToZero;
 
-                                                             _textView.ContextMenu.ForceMinimumPosToZero =
-                                                                 _forceMinimumPosToZero;
+                                                             //_textView.ContextMenu.ForceMinimumPosToZero =
+                                                             //    _forceMinimumPosToZero;
                                                          }
                                                         )
                          {
@@ -777,6 +778,26 @@ public class Editor : Scenario
         return new [] { item };
     }
 
+    private MenuItem CreateSelectWordOnlyOnDoubleClick ()
+    {
+        var item = new MenuItem { Title = "SelectWordOnlyOnDoubleClick" };
+        item.CheckType |= MenuItemCheckStyle.Checked;
+        item.Checked = _textView.SelectWordOnlyOnDoubleClick;
+        item.Action += () => _textView.SelectWordOnlyOnDoubleClick = (bool)(item.Checked = !item.Checked);
+
+        return item;
+    }
+
+    private MenuItem CreateUseSameRuneTypeForWords ()
+    {
+        var item = new MenuItem { Title = "UseSameRuneTypeForWords" };
+        item.CheckType |= MenuItemCheckStyle.Checked;
+        item.Checked = _textView.UseSameRuneTypeForWords;
+        item.Action += () => _textView.UseSameRuneTypeForWords = (bool)(item.Checked = !item.Checked);
+
+        return item;
+    }
+
     private MenuItem CreateReadOnlyChecked ()
     {
         var item = new MenuItem { Title = "Read Only" };
@@ -902,14 +923,14 @@ public class Editor : Scenario
         {
             X = 0, Y = Pos.Top (txtToFind) + 2, CheckedState = _matchCase ? CheckState.Checked : CheckState.UnChecked, Text = "Match c_ase"
         };
-        ckbMatchCase.CheckedStateChanging += (s, e) => _matchCase = e.NewValue == CheckState.Checked;
+        ckbMatchCase.CheckedStateChanging += (s, e) => _matchCase = e.Result == CheckState.Checked;
         d.Add (ckbMatchCase);
 
         var ckbMatchWholeWord = new CheckBox
         {
             X = 0, Y = Pos.Top (ckbMatchCase) + 1, CheckedState = _matchWholeWord ? CheckState.Checked : CheckState.UnChecked, Text = "Match _whole word"
         };
-        ckbMatchWholeWord.CheckedStateChanging += (s, e) => _matchWholeWord = e.NewValue == CheckState.Checked;
+        ckbMatchWholeWord.CheckedStateChanging += (s, e) => _matchWholeWord = e.Result == CheckState.Checked;
         d.Add (ckbMatchWholeWord);
         return d;
     }
@@ -1160,14 +1181,14 @@ public class Editor : Scenario
         {
             X = 0, Y = Pos.Top (txtToFind) + 2, CheckedState = _matchCase ? CheckState.Checked : CheckState.UnChecked, Text = "Match c_ase"
         };
-        ckbMatchCase.CheckedStateChanging += (s, e) => _matchCase = e.NewValue == CheckState.Checked;
+        ckbMatchCase.CheckedStateChanging += (s, e) => _matchCase = e.Result == CheckState.Checked;
         d.Add (ckbMatchCase);
 
         var ckbMatchWholeWord = new CheckBox
         {
             X = 0, Y = Pos.Top (ckbMatchCase) + 1, CheckedState = _matchWholeWord ? CheckState.Checked : CheckState.UnChecked, Text = "Match _whole word"
         };
-        ckbMatchWholeWord.CheckedStateChanging += (s, e) => _matchWholeWord = e.NewValue == CheckState.Checked;
+        ckbMatchWholeWord.CheckedStateChanging += (s, e) => _matchWholeWord = e.Result == CheckState.Checked;
         d.Add (ckbMatchWholeWord);
 
         return d;

+ 9 - 9
UICatalog/Scenarios/Editors/AdornmentEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentEditor.cs

@@ -1,6 +1,5 @@
 #nullable enable
 using System;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -60,9 +59,9 @@ public class AdornmentEditor : EditorBase
 
                 _adornment.Initialized += (sender, args) =>
                                           {
-                                              ColorScheme? cs = _adornment.ColorScheme;
-                                              _foregroundColorPicker.SelectedColor = cs!.Normal.Foreground.GetClosestNamedColor16 ();
-                                              _backgroundColorPicker.SelectedColor = cs.Normal.Background.GetClosestNamedColor16 ();
+                                              Scheme? cs = _adornment.GetScheme ();
+                                              _foregroundColorPicker.SelectedColor = _adornment.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ();
+                                              _backgroundColorPicker.SelectedColor = _adornment.GetAttributeForRole (VisualRole.Normal).Background.GetClosestNamedColor16 ();
                                           };
             }
 
@@ -171,7 +170,7 @@ public class AdornmentEditor : EditorBase
 
         _diagThicknessCheckBox.CheckedStateChanging += (s, e) =>
                                                        {
-                                                           if (e.NewValue == CheckState.Checked)
+                                                           if (e.Result == CheckState.Checked)
                                                            {
                                                                AdornmentToEdit!.Diagnostics |= ViewDiagnosticFlags.Thickness;
                                                            }
@@ -197,7 +196,7 @@ public class AdornmentEditor : EditorBase
 
         _diagRulerCheckBox.CheckedStateChanging += (s, e) =>
                                                    {
-                                                       if (e.NewValue == CheckState.Checked)
+                                                       if (e.Result == CheckState.Checked)
                                                        {
                                                            AdornmentToEdit!.Diagnostics |= ViewDiagnosticFlags.Ruler;
                                                        }
@@ -211,7 +210,7 @@ public class AdornmentEditor : EditorBase
         _diagRulerCheckBox.Y = Pos.Bottom (_diagThicknessCheckBox);
     }
 
-    private EventHandler<ColorEventArgs> ColorPickerColorChanged ()
+    private EventHandler<ResultEventArgs<Color>> ColorPickerColorChanged ()
     {
         return (o, a) =>
                {
@@ -220,10 +219,11 @@ public class AdornmentEditor : EditorBase
                        return;
                    }
 
-                   AdornmentToEdit.ColorScheme = new (AdornmentToEdit.ColorScheme)
+                   AdornmentToEdit.SetScheme (new (AdornmentToEdit.GetScheme ())
                    {
                        Normal = new (_foregroundColorPicker.SelectedColor, _backgroundColorPicker.SelectedColor)
-                   };
+                   })
+                   ;
                };
     }
 

+ 2 - 1
UICatalog/Scenarios/Editors/AdornmentsEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentsEditor.cs

@@ -1,6 +1,5 @@
 #nullable enable
 using System;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -18,6 +17,8 @@ public class AdornmentsEditor : EditorBase
         ExpanderButton!.Orientation = Orientation.Horizontal;
 
         Initialized += AdornmentsEditor_Initialized;
+
+        SchemeName = "Dialog";
     }
 
     public MarginEditor? MarginEditor { get; set; }

+ 194 - 0
Examples/UICatalog/Scenarios/EditorsAndHelpers/AllViewsView.cs

@@ -0,0 +1,194 @@
+#nullable enable
+namespace UICatalog.Scenarios;
+
+public class AllViewsView : View
+{
+    private const int MAX_VIEW_FRAME_HEIGHT = 25;
+    public AllViewsView ()
+    {
+        CanFocus = true;
+        BorderStyle = LineStyle.Heavy;
+        Arrangement = ViewArrangement.Resizable;
+        HorizontalScrollBar.AutoShow = false;
+        VerticalScrollBar.AutoShow = true;
+
+        SubViewsLaidOut += (sender, _) =>
+                           {
+                               if (sender is View sendingView)
+                               {
+                                   sendingView.SetContentSize (new Size (sendingView.Viewport.Width, sendingView.GetHeightRequiredForSubViews ()));
+                               }
+                           };
+
+        AddCommand (Command.Up, () => ScrollVertical (-1));
+        AddCommand (Command.Down, () => ScrollVertical (1));
+        AddCommand (Command.PageUp, () => ScrollVertical (-SubViews.OfType<FrameView> ().First ().Frame.Height));
+        AddCommand (Command.PageDown, () => ScrollVertical (SubViews.OfType<FrameView> ().First ().Frame.Height));
+        AddCommand (
+                    Command.Start,
+                    () =>
+                    {
+                        Viewport = Viewport with { Y = 0 };
+
+                        return true;
+                    });
+        AddCommand (
+                    Command.End,
+                    () =>
+                    {
+                        Viewport = Viewport with { Y = GetContentSize ().Height };
+
+                        return true;
+                    });
+
+        AddCommand (Command.ScrollDown, () => ScrollVertical (1));
+        AddCommand (Command.ScrollUp, () => ScrollVertical (-1));
+        AddCommand (Command.ScrollRight, () => ScrollHorizontal (1));
+        AddCommand (Command.ScrollLeft, () => ScrollHorizontal (-1));
+
+        KeyBindings.Add (Key.CursorUp, Command.Up);
+        KeyBindings.Add (Key.CursorDown, Command.Down);
+        KeyBindings.Add (Key.CursorLeft, Command.Left);
+        KeyBindings.Add (Key.CursorRight, Command.Right);
+        KeyBindings.Add (Key.PageUp, Command.PageUp);
+        KeyBindings.Add (Key.PageDown, Command.PageDown);
+        KeyBindings.Add (Key.Home, Command.Start);
+        KeyBindings.Add (Key.End, Command.End);
+        KeyBindings.Add (PopoverMenu.DefaultKey, Command.Context);
+
+        MouseBindings.Add (MouseFlags.Button1DoubleClicked, Command.Accept);
+        MouseBindings.ReplaceCommands (MouseFlags.Button3Clicked, Command.Context);
+        MouseBindings.ReplaceCommands (MouseFlags.Button1Clicked | MouseFlags.ButtonCtrl, Command.Context);
+        MouseBindings.Add (MouseFlags.WheeledDown, Command.ScrollDown);
+        MouseBindings.Add (MouseFlags.WheeledUp, Command.ScrollUp);
+        MouseBindings.Add (MouseFlags.WheeledLeft, Command.ScrollLeft);
+        MouseBindings.Add (MouseFlags.WheeledRight, Command.ScrollRight);
+    }
+
+    /// <inheritdoc />
+    public override void EndInit ()
+    {
+        base.EndInit ();
+
+        var allClasses = GetAllViewClassesCollection ();
+
+        View? previousView = null;
+
+        foreach (Type? type in allClasses)
+        {
+            View? view = CreateView (type);
+
+            if (view is { })
+            {
+                FrameView frame = new ()
+                {
+                    CanFocus = true,
+                    Title = type.Name,
+                    Y = previousView is { } ? Pos.Bottom (previousView) : 0,
+                    Width = Dim.Fill (),
+                    Height = Dim.Auto (DimAutoStyle.Content, maximumContentDim: MAX_VIEW_FRAME_HEIGHT)
+                };
+                frame.Add (view);
+                Add (frame);
+                previousView = frame;
+            }
+        }
+    }
+
+    private static List<Type> GetAllViewClassesCollection ()
+    {
+        List<Type> types = typeof (View).Assembly.GetTypes ()
+                                        .Where (
+                                                myType => myType is { IsClass: true, IsAbstract: false, IsPublic: true }
+                                                          && myType.IsSubclassOf (typeof (View)))
+                                        .ToList ();
+
+        types.Add (typeof (View));
+
+        return types;
+    }
+
+    private View? CreateView (Type type)
+    {
+        // If we are to create a generic Type
+        if (type.IsGenericType)
+        {
+            // For each of the <T> arguments
+            List<Type> typeArguments = new ();
+
+            // use <object> or the original type if applicable
+            foreach (Type arg in type.GetGenericArguments ())
+            {
+                if (arg.IsValueType && Nullable.GetUnderlyingType (arg) == null)
+                {
+                    typeArguments.Add (arg);
+                }
+                else
+                {
+                    typeArguments.Add (typeof (object));
+                }
+            }
+
+            // And change what type we are instantiating from MyClass<T> to MyClass<object> or MyClass<T>
+            type = type.MakeGenericType (typeArguments.ToArray ());
+        }
+
+        // Ensure the type does not contain any generic parameters
+        if (type.ContainsGenericParameters)
+        {
+            Logging.Warning ($"Cannot create an instance of {type} because it contains generic parameters.");
+
+            //throw new ArgumentException ($"Cannot create an instance of {type} because it contains generic parameters.");
+            return null;
+        }
+
+        // Instantiate view
+        var view = (View)Activator.CreateInstance (type)!;
+        var demoText = "This, that, and the other thing.";
+
+        if (view is IDesignable designable)
+        {
+            designable.EnableForDesign (ref demoText);
+        }
+        else
+        {
+            view.Text = demoText;
+            view.Title = "_Test Title";
+        }
+
+        view.X = 0;
+        view.Y = 0;
+
+        view.Initialized += OnViewInitialized;
+
+        return view;
+    }
+
+    private void OnViewInitialized (object? sender, EventArgs e)
+    {
+        if (sender is not View view)
+        {
+            return;
+        }
+
+        if (view.Width == Dim.Absolute (0) || view.Width is null)
+        {
+            view.Width = Dim.Fill ();
+        }
+
+        if (view.Height == Dim.Absolute (0) || view.Height is null)
+        {
+            view.Height = MAX_VIEW_FRAME_HEIGHT - 2;
+        }
+
+        if (!view.Width!.Has<DimAuto> (out _))
+        {
+            view.Width = Dim.Fill ();
+        }
+
+        if (!view.Height.Has<DimAuto> (out _))
+        {
+            view.Height = Dim.Auto (minimumContentDim: MAX_VIEW_FRAME_HEIGHT - 2, maximumContentDim: MAX_VIEW_FRAME_HEIGHT - 2);
+        }
+    }
+}

+ 2 - 3
UICatalog/Scenarios/Editors/ArrangementEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/ArrangementEditor.cs

@@ -1,7 +1,6 @@
 #nullable enable
 using System;
 using System.Collections.Generic;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -107,12 +106,12 @@ public sealed class ArrangementEditor : EditorBase
             if (ViewToEdit.Arrangement.HasFlag (ViewArrangement.Overlapped))
             {
                 ViewToEdit.ShadowStyle = ShadowStyle.Transparent;
-                ViewToEdit.ColorScheme = Colors.ColorSchemes ["Toplevel"];
+                ViewToEdit.SchemeName = "Toplevel";
             }
             else
             {
                 ViewToEdit.ShadowStyle = ShadowStyle.None;
-                ViewToEdit.ColorScheme = ViewToEdit!.SuperView!.ColorScheme;
+                ViewToEdit.SchemeName = ViewToEdit!.SuperView!.SchemeName;
             }
 
             if (ViewToEdit.Arrangement.HasFlag (ViewArrangement.Movable))

+ 5 - 6
UICatalog/Scenarios/Editors/BorderEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/BorderEditor.cs

@@ -2,7 +2,6 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -77,7 +76,7 @@ public class BorderEditor : AdornmentEditor
         void OnRbBorderStyleOnSelectedItemChanged (object? s, SelectedItemChangedArgs args)
         {
             LineStyle prevBorderStyle = AdornmentToEdit!.BorderStyle;
-            ((Border)AdornmentToEdit).LineStyle = (LineStyle)args.SelectedItem;
+            ((Border)AdornmentToEdit).LineStyle = (LineStyle)args.SelectedItem!;
 
             if (((Border)AdornmentToEdit).LineStyle == LineStyle.None)
             {
@@ -92,9 +91,9 @@ public class BorderEditor : AdornmentEditor
             SetNeedsLayout ();
         }
 
-        void OnCkbTitleOnToggle (object? _, CancelEventArgs<CheckState> args)
+        void OnCkbTitleOnToggle (object? _, ResultEventArgs<CheckState> args)
         {
-            if (args.NewValue == CheckState.Checked)
+            if (args.Result == CheckState.Checked)
 
             {
                 ((Border)AdornmentToEdit!).Settings |= BorderSettings.Title;
@@ -106,9 +105,9 @@ public class BorderEditor : AdornmentEditor
             }
         }
 
-        void OnCkbGradientOnToggle (object? _, CancelEventArgs<CheckState> args)
+        void OnCkbGradientOnToggle (object? _, ResultEventArgs<CheckState> args)
         {
-            if (args.NewValue == CheckState.Checked)
+            if (args.Result == CheckState.Checked)
 
             {
                 ((Border)AdornmentToEdit!).Settings |= BorderSettings.Gradient;

+ 4 - 5
UICatalog/Scenarios/Editors/DimEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/DimEditor.cs

@@ -3,7 +3,6 @@ using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -27,11 +26,11 @@ public class DimEditor : EditorBase
     {
         if (ViewToEdit is { })
         {
-            ViewToEdit.SubViewsLaidOut += (_, _) => { OnUpdateSettings (); };
+            ViewToEdit.SubViewsLaidOut += (_, _) => { OnUpdateLayoutSettings (); };
         }
     }
 
-    protected override void OnUpdateSettings ()
+    protected override void OnUpdateLayoutSettings ()
     {
         Enabled = ViewToEdit is not Adornment;
 
@@ -114,7 +113,7 @@ public class DimEditor : EditorBase
             {
                 // ignored
             }
-            args.Cancel = true;
+            args.Handled = true;
         };
         Add (_valueEdit);
 
@@ -130,7 +129,7 @@ public class DimEditor : EditorBase
 
     private void DimChanged ()
     {
-        if (ViewToEdit == null || UpdatingSettings)
+        if (ViewToEdit == null || UpdatingLayoutSettings)
         {
             return;
         }

+ 7 - 6
UICatalog/Scenarios/Editors/EditorBase.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/EditorBase.cs

@@ -2,7 +2,6 @@
 using System;
 using System.Diagnostics;
 using System.Linq;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -48,6 +47,8 @@ public abstract class EditorBase : View
 
         AddCommand (Command.Accept, () => true);
 
+        SchemeName = "Dialog";
+
     }
 
     private readonly ExpanderButton? _expanderButton;
@@ -65,15 +66,15 @@ public abstract class EditorBase : View
         }
     }
 
-    public bool UpdatingSettings { get; private set; } = false;
+    public bool UpdatingLayoutSettings { get; private set; } = false;
 
     private void View_LayoutComplete (object? sender, LayoutEventArgs e)
     {
-        UpdatingSettings = true;
+        UpdatingLayoutSettings = true;
 
-        OnUpdateSettings ();
+        OnUpdateLayoutSettings ();
 
-        UpdatingSettings = false;
+        UpdatingLayoutSettings = false;
     }
 
 
@@ -108,7 +109,7 @@ public abstract class EditorBase : View
 
     protected virtual void OnViewToEditChanged () { }
 
-    protected virtual void OnUpdateSettings () { }
+    protected virtual void OnUpdateLayoutSettings () { }
 
     /// <summary>
     ///     Gets or sets whether the DimEditor should automatically select the View to edit

+ 0 - 1
UICatalog/Scenarios/Editors/EventLog.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/EventLog.cs

@@ -1,7 +1,6 @@
 #nullable enable
 using System;
 using System.Collections.ObjectModel;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 

+ 3 - 4
UICatalog/Scenarios/Editors/ExpanderButton.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/ExpanderButton.cs

@@ -1,7 +1,6 @@
 #nullable enable
 using System;
 using System.Text;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -14,9 +13,9 @@ namespace UICatalog.Scenarios;
 ///         (F4) or mouse.
 ///     </para>
 ///     <para>
-///         If <see cref="Orientation"/> is set to <see cref="Terminal.Gui.Orientation.Vertical"/>, the button will appear
+///         If <see cref="Orientation"/> is set to <see cref="Orientation.Vertical"/>, the button will appear
 ///         at the top/right.
-///         If <see cref="Orientation"/> is set to <see cref="Terminal.Gui.Orientation.Horizontal"/>, the button will
+///         If <see cref="Orientation"/> is set to <see cref="Orientation.Horizontal"/>, the button will
 ///         appear at the
 ///         bottom/left.
 ///     </para>
@@ -44,7 +43,7 @@ public class ExpanderButton : Button
 
         Orientation = Orientation.Vertical;
 
-        HighlightStyle = HighlightStyle.None;
+        HighlightStates = Terminal.Gui.ViewBase.MouseState.None;
 
         Initialized += ExpanderButton_Initialized;
 

+ 0 - 1
UICatalog/Scenarios/Editors/LayoutEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/LayoutEditor.cs

@@ -2,7 +2,6 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 

+ 89 - 0
Examples/UICatalog/Scenarios/EditorsAndHelpers/MarginEditor.cs

@@ -0,0 +1,89 @@
+#nullable enable
+using System;
+
+namespace UICatalog.Scenarios;
+
+public class MarginEditor : AdornmentEditor
+{
+    public MarginEditor ()
+    {
+        Title = "_Margin";
+        Initialized += MarginEditor_Initialized;
+        AdornmentChanged += MarginEditor_AdornmentChanged;
+    }
+
+    private RadioGroup? _rgShadow;
+
+    private FlagSelector? _flagSelectorTransparent;
+
+    private void MarginEditor_AdornmentChanged (object? sender, EventArgs e)
+    {
+        if (AdornmentToEdit is { })
+        {
+            _rgShadow!.SelectedItem = (int)((Margin)AdornmentToEdit).ShadowStyle;
+        }
+
+        if (AdornmentToEdit is { })
+        {
+            _flagSelectorTransparent!.Value = (uint)((Margin)AdornmentToEdit).ViewportSettings;
+        }
+    }
+
+    private void MarginEditor_Initialized (object? sender, EventArgs e)
+    {
+        _rgShadow = new RadioGroup
+        {
+            X = 0,
+            Y = Pos.Bottom (SubViews.ElementAt(SubViews.Count-1)),
+
+            SuperViewRendersLineCanvas = true,
+            Title = "_Shadow",
+            BorderStyle = LineStyle.Single,
+            RadioLabels = Enum.GetNames (typeof (ShadowStyle)),
+        };
+
+        if (AdornmentToEdit is { })
+        {
+            _rgShadow.SelectedItem = (int)((Margin)AdornmentToEdit).ShadowStyle;
+        }
+
+        _rgShadow.SelectedItemChanged += (_, args) =>
+                                        {
+                                            ((Margin)AdornmentToEdit!).ShadowStyle = (ShadowStyle)args.SelectedItem!;
+                                        };
+
+        Add (_rgShadow);
+
+        var flags = new Dictionary<uint, string> ()
+        {
+            { (uint)Terminal.Gui.ViewBase.ViewportSettingsFlags.Transparent, "Transparent" },
+            { (uint)Terminal.Gui.ViewBase.ViewportSettingsFlags.TransparentMouse, "TransparentMouse" }
+        };
+
+        _flagSelectorTransparent = new FlagSelector ()
+        {
+            X = 0,
+            Y = Pos.Bottom (_rgShadow),
+
+            SuperViewRendersLineCanvas = true,
+            Title = "_ViewportSettings",
+            BorderStyle = LineStyle.Single,
+        };
+        _flagSelectorTransparent.SetFlags(flags.AsReadOnly ());
+
+
+        Add (_flagSelectorTransparent);
+
+        if (AdornmentToEdit is { })
+        {
+            _flagSelectorTransparent.Value = (uint)((Margin)AdornmentToEdit).ViewportSettings;
+        }
+
+        _flagSelectorTransparent.ValueChanged += (_, args) =>
+                                                 {
+                                                     ((Margin)AdornmentToEdit!).ViewportSettings = (ViewportSettingsFlags)args.Value!;
+                                                 };
+
+
+    }
+}

+ 0 - 0
UICatalog/Scenarios/Editors/PaddingEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/PaddingEditor.cs


+ 3 - 4
UICatalog/Scenarios/Editors/PosEditor.cs → Examples/UICatalog/Scenarios/EditorsAndHelpers/PosEditor.cs

@@ -3,7 +3,6 @@ using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
-using Terminal.Gui;
 
 namespace UICatalog.Scenarios;
 
@@ -23,7 +22,7 @@ public class PosEditor : EditorBase
     private RadioGroup? _posRadioGroup;
     private TextField? _valueEdit;
 
-    protected override void OnUpdateSettings ()
+    protected override void OnUpdateLayoutSettings ()
     {
         Enabled = ViewToEdit is not Adornment;
 
@@ -115,7 +114,7 @@ public class PosEditor : EditorBase
                                         // ignored
                                     }
 
-                                    args.Cancel = true;
+                                    args.Handled = true;
                                 };
         Add (_valueEdit);
 
@@ -130,7 +129,7 @@ public class PosEditor : EditorBase
 
     private void PosChanged ()
     {
-        if (ViewToEdit == null || UpdatingSettings)
+        if (ViewToEdit == null || UpdatingLayoutSettings)
         {
             return;
         }

+ 46 - 0
Examples/UICatalog/Scenarios/EditorsAndHelpers/SchemeViewer.cs

@@ -0,0 +1,46 @@
+#nullable enable
+
+namespace UICatalog.Scenarios;
+
+public class SchemeViewer : FrameView
+{
+    public SchemeViewer ()
+    {
+        TabStop = TabBehavior.TabStop;
+        CanFocus = true;
+        Height = Dim.Auto ();
+        Width = Dim.Auto ();
+
+        VisualRoleViewer? prevRoleViewer = null;
+
+        foreach (VisualRole role in Enum.GetValues<VisualRole> ())
+        {
+            var roleViewer = new VisualRoleViewer
+            {
+                Role = role
+            };
+
+            if (prevRoleViewer is { })
+            {
+                roleViewer.Y = Pos.Bottom (prevRoleViewer);
+            }
+
+            base.Add (roleViewer);
+
+            prevRoleViewer = roleViewer;
+        }
+    }
+
+    /// <inheritdoc/>
+    protected override bool OnSchemeNameChanging (ValueChangingEventArgs<string?> args)
+    {
+        Title = args.NewValue ?? "null";
+
+        foreach (VisualRoleViewer v in SubViews.OfType<VisualRoleViewer> ())
+        {
+            v.SchemeName = args.NewValue;
+        }
+
+        return base.OnSchemeNameChanging (args);
+    }
+}

+ 120 - 0
Examples/UICatalog/Scenarios/EditorsAndHelpers/ThemeViewer.cs

@@ -0,0 +1,120 @@
+#nullable enable
+
+namespace UICatalog.Scenarios;
+
+public class ThemeViewer : FrameView
+{
+    public ThemeViewer ()
+    {
+        BorderStyle = LineStyle.Rounded;
+        Border!.Thickness = new (0, 1, 0, 0);
+        Margin!.Thickness = new (0, 0, 1, 0);
+        TabStop = TabBehavior.TabStop;
+        CanFocus = true;
+        Height = Dim.Fill ();
+        Width = Dim.Auto ();
+        Title = $"{ThemeManager.Theme}";
+
+        VerticalScrollBar.AutoShow = true;
+        HorizontalScrollBar.AutoShow = true;
+
+        SubViewsLaidOut += (sender, _) =>
+                           {
+                               if (sender is View sendingView)
+                               {
+                                   sendingView.SetContentSize (new Size (sendingView.GetContentSize ().Width, sendingView.GetHeightRequiredForSubViews ()));
+                               }
+                           };
+
+        AddCommand (Command.Up, () => ScrollVertical (-1));
+        AddCommand (Command.Down, () => ScrollVertical (1));
+
+        AddCommand (Command.PageUp, () => ScrollVertical (-SubViews.OfType<SchemeViewer> ().First ().Frame.Height));
+        AddCommand (Command.PageDown, () => ScrollVertical (SubViews.OfType<SchemeViewer> ().First ().Frame.Height));
+
+        AddCommand (
+                    Command.Start,
+                    () =>
+                    {
+                        Viewport = Viewport with { Y = 0 };
+
+                        return true;
+                    });
+
+        AddCommand (
+                    Command.End,
+                    () =>
+                    {
+                        Viewport = Viewport with { Y = GetContentSize ().Height };
+
+                        return true;
+                    });
+
+        AddCommand (Command.ScrollDown, () => ScrollVertical (1));
+        AddCommand (Command.ScrollUp, () => ScrollVertical (-1));
+        AddCommand (Command.ScrollRight, () => ScrollHorizontal (1));
+        AddCommand (Command.ScrollLeft, () => ScrollHorizontal (-1));
+
+        KeyBindings.Add (Key.CursorUp, Command.Up);
+        KeyBindings.Add (Key.CursorDown, Command.Down);
+        KeyBindings.Add (Key.CursorLeft, Command.Left);
+        KeyBindings.Add (Key.CursorRight, Command.Right);
+        KeyBindings.Add (Key.PageUp, Command.PageUp);
+        KeyBindings.Add (Key.PageDown, Command.PageDown);
+        KeyBindings.Add (Key.Home, Command.Start);
+        KeyBindings.Add (Key.End, Command.End);
+        KeyBindings.Add (PopoverMenu.DefaultKey, Command.Context);
+
+        MouseBindings.Add (MouseFlags.Button1DoubleClicked, Command.Accept);
+        MouseBindings.ReplaceCommands (MouseFlags.Button3Clicked, Command.Context);
+        MouseBindings.ReplaceCommands (MouseFlags.Button1Clicked | MouseFlags.ButtonCtrl, Command.Context);
+        MouseBindings.Add (MouseFlags.WheeledDown, Command.ScrollDown);
+        MouseBindings.Add (MouseFlags.WheeledUp, Command.ScrollUp);
+        MouseBindings.Add (MouseFlags.WheeledLeft, Command.ScrollLeft);
+        MouseBindings.Add (MouseFlags.WheeledRight, Command.ScrollRight);
+
+        SchemeViewer? prevSchemeViewer = null;
+
+        foreach (KeyValuePair<string, Scheme?> kvp in SchemeManager.GetSchemesForCurrentTheme ())
+        {
+            var schemeViewer = new SchemeViewer
+            {
+                Id = $"schemeViewer for {kvp.Key}",
+                SchemeName = kvp.Key
+            };
+
+            if (prevSchemeViewer is { })
+            {
+                schemeViewer.Y = Pos.Bottom (prevSchemeViewer);
+            }
+
+            prevSchemeViewer = schemeViewer;
+            base.Add (schemeViewer);
+        }
+
+        ThemeManager.ThemeChanged += OnThemeManagerOnThemeChanged;
+    }
+
+    /// <inheritdoc/>
+    protected override void OnFocusedChanged (View? previousFocused, View? focused)
+    {
+        base.OnFocusedChanged (previousFocused, focused);
+
+        if (focused is { })
+        {
+            SchemeName = focused.Title;
+        }
+    }
+
+    private void OnThemeManagerOnThemeChanged (object? _, EventArgs<string> args) { Title = args.Value!; }
+
+    protected override void Dispose (bool disposing)
+    {
+        if (disposing)
+        {
+            ThemeManager.ThemeChanged -= OnThemeManagerOnThemeChanged;
+        }
+
+        base.Dispose (disposing);
+    }
+}

Some files were not shown because too many files changed in this diff