EventEditorControl.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using InABox.WPF;
  2. using PRS.Shared.Events;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Media;
  11. namespace PRS.Shared;
  12. public class EventEditorControl<TEvent, TDataModel> : Grid
  13. where TEvent : IEvent<TDataModel>
  14. where TDataModel : IEventDataModel
  15. {
  16. public EventData<TEvent, TDataModel> Data { get; set; }
  17. public EventEditorControl(EventData<TEvent, TDataModel> evData)
  18. {
  19. Data = evData;
  20. var triggerLabelBorder = new Border
  21. {
  22. BorderBrush = Colors.Gray.ToBrush(),
  23. BorderThickness = new(0.75),
  24. Background = Colors.WhiteSmoke.ToBrush(),
  25. Child = new Label
  26. {
  27. Content = "Triggers",
  28. VerticalAlignment = System.Windows.VerticalAlignment.Center,
  29. HorizontalAlignment = System.Windows.HorizontalAlignment.Center
  30. }
  31. };
  32. var actionsLabelBorder = new Border
  33. {
  34. BorderBrush = Colors.Gray.ToBrush(),
  35. BorderThickness = new(0.75),
  36. Background = Colors.WhiteSmoke.ToBrush(),
  37. Child = new Label
  38. {
  39. Content = "Actions",
  40. VerticalAlignment = System.Windows.VerticalAlignment.Center,
  41. HorizontalAlignment = System.Windows.HorizontalAlignment.Center
  42. }
  43. };
  44. var separator = new StackPanel
  45. {
  46. Orientation = Orientation.Horizontal,
  47. };
  48. separator.Children.Add(new Separator
  49. {
  50. Style = (Style)Application.Current.TryFindResource(ToolBar.SeparatorStyleKey),
  51. Margin = new(3, 0, 3, 0)
  52. });
  53. var triggersGrid = new EventTriggerGrid<TEvent, TDataModel>(Data.Triggers)
  54. {
  55. Margin = new(0, 5, 0, 0)
  56. };
  57. var actionsControl = new ContentControl
  58. {
  59. Margin = new(0, 5, 0, 0),
  60. Content = new Border
  61. {
  62. BorderBrush = Colors.Gray.ToBrush(),
  63. BorderThickness = new(0.75),
  64. Background = Colors.White.ToBrush()
  65. }
  66. };
  67. this.AddRow(GridUnitType.Auto);
  68. this.AddRow(GridUnitType.Star);
  69. this.AddColumn(GridUnitType.Star);
  70. this.AddColumn(GridUnitType.Auto);
  71. this.AddColumn(GridUnitType.Star);
  72. this.AddChild(triggerLabelBorder, 0, 0);
  73. this.AddChild(separator, 0, 1, rowSpan: 2);
  74. this.AddChild(actionsLabelBorder, 0, 2);
  75. this.AddChild(triggersGrid, 1, 0);
  76. this.AddChild(actionsControl, 1, 2);
  77. triggersGrid.Refresh(true, true);
  78. }
  79. }