mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Fixed force16color logic
This commit is contained in:
@@ -253,7 +253,7 @@ namespace Terminal.Gui {
|
||||
/// Gets or sets the <see cref="Color"/> using a legacy 16-color <see cref="ColorNames"/> value.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Get returns the closest 24-bit color value. Set sets the RGB value using a hard-coded map.
|
||||
/// Get returns the <see cref="ColorName"/> of the closest 24-bit color value. Set sets the RGB value using a hard-coded map.
|
||||
/// </remarks>
|
||||
public ColorNames ColorName {
|
||||
get => FindClosestColor (this.Value);
|
||||
|
||||
@@ -38,10 +38,10 @@ namespace UICatalog.Scenarios {
|
||||
var cbUseTrueColor = new CheckBox ("Use true color") {
|
||||
X = x,
|
||||
Y = y++,
|
||||
Checked = Application.Driver.Force16Colors,
|
||||
Checked = !Application.Driver.Force16Colors,
|
||||
Enabled = canTrueColor,
|
||||
};
|
||||
cbUseTrueColor.Toggled += (_, evt) => Application.Driver.Force16Colors = evt.NewValue ?? false;
|
||||
cbUseTrueColor.Toggled += (_, evt) => Application.Driver.Force16Colors = !evt.NewValue ?? false;
|
||||
Win.Add (cbUseTrueColor);
|
||||
|
||||
var btnOpenImage = new Button ("Open Image") {
|
||||
@@ -60,11 +60,16 @@ namespace UICatalog.Scenarios {
|
||||
|
||||
|
||||
btnOpenImage.Clicked += (_, _) => {
|
||||
var ofd = new OpenDialog ("Open Image") { AllowsMultipleSelection = false };
|
||||
var ofd = new OpenDialog ("Open Image") { AllowsMultipleSelection = false, };
|
||||
Application.Run (ofd);
|
||||
|
||||
if (ofd.Canceled)
|
||||
if (ofd.Path is not null) {
|
||||
Directory.SetCurrentDirectory (Path.GetFullPath(Path.GetDirectoryName(ofd.Path)!));
|
||||
}
|
||||
|
||||
if (ofd.Canceled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var path = ofd.FilePaths [0];
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ namespace UICatalog {
|
||||
scenario.Theme = _cachedTheme;
|
||||
scenario.TopLevelColorScheme = _topLevelColorScheme;
|
||||
scenario.Init ();
|
||||
Application.Driver.Force16Colors = _force16Colors;
|
||||
scenario.Setup ();
|
||||
scenario.Run ();
|
||||
scenario.Dispose ();
|
||||
@@ -231,6 +232,7 @@ namespace UICatalog {
|
||||
static Scenario? _selectedScenario = null;
|
||||
|
||||
static bool _useSystemConsole = false;
|
||||
static bool _force16Colors = false;
|
||||
static ConsoleDriver.DiagnosticFlags _diagnosticFlags;
|
||||
static bool _isFirstRunning = true;
|
||||
static string _topLevelColorScheme = string.Empty;
|
||||
@@ -532,12 +534,13 @@ namespace UICatalog {
|
||||
{
|
||||
List<MenuItem> menuItems = new List<MenuItem> ();
|
||||
miForce16Colors = new MenuItem {
|
||||
Title = "Force 16 _Colors"
|
||||
Title = "Force 16 _Colors",
|
||||
Checked = _force16Colors
|
||||
};
|
||||
miForce16Colors.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miForce16Colors!.Title!.Substring (10, 1) [0];
|
||||
miForce16Colors.CheckType |= MenuItemCheckStyle.Checked;
|
||||
miForce16Colors.Action += () => {
|
||||
miForce16Colors.Checked = Application.Driver.Force16Colors = (bool)!miForce16Colors.Checked!;
|
||||
miForce16Colors.Checked = _force16Colors = Application.Driver.Force16Colors = (bool)!miForce16Colors.Checked!;
|
||||
Application.Refresh ();
|
||||
};
|
||||
menuItems.Add (miForce16Colors);
|
||||
|
||||
Reference in New Issue
Block a user