| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- using InABox.WPF;
- using PRS.Shared.Events;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- namespace PRS.Shared;
- public class EventEditorControl<TEvent, TDataModel> : Grid
- where TEvent : IEvent<TDataModel>
- where TDataModel : IEventDataModel
- {
- public EventData<TEvent, TDataModel> Data { get; set; }
- public EventEditorControl(EventData<TEvent, TDataModel> evData)
- {
- Data = evData;
- var triggerLabelBorder = new Border
- {
- BorderBrush = Colors.Gray.ToBrush(),
- BorderThickness = new(0.75),
- Background = Colors.WhiteSmoke.ToBrush(),
- Child = new Label
- {
- Content = "Triggers",
- VerticalAlignment = System.Windows.VerticalAlignment.Center,
- HorizontalAlignment = System.Windows.HorizontalAlignment.Center
- }
- };
- var actionsLabelBorder = new Border
- {
- BorderBrush = Colors.Gray.ToBrush(),
- BorderThickness = new(0.75),
- Background = Colors.WhiteSmoke.ToBrush(),
- Child = new Label
- {
- Content = "Actions",
- VerticalAlignment = System.Windows.VerticalAlignment.Center,
- HorizontalAlignment = System.Windows.HorizontalAlignment.Center
- }
- };
- var separator = new StackPanel
- {
- Orientation = Orientation.Horizontal,
- };
- separator.Children.Add(new Separator
- {
- Style = (Style)Application.Current.TryFindResource(ToolBar.SeparatorStyleKey),
- Margin = new(3, 0, 3, 0)
- });
- var triggersGrid = new EventTriggerGrid<TEvent, TDataModel>(Data.Triggers)
- {
- Margin = new(0, 5, 0, 0)
- };
- var actionsControl = new ContentControl
- {
- Margin = new(0, 5, 0, 0),
- Content = new Border
- {
- BorderBrush = Colors.Gray.ToBrush(),
- BorderThickness = new(0.75),
- Background = Colors.White.ToBrush()
- }
- };
- this.AddRow(GridUnitType.Auto);
- this.AddRow(GridUnitType.Star);
- this.AddColumn(GridUnitType.Star);
- this.AddColumn(GridUnitType.Auto);
- this.AddColumn(GridUnitType.Star);
- this.AddChild(triggerLabelBorder, 0, 0);
- this.AddChild(separator, 0, 1, rowSpan: 2);
- this.AddChild(actionsLabelBorder, 0, 2);
- this.AddChild(triggersGrid, 1, 0);
- this.AddChild(actionsControl, 1, 2);
- triggersGrid.Refresh(true, true);
- }
- }
|