ShadowStyles.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. Id = "app",
  19. Title = GetQuitKeyAndName ()
  20. };
  21. var editor = new AdornmentsEditor ()
  22. {
  23. Id = "editor",
  24. AutoSelectViewToEdit = true,
  25. ShowViewIdentifier = true,
  26. };
  27. editor.Initialized += (sender, args) => editor.MarginEditor.ExpanderButton.Collapsed = false;
  28. app.Add (editor);
  29. Window shadowWindow = new ()
  30. {
  31. Id = "shadowWindow",
  32. X = Pos.Right (editor),
  33. Y = 0,
  34. Width = Dim.Percent (30),
  35. Height = Dim.Percent (30),
  36. Title = "Shadow Window",
  37. Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped,
  38. BorderStyle = LineStyle.Double,
  39. ShadowStyle = ShadowStyle.Transparent,
  40. };
  41. app.DrawingContent += (s, e) =>
  42. {
  43. app!.FillRect (app!.Viewport, Glyphs.Dot);
  44. e.Cancel = true;
  45. };
  46. var buttonInWin = new Button
  47. {
  48. Id = "buttonInWin",
  49. X = Pos.Center (),
  50. Y = Pos.Center (), Text = "Button in Window",
  51. ShadowStyle = ShadowStyle.Opaque
  52. };
  53. shadowWindow.Add (buttonInWin);
  54. app.Add (shadowWindow);
  55. var button = new Button
  56. {
  57. Id = "button",
  58. X = Pos.Right (editor) + 10,
  59. Y = Pos.Center (), Text = "Button",
  60. ShadowStyle = ShadowStyle.Opaque
  61. };
  62. ColorPicker colorPicker = new ()
  63. {
  64. Title = "ColorPicker to illustrate highlight (currently broken)",
  65. BorderStyle = LineStyle.Dotted,
  66. Id = "colorPicker16",
  67. X = Pos.Center (),
  68. Y = Pos.AnchorEnd (),
  69. Width = Dim.Percent(80),
  70. };
  71. colorPicker.ColorChanged += (sender, args) =>
  72. {
  73. var normal = app.GetScheme ().Normal;
  74. app.SetScheme (app.GetScheme() with {Normal = new Attribute(normal.Foreground, args.CurrentValue)});
  75. };
  76. app.Add (button, colorPicker);
  77. editor.AutoSelectViewToEdit = true;
  78. editor.AutoSelectSuperView = app;
  79. editor.AutoSelectAdornments = false;
  80. Application.Run (app);
  81. app.Dispose ();
  82. Application.Shutdown ();
  83. }
  84. }