ShadowStyles.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Diagnostics.Metrics;
  5. using System.Linq;
  6. using Terminal.Gui;
  7. namespace UICatalog.Scenarios;
  8. [ScenarioMetadata ("ShadowStyles Demo", "Demonstrates ShadowStyles Effects.")]
  9. [ScenarioCategory ("Layout")]
  10. [ScenarioCategory ("Adornments")]
  11. public class ShadowStyles : Scenario
  12. {
  13. public override void Main ()
  14. {
  15. Application.Init ();
  16. Window app = new ()
  17. {
  18. Title = GetQuitKeyAndName ()
  19. };
  20. var editor = new AdornmentsEditor ()
  21. {
  22. AutoSelectViewToEdit = true,
  23. ShowViewIdentifier = true,
  24. };
  25. editor.Initialized += (sender, args) => editor.MarginEditor.ExpanderButton.Collapsed = false;
  26. app.Add (editor);
  27. Window win = new ()
  28. {
  29. X = Pos.Right (editor),
  30. Y = 0,
  31. Width = Dim.Percent (30),
  32. Height = Dim.Percent (30),
  33. Title = "Shadow Window",
  34. Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped,
  35. BorderStyle = LineStyle.Double,
  36. ShadowStyle = ShadowStyle.Transparent,
  37. };
  38. app.DrawingText += (s, e) =>
  39. {
  40. Application.Driver?.FillRect (app.ViewportToScreen (app.Viewport), '*');
  41. e.Cancel = true;
  42. };
  43. var buttonInWin = new Button
  44. {
  45. X = Pos.Center (),
  46. Y = Pos.Center (), Text = "Button in Window",
  47. ShadowStyle = ShadowStyle.Opaque
  48. };
  49. win.Add (buttonInWin);
  50. app.Add (win);
  51. var button = new Button
  52. {
  53. X = Pos.Right (editor) + 10,
  54. Y = Pos.Center (), Text = "Button",
  55. ShadowStyle = ShadowStyle.Opaque
  56. };
  57. app.Add (button);
  58. editor.AutoSelectViewToEdit = true;
  59. editor.AutoSelectSuperView = app;
  60. editor.AutoSelectAdornments = false;
  61. Application.Run (app);
  62. app.Dispose ();
  63. Application.Shutdown ();
  64. }
  65. }