using System.Collections.Generic; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Essentials.Core; namespace PepperDash.Essentials.Core.PageManagers { /// /// The PageManager classes are used to bridge a device to subpage /// visibility. /// public abstract class PageManager { protected List ActiveJoins = new List(); public abstract void Show(); public abstract void Hide(); /// /// For device types 1-49, returns the offset join for subpage management 10100 - 14900 /// /// 1 through 49, as defined in some constants somewhere! /// public uint GetOffsetJoin(uint deviceType) { return 10000 + (deviceType * 100); } } /// /// A simple class that hides and shows the default subpage for a given source type /// public class DefaultPageManager : PageManager { BasicTriList TriList; uint BackingPageJoin; public DefaultPageManager(IUiDisplayInfo device, BasicTriList trilist) { TriList = trilist; BackingPageJoin = GetOffsetJoin(device.DisplayUiType) + 1; } public DefaultPageManager(uint join, BasicTriList trilist) { TriList = trilist; BackingPageJoin = join; } public override void Show() { TriList.BooleanInput[BackingPageJoin].BoolValue = true; } public override void Hide() { TriList.BooleanInput[BackingPageJoin].BoolValue = false; } } /// /// A page manager for a page with backing panel and a switchable side panel /// public abstract class MediumLeftSwitchablePageManager : PageManager { protected BasicTriListWithSmartObject TriList; protected uint LeftSubpageJoin; protected uint BackingPageJoin; protected uint[] AllLeftSubpages; protected uint DisplayUiType; protected MediumLeftSwitchablePageManager(uint displayUiType) { DisplayUiType = displayUiType; } protected void InterlockLeftSubpage(uint join) { join = join + GetOffsetJoin(); ClearLeftInterlock(); TriList.BooleanInput[join].BoolValue = true; LeftSubpageJoin = join; } protected void ClearLeftInterlock() { foreach (var p in AllLeftSubpages) TriList.BooleanInput[GetOffsetJoin() + p].BoolValue = false; } protected uint GetOffsetJoin() { return GetOffsetJoin(DisplayUiType); } } }