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 LeftElements = new(); private readonly List 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 GetLeftElements() => LeftElements; public IEnumerable GetRightElements() => RightElements; } public interface IHeaderDashboard { DashboardHeader Header { get; } } }