From e10564389c2a18e9e9ceb55b9314d4d4ac1bad6f Mon Sep 17 00:00:00 2001 From: Tig Date: Mon, 15 Jul 2024 09:27:23 -0600 Subject: [PATCH] Updated About box --- UICatalog/UICatalog.cs | 102 +++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs index ab616f12e..1218c701f 100644 --- a/UICatalog/UICatalog.cs +++ b/UICatalog/UICatalog.cs @@ -1,4 +1,4 @@ -global using Attribute = Terminal.Gui.Attribute; +global using Attribute = Terminal.Gui.Attribute; global using CM = Terminal.Gui.ConfigurationManager; using System; using System.Collections.Generic; @@ -295,6 +295,7 @@ internal class UICatalogApp _selectedScenario.Main (); _selectedScenario.Dispose (); _selectedScenario = null; + // TODO: Throw if shutdown was not called already Application.Shutdown (); VerifyObjectsWereDisposed (); @@ -302,20 +303,6 @@ internal class UICatalogApp return; } - _aboutMessage = new (); - _aboutMessage.AppendLine (@"A comprehensive sample library for"); - _aboutMessage.AppendLine (@""); - _aboutMessage.AppendLine (@" _______ _ _ _____ _ "); - _aboutMessage.AppendLine (@"|__ __| (_) | | / ____| (_)"); - _aboutMessage.AppendLine (@" | | ___ _ __ _ __ ___ _ _ __ __ _| || | __ _ _ _ "); - _aboutMessage.AppendLine (@" | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | |"); - _aboutMessage.AppendLine (@" | | __/ | | | | | | | | | | | (_| | || |__| | |_| | |"); - _aboutMessage.AppendLine (@" |_|\___|_| |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_|"); - _aboutMessage.AppendLine (@""); - _aboutMessage.AppendLine (@"v2 - Work in Progress"); - _aboutMessage.AppendLine (@""); - _aboutMessage.AppendLine (@"https://github.com/gui-cs/Terminal.Gui"); - while (RunUICatalogTopLevel () is { } scenario) { VerifyObjectsWereDisposed (); @@ -346,7 +333,6 @@ internal class UICatalogApp // 'app' closed cleanly. foreach (Responder? inst in Responder.Instances) { - Debug.Assert (inst.WasDisposed); } @@ -375,7 +361,9 @@ internal class UICatalogApp public MenuItem? MiIsMenuBorderDisabled; public MenuItem? MiIsMouseDisabled; public MenuItem? MiUseSubMenusSingleFrame; + public Shortcut? ShForce16Colors; + //public Shortcut? ShDiagnostics; public Shortcut? ShVersion; @@ -388,11 +376,27 @@ internal class UICatalogApp public UICatalogTopLevel () { - _diagnosticFlags = View.Diagnostics; + _diagnosticFlags = Diagnostics; _themeMenuItems = CreateThemeMenuItems (); _themeMenuBarItem = new ("_Themes", _themeMenuItems); + _aboutMessage = new (); + _aboutMessage.AppendLine (@"A comprehensive sample library for"); + _aboutMessage.AppendLine ( + """ + _______ _ _ _____ _ + |__ __| (_) | | / ____| (_) + | | ___ _ __ _ __ ___ _ _ __ __ _| || | __ _ _ _ + | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | | + | | __/ | | | | | | | | | | | (_| | || |__| | |_| | | + |_|\___|_| |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_| + """); + _aboutMessage.AppendLine (@""); + _aboutMessage.AppendLine (@"v2 - Pre-Alpha"); + _aboutMessage.AppendLine (@""); + _aboutMessage.Append (@"https://github.com/gui-cs/Terminal.Gui"); + MenuBar = new () { Menus = @@ -436,9 +440,8 @@ internal class UICatalogApp () => MessageBox.Query ( "About UI Catalog", _aboutMessage!.ToString (), - 0, - false, - "_Ok" + wrapMessage: false, + buttons: "_Ok" ), null, null, @@ -460,35 +463,34 @@ internal class UICatalogApp ShVersion = new () { Title = "Version Info", - CanFocus = false, - + CanFocus = false }; - Shortcut statusBarShortcut = new Shortcut () + var statusBarShortcut = new Shortcut { Key = Key.F10, - Title = "Show/Hide Status Bar", + Title = "Show/Hide Status Bar" }; statusBarShortcut.Accept += (sender, args) => { StatusBar.Visible = !StatusBar.Visible; }; - ShForce16Colors = new Shortcut () + ShForce16Colors = new() { - CommandView = new CheckBox () + CommandView = new CheckBox { Title = "16 color mode", State = Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked, - CanFocus = false, + CanFocus = false }, HelpText = "", - Key = Key.F6, + Key = Key.F6 }; ((CheckBox)ShForce16Colors.CommandView).Toggle += (sender, args) => - { - Application.Force16Colors = args.NewValue == CheckState.Checked; - MiForce16Colors!.Checked = Application.Force16Colors; - Application.Refresh (); - }; + { + Application.Force16Colors = args.NewValue == CheckState.Checked; + MiForce16Colors!.Checked = Application.Force16Colors; + Application.Refresh (); + }; //ShDiagnostics = new Shortcut () //{ @@ -503,10 +505,10 @@ internal class UICatalogApp //}; StatusBar.Add ( - new Shortcut () + new Shortcut { Title = "Quit", - Key = Application.QuitKey, + Key = Application.QuitKey }, statusBarShortcut, ShForce16Colors, @@ -846,24 +848,24 @@ internal class UICatalogApp string GetDiagnosticsTitle (Enum diag) { return Enum.GetName (_diagnosticFlags.GetType (), diag) switch - { - "Off" => OFF, - "Ruler" => RULER, - "Padding" => PADDING, - "MouseEnter" => MOUSEENTER, - _ => "" - }; + { + "Off" => OFF, + "Ruler" => RULER, + "Padding" => PADDING, + "MouseEnter" => MOUSEENTER, + _ => "" + }; } Enum GetDiagnosticsEnumValue (string title) { return title switch - { - RULER => ViewDiagnosticFlags.Ruler, - PADDING => ViewDiagnosticFlags.Padding, - MOUSEENTER => ViewDiagnosticFlags.MouseEnter, - _ => null! - }; + { + RULER => ViewDiagnosticFlags.Ruler, + PADDING => ViewDiagnosticFlags.Padding, + MOUSEENTER => ViewDiagnosticFlags.MouseEnter, + _ => null! + }; } void SetDiagnosticsFlag (Enum diag, bool add) @@ -1007,7 +1009,9 @@ internal class UICatalogApp MiForce16Colors.Action += () => { MiForce16Colors.Checked = Application.Force16Colors = (bool)!MiForce16Colors.Checked!; - ((CheckBox)ShForce16Colors!.CommandView!).State = Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked; + + ((CheckBox)ShForce16Colors!.CommandView!).State = + Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked; Application.Refresh (); }; menuItems.Add (MiForce16Colors);