Browse Source

Add InvertColors scenario.

BDisp 4 years ago
parent
commit
f256046984
1 changed files with 32 additions and 0 deletions
  1. 32 0
      UICatalog/Scenarios/InvertColors.cs

+ 32 - 0
UICatalog/Scenarios/InvertColors.cs

@@ -0,0 +1,32 @@
+using Terminal.Gui;
+
+namespace UICatalog {
+	[ScenarioMetadata (Name: "Invert Colors", Description: "Invert the foreground and the background colors.")]
+	[ScenarioCategory ("Colors")]
+	class InvertColors : Scenario {
+		public override void Setup ()
+		{
+			Win.ColorScheme = Colors.TopLevel;
+
+			var color = Application.Driver.MakeAttribute (Color.Red, Color.Blue);
+
+			var label = new Label ("Test") {
+				ColorScheme = new ColorScheme()
+			};
+			label.ColorScheme.Normal = color;
+			Win.Add (label);
+
+			var button = new Button ("Invert color!") {
+				X = Pos.Center (),
+				Y = Pos.Center (),
+			};
+			button.Clicked += () => {
+				color = Application.Driver.MakeAttribute (color.Background, color.Foreground);
+
+				label.ColorScheme.Normal = color;
+				label.SetNeedsDisplay ();
+			};
+			Win.Add (button);
+		}
+	}
+}