Răsfoiți Sursa

Init->Main in Buttons scenario

Tig 1 an în urmă
părinte
comite
f3c3825f34
2 a modificat fișierele cu 28 adăugiri și 25 ștergeri
  1. 28 22
      UICatalog/Scenarios/Buttons.cs
  2. 0 3
      UICatalog/Scenarios/CharacterMap.cs

+ 28 - 22
UICatalog/Scenarios/Buttons.cs

@@ -9,21 +9,25 @@ namespace UICatalog.Scenarios;
 [ScenarioCategory ("Layout")]
 public class Buttons : Scenario
 {
-    public override void Setup ()
+    public override void Main ()
     {
+        Window main = new ()
+        {
+            Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}",
+        };
         // Add a label & text field so we can demo IsDefault
         var editLabel = new Label { X = 0, Y = 0, TabStop = true, Text = "TextField (to demo IsDefault):" };
-        Win.Add (editLabel);
+        main.Add (editLabel);
 
         // Add a TextField using Absolute layout. 
         var edit = new TextField { X = 31, Width = 15, HotKey = Key.Y.WithAlt };
-        Win.Add (edit);
+        main.Add (edit);
 
         // This is the default button (IsDefault = true); if user presses ENTER in the TextField
         // the scenario will quit
         var defaultButton = new Button { X = Pos.Center (), Y = Pos.AnchorEnd (1), IsDefault = true, Text = "_Quit" };
         defaultButton.Accept += (s, e) => Application.RequestStop ();
-        Win.Add (defaultButton);
+        main.Add (defaultButton);
 
         var swapButton = new Button { X = 50, Text = "S_wap Default (Absolute Layout)" };
 
@@ -32,7 +36,7 @@ public class Buttons : Scenario
                                   defaultButton.IsDefault = !defaultButton.IsDefault;
                                   swapButton.IsDefault = !swapButton.IsDefault;
                               };
-        Win.Add (swapButton);
+        main.Add (swapButton);
 
         static void DoMessage (Button button, string txt)
         {
@@ -44,7 +48,7 @@ public class Buttons : Scenario
         }
 
         var colorButtonsLabel = new Label { X = 0, Y = Pos.Bottom (editLabel) + 1, Text = "Color Buttons:" };
-        Win.Add (colorButtonsLabel);
+        main.Add (colorButtonsLabel);
 
         View prev = colorButtonsLabel;
 
@@ -63,7 +67,7 @@ public class Buttons : Scenario
                 Text = $"_{colorScheme.Key}"
             };
             DoMessage (colorButton, colorButton.Text);
-            Win.Add (colorButton);
+            main.Add (colorButton);
             prev = colorButton;
 
             // BUGBUG: AutoSize is true and the X doesn't change
@@ -72,7 +76,7 @@ public class Buttons : Scenario
 
         Button button;
 
-        Win.Add (
+        main.Add (
                  button = new Button
                  {
                      X = 2,
@@ -84,16 +88,16 @@ public class Buttons : Scenario
         DoMessage (button, button.Text);
 
         // Note the 'N' in 'Newline' will be the hotkey
-        Win.Add (
+        main.Add (
                  button = new Button { X = 2, Y = Pos.Bottom (button) + 1, Text = "a Newline\nin the button" }
                 );
         button.Accept += (s, e) => MessageBox.Query ("Message", "Question?", "Yes", "No");
 
         var textChanger = new Button { X = 2, Y = Pos.Bottom (button) + 1, Text = "Te_xt Changer" };
-        Win.Add (textChanger);
+        main.Add (textChanger);
         textChanger.Accept += (s, e) => textChanger.Text += "!";
 
-        Win.Add (
+        main.Add (
                  button = new Button
                  {
                      X = Pos.Right (textChanger) + 2,
@@ -106,13 +110,13 @@ public class Buttons : Scenario
         {
             X = 2, Y = Pos.Bottom (button) + 1, ColorScheme = Colors.ColorSchemes ["Error"], Text = "Remove this button"
         };
-        Win.Add (removeButton);
+        main.Add (removeButton);
 
         // This in interesting test case because `moveBtn` and below are laid out relative to this one!
         removeButton.Accept += (s, e) =>
                                 {
                                     // Now this throw a InvalidOperationException on the TopologicalSort method as is expected.
-                                    //Win.Remove (removeButton);
+                                    //main.Remove (removeButton);
 
                                     removeButton.Visible = false;
                                 };
@@ -125,7 +129,7 @@ public class Buttons : Scenario
             Height = 5,
             Title = "Computed Layout"
         };
-        Win.Add (computedFrame);
+        main.Add (computedFrame);
 
         // Demonstrates how changing the View.Frame property can move Views
         var moveBtn = new Button
@@ -176,7 +180,7 @@ public class Buttons : Scenario
             Height = 5,
             Title = "Absolute Layout"
         };
-        Win.Add (absoluteFrame);
+        main.Add (absoluteFrame);
 
         // Demonstrates how changing the View.Frame property can move Views
         var moveBtnA = new Button { ColorScheme = Colors.ColorSchemes ["Error"], Text = "Move This Button via Frame" };
@@ -213,7 +217,7 @@ public class Buttons : Scenario
         {
             X = 2, Y = Pos.Bottom (computedFrame) + 1, Text = "Text Alignment (changes the four buttons above): "
         };
-        Win.Add (label);
+        main.Add (label);
 
         var radioGroup = new RadioGroup
         {
@@ -222,7 +226,7 @@ public class Buttons : Scenario
             SelectedItem = 2,
             RadioLabels = new [] { "Left", "Right", "Centered", "Justified" }
         };
-        Win.Add (radioGroup);
+        main.Add (radioGroup);
 
         // Demo changing hotkey
         string MoveHotkey (string txt)
@@ -269,7 +273,7 @@ public class Buttons : Scenario
             Text = mhkb
         };
         moveHotKeyBtn.Accept += (s, e) => { moveHotKeyBtn.Text = MoveHotkey (moveHotKeyBtn.Text); };
-        Win.Add (moveHotKeyBtn);
+        main.Add (moveHotKeyBtn);
 
         var muhkb = " ~  s  gui.cs   master ↑10 = Сохранить";
 
@@ -284,7 +288,7 @@ public class Buttons : Scenario
             Text = muhkb
         };
         moveUnicodeHotKeyBtn.Accept += (s, e) => { moveUnicodeHotKeyBtn.Text = MoveHotkey (moveUnicodeHotKeyBtn.Text); };
-        Win.Add (moveUnicodeHotKeyBtn);
+        main.Add (moveUnicodeHotKeyBtn);
 
         radioGroup.SelectedItemChanged += (s, args) =>
         {
@@ -379,7 +383,7 @@ public class Buttons : Scenario
                                numericEdit.Text = $"{int.Parse (numericEdit.Text) + 1}";
                            };
 
-        Win.Add (label, downButton, numericEdit, upButton);
+        main.Add (label, downButton, numericEdit, upButton);
 
         label = new Label ()
         {
@@ -400,8 +404,10 @@ public class Buttons : Scenario
                                    repeatButton.Title = $"Accept Count: {++acceptCount}";
                                };
 
-        Win.Add(label, repeatButton);
+        main.Add(label, repeatButton);
 
-        Top.Ready += (s, e) => radioGroup.Refresh ();
+        main.Ready += (s, e) => radioGroup.Refresh ();
+        Application.Run (main);
+        main.Dispose ();
     }
 }

+ 0 - 3
UICatalog/Scenarios/CharacterMap.cs

@@ -1,6 +1,3 @@
-#define DRAW_CONTENT
-
-//#define BASE_DRAW_CONTENT
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;