|
@@ -13,6 +13,7 @@ using System.Threading;
|
|
using Terminal.Gui.Configuration;
|
|
using Terminal.Gui.Configuration;
|
|
using static Terminal.Gui.Configuration.ConfigurationManager;
|
|
using static Terminal.Gui.Configuration.ConfigurationManager;
|
|
using System.Text.Json.Serialization;
|
|
using System.Text.Json.Serialization;
|
|
|
|
+using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
#nullable enable
|
|
#nullable enable
|
|
|
|
|
|
@@ -70,7 +71,6 @@ namespace UICatalog {
|
|
|
|
|
|
_scenarios = Scenario.GetScenarios ();
|
|
_scenarios = Scenario.GetScenarios ();
|
|
_categories = Scenario.GetAllCategories ();
|
|
_categories = Scenario.GetAllCategories ();
|
|
- _nameColumnWidth = _scenarios.OrderByDescending (s => s.GetName ().Length).FirstOrDefault ().GetName ().Length;
|
|
|
|
|
|
|
|
if (args.Length > 0 && args.Contains ("-usc")) {
|
|
if (args.Length > 0 && args.Contains ("-usc")) {
|
|
_useSystemConsole = true;
|
|
_useSystemConsole = true;
|
|
@@ -83,7 +83,7 @@ namespace UICatalog {
|
|
// run it and exit when done.
|
|
// run it and exit when done.
|
|
if (args.Length > 0) {
|
|
if (args.Length > 0) {
|
|
var item = _scenarios.FindIndex (s => s.GetName ().Equals (args [0], StringComparison.OrdinalIgnoreCase));
|
|
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.UseSystemConsole = _useSystemConsole;
|
|
Application.Init ();
|
|
Application.Init ();
|
|
_selectedScenario.Theme = _cachedTheme;
|
|
_selectedScenario.Theme = _cachedTheme;
|
|
@@ -115,7 +115,7 @@ namespace UICatalog {
|
|
Scenario scenario;
|
|
Scenario scenario;
|
|
while ((scenario = RunUICatalogTopLevel ()) != null) {
|
|
while ((scenario = RunUICatalogTopLevel ()) != null) {
|
|
VerifyObjectsWereDisposed ();
|
|
VerifyObjectsWereDisposed ();
|
|
- ConfigurationManager.Themes.Theme = _cachedTheme;
|
|
|
|
|
|
+ ConfigurationManager.Themes!.Theme = _cachedTheme!;
|
|
ConfigurationManager.Apply ();
|
|
ConfigurationManager.Apply ();
|
|
scenario.Theme = _cachedTheme;
|
|
scenario.Theme = _cachedTheme;
|
|
scenario.TopLevelColorScheme = _topLevelColorScheme;
|
|
scenario.TopLevelColorScheme = _topLevelColorScheme;
|
|
@@ -151,7 +151,7 @@ namespace UICatalog {
|
|
// Setup a file system watcher for `./.tui/`
|
|
// Setup a file system watcher for `./.tui/`
|
|
_currentDirWatcher.NotifyFilter = NotifyFilters.LastWrite;
|
|
_currentDirWatcher.NotifyFilter = NotifyFilters.LastWrite;
|
|
var f = new FileInfo (Assembly.GetExecutingAssembly ().Location);
|
|
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)) {
|
|
if (!Directory.Exists (tuiDir)) {
|
|
Directory.CreateDirectory (tuiDir);
|
|
Directory.CreateDirectory (tuiDir);
|
|
@@ -206,9 +206,9 @@ namespace UICatalog {
|
|
Application.Init ();
|
|
Application.Init ();
|
|
|
|
|
|
if (_cachedTheme is null) {
|
|
if (_cachedTheme is null) {
|
|
- _cachedTheme = ConfigurationManager.Themes.Theme;
|
|
|
|
|
|
+ _cachedTheme = ConfigurationManager.Themes?.Theme;
|
|
} else {
|
|
} else {
|
|
- ConfigurationManager.Themes.Theme = _cachedTheme;
|
|
|
|
|
|
+ ConfigurationManager.Themes!.Theme = _cachedTheme;
|
|
ConfigurationManager.Apply ();
|
|
ConfigurationManager.Apply ();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -217,40 +217,40 @@ namespace UICatalog {
|
|
Application.Run<UICatalogTopLevel> ();
|
|
Application.Run<UICatalogTopLevel> ();
|
|
Application.Shutdown ();
|
|
Application.Shutdown ();
|
|
|
|
|
|
- return _selectedScenario;
|
|
|
|
|
|
+ return _selectedScenario!;
|
|
}
|
|
}
|
|
|
|
|
|
- static List<Scenario> _scenarios;
|
|
|
|
- static List<string> _categories;
|
|
|
|
- static int _nameColumnWidth;
|
|
|
|
|
|
+ static List<Scenario>? _scenarios;
|
|
|
|
+ static List<string>? _categories;
|
|
|
|
+
|
|
// When a scenario is run, the main app is killed. These items
|
|
// When a scenario is run, the main app is killed. These items
|
|
// are therefore cached so that when the scenario exits the
|
|
// are therefore cached so that when the scenario exits the
|
|
// main app UI can be restored to previous state
|
|
// main app UI can be restored to previous state
|
|
static int _cachedScenarioIndex = 0;
|
|
static int _cachedScenarioIndex = 0;
|
|
static int _cachedCategoryIndex = 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
|
|
// If set, holds the scenario the user selected
|
|
- static Scenario _selectedScenario = null;
|
|
|
|
|
|
+ static Scenario? _selectedScenario = null;
|
|
|
|
|
|
static bool _useSystemConsole = false;
|
|
static bool _useSystemConsole = false;
|
|
static ConsoleDriver.DiagnosticFlags _diagnosticFlags;
|
|
static ConsoleDriver.DiagnosticFlags _diagnosticFlags;
|
|
//static bool _enableConsoleScrolling = false;
|
|
//static bool _enableConsoleScrolling = false;
|
|
static bool _isFirstRunning = true;
|
|
static bool _isFirstRunning = true;
|
|
- static string _topLevelColorScheme;
|
|
|
|
-
|
|
|
|
- static MenuItem [] _themeMenuItems;
|
|
|
|
- static MenuBarItem _themeMenuBarItem;
|
|
|
|
|
|
+ static string _topLevelColorScheme = string.Empty;
|
|
|
|
|
|
|
|
+ static MenuItem []? _themeMenuItems;
|
|
|
|
+ static MenuBarItem? _themeMenuBarItem;
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// This is the main UI Catalog app view. It is run fresh when the app loads (if a Scenario has not been passed on
|
|
/// 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.
|
|
/// the command line) and each time a Scenario ends.
|
|
/// </summary>
|
|
/// </summary>
|
|
public class UICatalogTopLevel : Toplevel {
|
|
public class UICatalogTopLevel : Toplevel {
|
|
- public MenuItem miIsMouseDisabled;
|
|
|
|
- public MenuItem miEnableConsoleScrolling;
|
|
|
|
|
|
+ public MenuItem? miIsMouseDisabled;
|
|
|
|
+ public MenuItem? miEnableConsoleScrolling;
|
|
|
|
|
|
public TileView ContentPane;
|
|
public TileView ContentPane;
|
|
public ListView CategoryListView;
|
|
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 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 ("gui.cs _README", "", () => OpenUrl ("https://github.com/gui-cs/Terminal.Gui"), null, null, Key.F2),
|
|
new MenuItem ("_About...",
|
|
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", () => {
|
|
new StatusItem(Key.F10, "~F10~ Status Bar", () => {
|
|
StatusBar.Visible = !StatusBar.Visible;
|
|
StatusBar.Visible = !StatusBar.Visible;
|
|
- ContentPane.Height = Dim.Fill(StatusBar.Visible ? 1 : 0);
|
|
|
|
|
|
+ ContentPane!.Height = Dim.Fill(StatusBar.Visible ? 1 : 0);
|
|
LayoutSubviews();
|
|
LayoutSubviews();
|
|
SetSubViewNeedsDisplay();
|
|
SetSubViewNeedsDisplay();
|
|
}),
|
|
}),
|
|
@@ -332,7 +332,7 @@ namespace UICatalog {
|
|
CanFocus = true,
|
|
CanFocus = true,
|
|
};
|
|
};
|
|
CategoryListView.OpenSelectedItem += (s,a) => {
|
|
CategoryListView.OpenSelectedItem += (s,a) => {
|
|
- ScenarioListView.SetFocus ();
|
|
|
|
|
|
+ ScenarioListView!.SetFocus ();
|
|
};
|
|
};
|
|
CategoryListView.SelectedItemChanged += CategoryListView_SelectedChanged;
|
|
CategoryListView.SelectedItemChanged += CategoryListView_SelectedChanged;
|
|
|
|
|
|
@@ -371,12 +371,12 @@ namespace UICatalog {
|
|
ConfigurationManager.Applied += ConfigAppliedHandler;
|
|
ConfigurationManager.Applied += ConfigAppliedHandler;
|
|
}
|
|
}
|
|
|
|
|
|
- void LoadedHandler (object sender, EventArgs args)
|
|
|
|
|
|
+ void LoadedHandler (object? sender, EventArgs? args)
|
|
{
|
|
{
|
|
ConfigChanged ();
|
|
ConfigChanged ();
|
|
|
|
|
|
- miIsMouseDisabled.Checked = Application.IsMouseDisabled;
|
|
|
|
- miEnableConsoleScrolling.Checked = Application.EnableConsoleScrolling;
|
|
|
|
|
|
+ miIsMouseDisabled!.Checked = Application.IsMouseDisabled;
|
|
|
|
+ miEnableConsoleScrolling!.Checked = Application.EnableConsoleScrolling;
|
|
DriverName.Title = $"Driver: {Driver.GetType ().Name}";
|
|
DriverName.Title = $"Driver: {Driver.GetType ().Name}";
|
|
OS.Title = $"OS: {Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystem} {Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystemVersion}";
|
|
OS.Title = $"OS: {Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystem} {Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystemVersion}";
|
|
|
|
|
|
@@ -391,7 +391,7 @@ namespace UICatalog {
|
|
StatusBar.VisibleChanged += (s, e) => {
|
|
StatusBar.VisibleChanged += (s, e) => {
|
|
UICatalogApp.ShowStatusBar = StatusBar.Visible;
|
|
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);
|
|
ContentPane.Height = Dim.Fill (height);
|
|
LayoutSubviews ();
|
|
LayoutSubviews ();
|
|
SetSubViewNeedsDisplay ();
|
|
SetSubViewNeedsDisplay ();
|
|
@@ -400,13 +400,13 @@ namespace UICatalog {
|
|
Loaded -= LoadedHandler;
|
|
Loaded -= LoadedHandler;
|
|
}
|
|
}
|
|
|
|
|
|
- private void UnloadedHandler (object sender, EventArgs args)
|
|
|
|
|
|
+ private void UnloadedHandler (object? sender, EventArgs? args)
|
|
{
|
|
{
|
|
ConfigurationManager.Applied -= ConfigAppliedHandler;
|
|
ConfigurationManager.Applied -= ConfigAppliedHandler;
|
|
Unloaded -= UnloadedHandler;
|
|
Unloaded -= UnloadedHandler;
|
|
}
|
|
}
|
|
|
|
|
|
- void ConfigAppliedHandler (object sender, ConfigurationManagerEventArgs a)
|
|
|
|
|
|
+ void ConfigAppliedHandler (object? sender, ConfigurationManagerEventArgs? a)
|
|
{
|
|
{
|
|
ConfigChanged ();
|
|
ConfigChanged ();
|
|
}
|
|
}
|
|
@@ -415,14 +415,16 @@ namespace UICatalog {
|
|
/// Launches the selected scenario, setting the global _selectedScenario
|
|
/// Launches the selected scenario, setting the global _selectedScenario
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
/// <param name="e"></param>
|
|
- void ScenarioListView_OpenSelectedItem (object sender, EventArgs e)
|
|
|
|
|
|
+ void ScenarioListView_OpenSelectedItem (object? sender, EventArgs? e)
|
|
{
|
|
{
|
|
if (_selectedScenario is null) {
|
|
if (_selectedScenario is null) {
|
|
// Save selected item state
|
|
// Save selected item state
|
|
_cachedCategoryIndex = CategoryListView.SelectedItem;
|
|
_cachedCategoryIndex = CategoryListView.SelectedItem;
|
|
_cachedScenarioIndex = ScenarioListView.SelectedItem;
|
|
_cachedScenarioIndex = ScenarioListView.SelectedItem;
|
|
// Create new instance of scenario (even though Scenarios contains instances)
|
|
// 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
|
|
// Tell the main app to stop
|
|
Application.RequestStop ();
|
|
Application.RequestStop ();
|
|
@@ -431,12 +433,13 @@ namespace UICatalog {
|
|
|
|
|
|
List<MenuItem []> CreateDiagnosticMenuItems ()
|
|
List<MenuItem []> CreateDiagnosticMenuItems ()
|
|
{
|
|
{
|
|
- List<MenuItem []> menuItems = new List<MenuItem []> ();
|
|
|
|
- menuItems.Add (CreateDiagnosticFlagsMenuItems ());
|
|
|
|
- menuItems.Add (new MenuItem [] { null });
|
|
|
|
- menuItems.Add (CreateEnableConsoleScrollingMenuItems ());
|
|
|
|
- menuItems.Add (CreateDisabledEnabledMouseItems ());
|
|
|
|
- menuItems.Add (CreateKeybindingsMenuItems ());
|
|
|
|
|
|
+ List<MenuItem []> menuItems = new List<MenuItem []> {
|
|
|
|
+ CreateDiagnosticFlagsMenuItems (),
|
|
|
|
+ new MenuItem [] { },
|
|
|
|
+ CreateEnableConsoleScrollingMenuItems (),
|
|
|
|
+ CreateDisabledEnabledMouseItems (),
|
|
|
|
+ CreateKeybindingsMenuItems ()
|
|
|
|
+ };
|
|
return menuItems;
|
|
return menuItems;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -446,10 +449,10 @@ namespace UICatalog {
|
|
miIsMouseDisabled = new MenuItem {
|
|
miIsMouseDisabled = new MenuItem {
|
|
Title = "_Disable Mouse"
|
|
Title = "_Disable Mouse"
|
|
};
|
|
};
|
|
- miIsMouseDisabled.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miIsMouseDisabled.Title.ToString ().Substring (1, 1) [0];
|
|
|
|
|
|
+ miIsMouseDisabled.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miIsMouseDisabled!.Title!.ToString ()!.Substring (1, 1) [0];
|
|
miIsMouseDisabled.CheckType |= MenuItemCheckStyle.Checked;
|
|
miIsMouseDisabled.CheckType |= MenuItemCheckStyle.Checked;
|
|
miIsMouseDisabled.Action += () => {
|
|
miIsMouseDisabled.Action += () => {
|
|
- miIsMouseDisabled.Checked = Application.IsMouseDisabled = (bool)!miIsMouseDisabled.Checked;
|
|
|
|
|
|
+ miIsMouseDisabled.Checked = Application.IsMouseDisabled = (bool)!miIsMouseDisabled.Checked!;
|
|
};
|
|
};
|
|
menuItems.Add (miIsMouseDisabled);
|
|
menuItems.Add (miIsMouseDisabled);
|
|
|
|
|
|
@@ -468,7 +471,7 @@ namespace UICatalog {
|
|
Application.Run (dlg);
|
|
Application.Run (dlg);
|
|
};
|
|
};
|
|
|
|
|
|
- menuItems.Add (null);
|
|
|
|
|
|
+ menuItems.Add (null!);
|
|
menuItems.Add (item);
|
|
menuItems.Add (item);
|
|
|
|
|
|
return menuItems.ToArray ();
|
|
return menuItems.ToArray ();
|
|
@@ -479,11 +482,11 @@ namespace UICatalog {
|
|
List<MenuItem> menuItems = new List<MenuItem> ();
|
|
List<MenuItem> menuItems = new List<MenuItem> ();
|
|
miEnableConsoleScrolling = new MenuItem ();
|
|
miEnableConsoleScrolling = new MenuItem ();
|
|
miEnableConsoleScrolling.Title = "_Enable Console Scrolling";
|
|
miEnableConsoleScrolling.Title = "_Enable Console Scrolling";
|
|
- miEnableConsoleScrolling.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miEnableConsoleScrolling.Title.ToString ().Substring (1, 1) [0];
|
|
|
|
|
|
+ miEnableConsoleScrolling.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miEnableConsoleScrolling.Title.ToString ()!.Substring (1, 1) [0];
|
|
miEnableConsoleScrolling.CheckType |= MenuItemCheckStyle.Checked;
|
|
miEnableConsoleScrolling.CheckType |= MenuItemCheckStyle.Checked;
|
|
miEnableConsoleScrolling.Action += () => {
|
|
miEnableConsoleScrolling.Action += () => {
|
|
miEnableConsoleScrolling.Checked = !miEnableConsoleScrolling.Checked;
|
|
miEnableConsoleScrolling.Checked = !miEnableConsoleScrolling.Checked;
|
|
- Application.EnableConsoleScrolling = (bool)miEnableConsoleScrolling.Checked;
|
|
|
|
|
|
+ Application.EnableConsoleScrolling = (bool)miEnableConsoleScrolling.Checked!;
|
|
};
|
|
};
|
|
menuItems.Add (miEnableConsoleScrolling);
|
|
menuItems.Add (miEnableConsoleScrolling);
|
|
|
|
|
|
@@ -554,10 +557,10 @@ namespace UICatalog {
|
|
|
|
|
|
Enum GetDiagnosticsEnumValue (ustring title)
|
|
Enum GetDiagnosticsEnumValue (ustring title)
|
|
{
|
|
{
|
|
- return title.ToString () switch {
|
|
|
|
|
|
+ return title!.ToString () switch {
|
|
FRAME_RULER => ConsoleDriver.DiagnosticFlags.FrameRuler,
|
|
FRAME_RULER => ConsoleDriver.DiagnosticFlags.FrameRuler,
|
|
FRAME_PADDING => ConsoleDriver.DiagnosticFlags.FramePadding,
|
|
FRAME_PADDING => ConsoleDriver.DiagnosticFlags.FramePadding,
|
|
- _ => null,
|
|
|
|
|
|
+ _ => null!,
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
@@ -585,10 +588,10 @@ namespace UICatalog {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public MenuItem [] CreateThemeMenuItems ()
|
|
|
|
|
|
+ public MenuItem []? CreateThemeMenuItems ()
|
|
{
|
|
{
|
|
List<MenuItem> menuItems = new List<MenuItem> ();
|
|
List<MenuItem> menuItems = new List<MenuItem> ();
|
|
- foreach (var theme in ConfigurationManager.Themes) {
|
|
|
|
|
|
+ foreach (var theme in ConfigurationManager.Themes!) {
|
|
var item = new MenuItem {
|
|
var item = new MenuItem {
|
|
Title = theme.Key,
|
|
Title = theme.Key,
|
|
Shortcut = Key.AltMask + theme.Key [0]
|
|
Shortcut = Key.AltMask + theme.Key [0]
|
|
@@ -621,7 +624,7 @@ namespace UICatalog {
|
|
};
|
|
};
|
|
schemeMenuItems.Add (item);
|
|
schemeMenuItems.Add (item);
|
|
}
|
|
}
|
|
- menuItems.Add (null);
|
|
|
|
|
|
+ menuItems.Add (null!);
|
|
var mbi = new MenuBarItem ("_Color Scheme for Application.Top", schemeMenuItems.ToArray ());
|
|
var mbi = new MenuBarItem ("_Color Scheme for Application.Top", schemeMenuItems.ToArray ());
|
|
menuItems.Add (mbi);
|
|
menuItems.Add (mbi);
|
|
|
|
|
|
@@ -635,18 +638,19 @@ namespace UICatalog {
|
|
}
|
|
}
|
|
|
|
|
|
_themeMenuItems = ((UICatalogTopLevel)Application.Top).CreateThemeMenuItems ();
|
|
_themeMenuItems = ((UICatalogTopLevel)Application.Top).CreateThemeMenuItems ();
|
|
- _themeMenuBarItem.Children = _themeMenuItems;
|
|
|
|
|
|
+ _themeMenuBarItem!.Children = _themeMenuItems;
|
|
|
|
|
|
- var checkedThemeMenu = _themeMenuItems.Where (m => (bool)m.Checked).FirstOrDefault ();
|
|
|
|
|
|
+ var checkedThemeMenu = _themeMenuItems?.Where (m => m?.Checked ?? false).FirstOrDefault ();
|
|
if (checkedThemeMenu != null) {
|
|
if (checkedThemeMenu != null) {
|
|
checkedThemeMenu.Checked = false;
|
|
checkedThemeMenu.Checked = false;
|
|
}
|
|
}
|
|
- checkedThemeMenu = _themeMenuItems.Where (m => m != null && m.Title == ConfigurationManager.Themes.Theme).FirstOrDefault ();
|
|
|
|
|
|
+ checkedThemeMenu = _themeMenuItems?.Where (m => m != null && m.Title == ConfigurationManager.Themes?.Theme).FirstOrDefault ();
|
|
if (checkedThemeMenu != null) {
|
|
if (checkedThemeMenu != null) {
|
|
- ConfigurationManager.Themes.Theme = checkedThemeMenu.Title.ToString ();
|
|
|
|
|
|
+ ConfigurationManager.Themes!.Theme = checkedThemeMenu.Title.ToString ()!;
|
|
checkedThemeMenu.Checked = true;
|
|
checkedThemeMenu.Checked = true;
|
|
}
|
|
}
|
|
- var schemeMenuItems = ((MenuBarItem)_themeMenuItems.Where (i => i is MenuBarItem).FirstOrDefault ()).Children;
|
|
|
|
|
|
+
|
|
|
|
+ var schemeMenuItems = ((MenuBarItem)_themeMenuItems?.Where (i => i is MenuBarItem)!.FirstOrDefault ()!)!.Children;
|
|
foreach (var schemeMenuItem in schemeMenuItems) {
|
|
foreach (var schemeMenuItem in schemeMenuItems) {
|
|
schemeMenuItem.Checked = (string)schemeMenuItem.Data == _topLevelColorScheme;
|
|
schemeMenuItem.Checked = (string)schemeMenuItem.Data == _topLevelColorScheme;
|
|
}
|
|
}
|
|
@@ -659,8 +663,8 @@ namespace UICatalog {
|
|
StatusBar.Items [0].Shortcut = Application.QuitKey;
|
|
StatusBar.Items [0].Shortcut = Application.QuitKey;
|
|
StatusBar.Items [0].Title = $"~{Application.QuitKey} to quit";
|
|
StatusBar.Items [0].Title = $"~{Application.QuitKey} to quit";
|
|
|
|
|
|
- miIsMouseDisabled.Checked = Application.IsMouseDisabled;
|
|
|
|
- miEnableConsoleScrolling.Checked = Application.EnableConsoleScrolling;
|
|
|
|
|
|
+ miIsMouseDisabled!.Checked = Application.IsMouseDisabled;
|
|
|
|
+ miEnableConsoleScrolling!.Checked = Application.EnableConsoleScrolling;
|
|
|
|
|
|
var height = (UICatalogApp.ShowStatusBar ? 1 : 0);// + (MenuBar.Visible ? 1 : 0);
|
|
var height = (UICatalogApp.ShowStatusBar ? 1 : 0);// + (MenuBar.Visible ? 1 : 0);
|
|
ContentPane.Height = Dim.Fill (height);
|
|
ContentPane.Height = Dim.Fill (height);
|
|
@@ -670,9 +674,9 @@ namespace UICatalog {
|
|
Application.Top.SetNeedsDisplay ();
|
|
Application.Top.SetNeedsDisplay ();
|
|
}
|
|
}
|
|
|
|
|
|
- void KeyDownHandler (object sender, KeyEventEventArgs a)
|
|
|
|
|
|
+ void KeyDownHandler (object? sender, KeyEventEventArgs? a)
|
|
{
|
|
{
|
|
- if (a.KeyEvent.IsCapslock) {
|
|
|
|
|
|
+ if (a!.KeyEvent.IsCapslock) {
|
|
Capslock.Title = "Caps: On";
|
|
Capslock.Title = "Caps: On";
|
|
StatusBar.SetNeedsDisplay ();
|
|
StatusBar.SetNeedsDisplay ();
|
|
} else {
|
|
} else {
|
|
@@ -680,7 +684,7 @@ namespace UICatalog {
|
|
StatusBar.SetNeedsDisplay ();
|
|
StatusBar.SetNeedsDisplay ();
|
|
}
|
|
}
|
|
|
|
|
|
- if (a.KeyEvent.IsNumlock) {
|
|
|
|
|
|
+ if (a!.KeyEvent.IsNumlock) {
|
|
Numlock.Title = "Num: On";
|
|
Numlock.Title = "Num: On";
|
|
StatusBar.SetNeedsDisplay ();
|
|
StatusBar.SetNeedsDisplay ();
|
|
} else {
|
|
} else {
|
|
@@ -688,7 +692,7 @@ namespace UICatalog {
|
|
StatusBar.SetNeedsDisplay ();
|
|
StatusBar.SetNeedsDisplay ();
|
|
}
|
|
}
|
|
|
|
|
|
- if (a.KeyEvent.IsScrolllock) {
|
|
|
|
|
|
+ if (a!.KeyEvent.IsScrolllock) {
|
|
Scrolllock.Title = "Scroll: On";
|
|
Scrolllock.Title = "Scroll: On";
|
|
StatusBar.SetNeedsDisplay ();
|
|
StatusBar.SetNeedsDisplay ();
|
|
} else {
|
|
} else {
|
|
@@ -697,16 +701,16 @@ namespace UICatalog {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- void CategoryListView_SelectedChanged (object sender, ListViewItemEventArgs e)
|
|
|
|
|
|
+ void CategoryListView_SelectedChanged (object? sender, ListViewItemEventArgs? e)
|
|
{
|
|
{
|
|
- var item = _categories [e.Item];
|
|
|
|
|
|
+ var item = _categories! [e!.Item];
|
|
List<Scenario> newlist;
|
|
List<Scenario> newlist;
|
|
if (e.Item == 0) {
|
|
if (e.Item == 0) {
|
|
// First category is "All"
|
|
// First category is "All"
|
|
- newlist = _scenarios;
|
|
|
|
|
|
+ newlist = _scenarios!;
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- newlist = _scenarios.Where (s => s.GetCategories ().Contains (item)).ToList ();
|
|
|
|
|
|
+ newlist = _scenarios!.Where (s => s.GetCategories ().Contains (item)).ToList ();
|
|
}
|
|
}
|
|
ScenarioListView.SetSource (newlist.ToList ());
|
|
ScenarioListView.SetSource (newlist.ToList ());
|
|
}
|
|
}
|