diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs
index 5b93b2e1a..e92db8d1d 100644
--- a/Terminal.Gui/Core/View.cs
+++ b/Terminal.Gui/Core/View.cs
@@ -857,7 +857,7 @@ namespace Terminal.Gui {
///
/// Gets or sets the which can be handled differently by any derived class.
///
- public TextFormatter? TextFormatter { get; set; }
+ public TextFormatter TextFormatter { get; set; }
///
/// Returns the container for this view, or null if this view has not been added to a container.
diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs
index 9939e42b2..cc6899e77 100644
--- a/UICatalog/Scenarios/Scrolling.cs
+++ b/UICatalog/Scenarios/Scrolling.cs
@@ -128,7 +128,7 @@ namespace UICatalog.Scenarios {
};
label.Text = $"{scrollView}\nContentSize: {scrollView.ContentSize}\nContentOffset: {scrollView.ContentOffset}";
- const string rule = "0123456789";
+ //const string rule = "0123456789";
var horizontalRuler = new Label () {
X = 0,
@@ -140,7 +140,7 @@ namespace UICatalog.Scenarios {
};
scrollView.Add (horizontalRuler);
- const string vrule = "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n";
+ //const string vrule = "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n";
var verticalRuler = new Label () {
X = 0,
diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs
index f0f5e70b0..228b7deaf 100644
--- a/UICatalog/UICatalog.cs
+++ b/UICatalog/UICatalog.cs
@@ -13,6 +13,7 @@ using System.Threading;
using Terminal.Gui.Configuration;
using static Terminal.Gui.Configuration.ConfigurationManager;
using System.Text.Json.Serialization;
+using System.ComponentModel.DataAnnotations;
#nullable enable
@@ -70,7 +71,6 @@ namespace UICatalog {
_scenarios = Scenario.GetScenarios ();
_categories = Scenario.GetAllCategories ();
- _nameColumnWidth = _scenarios.OrderByDescending (s => s.GetName ().Length).FirstOrDefault ().GetName ().Length;
if (args.Length > 0 && args.Contains ("-usc")) {
_useSystemConsole = true;
@@ -83,7 +83,7 @@ namespace UICatalog {
// run it and exit when done.
if (args.Length > 0) {
var item = _scenarios.FindIndex (s => s.GetName ().Equals (args [0], StringComparison.OrdinalIgnoreCase));
- _selectedScenario = (Scenario)Activator.CreateInstance (_scenarios [item].GetType ());
+ _selectedScenario = (Scenario)Activator.CreateInstance (_scenarios [item].GetType ())!;
Application.UseSystemConsole = _useSystemConsole;
Application.Init ();
_selectedScenario.Theme = _cachedTheme;
@@ -115,7 +115,7 @@ namespace UICatalog {
Scenario scenario;
while ((scenario = RunUICatalogTopLevel ()) != null) {
VerifyObjectsWereDisposed ();
- ConfigurationManager.Themes.Theme = _cachedTheme;
+ ConfigurationManager.Themes!.Theme = _cachedTheme!;
ConfigurationManager.Apply ();
scenario.Theme = _cachedTheme;
scenario.TopLevelColorScheme = _topLevelColorScheme;
@@ -151,7 +151,7 @@ namespace UICatalog {
// Setup a file system watcher for `./.tui/`
_currentDirWatcher.NotifyFilter = NotifyFilters.LastWrite;
var f = new FileInfo (Assembly.GetExecutingAssembly ().Location);
- var tuiDir = Path.Combine (f.Directory.FullName, ".tui");
+ var tuiDir = Path.Combine (f.Directory!.FullName, ".tui");
if (!Directory.Exists (tuiDir)) {
Directory.CreateDirectory (tuiDir);
@@ -206,9 +206,9 @@ namespace UICatalog {
Application.Init ();
if (_cachedTheme is null) {
- _cachedTheme = ConfigurationManager.Themes.Theme;
+ _cachedTheme = ConfigurationManager.Themes?.Theme;
} else {
- ConfigurationManager.Themes.Theme = _cachedTheme;
+ ConfigurationManager.Themes!.Theme = _cachedTheme;
ConfigurationManager.Apply ();
}
@@ -217,40 +217,40 @@ namespace UICatalog {
Application.Run ();
Application.Shutdown ();
- return _selectedScenario;
+ return _selectedScenario!;
}
- static List _scenarios;
- static List _categories;
- static int _nameColumnWidth;
+ static List? _scenarios;
+ static List? _categories;
+
// When a scenario is run, the main app is killed. These items
// are therefore cached so that when the scenario exits the
// main app UI can be restored to previous state
static int _cachedScenarioIndex = 0;
static int _cachedCategoryIndex = 0;
- static string? _cachedTheme;
-
- static StringBuilder _aboutMessage;
+ static string? _cachedTheme = string.Empty;
+
+ static StringBuilder? _aboutMessage = null;
// If set, holds the scenario the user selected
- static Scenario _selectedScenario = null;
+ static Scenario? _selectedScenario = null;
static bool _useSystemConsole = false;
static ConsoleDriver.DiagnosticFlags _diagnosticFlags;
//static bool _enableConsoleScrolling = false;
static bool _isFirstRunning = true;
- static string _topLevelColorScheme;
-
- static MenuItem [] _themeMenuItems;
- static MenuBarItem _themeMenuBarItem;
+ static string _topLevelColorScheme = string.Empty;
+ static MenuItem []? _themeMenuItems;
+ static MenuBarItem? _themeMenuBarItem;
+
///
/// This is the main UI Catalog app view. It is run fresh when the app loads (if a Scenario has not been passed on
/// the command line) and each time a Scenario ends.
///
public class UICatalogTopLevel : Toplevel {
- public MenuItem miIsMouseDisabled;
- public MenuItem miEnableConsoleScrolling;
+ public MenuItem? miIsMouseDisabled;
+ public MenuItem? miEnableConsoleScrolling;
public TileView ContentPane;
public ListView CategoryListView;
@@ -276,7 +276,7 @@ namespace UICatalog {
new MenuItem ("_gui.cs API Overview", "", () => OpenUrl ("https://gui-cs.github.io/Terminal.Gui/articles/overview.html"), null, null, Key.F1),
new MenuItem ("gui.cs _README", "", () => OpenUrl ("https://github.com/gui-cs/Terminal.Gui"), null, null, Key.F2),
new MenuItem ("_About...",
- "About UI Catalog", () => MessageBox.Query ("About UI Catalog", _aboutMessage.ToString(), 0, false, "_Ok"), null, null, Key.CtrlMask | Key.A),
+ "About UI Catalog", () => MessageBox.Query ("About UI Catalog", _aboutMessage!.ToString(), 0, false, "_Ok"), null, null, Key.CtrlMask | Key.A),
}),
});
@@ -302,7 +302,7 @@ namespace UICatalog {
}),
new StatusItem(Key.F10, "~F10~ Status Bar", () => {
StatusBar.Visible = !StatusBar.Visible;
- ContentPane.Height = Dim.Fill(StatusBar.Visible ? 1 : 0);
+ ContentPane!.Height = Dim.Fill(StatusBar.Visible ? 1 : 0);
LayoutSubviews();
SetSubViewNeedsDisplay();
}),
@@ -332,7 +332,7 @@ namespace UICatalog {
CanFocus = true,
};
CategoryListView.OpenSelectedItem += (s,a) => {
- ScenarioListView.SetFocus ();
+ ScenarioListView!.SetFocus ();
};
CategoryListView.SelectedItemChanged += CategoryListView_SelectedChanged;
@@ -371,12 +371,12 @@ namespace UICatalog {
ConfigurationManager.Applied += ConfigAppliedHandler;
}
- void LoadedHandler (object sender, EventArgs args)
+ void LoadedHandler (object? sender, EventArgs? args)
{
ConfigChanged ();
- miIsMouseDisabled.Checked = Application.IsMouseDisabled;
- miEnableConsoleScrolling.Checked = Application.EnableConsoleScrolling;
+ miIsMouseDisabled!.Checked = Application.IsMouseDisabled;
+ miEnableConsoleScrolling!.Checked = Application.EnableConsoleScrolling;
DriverName.Title = $"Driver: {Driver.GetType ().Name}";
OS.Title = $"OS: {Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystem} {Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystemVersion}";
@@ -391,7 +391,7 @@ namespace UICatalog {
StatusBar.VisibleChanged += (s, e) => {
UICatalogApp.ShowStatusBar = StatusBar.Visible;
- var height = (StatusBar.Visible ? 1 : 0);// + (MenuBar.Visible ? 1 : 0);
+ var height = (StatusBar.Visible ? 1 : 0);
ContentPane.Height = Dim.Fill (height);
LayoutSubviews ();
SetSubViewNeedsDisplay ();
@@ -400,13 +400,13 @@ namespace UICatalog {
Loaded -= LoadedHandler;
}
- private void UnloadedHandler (object sender, EventArgs args)
+ private void UnloadedHandler (object? sender, EventArgs? args)
{
ConfigurationManager.Applied -= ConfigAppliedHandler;
Unloaded -= UnloadedHandler;
}
- void ConfigAppliedHandler (object sender, ConfigurationManagerEventArgs a)
+ void ConfigAppliedHandler (object? sender, ConfigurationManagerEventArgs? a)
{
ConfigChanged ();
}
@@ -415,14 +415,16 @@ namespace UICatalog {
/// Launches the selected scenario, setting the global _selectedScenario
///
///
- void ScenarioListView_OpenSelectedItem (object sender, EventArgs e)
+ void ScenarioListView_OpenSelectedItem (object? sender, EventArgs? e)
{
if (_selectedScenario is null) {
// Save selected item state
_cachedCategoryIndex = CategoryListView.SelectedItem;
_cachedScenarioIndex = ScenarioListView.SelectedItem;
// Create new instance of scenario (even though Scenarios contains instances)
- _selectedScenario = (Scenario)Activator.CreateInstance (ScenarioListView.Source.ToList () [ScenarioListView.SelectedItem].GetType ());
+ var sourceList = ScenarioListView.Source.ToList ();
+
+ _selectedScenario = (Scenario)Activator.CreateInstance (ScenarioListView.Source.ToList () [ScenarioListView.SelectedItem]!.GetType ())!;
// Tell the main app to stop
Application.RequestStop ();
@@ -431,12 +433,13 @@ namespace UICatalog {
List