ShadowStyles.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Diagnostics.Metrics;
  5. using System.Linq;
  6. namespace UICatalog.Scenarios;
  7. [ScenarioMetadata ("ShadowStyles Demo", "Demonstrates ShadowStyles Effects.")]
  8. [ScenarioCategory ("Layout")]
  9. [ScenarioCategory ("Adornments")]
  10. public class ShadowStyles : Scenario
  11. {
  12. public override void Main ()
  13. {
  14. Application.Init ();
  15. Window app = new ()
  16. {
  17. Id = "app",
  18. Title = GetQuitKeyAndName ()
  19. };
  20. var editor = new AdornmentsEditor ()
  21. {
  22. Id = "editor",
  23. AutoSelectViewToEdit = true,
  24. ShowViewIdentifier = true,
  25. };
  26. editor.Initialized += (sender, args) => editor.MarginEditor.ExpanderButton.Collapsed = false;
  27. app.Add (editor);
  28. Window shadowWindow = new ()
  29. {
  30. Id = "shadowWindow",
  31. X = Pos.Right (editor),
  32. Y = 0,
  33. Width = Dim.Percent (30),
  34. Height = Dim.Percent (30),
  35. Title = "Shadow Window",
  36. Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped,
  37. BorderStyle = LineStyle.Double,
  38. ShadowStyle = ShadowStyle.Transparent,
  39. };
  40. app.DrawingContent += (s, e) =>
  41. {
  42. app!.FillRect (app!.Viewport, Glyphs.Dot);
  43. e.Cancel = true;
  44. };
  45. var buttonInWin = new Button
  46. {
  47. Id = "buttonInWin",
  48. X = Pos.Center (),
  49. Y = Pos.Center (), Text = "Button in Window",
  50. ShadowStyle = ShadowStyle.Opaque
  51. };
  52. shadowWindow.Add (buttonInWin);
  53. app.Add (shadowWindow);
  54. var button = new Button
  55. {
  56. Id = "button",
  57. X = Pos.Right (editor) + 10,
  58. Y = Pos.Center (), Text = "Button",
  59. ShadowStyle = ShadowStyle.Opaque
  60. };
  61. ColorPicker colorPicker = new ()
  62. {
  63. Title = "ColorPicker to illustrate highlight (currently broken)",
  64. BorderStyle = LineStyle.Dotted,
  65. Id = "colorPicker16",
  66. X = Pos.Center (),
  67. Y = Pos.AnchorEnd (),
  68. Width = Dim.Percent(80),
  69. };
  70. colorPicker.ColorChanged += (sender, args) =>
  71. {
  72. var normal = app.GetScheme ().Normal;
  73. app.SetScheme (app.GetScheme() with {Normal = new Attribute(normal.Foreground, args.Result)});
  74. };
  75. app.Add (button, colorPicker);
  76. editor.AutoSelectViewToEdit = true;
  77. editor.AutoSelectSuperView = app;
  78. editor.AutoSelectAdornments = false;
  79. Application.Run (app);
  80. app.Dispose ();
  81. Application.Shutdown ();
  82. }
  83. }