1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using PRS.Shared;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- namespace PRSDesktop
- {
- public delegate void HeaderChangedEvent(DashboardHeader header);
- public class DashboardHeader
- {
- private readonly List<FrameworkElement> LeftElements = new();
- private readonly List<FrameworkElement> RightElements = new();
- private bool Updating = false;
- public event HeaderChangedEvent? HeaderChanged;
- public DashboardHeader BeginUpdate()
- {
- Updating = true;
- return this;
- }
- public DashboardHeader EndUpdate()
- {
- Updating = false;
- Update();
- return this;
- }
- private void Update()
- {
- if (!Updating)
- {
- HeaderChanged?.Invoke(this);
- }
- }
- public DashboardHeader Clear()
- {
- LeftElements.Clear();
- RightElements.Clear();
- Update();
- return this;
- }
- public DashboardHeader Add(FrameworkElement element)
- {
- LeftElements.Add(element);
- Update();
- return this;
- }
- public DashboardHeader AddRight(FrameworkElement element)
- {
- RightElements.Add(element);
- Update();
- return this;
- }
- public IEnumerable<FrameworkElement> GetLeftElements() => LeftElements;
- public IEnumerable<FrameworkElement> GetRightElements() => RightElements;
- }
- public interface IHeaderDashboard
- {
- DashboardHeader Header { get; }
- }
- }
|