Combining repos

This commit is contained in:
Heath Volmer
2017-03-21 08:36:26 -06:00
parent e196ad0419
commit b5444e3544
358 changed files with 17256 additions and 10215 deletions

View File

@@ -0,0 +1,42 @@
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.PageManagers
{
public class DiscPlayerMediumPageManager : MediumLeftSwitchablePageManager
{
IDiscPlayerControls Player;
public DiscPlayerMediumPageManager(IDiscPlayerControls player, BasicTriListWithSmartObject trilist)
: base(player.DisplayUiType)
{
Player = player;
TriList = trilist;
}
public override void Show()
{
uint offset = GetOffsetJoin();
BackingPageJoin = offset + 1;
AllLeftSubpages = new uint[] { 7, 8 };
if (LeftSubpageJoin == 0)
LeftSubpageJoin = offset + 8; // default to transport
TriList.BooleanInput[BackingPageJoin].BoolValue = true;
TriList.BooleanInput[LeftSubpageJoin].BoolValue = true;
// Attach buttons to interlock
foreach(var p in AllLeftSubpages)
{
var p2 = p; // scope
TriList.SetSigFalseAction(10000 + p2, () => InterlockLeftSubpage(p2));
}
}
public override void Hide()
{
TriList.BooleanInput[BackingPageJoin].BoolValue = false;
TriList.BooleanInput[LeftSubpageJoin].BoolValue = false;
}
}
}

View File

@@ -0,0 +1,96 @@
using System.Collections.Generic;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.PageManagers
{
/// <summary>
/// The PageManager classes are used to bridge a device to subpage
/// visibility.
/// </summary>
public abstract class PageManager
{
protected List<uint> ActiveJoins = new List<uint>();
public abstract void Show();
public abstract void Hide();
/// <summary>
/// For device types 1-49, returns the offset join for subpage management 10100 - 14900
/// </summary>
/// <param name="deviceType">1 through 49, as defined in some constants somewhere!</param>
/// <returns></returns>
public uint GetOffsetJoin(uint deviceType)
{
return 10000 + (deviceType * 100);
}
}
/// <summary>
/// A simple class that hides and shows the default subpage for a given source type
/// </summary>
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;
}
}
/// <summary>
/// A page manager for a page with backing panel and a switchable side panel
/// </summary>
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);
}
}
}

View File

@@ -0,0 +1,192 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Presets;
namespace PepperDash.Essentials.Core.PageManagers
{
public class ThreePanelPlusOnePageManager : PageManager
{
protected BasicTriListWithSmartObject TriList;
public uint Position5TabsId { get; set; }
/// <summary>
/// Show the tabs on the third panel
/// </summary>
protected bool ShowPosition5Tabs;
/// <summary>
/// Joins that are always visible when this manager is visible
/// </summary>
protected uint[] FixedVisibilityJoins;
/// <summary>
///
/// </summary>
protected uint CurrentVisiblePosition5Item;
/// <summary>
///
/// </summary>
/// <param name="trilist"></param>
public ThreePanelPlusOnePageManager(BasicTriListWithSmartObject trilist)
{
TriList = trilist;
CurrentVisiblePosition5Item = 1;
}
/// <summary>
/// The joins for the switchable panel in position 5
/// </summary>
Dictionary<uint, uint> Position5SubpageJoins = new Dictionary<uint, uint>
{
{ 1, 10053 },
{ 2, 10054 }
};
/// <summary>
///
/// </summary>
public override void Show()
{
// Project the joins into corresponding sigs.
var fixedSigs = FixedVisibilityJoins.Select(u => TriList.BooleanInput[u]).ToList();
foreach (var sig in fixedSigs)
sig.BoolValue = true;
if (ShowPosition5Tabs)
{
// Show selected tab
TriList.BooleanInput[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = true;
// hook up tab object
var tabSo = TriList.SmartObjects[Position5TabsId];
tabSo.BooleanOutput["Tab Button 1 Press"].UserObject = new Action<bool>(b => { if (!b) ShowTab(1); });
tabSo.BooleanOutput["Tab Button 2 Press"].UserObject = new Action<bool>(b => { if (!b) ShowTab(2); });
tabSo.SigChange -= tabSo_SigChange;
tabSo.SigChange += tabSo_SigChange;
}
}
void tabSo_SigChange(Crestron.SimplSharpPro.GenericBase currentDevice, Crestron.SimplSharpPro.SmartObjectEventArgs args)
{
var uo = args.Sig.UserObject;
if(uo is Action<bool>)
(uo as Action<bool>)(args.Sig.BoolValue);
}
public override void Hide()
{
var fixedSigs = FixedVisibilityJoins.Select(u => TriList.BooleanInput[u]).ToList();
foreach (var sig in fixedSigs)
sig.BoolValue = false;
if (ShowPosition5Tabs)
{
TriList.BooleanInput[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = false;
//var tabSo = TriList.SmartObjects[Position5TabsId];
//tabSo.BooleanOutput["Tab Button 1 Press"].UserObject = null;
//tabSo.BooleanOutput["Tab Button 2 Press"].UserObject = null;
}
}
void ShowTab(uint number)
{
// Ignore re-presses
if (CurrentVisiblePosition5Item == number) return;
// Swap subpage
var bi = TriList.BooleanInput;
if (CurrentVisiblePosition5Item > 0)
bi[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = false;
CurrentVisiblePosition5Item = number;
bi[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = true;
}
}
public class SetTopBoxThreePanelPageManager : ThreePanelPlusOnePageManager
{
ISetTopBoxControls SetTopBox;
DevicePresetsView PresetsView;
public uint DpadSmartObjectId { get; set; }
public uint NumberPadSmartObjectId { get; set; }
public uint PresetsSmartObjectId { get; set; }
/// <summary>
/// A page manager for set top box that shows some combination of four different panels,
/// in three slots on the page.
/// </summary>
/// <param name="stb"></param>
/// <param name="trilist"></param>
public SetTopBoxThreePanelPageManager(ISetTopBoxControls stb, BasicTriListWithSmartObject trilist)
: base(trilist)
{
SetTopBox = stb;
TriList = trilist;
DpadSmartObjectId = 10011;
NumberPadSmartObjectId = 10014;
PresetsSmartObjectId = 10012;
Position5TabsId = 10081;
bool dpad = stb.HasDpad;
bool preset = stb.HasPresets;
bool dvr = stb.HasDvr;
bool numbers = stb.HasNumeric;
if (dpad && !preset && !dvr && !numbers) FixedVisibilityJoins = new uint[] { 10031, 10091 };
else if (!dpad && preset && !dvr && !numbers) FixedVisibilityJoins = new uint[] { 10032, 10091 };
else if (!dpad && !preset && dvr && !numbers) FixedVisibilityJoins = new uint[] { 10033, 10091 };
else if (!dpad && !preset && !dvr && numbers) FixedVisibilityJoins = new uint[] { 10034, 10091 };
else if (dpad && preset && !dvr && !numbers) FixedVisibilityJoins = new uint[] { 10042, 10021, 10092 };
else if (dpad && !preset && dvr && !numbers) FixedVisibilityJoins = new uint[] { 10043, 10021, 10092 };
else if (dpad && !preset && !dvr && numbers) FixedVisibilityJoins = new uint[] { 10044, 10021, 10092 };
else if (!dpad && preset && dvr && !numbers) FixedVisibilityJoins = new uint[] { 10043, 10022, 10092 };
else if (!dpad && preset && !dvr && numbers) FixedVisibilityJoins = new uint[] { 10044, 10022, 10092 };
else if (!dpad && !preset && dvr && numbers) FixedVisibilityJoins = new uint[] { 10044, 10023, 10092 };
else if (dpad && preset && dvr && !numbers) FixedVisibilityJoins = new uint[] { 10053, 10032, 10011, 10093 };
else if (dpad && preset && !dvr && numbers) FixedVisibilityJoins = new uint[] { 10054, 10032, 10011, 10093 };
else if (dpad && !preset && dvr && numbers) FixedVisibilityJoins = new uint[] { 10054, 10033, 10011, 10093 };
else if (!dpad && preset && dvr && numbers) FixedVisibilityJoins = new uint[] { 10054, 10033, 10012, 10093 };
else if (dpad && preset && dvr && numbers)
{
FixedVisibilityJoins = new uint[] { 10081, 10032, 10011, 10093 }; // special case
ShowPosition5Tabs = true;
}
// Bad config case
else
{
Debug.Console(1, stb, "WARNING: Not configured to show any UI elements");
FixedVisibilityJoins = new uint[] { 10091 };
}
// Build presets
if (stb.HasPresets && stb.PresetsModel != null)
{
PresetsView = new DevicePresetsView(trilist, stb.PresetsModel);
}
}
public override void Show()
{
if(PresetsView != null)
PresetsView.Attach();
base.Show();
}
public override void Hide()
{
if (PresetsView != null)
PresetsView.Detach();
base.Hide();
}
}
}

View File

@@ -0,0 +1,60 @@
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Presets;
namespace PepperDash.Essentials.Core.PageManagers
{
/// <summary>
/// A fixed-layout page manager that expects a DPad on the right, fixed portion of the page, and a two/three
/// tab switchable area on the left for presets, numeric and transport controls
/// </summary>
public class SetTopBoxMediumPageManager : MediumLeftSwitchablePageManager
{
ISetTopBoxControls SetTopBox;
DevicePresetsView PresetsView;
public SetTopBoxMediumPageManager(ISetTopBoxControls stb, BasicTriListWithSmartObject trilist)
: base(stb.DisplayUiType)
{
SetTopBox = stb;
TriList = trilist;
if(stb.PresetsModel != null)
PresetsView = new DevicePresetsView(trilist, stb.PresetsModel);
}
public override void Show()
{
if(PresetsView != null)
PresetsView.Attach();
uint offset = GetOffsetJoin();
if (SetTopBox.HasDvr) // Show backing page with DVR controls
{
BackingPageJoin = offset + 1;
AllLeftSubpages = new uint[] { 6, 7, 8 };
}
else // Show the backing page with no DVR controls
{
BackingPageJoin = offset + 2;
AllLeftSubpages = new uint[] { 6, 7 };
}
if (LeftSubpageJoin == 0)
LeftSubpageJoin = offset + 6; // default to presets
TriList.BooleanInput[BackingPageJoin].BoolValue = true;
TriList.BooleanInput[LeftSubpageJoin].BoolValue = true;
// Attach buttons to interlock
foreach(var p in AllLeftSubpages)
{
var p2 = p; // scope
TriList.SetSigFalseAction(10000 + p2, () => InterlockLeftSubpage(p2));
}
}
public override void Hide()
{
TriList.BooleanInput[BackingPageJoin].BoolValue = false;
TriList.BooleanInput[LeftSubpageJoin].BoolValue = false;
}
}
}

View File

@@ -0,0 +1,31 @@
using System.Collections.Generic;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.PageManagers
{
/// <summary>
/// A simple class that hides and shows the default subpage for a given source type
/// </summary>
public class SinglePageManager : PageManager
{
BasicTriList TriList;
uint BackingPageJoin;
public SinglePageManager(uint pageJoin, BasicTriList trilist)
{
TriList = trilist;
BackingPageJoin = pageJoin;
}
public override void Show()
{
TriList.BooleanInput[BackingPageJoin].BoolValue = true;
}
public override void Hide()
{
TriList.BooleanInput[BackingPageJoin].BoolValue = false;
}
}
}