mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-10 18:24:50 +00:00
Removes essentials-framework as a submodule and brings the files back into the main repo
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public class CrestronTouchpanelPropertiesConfig
|
||||
{
|
||||
public string IpId { get; set; }
|
||||
public string DefaultRoomKey { get; set; }
|
||||
public string RoomListKey { get; set; }
|
||||
public string SgdFile { get; set; }
|
||||
public string ProjectName { get; set; }
|
||||
public bool ShowVolumeGauge { get; set; }
|
||||
public bool UsesSplashPage { get; set; }
|
||||
public bool ShowDate { get; set; }
|
||||
public bool ShowTime { get; set; }
|
||||
public UiSetupPropertiesConfig Setup { get; set; }
|
||||
public string HeaderStyle { get; set; }
|
||||
public bool IncludeInFusionRoomHealth { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The count of sources that will trigger the "additional" arrows to show on the SRL.
|
||||
/// Defaults to 5
|
||||
/// </summary>
|
||||
public int SourcesOverflowCount { get; set; }
|
||||
|
||||
public CrestronTouchpanelPropertiesConfig()
|
||||
{
|
||||
SourcesOverflowCount = 5;
|
||||
HeaderStyle = CrestronTouchpanelPropertiesConfig.Habanero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "habanero"
|
||||
/// </summary>
|
||||
public const string Habanero = "habanero";
|
||||
/// <summary>
|
||||
/// "verbose"
|
||||
/// </summary>
|
||||
public const string Verbose = "verbose";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class UiSetupPropertiesConfig
|
||||
{
|
||||
public bool IsVisible { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,436 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Touchpanels.Keyboards
|
||||
{
|
||||
public class HabaneroKeyboardController
|
||||
{
|
||||
/// <summary>
|
||||
/// Single-key press events, rather than using a built-up text string on the OutputFeedback
|
||||
/// </summary>
|
||||
public event EventHandler<KeyboardControllerPressEventArgs> KeyPress;
|
||||
|
||||
public BasicTriList TriList { get; private set; }
|
||||
|
||||
public StringFeedback OutputFeedback { get; private set; }
|
||||
|
||||
public bool IsVisible { get; private set; }
|
||||
|
||||
public string DotComButtonString { get; set; }
|
||||
|
||||
public string GoButtonText { get; set; }
|
||||
|
||||
public string SecondaryButtonText { get; set; }
|
||||
|
||||
public bool GoButtonVisible { get; set; }
|
||||
|
||||
public bool SecondaryButtonVisible { get; set; }
|
||||
|
||||
int ShiftMode = 0;
|
||||
|
||||
StringBuilder Output;
|
||||
|
||||
public Action HideAction { get; set; }
|
||||
|
||||
CTimer BackspaceTimer;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="trilist"></param>
|
||||
public HabaneroKeyboardController(BasicTriList trilist)
|
||||
{
|
||||
TriList = trilist;
|
||||
Output = new StringBuilder();
|
||||
OutputFeedback = new StringFeedback(() => Output.ToString());
|
||||
DotComButtonString = ".com";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the keyboard and attaches sig handlers in the range of 2901-2969
|
||||
/// </summary>
|
||||
public void Show()
|
||||
{
|
||||
if (IsVisible)
|
||||
return;
|
||||
|
||||
TriList.SetSigTrueAction(ClosePressJoin, Hide);
|
||||
TriList.SetSigTrueAction(GoButtonPressJoin, () => OnKeyPress(KeyboardSpecialKey.GoButton));
|
||||
TriList.SetSigTrueAction(SecondaryButtonPressJoin, () => OnKeyPress(KeyboardSpecialKey.SecondaryButton));
|
||||
TriList.SetSigTrueAction(2921, () => Press(A(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2922, () => Press(B(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2923, () => Press(C(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2924, () => Press(D(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2925, () => Press(E(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2926, () => Press(F(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2927, () => Press(G(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2928, () => Press(H(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2929, () => Press(I(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2930, () => Press(J(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2931, () => Press(K(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2932, () => Press(L(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2933, () => Press(M(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2934, () => Press(N(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2935, () => Press(O(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2936, () => Press(P(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2937, () => Press(Q(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2938, () => Press(R(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2939, () => Press(S(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2940, () => Press(T(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2941, () => Press(U(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2942, () => Press(V(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2943, () => Press(W(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2944, () => Press(X(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2945, () => Press(Y(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2946, () => Press(Z(ShiftMode)));
|
||||
TriList.SetSigTrueAction(2947, () => Press('.'));
|
||||
TriList.SetSigTrueAction(2948, () => Press('@'));
|
||||
TriList.SetSigTrueAction(2949, () => Press(' '));
|
||||
TriList.SetSigHeldAction(2950, 500, StartBackspaceRepeat, StopBackspaceRepeat, Backspace);
|
||||
//TriList.SetSigTrueAction(2950, Backspace);
|
||||
TriList.SetSigTrueAction(2951, Shift);
|
||||
TriList.SetSigTrueAction(2952, NumShift);
|
||||
TriList.SetSigTrueAction(2953, Clear);
|
||||
TriList.SetSigTrueAction(2954, () => Press(DotComButtonString));
|
||||
|
||||
TriList.SetBool(GoButtonVisibleJoin, GoButtonVisible);
|
||||
TriList.SetString(GoButtonTextJoin, GoButtonText);
|
||||
TriList.SetBool(SecondaryButtonVisibleJoin, SecondaryButtonVisible);
|
||||
TriList.SetString(SecondaryButtonTextJoin, SecondaryButtonText);
|
||||
|
||||
TriList.SetBool(KeyboardVisible, true);
|
||||
ShowKeys();
|
||||
IsVisible = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hides the keyboard and disconnects ALL sig handlers from 2901 - 2969
|
||||
/// </summary>
|
||||
public void Hide()
|
||||
{
|
||||
if (!IsVisible)
|
||||
return;
|
||||
|
||||
for (uint i = 2901; i < 2970; i++)
|
||||
TriList.ClearBoolSigAction(i);
|
||||
|
||||
// run attached actions
|
||||
if(HideAction != null)
|
||||
HideAction();
|
||||
|
||||
TriList.SetBool(KeyboardVisible, false);
|
||||
IsVisible = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
public void Press(char c)
|
||||
{
|
||||
OnKeyPress(c.ToString());
|
||||
Output.Append(c);
|
||||
OutputFeedback.FireUpdate();
|
||||
ResetShift();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
public void Press(string s)
|
||||
{
|
||||
OnKeyPress(s);
|
||||
Output.Append(s);
|
||||
OutputFeedback.FireUpdate();
|
||||
ResetShift();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void EnableGoButton()
|
||||
{
|
||||
TriList.SetBool(GoButtonEnableJoin, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void DisableGoButton()
|
||||
{
|
||||
TriList.SetBool(GoButtonEnableJoin, false);
|
||||
}
|
||||
|
||||
void ResetShift()
|
||||
{
|
||||
if (ShiftMode == 1)
|
||||
{
|
||||
ShiftMode = 0;
|
||||
ShowKeys();
|
||||
}
|
||||
else if (ShiftMode == 3)
|
||||
{
|
||||
ShiftMode = 2;
|
||||
ShowKeys();
|
||||
}
|
||||
}
|
||||
|
||||
char A(int i) { return new char[] { 'a', 'A', '?', '?' }[i]; }
|
||||
char B(int i) { return new char[] { 'b', 'B', ':', ':' }[i]; }
|
||||
char C(int i) { return new char[] { 'c', 'C', '>', '>' }[i]; }
|
||||
char D(int i) { return new char[] { 'd', 'D', '_', '_' }[i]; }
|
||||
char E(int i) { return new char[] { 'e', 'E', '3', '#' }[i]; }
|
||||
char F(int i) { return new char[] { 'f', 'F', '=', '=' }[i]; }
|
||||
char G(int i) { return new char[] { 'g', 'G', '+', '+' }[i]; }
|
||||
char H(int i) { return new char[] { 'h', 'H', '[', '[' }[i]; }
|
||||
char I(int i) { return new char[] { 'i', 'I', '8', '*' }[i]; }
|
||||
char J(int i) { return new char[] { 'j', 'J', ']', ']' }[i]; }
|
||||
char K(int i) { return new char[] { 'k', 'K', '/', '/' }[i]; }
|
||||
char L(int i) { return new char[] { 'l', 'L', '\\', '\\' }[i]; }
|
||||
char M(int i) { return new char[] { 'm', 'M', '"', '"' }[i]; }
|
||||
char N(int i) { return new char[] { 'n', 'N', '\'', '\'' }[i]; }
|
||||
char O(int i) { return new char[] { 'o', 'O', '9', '(' }[i]; }
|
||||
char P(int i) { return new char[] { 'p', 'P', '0', ')' }[i]; }
|
||||
char Q(int i) { return new char[] { 'q', 'Q', '1', '!' }[i]; }
|
||||
char R(int i) { return new char[] { 'r', 'R', '4', '$' }[i]; }
|
||||
char S(int i) { return new char[] { 's', 'S', '-', '-' }[i]; }
|
||||
char T(int i) { return new char[] { 't', 'T', '5', '%' }[i]; }
|
||||
char U(int i) { return new char[] { 'u', 'U', '7', '&' }[i]; }
|
||||
char V(int i) { return new char[] { 'v', 'V', ';', ';' }[i]; }
|
||||
char W(int i) { return new char[] { 'w', 'W', '2', '@' }[i]; }
|
||||
char X(int i) { return new char[] { 'x', 'X', '<', '<' }[i]; }
|
||||
char Y(int i) { return new char[] { 'y', 'Y', '6', '^' }[i]; }
|
||||
char Z(int i) { return new char[] { 'z', 'Z', ',', ',' }[i]; }
|
||||
|
||||
/// <summary>
|
||||
/// Does what it says
|
||||
/// </summary>
|
||||
void StartBackspaceRepeat()
|
||||
{
|
||||
if (BackspaceTimer == null)
|
||||
{
|
||||
BackspaceTimer = new CTimer(o => Backspace(), null, 0, 175);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does what it says
|
||||
/// </summary>
|
||||
void StopBackspaceRepeat()
|
||||
{
|
||||
if (BackspaceTimer != null)
|
||||
{
|
||||
BackspaceTimer.Stop();
|
||||
BackspaceTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
void Backspace()
|
||||
{
|
||||
OnKeyPress(KeyboardSpecialKey.Backspace);
|
||||
|
||||
if (Output.Length > 0)
|
||||
{
|
||||
Output.Remove(Output.Length - 1, 1);
|
||||
OutputFeedback.FireUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
OnKeyPress(KeyboardSpecialKey.Clear);
|
||||
|
||||
Output.Remove(0, Output.Length);
|
||||
OutputFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
/* When in mode 0 (lowercase):
|
||||
* shift button: up arrow 0
|
||||
* numShift button: 123/#$@#$ 0
|
||||
*
|
||||
* - shift --> mode 1
|
||||
* - double-tap shift --> caps lock
|
||||
* - numShift --> mode 2
|
||||
*
|
||||
* mode 1 (uppercase)
|
||||
* shift button: down arrow 1
|
||||
* numShift button: 123/##$# 0
|
||||
*
|
||||
* - shift --> mode 0
|
||||
* - numShift --> mode 2
|
||||
*
|
||||
* - Tapping any key will go back to mode 0
|
||||
*
|
||||
* mode 2 (numbers-sym)
|
||||
* Shift button: #$#$#$ 2
|
||||
* numShift: ABC 1
|
||||
*
|
||||
* - shift --> mode 3
|
||||
* - double-tap shift --> caps lock
|
||||
* - numShift --> mode 0
|
||||
*
|
||||
* mode 3 (sym)
|
||||
* Shift button: 123 3
|
||||
* numShift: ABC 1
|
||||
*
|
||||
* - shift --> mode 2
|
||||
* - numShift --> mode 0
|
||||
*
|
||||
* - Tapping any key will go back to mode 2
|
||||
*/
|
||||
void Shift()
|
||||
{
|
||||
if (ShiftMode == 0)
|
||||
ShiftMode = 1;
|
||||
else if (ShiftMode == 1)
|
||||
ShiftMode = 0;
|
||||
else if (ShiftMode == 2)
|
||||
ShiftMode = 3;
|
||||
else
|
||||
ShiftMode = 2;
|
||||
|
||||
ShowKeys();
|
||||
}
|
||||
|
||||
void NumShift()
|
||||
{
|
||||
if (ShiftMode == 0 || ShiftMode == 1)
|
||||
ShiftMode = 2;
|
||||
else if (ShiftMode == 2 || ShiftMode == 3)
|
||||
ShiftMode = 0;
|
||||
ShowKeys();
|
||||
}
|
||||
|
||||
void ShowKeys()
|
||||
{
|
||||
TriList.SetString(2921, A(ShiftMode).ToString());
|
||||
TriList.SetString(2922, B(ShiftMode).ToString());
|
||||
TriList.SetString(2923, C(ShiftMode).ToString());
|
||||
TriList.SetString(2924, D(ShiftMode).ToString());
|
||||
TriList.SetString(2925, E(ShiftMode).ToString());
|
||||
TriList.SetString(2926, F(ShiftMode).ToString());
|
||||
TriList.SetString(2927, G(ShiftMode).ToString());
|
||||
TriList.SetString(2928, H(ShiftMode).ToString());
|
||||
TriList.SetString(2929, I(ShiftMode).ToString());
|
||||
TriList.SetString(2930, J(ShiftMode).ToString());
|
||||
TriList.SetString(2931, K(ShiftMode).ToString());
|
||||
TriList.SetString(2932, L(ShiftMode).ToString());
|
||||
TriList.SetString(2933, M(ShiftMode).ToString());
|
||||
TriList.SetString(2934, N(ShiftMode).ToString());
|
||||
TriList.SetString(2935, O(ShiftMode).ToString());
|
||||
TriList.SetString(2936, P(ShiftMode).ToString());
|
||||
TriList.SetString(2937, Q(ShiftMode).ToString());
|
||||
TriList.SetString(2938, R(ShiftMode).ToString());
|
||||
TriList.SetString(2939, S(ShiftMode).ToString());
|
||||
TriList.SetString(2940, T(ShiftMode).ToString());
|
||||
TriList.SetString(2941, U(ShiftMode).ToString());
|
||||
TriList.SetString(2942, V(ShiftMode).ToString());
|
||||
TriList.SetString(2943, W(ShiftMode).ToString());
|
||||
TriList.SetString(2944, X(ShiftMode).ToString());
|
||||
TriList.SetString(2945, Y(ShiftMode).ToString());
|
||||
TriList.SetString(2946, Z(ShiftMode).ToString());
|
||||
TriList.SetString(2954, DotComButtonString);
|
||||
|
||||
TriList.SetUshort(2951, (ushort)ShiftMode); // 0 = up, 1 = down, 2 = #, 3 = 123
|
||||
TriList.SetUshort(2952, (ushort)(ShiftMode < 2 ? 0 : 1)); // 0 = #, 1 = abc
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event fire helper for text
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
void OnKeyPress(string text)
|
||||
{
|
||||
var handler = KeyPress;
|
||||
if (handler != null)
|
||||
KeyPress(this, new KeyboardControllerPressEventArgs(text));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// event helper for special keys
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
void OnKeyPress(KeyboardSpecialKey key)
|
||||
{
|
||||
var handler = KeyPress;
|
||||
if (handler != null)
|
||||
KeyPress(this, new KeyboardControllerPressEventArgs(key));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 2901
|
||||
/// </summary>
|
||||
public const uint KeyboardVisible = 2901;
|
||||
/// <summary>
|
||||
/// 2902
|
||||
/// </summary>
|
||||
public const uint ClosePressJoin = 2902;
|
||||
/// <summary>
|
||||
/// 2903
|
||||
/// </summary>
|
||||
public const uint GoButtonPressJoin = 2903;
|
||||
/// <summary>
|
||||
/// 2903
|
||||
/// </summary>
|
||||
public const uint GoButtonTextJoin = 2903;
|
||||
/// <summary>
|
||||
/// 2904
|
||||
/// </summary>
|
||||
public const uint SecondaryButtonPressJoin = 2904;
|
||||
/// <summary>
|
||||
/// 2904
|
||||
/// </summary>
|
||||
public const uint SecondaryButtonTextJoin = 2904;
|
||||
/// <summary>
|
||||
/// 2905
|
||||
/// </summary>
|
||||
public const uint GoButtonVisibleJoin = 2905;
|
||||
/// <summary>
|
||||
/// 2906
|
||||
/// </summary>
|
||||
public const uint SecondaryButtonVisibleJoin = 2906;
|
||||
/// <summary>
|
||||
/// 2907
|
||||
/// </summary>
|
||||
public const uint GoButtonEnableJoin = 2907;
|
||||
/// <summary>
|
||||
/// 2910
|
||||
/// </summary>
|
||||
public const uint ClearPressJoin = 2910;
|
||||
/// <summary>
|
||||
/// 2911
|
||||
/// </summary>
|
||||
public const uint ClearVisibleJoin = 2911;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class KeyboardControllerPressEventArgs : EventArgs
|
||||
{
|
||||
public string Text { get; private set; }
|
||||
public KeyboardSpecialKey SpecialKey { get; private set; }
|
||||
|
||||
public KeyboardControllerPressEventArgs(string text)
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
|
||||
public KeyboardControllerPressEventArgs(KeyboardSpecialKey key)
|
||||
{
|
||||
SpecialKey = key;
|
||||
}
|
||||
}
|
||||
|
||||
public enum KeyboardSpecialKey
|
||||
{
|
||||
None = 0, Backspace, Clear, GoButton, SecondaryButton
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
//using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
//using PepperDash.Core;
|
||||
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public class LargeTouchpanelControllerBase : SmartGraphicsTouchpanelControllerBase
|
||||
// {
|
||||
// public string PresentationShareButtonInVideoText = "Share";
|
||||
// public string PresentationShareButtonNotInVideoText = "Presentation";
|
||||
|
||||
// SourceListSubpageReferenceList SourceSelectSRL;
|
||||
// DevicePageControllerBase CurrentPresentationSourcePageController;
|
||||
|
||||
// public LargeTouchpanelControllerBase(string key, string name,
|
||||
// BasicTriListWithSmartObject triList, string sgdFilePath)
|
||||
// : base(key, name, triList, sgdFilePath)
|
||||
// {
|
||||
// }
|
||||
|
||||
// public override bool CustomActivate()
|
||||
// {
|
||||
// var baseSuccess = base.CustomActivate();
|
||||
// if (!baseSuccess) return false;
|
||||
|
||||
// SourceSelectSRL = new SourceListSubpageReferenceList(this.TriList, n =>
|
||||
// { if (CurrentRoom != null) CurrentRoom.SelectSource(n); });
|
||||
|
||||
// var lm = Global.LicenseManager;
|
||||
// if (lm != null)
|
||||
// {
|
||||
// lm.LicenseIsValid.LinkInputSig(TriList.BooleanInput[UiCue.ShowLicensed.Number]);
|
||||
// //others
|
||||
// }
|
||||
|
||||
// // Temp things -----------------------------------------------------------------------
|
||||
// TriList.StringInput[UiCue.SplashMessage.Number].StringValue = SplashMessage;
|
||||
// //------------------------------------------------------------------------------------
|
||||
|
||||
// // Initialize initial view
|
||||
// ShowSplashOrMain();
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// In Essentials, this should NEVER be called, since it's a one-room solution
|
||||
// /// </summary>
|
||||
// protected override void HideRoomUI()
|
||||
// {
|
||||
// // UI Cleanup here????
|
||||
|
||||
// //SwapAudioDeviceControls(CurrentRoom.CurrentAudioDevice, null);
|
||||
// //CurrentRoom.AudioDeviceWillChange -= CurrentRoom_AudioDeviceWillChange;
|
||||
|
||||
// CurrentRoom.IsCoolingDown.OutputChange -= CurrentRoom_IsCoolingDown_OutputChange;
|
||||
// CurrentRoom.IsWarmingUp.OutputChange -= CurrentRoom_IsWarmingUp_OutputChange;
|
||||
|
||||
// SourceSelectSRL.DetachFromCurrentRoom();
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Ties this panel controller to the Room and gets updates.
|
||||
// /// </summary>
|
||||
// protected override void ShowRoomUI()
|
||||
// {
|
||||
// Debug.Console(1, this, "connecting to system '{0}'", CurrentRoom.Key);
|
||||
|
||||
// TriList.StringInput[RoomCue.Name.Number].StringValue = CurrentRoom.Name;
|
||||
// TriList.StringInput[RoomCue.Description.Number].StringValue = CurrentRoom.Description;
|
||||
|
||||
// CurrentRoom.IsCoolingDown.OutputChange -= CurrentRoom_IsCoolingDown_OutputChange;
|
||||
// CurrentRoom.IsWarmingUp.OutputChange -= CurrentRoom_IsWarmingUp_OutputChange;
|
||||
// CurrentRoom.IsCoolingDown.OutputChange += CurrentRoom_IsCoolingDown_OutputChange;
|
||||
// CurrentRoom.IsWarmingUp.OutputChange += CurrentRoom_IsWarmingUp_OutputChange;
|
||||
|
||||
// SourceSelectSRL.AttachToRoom(CurrentRoom);
|
||||
// }
|
||||
|
||||
// void CurrentRoom_IsCoolingDown_OutputChange(object sender, EventArgs e)
|
||||
// {
|
||||
// Debug.Console(2, this, "Received room in cooldown={0}", CurrentRoom.IsCoolingDown.BoolValue);
|
||||
// if (CurrentRoom.IsCoolingDown.BoolValue) // When entering cooldown
|
||||
// {
|
||||
// // Do we need to check for an already-running cooldown - like in the case of room switches?
|
||||
// new ModalDialog(TriList).PresentModalTimerDialog(0, "Power Off", "Power", "Please wait, shutting down",
|
||||
// "", "", CurrentRoom.CooldownTime, true, b =>
|
||||
// {
|
||||
// ShowSplashOrMain();
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
// void CurrentRoom_IsWarmingUp_OutputChange(object sender, EventArgs e)
|
||||
// {
|
||||
// Debug.Console(2, this, "Received room in warmup={0}", CurrentRoom.IsWarmingUp.BoolValue);
|
||||
// if (CurrentRoom.IsWarmingUp.BoolValue) // When entering warmup
|
||||
// {
|
||||
// // Do we need to check for an already-running cooldown - like in the case of room switches?
|
||||
// new ModalDialog(TriList).PresentModalTimerDialog(0, "Power On", "Power", "Please wait, powering on",
|
||||
// "", "", CurrentRoom.WarmupTime, false, b =>
|
||||
// {
|
||||
// // Reveal sources - or has already been done behind modal
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Handler for source change events.
|
||||
// void CurrentRoom_PresentationSourceChange(object sender, EssentialsRoomSourceChangeEventArgs args)
|
||||
// {
|
||||
// // Put away the old source and set up the new source.
|
||||
// Debug.Console(2, this, "Received source change={0}", args.NewSource != null ? args.NewSource.Key : "none");
|
||||
|
||||
// // If we're in tech, don't switch screen modes. Add any other modes we may want to switch away from
|
||||
// // inside the if below.
|
||||
// if (MainMode == eMainModeType.Splash)
|
||||
// setMainMode(eMainModeType.Presentation);
|
||||
// SetControlSource(args.NewSource);
|
||||
// }
|
||||
|
||||
// //***********************************************************************
|
||||
// //** UI Manipulation
|
||||
// //***********************************************************************
|
||||
|
||||
// /// <summary>
|
||||
// /// Shows the splash page or the main presentation page, depending on config setting
|
||||
// /// </summary>
|
||||
// void ShowSplashOrMain()
|
||||
// {
|
||||
// if (UsesSplashPage)
|
||||
// setMainMode(eMainModeType.Splash);
|
||||
// else
|
||||
// setMainMode(eMainModeType.Presentation);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Switches between main modes
|
||||
// /// </summary>
|
||||
// void setMainMode(eMainModeType mode)
|
||||
// {
|
||||
// MainMode = mode;
|
||||
// switch (mode)
|
||||
// {
|
||||
// case eMainModeType.Presentation:
|
||||
// TriList.BooleanInput[UiCue.VisibleCommonFooter.Number].BoolValue = true;
|
||||
// TriList.BooleanInput[UiCue.VisibleCommonHeader.Number].BoolValue = true;
|
||||
// TriList.BooleanInput[UiCue.VisibleSplash.Number].BoolValue = false;
|
||||
// TriList.BooleanInput[UiCue.VisiblePresentationSourceList.Number].BoolValue = true;
|
||||
// ShowCurrentPresentationSourceUi();
|
||||
// break;
|
||||
// case eMainModeType.Splash:
|
||||
// TriList.BooleanInput[UiCue.VisibleCommonFooter.Number].BoolValue = false;
|
||||
// TriList.BooleanInput[UiCue.VisibleCommonHeader.Number].BoolValue = false;
|
||||
// TriList.BooleanInput[UiCue.VisiblePresentationSourceList.Number].BoolValue = false;
|
||||
// TriList.BooleanInput[UiCue.VisibleSplash.Number].BoolValue = true;
|
||||
// HideCurrentPresentationSourceUi();
|
||||
// break;
|
||||
// case eMainModeType.Tech:
|
||||
// new ModalDialog(TriList).PresentModalTimerDialog(1, "Tech page", "Info",
|
||||
// "Tech page will be here soon!<br>I promise",
|
||||
// "Bueno!", "", 0, false, null);
|
||||
// MainMode = eMainModeType.Presentation;
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// void PowerOffWithConfirmPressed()
|
||||
// {
|
||||
// if (!CurrentRoom.RoomIsOn.BoolValue) return;
|
||||
// // Timeout or button 1 press will shut down
|
||||
// var modal = new ModalDialog(TriList);
|
||||
// uint seconds = CurrentRoom.UnattendedShutdownTimeMs / 1000;
|
||||
// var message = string.Format("Meeting will end in {0} seconds", seconds);
|
||||
// modal.PresentModalTimerDialog(2, "End Meeting", "Info", message,
|
||||
// "End Meeting Now", "Cancel", CurrentRoom.UnattendedShutdownTimeMs, true,
|
||||
// but => { if (but != 2) CurrentRoom.RoomOff(); });
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Reveals the basic UI for the current device
|
||||
// /// </summary>
|
||||
// protected override void ShowCurrentPresentationSourceUi()
|
||||
// {
|
||||
// if (MainMode == eMainModeType.Splash && CurrentRoom.RoomIsOn.BoolValue)
|
||||
// setMainMode(eMainModeType.Presentation);
|
||||
|
||||
// if (CurrentPresentationControlDevice == null)
|
||||
// {
|
||||
// // If system is off, do one thing
|
||||
|
||||
// // Otherwise, do something else - shouldn't be in this condition
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // If a controller is already loaded, use it
|
||||
// if (LoadedPageControllers.ContainsKey(CurrentPresentationControlDevice))
|
||||
// CurrentPresentationSourcePageController = LoadedPageControllers[CurrentPresentationControlDevice];
|
||||
// else
|
||||
// {
|
||||
// // This is by no means optimal, but for now....
|
||||
// if (CurrentPresentationControlDevice.Type == PresentationSourceType.SetTopBox
|
||||
// && CurrentPresentationControlDevice is IHasSetTopBoxProperties)
|
||||
// CurrentPresentationSourcePageController = new PageControllerLargeSetTopBoxGeneric(TriList,
|
||||
// CurrentPresentationControlDevice as IHasSetTopBoxProperties);
|
||||
|
||||
// else if (CurrentPresentationControlDevice.Type == PresentationSourceType.Laptop)
|
||||
// CurrentPresentationSourcePageController = new PageControllerLaptop(TriList);
|
||||
|
||||
// // separate these...
|
||||
// else if (CurrentPresentationControlDevice.Type == PresentationSourceType.Dvd)
|
||||
// CurrentPresentationSourcePageController =
|
||||
// new PageControllerLargeDvd(TriList, CurrentPresentationControlDevice as IHasCueActionList);
|
||||
|
||||
// else
|
||||
// CurrentPresentationSourcePageController = null;
|
||||
|
||||
// // Save it.
|
||||
// if (CurrentPresentationSourcePageController != null)
|
||||
// LoadedPageControllers[CurrentPresentationControlDevice] = CurrentPresentationSourcePageController;
|
||||
// }
|
||||
|
||||
// if (CurrentPresentationSourcePageController != null)
|
||||
// CurrentPresentationSourcePageController.SetVisible(true);
|
||||
// }
|
||||
|
||||
// protected override void HideCurrentPresentationSourceUi()
|
||||
// {
|
||||
// if (CurrentPresentationControlDevice != null && CurrentPresentationSourcePageController != null)
|
||||
// CurrentPresentationSourcePageController.SetVisible(false);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// void ShowHelp()
|
||||
// {
|
||||
// new ModalDialog(TriList).PresentModalTimerDialog(1, "Help", "Help", CurrentRoom.HelpMessage,
|
||||
// "OK", "", 0, false, null);
|
||||
// }
|
||||
|
||||
// protected void ListSmartObjects()
|
||||
// {
|
||||
// Debug.Console(0, this, "Smart objects IDs:");
|
||||
// var list = TriList.SmartObjects.OrderBy(s => s.Key);
|
||||
// foreach (var kvp in list)
|
||||
// Debug.Console(0, " {0}", kvp.Key);
|
||||
// }
|
||||
|
||||
// public override List<CueActionPair> FunctionList
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return new List<CueActionPair>
|
||||
// {
|
||||
// new BoolCueActionPair(UiCue.PressSplash, b => { if(!b) setMainMode(eMainModeType.Presentation); }),
|
||||
// new BoolCueActionPair(UiCue.PressRoomOffWithConfirm, b => { if(!b) PowerOffWithConfirmPressed(); }),
|
||||
// new BoolCueActionPair(UiCue.PressModePresentationShare, b => { if(!b) setMainMode(eMainModeType.Presentation); }),
|
||||
// new BoolCueActionPair(UiCue.PressHelp, b => { if(!b) ShowHelp(); }),
|
||||
// new BoolCueActionPair(UiCue.PressSettings, b => { if(!b) setMainMode(eMainModeType.Tech); }),
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
// //#endregion
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,244 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
//using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
//using PepperDash.Essentials.Core.Presets;
|
||||
|
||||
//using PepperDash.Core;
|
||||
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// public abstract class DevicePageControllerBase
|
||||
// {
|
||||
|
||||
// protected BasicTriListWithSmartObject TriList;
|
||||
// protected List<BoolInputSig> FixedObjectSigs;
|
||||
|
||||
// public DevicePageControllerBase(BasicTriListWithSmartObject triList)
|
||||
// {
|
||||
// TriList = triList;
|
||||
// }
|
||||
|
||||
// public void SetVisible(bool state)
|
||||
// {
|
||||
// foreach (var sig in FixedObjectSigs)
|
||||
// {
|
||||
// Debug.Console(2, "set visible {0}={1}", sig.Number, state);
|
||||
// sig.BoolValue = state;
|
||||
// }
|
||||
// CustomSetVisible(state);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Add any specialized show/hide logic here - beyond FixedObjectSigs. Overriding
|
||||
// /// methods do not need to call this base method
|
||||
// /// </summary>
|
||||
// protected virtual void CustomSetVisible(bool state)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
|
||||
// //public class InterlockedDevicePageController
|
||||
// //{
|
||||
// // public List<uint> ObjectBoolJoins { get; set; }
|
||||
// // public uint DefaultJoin { get; set; }
|
||||
// //}
|
||||
|
||||
|
||||
|
||||
|
||||
// ///// <summary>
|
||||
// /////
|
||||
// ///// </summary>
|
||||
// //public interface IHasSetTopBoxProperties
|
||||
// //{
|
||||
// // bool HasDpad { get; }
|
||||
// // bool HasPreset { get; }
|
||||
// // bool HasDvr { get; }
|
||||
// // bool HasNumbers { get; }
|
||||
// // DevicePresetsModel PresetsModel { get; }
|
||||
// // void LoadPresets(string filePath);
|
||||
// //}
|
||||
|
||||
// public class PageControllerLaptop : DevicePageControllerBase
|
||||
// {
|
||||
// public PageControllerLaptop(BasicTriListWithSmartObject tl)
|
||||
// : base(tl)
|
||||
// {
|
||||
// FixedObjectSigs = new List<BoolInputSig>
|
||||
// {
|
||||
// tl.BooleanInput[10092], // well
|
||||
// tl.BooleanInput[11001] // Laptop info
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
|
||||
// ///// <summary>
|
||||
// /////
|
||||
// ///// </summary>
|
||||
// //public class PageControllerLargeDvd : DevicePageControllerBase
|
||||
// //{
|
||||
// // IHasCueActionList Device;
|
||||
|
||||
// // public PageControllerLargeDvd(BasicTriListWithSmartObject tl, IHasCueActionList device)
|
||||
// // : base(tl)
|
||||
// // {
|
||||
|
||||
// // Device = device;
|
||||
// // FixedObjectSigs = new List<BoolInputSig>
|
||||
// // {
|
||||
// // tl.BooleanInput[10093], // well
|
||||
// // tl.BooleanInput[10411], // DVD Dpad
|
||||
// // tl.BooleanInput[10412] // everything else
|
||||
// // };
|
||||
// // }
|
||||
|
||||
// // protected override void CustomSetVisible(bool state)
|
||||
// // {
|
||||
// // // Hook up smart objects if applicable
|
||||
// // if (Device != null)
|
||||
// // {
|
||||
// // var uos = (Device as IHasCueActionList).CueActionList;
|
||||
// // SmartObjectHelper.LinkDpadWithUserObjects(TriList, 10411, uos, state);
|
||||
// // }
|
||||
// // }
|
||||
// //}
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// //public class PageControllerLargeSetTopBoxGeneric : DevicePageControllerBase
|
||||
// //{
|
||||
// // // To-DO: Add properties for component subpage names. DpadPos1, DpadPos2...
|
||||
// // // Derived classes can then insert special subpages for variations on given
|
||||
// // // device types. Like DirecTV vs Comcast
|
||||
|
||||
// // public uint DpadSmartObjectId { get; set; }
|
||||
// // public uint NumberPadSmartObjectId { get; set; }
|
||||
// // public uint PresetsSmartObjectId { get; set; }
|
||||
// // public uint Position5TabsId { get; set; }
|
||||
|
||||
// // IHasSetTopBoxProperties Device;
|
||||
// // DevicePresetsView PresetsView;
|
||||
|
||||
|
||||
// // bool ShowPosition5Tabs;
|
||||
// // uint CurrentVisiblePosition5Item = 1;
|
||||
// // Dictionary<uint, uint> Position5SubpageJoins = new Dictionary<uint, uint>
|
||||
// // {
|
||||
// // { 1, 10053 },
|
||||
// // { 2, 10054 }
|
||||
// // };
|
||||
|
||||
// // public PageControllerLargeSetTopBoxGeneric(BasicTriListWithSmartObject tl, IHasSetTopBoxProperties device)
|
||||
// // : base(tl)
|
||||
// // {
|
||||
// // Device = device;
|
||||
// // DpadSmartObjectId = 10011;
|
||||
// // NumberPadSmartObjectId = 10014;
|
||||
// // PresetsSmartObjectId = 10012;
|
||||
// // Position5TabsId = 10081;
|
||||
|
||||
// // bool dpad = device.HasDpad;
|
||||
// // bool preset = device.HasPreset;
|
||||
// // bool dvr = device.HasDvr;
|
||||
// // bool numbers = device.HasNumbers;
|
||||
// // uint[] joins = null;
|
||||
|
||||
// // if (dpad && !preset && !dvr && !numbers) joins = new uint[] { 10031, 10091 };
|
||||
// // else if (!dpad && preset && !dvr && !numbers) joins = new uint[] { 10032, 10091 };
|
||||
// // else if (!dpad && !preset && dvr && !numbers) joins = new uint[] { 10033, 10091 };
|
||||
// // else if (!dpad && !preset && !dvr && numbers) joins = new uint[] { 10034, 10091 };
|
||||
|
||||
// // else if (dpad && preset && !dvr && !numbers) joins = new uint[] { 10042, 10021, 10092 };
|
||||
// // else if (dpad && !preset && dvr && !numbers) joins = new uint[] { 10043, 10021, 10092 };
|
||||
// // else if (dpad && !preset && !dvr && numbers) joins = new uint[] { 10044, 10021, 10092 };
|
||||
// // else if (!dpad && preset && dvr && !numbers) joins = new uint[] { 10043, 10022, 10092 };
|
||||
// // else if (!dpad && preset && !dvr && numbers) joins = new uint[] { 10044, 10022, 10092 };
|
||||
// // else if (!dpad && !preset && dvr && numbers) joins = new uint[] { 10044, 10023, 10092 };
|
||||
|
||||
// // else if (dpad && preset && dvr && !numbers) joins = new uint[] { 10053, 10032, 10011, 10093 };
|
||||
// // else if (dpad && preset && !dvr && numbers) joins = new uint[] { 10054, 10032, 10011, 10093 };
|
||||
// // else if (dpad && !preset && dvr && numbers) joins = new uint[] { 10054, 10033, 10011, 10093 };
|
||||
// // else if (!dpad && preset && dvr && numbers) joins = new uint[] { 10054, 10033, 10012, 10093 };
|
||||
|
||||
// // else if (dpad && preset && dvr && numbers)
|
||||
// // {
|
||||
// // joins = new uint[] { 10081, 10032, 10011, 10093 }; // special case
|
||||
// // ShowPosition5Tabs = true;
|
||||
// // }
|
||||
// // // Project the joins into corresponding sigs.
|
||||
// // FixedObjectSigs = joins.Select(u => TriList.BooleanInput[u]).ToList();
|
||||
|
||||
// // // Build presets
|
||||
// // if (device.HasPreset)
|
||||
// // {
|
||||
// // PresetsView = new DevicePresetsView(tl, device.PresetsModel);
|
||||
// // }
|
||||
|
||||
|
||||
// // }
|
||||
|
||||
// // protected override void CustomSetVisible(bool state)
|
||||
// // {
|
||||
// // if (ShowPosition5Tabs)
|
||||
// // {
|
||||
// // // Show selected tab
|
||||
// // TriList.BooleanInput[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = state;
|
||||
|
||||
// // var tabSo = TriList.SmartObjects[Position5TabsId];
|
||||
// // if (state) // Link up the tab object
|
||||
|
||||
// // {
|
||||
// // tabSo.BooleanOutput["Tab Button 1 Press"].UserObject = new BoolCueActionPair(b => ShowTab(1));
|
||||
// // tabSo.BooleanOutput["Tab Button 2 Press"].UserObject = new BoolCueActionPair(b => ShowTab(2));
|
||||
// // }
|
||||
// // else // Disco tab object
|
||||
// // {
|
||||
// // tabSo.BooleanOutput["Tab Button 1 Press"].UserObject = null;
|
||||
// // tabSo.BooleanOutput["Tab Button 2 Press"].UserObject = null;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // // Hook up smart objects if applicable
|
||||
// // if (Device is IHasCueActionList)
|
||||
// // {
|
||||
// // var uos = (Device as IHasCueActionList).CueActionList;
|
||||
// // SmartObjectHelper.LinkDpadWithUserObjects(TriList, DpadSmartObjectId, uos, state);
|
||||
// // SmartObjectHelper.LinkNumpadWithUserObjects(TriList, NumberPadSmartObjectId,
|
||||
// // uos, CommonBoolCue.Dash, CommonBoolCue.Last, state);
|
||||
// // }
|
||||
|
||||
|
||||
// // // Link, unlink presets
|
||||
// // if (Device.HasPreset && state)
|
||||
// // PresetsView.Attach();
|
||||
// // else if (Device.HasPreset && !state)
|
||||
// // PresetsView.Detach();
|
||||
// // }
|
||||
|
||||
// // 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;
|
||||
|
||||
// // // Show feedback on buttons
|
||||
// // }
|
||||
|
||||
// //}
|
||||
//}
|
||||
@@ -0,0 +1,211 @@
|
||||
using System;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public class ModalDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Bool press 3991
|
||||
/// </summary>
|
||||
public const uint Button1Join = 3991;
|
||||
/// <summary>
|
||||
/// Bool press 3992
|
||||
/// </summary>
|
||||
public const uint Button2Join = 3992;
|
||||
/// <summary>
|
||||
/// 3993
|
||||
/// </summary>
|
||||
public const uint CancelButtonJoin = 3993;
|
||||
/// <summary>
|
||||
///For visibility of single button. Bool feedback 3994
|
||||
/// </summary>
|
||||
public const uint OneButtonVisibleJoin = 3994;
|
||||
/// <summary>
|
||||
/// For visibility of two buttons. Bool feedback 3995.
|
||||
/// </summary>
|
||||
public const uint TwoButtonVisibleJoin = 3995;
|
||||
/// <summary>
|
||||
/// Shows the timer guage if in use. Bool feedback 3996
|
||||
/// </summary>
|
||||
public const uint TimerVisibleJoin = 3996;
|
||||
/// <summary>
|
||||
/// Visibility join to show "X" button 3997
|
||||
/// </summary>
|
||||
public const uint CancelVisibleJoin = 3997;
|
||||
/// <summary>
|
||||
/// Shows the modal subpage. Boolean feeback join 3999
|
||||
/// </summary>
|
||||
public const uint ModalVisibleJoin = 3999;
|
||||
|
||||
/// <summary>
|
||||
/// The seconds value of the countdown timer. Ushort join 3991
|
||||
/// </summary>
|
||||
//public const uint TimerSecondsJoin = 3991;
|
||||
/// <summary>
|
||||
/// The full ushort value of the countdown timer for a gauge. Ushort join 3992
|
||||
/// </summary>
|
||||
public const uint TimerGaugeJoin = 3992;
|
||||
|
||||
/// <summary>
|
||||
/// Text on button one. String join 3991
|
||||
/// </summary>
|
||||
public const uint Button1TextJoin = 3991;
|
||||
/// <summary>
|
||||
/// Text on button two. String join 3992
|
||||
/// </summary>
|
||||
public const uint Button2TextJoin = 3992;
|
||||
/// <summary>
|
||||
/// Message text. String join 3994
|
||||
/// </summary>
|
||||
public const uint MessageTextJoin = 3994;
|
||||
/// <summary>
|
||||
/// Title text. String join 3995
|
||||
/// </summary>
|
||||
public const uint TitleTextJoin = 3995;
|
||||
/// <summary>
|
||||
/// Icon name. String join 3996
|
||||
/// </summary>
|
||||
public const uint IconNameJoin = 3996;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when modal is showing
|
||||
/// </summary>
|
||||
public bool ModalIsVisible
|
||||
{
|
||||
get { return TriList.BooleanInput[ModalVisibleJoin].BoolValue; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool CanCancel { get; private set; }
|
||||
|
||||
|
||||
BasicTriList TriList;
|
||||
|
||||
Action<uint> ModalCompleteAction;
|
||||
|
||||
static object CompleteActionLock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new modal to be shown on provided TriList
|
||||
/// </summary>
|
||||
/// <param name="triList"></param>
|
||||
public ModalDialog(BasicTriList triList)
|
||||
{
|
||||
TriList = triList;
|
||||
// Attach actions to buttons
|
||||
|
||||
triList.SetSigFalseAction(Button1Join, () => OnModalComplete(1));
|
||||
triList.SetSigFalseAction(Button2Join, () => OnModalComplete(2));
|
||||
triList.SetSigFalseAction(CancelButtonJoin, () => { if (CanCancel) CancelDialog(); });
|
||||
CanCancel = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the dialog
|
||||
/// </summary>
|
||||
/// <param name="numberOfButtons">Number of buttons to show. 0, 1, 2</param>
|
||||
/// <param name="timeMs">The amount of time to show the dialog. Use 0 for no timeout.</param>
|
||||
/// <param name="decreasingGauge">If the progress bar gauge needs to count down instead of up</param>
|
||||
/// <param name="completeAction">The action to run when the dialog is dismissed. Parameter will be 1 or 2 if button pressed, or 0 if dialog times out</param>
|
||||
/// <returns>True when modal is created.</returns>
|
||||
public bool PresentModalDialog(uint numberOfButtons, string title, string iconName,
|
||||
string message, string button1Text,
|
||||
string button2Text, bool showGauge, bool showCancel, Action<uint> completeAction)
|
||||
{
|
||||
// Don't reset dialog if visible now
|
||||
if (!ModalIsVisible)
|
||||
{
|
||||
ModalCompleteAction = completeAction;
|
||||
TriList.StringInput[TitleTextJoin].StringValue = title;
|
||||
if (string.IsNullOrEmpty(iconName)) iconName = "Blank";
|
||||
TriList.StringInput[IconNameJoin].StringValue = iconName;
|
||||
TriList.StringInput[MessageTextJoin].StringValue = message;
|
||||
if (numberOfButtons == 0)
|
||||
{
|
||||
// Show no buttons
|
||||
TriList.BooleanInput[OneButtonVisibleJoin].BoolValue = false;
|
||||
TriList.BooleanInput[TwoButtonVisibleJoin].BoolValue = false;
|
||||
}
|
||||
else if (numberOfButtons == 1)
|
||||
{
|
||||
// Show one button
|
||||
TriList.BooleanInput[OneButtonVisibleJoin].BoolValue = true;
|
||||
TriList.BooleanInput[TwoButtonVisibleJoin].BoolValue = false;
|
||||
TriList.StringInput[Button1TextJoin].StringValue = button1Text;
|
||||
}
|
||||
else if (numberOfButtons == 2)
|
||||
{
|
||||
// Show two
|
||||
TriList.BooleanInput[OneButtonVisibleJoin].BoolValue = false;
|
||||
TriList.BooleanInput[TwoButtonVisibleJoin].BoolValue = true;
|
||||
TriList.StringInput[Button1TextJoin].StringValue = button1Text;
|
||||
TriList.StringInput[Button2TextJoin].StringValue = button2Text;
|
||||
}
|
||||
// Show/hide guage
|
||||
TriList.BooleanInput[TimerVisibleJoin].BoolValue = showGauge;
|
||||
|
||||
CanCancel = showCancel;
|
||||
TriList.BooleanInput[CancelVisibleJoin].BoolValue = showCancel;
|
||||
|
||||
//Reveal and activate
|
||||
TriList.BooleanInput[ModalVisibleJoin].BoolValue = true;
|
||||
|
||||
WakePanel();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wakes the panel by turning on the backlight if off
|
||||
/// </summary>
|
||||
public void WakePanel()
|
||||
{
|
||||
try
|
||||
{
|
||||
var panel = TriList as TswFt5Button;
|
||||
|
||||
if (panel != null && panel.ExtenderSystemReservedSigs.BacklightOffFeedback.BoolValue)
|
||||
panel.ExtenderSystemReservedSigs.BacklightOn();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.Console(1, "Error Waking Panel. Maybe testing with Xpanel?");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hide dialog from elsewhere, fires CompleteAction
|
||||
/// </summary>
|
||||
public void CancelDialog()
|
||||
{
|
||||
OnModalComplete(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hides dialog. Fires no action
|
||||
/// </summary>
|
||||
public void HideDialog()
|
||||
{
|
||||
TriList.BooleanInput[ModalVisibleJoin].BoolValue = false;
|
||||
}
|
||||
|
||||
// When the modal is cleared or times out, clean up the various bits
|
||||
void OnModalComplete(uint buttonNum)
|
||||
{
|
||||
TriList.BooleanInput[ModalVisibleJoin].BoolValue = false;
|
||||
|
||||
var action = ModalCompleteAction;
|
||||
if (action != null)
|
||||
action(buttonNum);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
//using Crestron.SimplSharpPro.DeviceSupport;
|
||||
//using Crestron.SimplSharpPro.UI;
|
||||
|
||||
//using PepperDash.Core;
|
||||
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
//[Obsolete("Replaced, initially with CrestronTsr302Controller in Resissentials")]
|
||||
// public class Tsr302Controller : SmartGraphicsTouchpanelControllerBase
|
||||
// {
|
||||
// //public override List<CueActionPair> FunctionList
|
||||
// //{
|
||||
// // get
|
||||
// // {
|
||||
// // return new List<CueActionPair>
|
||||
// // {
|
||||
|
||||
// // };
|
||||
// // }
|
||||
// //}
|
||||
|
||||
// public Tsr302 Remote { get; private set; }
|
||||
|
||||
// SourceListSubpageReferenceList SourceSelectSRL;
|
||||
// DevicePageControllerBase CurrentPresentationSourcePageController;
|
||||
// CTimer VolumeFeedbackTimer;
|
||||
|
||||
|
||||
// public Tsr302Controller(string key, string name, Tsr302 device, string sgdFilePath) :
|
||||
// base(key, name, device, sgdFilePath)
|
||||
// {
|
||||
// // Base takes care of TriList
|
||||
// Remote = device;
|
||||
// Remote.Home.UserObject = new BoolCueActionPair(b => { if (!b) PressHome(); });
|
||||
// Remote.VolumeUp.UserObject = new BoolCueActionPair(b => { if (!b) PressHome(); });
|
||||
// Remote.ButtonStateChange += Remote_ButtonStateChange;
|
||||
// }
|
||||
|
||||
// public override bool CustomActivate()
|
||||
// {
|
||||
// var baseSuccess = base.CustomActivate();
|
||||
// if (!baseSuccess) return false;
|
||||
|
||||
// SourceSelectSRL = new SourceListSubpageReferenceList(this.TriList, n =>
|
||||
// { if (CurrentRoom != null) CurrentRoom.SelectSource(n); });
|
||||
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// protected override void SwapAudioDeviceControls(IVolumeFunctions oldDev, IVolumeFunctions newDev)
|
||||
// {
|
||||
// // stop presses
|
||||
// if (oldDev != null)
|
||||
// {
|
||||
// ReleaseAudioPresses();
|
||||
// if (oldDev is IVolumeTwoWay)
|
||||
// {
|
||||
// (newDev as IVolumeTwoWay).VolumeLevelFeedback.OutputChange -= VolumeLevelOutput_OutputChange;
|
||||
// (oldDev as IVolumeTwoWay).VolumeLevelFeedback
|
||||
// .UnlinkInputSig(TriList.UShortInput[CommonIntCue.MainVolumeLevel.Number]);
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (newDev != null)
|
||||
// {
|
||||
// Remote.VolumeDown.UserObject = newDev.VolumeDownCueActionPair;
|
||||
// Remote.VolumeUp.UserObject = newDev.VolumeUpCueActionPair;
|
||||
// Remote.Mute.UserObject = newDev.MuteToggleCueActionPair;
|
||||
// if (newDev is IVolumeTwoWay)
|
||||
// {
|
||||
// var vOut = (newDev as IVolumeTwoWay).VolumeLevelFeedback;
|
||||
// vOut.OutputChange += VolumeLevelOutput_OutputChange;
|
||||
// TriList.UShortInput[CommonIntCue.MainVolumeLevel.Number].UShortValue = vOut.UShortValue;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Remote.VolumeDown.UserObject = null;
|
||||
// Remote.VolumeUp.UserObject = null;
|
||||
// Remote.Mute.UserObject = null;
|
||||
// }
|
||||
|
||||
// base.SwapAudioDeviceControls(oldDev, newDev);
|
||||
// }
|
||||
|
||||
// void PressHome()
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
// void VolumeLevelOutput_OutputChange(object sender, EventArgs e)
|
||||
// {
|
||||
// // Set level and show popup on timer
|
||||
// TriList.UShortInput[CommonIntCue.MainVolumeLevel.Number].UShortValue =
|
||||
// (sender as IntFeedback).UShortValue;
|
||||
|
||||
// if (VolumeFeedbackTimer == null)
|
||||
// {
|
||||
// TriList.BooleanInput[CommonBoolCue.ShowVolumeSlider.Number].BoolValue = true;
|
||||
// VolumeFeedbackTimer = new CTimer(o => {
|
||||
// TriList.BooleanInput[CommonBoolCue.ShowVolumeSlider.Number].BoolValue = false;
|
||||
// }, 1000);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// void ReleaseAudioPresses()
|
||||
// {
|
||||
// if (Remote.VolumeDown.UserObject is BoolCueActionPair && Remote.VolumeDown.State == eButtonState.Pressed)
|
||||
// (Remote.VolumeDown.UserObject as BoolCueActionPair).Invoke(false);
|
||||
// if (Remote.VolumeUp.UserObject is BoolCueActionPair && Remote.VolumeUp.State == eButtonState.Pressed)
|
||||
// (Remote.VolumeUp.UserObject as BoolCueActionPair).Invoke(false);
|
||||
// if (Remote.Mute.UserObject is BoolCueActionPair && Remote.Mute.State == eButtonState.Pressed)
|
||||
// (Remote.Mute.UserObject as BoolCueActionPair).Invoke(false);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Handler. Run UO's stored in buttons
|
||||
// /// </summary>
|
||||
// void Remote_ButtonStateChange(GenericBase device, ButtonEventArgs args)
|
||||
// {
|
||||
// Debug.Console(2, this, "{0}={1}", args.Button.Name, args.Button.State);
|
||||
// var uo = args.Button.UserObject as BoolCueActionPair;
|
||||
// if (uo != null)
|
||||
// uo.Invoke(args.NewButtonState == eButtonState.Pressed);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,309 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
//using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
// public abstract class SmartGraphicsTouchpanelControllerBase : CrestronGenericBaseDevice
|
||||
// {
|
||||
// public BasicTriListWithSmartObject TriList { get; protected set; }
|
||||
// public bool UsesSplashPage { get; set; }
|
||||
// public string SplashMessage { get; set; }
|
||||
// public bool ShowDate
|
||||
// {
|
||||
// set { TriList.BooleanInput[UiCue.ShowDate.Number].BoolValue = value; }
|
||||
// }
|
||||
// public bool ShowTime
|
||||
// {
|
||||
// set { TriList.BooleanInput[UiCue.ShowTime.Number].BoolValue = value; }
|
||||
// }
|
||||
|
||||
// public abstract List<CueActionPair> FunctionList { get; }
|
||||
|
||||
|
||||
// protected eMainModeType MainMode;
|
||||
// protected IPresentationSource CurrentPresentationControlDevice;
|
||||
|
||||
// /// <summary>
|
||||
// /// Defines the signal offset for the presentation device. Defaults to 100
|
||||
// /// </summary>
|
||||
// public uint PresentationControlDeviceJoinOffset { get { return 100; } }
|
||||
|
||||
// public enum eMainModeType
|
||||
// {
|
||||
// Presentation, Splash, Tech
|
||||
// }
|
||||
|
||||
// protected string SgdFilePath;
|
||||
// public EssentialsRoom CurrentRoom { get; protected set; }
|
||||
// protected Dictionary<IPresentationSource, DevicePageControllerBase> LoadedPageControllers
|
||||
// = new Dictionary<IPresentationSource, DevicePageControllerBase>();
|
||||
|
||||
// static object RoomChangeLock = new object();
|
||||
|
||||
// /// <summary>
|
||||
// /// Constructor
|
||||
// /// </summary>
|
||||
// public SmartGraphicsTouchpanelControllerBase(string key, string name, BasicTriListWithSmartObject triList,
|
||||
// string sgdFilePath)
|
||||
// : base(key, name, triList)
|
||||
// {
|
||||
// TriList = triList;
|
||||
// if (string.IsNullOrEmpty(key)) throw new ArgumentNullException("key");
|
||||
// if (string.IsNullOrEmpty(sgdFilePath)) throw new ArgumentNullException("sgdFilePath");
|
||||
// SgdFilePath = sgdFilePath;
|
||||
// TriList.LoadSmartObjects(SgdFilePath);
|
||||
// UsesSplashPage = true;
|
||||
// SplashMessage = "Welcome";
|
||||
// TriList.SigChange += Tsw_AnySigChange;
|
||||
// foreach (var kvp in TriList.SmartObjects)
|
||||
// kvp.Value.SigChange += this.Tsw_AnySigChange;
|
||||
// }
|
||||
|
||||
// public override bool CustomActivate()
|
||||
// {
|
||||
// var baseSuccess = base.CustomActivate();
|
||||
// if (!baseSuccess) return false;
|
||||
|
||||
// // Wiring up the buttons with UOs
|
||||
// foreach (var uo in this.FunctionList)
|
||||
// {
|
||||
// if (uo.Cue.Number == 0) continue;
|
||||
// if (uo is BoolCueActionPair)
|
||||
// TriList.BooleanOutput[uo.Cue.Number].UserObject = uo;
|
||||
// else if (uo is UShortCueActionPair)
|
||||
// TriList.UShortOutput[uo.Cue.Number].UserObject = uo;
|
||||
// else if (uo is StringCueActionPair)
|
||||
// TriList.StringOutput[uo.Cue.Number].UserObject = uo;
|
||||
// }
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// //public void SetCurrentRoom(EssentialsRoom room)
|
||||
// //{
|
||||
// // if (CurrentRoom != null)
|
||||
// // HideRoomUI();
|
||||
// // CurrentRoom = room;
|
||||
// // ShowRoomUI();
|
||||
// //}
|
||||
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// /// <param name="room"></param>
|
||||
// public void SetCurrentRoom(EssentialsRoom room)
|
||||
// {
|
||||
// if (CurrentRoom == room) return;
|
||||
|
||||
// IVolumeFunctions oldAudio = null;
|
||||
// //Disconnect current room and audio device
|
||||
// if (CurrentRoom != null)
|
||||
// {
|
||||
// HideRoomUI();
|
||||
// CurrentRoom.AudioDeviceWillChange -= CurrentRoom_AudioDeviceWillChange;
|
||||
// CurrentRoom.PresentationSourceChange -= CurrentRoom_PresentationSourceChange;
|
||||
// oldAudio = CurrentRoom.CurrentAudioDevice;
|
||||
// }
|
||||
|
||||
// CurrentRoom = room;
|
||||
// IVolumeFunctions newAudio = null;
|
||||
// if (CurrentRoom != null)
|
||||
// {
|
||||
// CurrentRoom.AudioDeviceWillChange += this.CurrentRoom_AudioDeviceWillChange;
|
||||
// CurrentRoom.PresentationSourceChange += this.CurrentRoom_PresentationSourceChange;
|
||||
// SetControlSource(CurrentRoom.CurrentPresentationSource);
|
||||
// newAudio = CurrentRoom.CurrentAudioDevice;
|
||||
// ShowRoomUI();
|
||||
// }
|
||||
|
||||
// SwapAudioDeviceControls(oldAudio, newAudio);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Detaches and attaches an IVolumeFunctions device to the appropriate TP TriList signals.
|
||||
// /// This will also add IVolumeNumeric if the device implements it.
|
||||
// /// Overriding classes should call this. Overriding classes are responsible for
|
||||
// /// linking up to hard keys, etc.
|
||||
// /// </summary>
|
||||
// /// <param name="oldDev">May be null</param>
|
||||
// /// <param name="newDev">May be null</param>
|
||||
// protected virtual void SwapAudioDeviceControls(IVolumeFunctions oldDev, IVolumeFunctions newDev)
|
||||
// {
|
||||
// // Disconnect
|
||||
// if (oldDev != null)
|
||||
// {
|
||||
// TriList.BooleanOutput[CommonBoolCue.VolumeDown.Number].UserObject = null;
|
||||
// TriList.BooleanOutput[CommonBoolCue.VolumeUp.Number].UserObject = null;
|
||||
// TriList.BooleanOutput[CommonBoolCue.MuteToggle.Number].UserObject = null;
|
||||
// TriList.BooleanInput[CommonBoolCue.ShowVolumeButtons.Number].BoolValue = false;
|
||||
// TriList.BooleanInput[CommonBoolCue.ShowVolumeSlider.Number].BoolValue = false;
|
||||
// if (oldDev is IVolumeTwoWay)
|
||||
// {
|
||||
// TriList.UShortOutput[CommonIntCue.MainVolumeLevel.Number].UserObject = null;
|
||||
// (oldDev as IVolumeTwoWay).IsMutedFeedback
|
||||
// .UnlinkInputSig(TriList.BooleanInput[CommonBoolCue.MuteOn.Number]);
|
||||
// (oldDev as IVolumeTwoWay).VolumeLevelFeedback
|
||||
// .UnlinkInputSig(TriList.UShortInput[CommonIntCue.MainVolumeLevel.Number]);
|
||||
// }
|
||||
// }
|
||||
// if (newDev != null)
|
||||
// {
|
||||
// TriList.BooleanInput[CommonBoolCue.ShowVolumeSlider.Number].BoolValue = true;
|
||||
// TriList.BooleanOutput[CommonBoolCue.VolumeDown.Number].UserObject = newDev.VolumeDownCueActionPair;
|
||||
// TriList.BooleanOutput[CommonBoolCue.VolumeUp.Number].UserObject = newDev.VolumeUpCueActionPair;
|
||||
// TriList.BooleanOutput[CommonBoolCue.MuteToggle.Number].UserObject = newDev.MuteToggleCueActionPair;
|
||||
// if (newDev is IVolumeTwoWay)
|
||||
// {
|
||||
// TriList.BooleanInput[CommonBoolCue.ShowVolumeSlider.Number].BoolValue = true;
|
||||
// var numDev = newDev as IVolumeTwoWay;
|
||||
// TriList.UShortOutput[CommonIntCue.MainVolumeLevel.Number].UserObject = numDev.VolumeLevelCueActionPair;
|
||||
// numDev.VolumeLevelFeedback
|
||||
// .LinkInputSig(TriList.UShortInput[CommonIntCue.MainVolumeLevel.Number]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Does nothing. Override to add functionality when calling SetCurrentRoom
|
||||
// /// </summary>
|
||||
// protected virtual void HideRoomUI() { }
|
||||
|
||||
// /// <summary>
|
||||
// /// Does nothing. Override to add functionality when calling SetCurrentRoom
|
||||
// /// </summary>
|
||||
// protected virtual void ShowRoomUI() { }
|
||||
|
||||
// /// <summary>
|
||||
// /// Sets up the current presentation device and updates statuses if the device is capable.
|
||||
// /// </summary>
|
||||
// protected void SetControlSource(IPresentationSource newSource)
|
||||
// {
|
||||
// if (CurrentPresentationControlDevice != null)
|
||||
// {
|
||||
// HideCurrentPresentationSourceUi();
|
||||
|
||||
// // Unhook presses and things
|
||||
// if (CurrentPresentationControlDevice is IHasCueActionList)
|
||||
// {
|
||||
// foreach (var uo in (CurrentPresentationControlDevice as IHasCueActionList).CueActionList)
|
||||
// {
|
||||
// if (uo.Cue.Number == 0) continue;
|
||||
// if (uo is BoolCueActionPair)
|
||||
// {
|
||||
// var bSig = TriList.BooleanOutput[uo.Cue.Number];
|
||||
// // Disconnection should also clear bool sigs in case they are pressed and
|
||||
// // might be orphaned
|
||||
// if (bSig.BoolValue)
|
||||
// (bSig.UserObject as BoolCueActionPair).Invoke(false);
|
||||
// bSig.UserObject = null;
|
||||
// }
|
||||
// else if (uo is UShortCueActionPair)
|
||||
// TriList.UShortOutput[uo.Cue.Number].UserObject = null;
|
||||
// else if (uo is StringCueActionPair)
|
||||
// TriList.StringOutput[uo.Cue.Number].UserObject = null;
|
||||
// }
|
||||
// }
|
||||
// // unhook outputs
|
||||
// if (CurrentPresentationControlDevice is IHasFeedback)
|
||||
// {
|
||||
// foreach (var output in (CurrentPresentationControlDevice as IHasFeedback).Feedbacks)
|
||||
// {
|
||||
// if (output.Cue.Number == 0) continue;
|
||||
// if (output is BoolFeedback)
|
||||
// (output as BoolFeedback).UnlinkInputSig(TriList.BooleanInput[output.Cue.Number]);
|
||||
// else if (output is IntFeedback)
|
||||
// (output as IntFeedback).UnlinkInputSig(TriList.UShortInput[output.Cue.Number]);
|
||||
// else if (output is StringFeedback)
|
||||
// (output as StringFeedback).UnlinkInputSig(TriList.StringInput[output.Cue.Number]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// CurrentPresentationControlDevice = newSource;
|
||||
// //connect presses and things
|
||||
// if (newSource is IHasCueActionList) // This has functions, get 'em
|
||||
// {
|
||||
// foreach (var ao in (newSource as IHasCueActionList).CueActionList)
|
||||
// {
|
||||
// if (ao.Cue.Number == 0) continue;
|
||||
// if (ao is BoolCueActionPair)
|
||||
// TriList.BooleanOutput[ao.Cue.Number].UserObject = ao;
|
||||
// else if (ao is UShortCueActionPair)
|
||||
// TriList.UShortOutput[ao.Cue.Number].UserObject = ao;
|
||||
// else if (ao is StringCueActionPair)
|
||||
// TriList.StringOutput[ao.Cue.Number].UserObject = ao;
|
||||
// }
|
||||
// }
|
||||
// // connect outputs (addInputSig should update sig)
|
||||
// if (CurrentPresentationControlDevice is IHasFeedback)
|
||||
// {
|
||||
// foreach (var output in (CurrentPresentationControlDevice as IHasFeedback).Feedbacks)
|
||||
// {
|
||||
// if (output.Cue.Number == 0) continue;
|
||||
// if (output is BoolFeedback)
|
||||
// (output as BoolFeedback).LinkInputSig(TriList.BooleanInput[output.Cue.Number]);
|
||||
// else if (output is IntFeedback)
|
||||
// (output as IntFeedback).LinkInputSig(TriList.UShortInput[output.Cue.Number]);
|
||||
// else if (output is StringFeedback)
|
||||
// (output as StringFeedback).LinkInputSig(TriList.StringInput[output.Cue.Number]);
|
||||
// }
|
||||
// }
|
||||
// ShowCurrentPresentationSourceUi();
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Reveals the basic UI for the current device
|
||||
// /// </summary>
|
||||
// protected virtual void ShowCurrentPresentationSourceUi()
|
||||
// {
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Hides the UI for the current device and calls for a feedback signal cleanup
|
||||
// /// </summary>
|
||||
// protected virtual void HideCurrentPresentationSourceUi()
|
||||
// {
|
||||
// }
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// void CurrentRoom_PresentationSourceChange(object sender, EssentialsRoomSourceChangeEventArgs args)
|
||||
// {
|
||||
// SetControlSource(args.NewSource);
|
||||
// }
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// void CurrentRoom_AudioDeviceWillChange(object sender, EssentialsRoomAudioDeviceChangeEventArgs e)
|
||||
// {
|
||||
// SwapAudioDeviceControls(e.OldDevice, e.NewDevice);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Panel event handler
|
||||
// /// </summary>
|
||||
// void Tsw_AnySigChange(object currentDevice, SigEventArgs args)
|
||||
// {
|
||||
// // plugged in commands
|
||||
// object uo = args.Sig.UserObject;
|
||||
|
||||
// if (uo is Action<bool>)
|
||||
// (uo as Action<bool>)(args.Sig.BoolValue);
|
||||
// else if (uo is Action<ushort>)
|
||||
// (uo as Action<ushort>)(args.Sig.UShortValue);
|
||||
// else if (uo is Action<string>)
|
||||
// (uo as Action<string>)(args.Sig.StringValue);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,287 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Extensions used for more-clear attachment of Actions to user objects on sigs
|
||||
/// </summary>
|
||||
public static class SigAndTriListExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Attaches Action to Sig's user object and returns the same Sig. This provides no protection
|
||||
/// from null sigs
|
||||
/// </summary>
|
||||
/// <param name="sig">The BoolOutputSig to attach the Action to</param>
|
||||
/// <param name="a">An action to run when sig is pressed and when released</param>
|
||||
/// <returns>The Sig, sig</returns>
|
||||
public static BoolOutputSig SetBoolSigAction(this BoolOutputSig sig, Action<bool> a)
|
||||
{
|
||||
sig.UserObject = a;
|
||||
return sig;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches Action to Sig's user object and returns the same Sig.
|
||||
/// </summary>
|
||||
/// <param name="tl"></param>
|
||||
/// <param name="sigNum"></param>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
public static BoolOutputSig SetBoolSigAction(this BasicTriList tl, uint sigNum, Action<bool> a)
|
||||
{
|
||||
return tl.BooleanOutput[sigNum].SetBoolSigAction(a);
|
||||
}
|
||||
|
||||
public static BoolOutputSig SetSigTrueAction(this BasicTriList tl, uint sigNum, Action a)
|
||||
{
|
||||
return tl.BooleanOutput[sigNum].SetBoolSigAction(b => { if(b) a(); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches a void Action to a TriList's output sig's UserObject, to be run on release
|
||||
/// </summary>
|
||||
/// <returns>The sig</returns>
|
||||
public static BoolOutputSig SetSigFalseAction(this BasicTriList tl, uint sigNum, Action a)
|
||||
{
|
||||
return tl.BooleanOutput[sigNum].SetBoolSigAction(b => { if (!b) a(); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches a void Action to an output sig's UserObject, to be run on release
|
||||
/// </summary>
|
||||
/// <returns>The Sig</returns>
|
||||
public static BoolOutputSig SetSigFalseAction(this BoolOutputSig sig, Action a)
|
||||
{
|
||||
return sig.SetBoolSigAction(b => { if (!b) a(); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets an action to a held sig
|
||||
/// </summary>
|
||||
/// <returns>The sig</returns>
|
||||
public static BoolOutputSig SetSigHeldAction(this BasicTriList tl, uint sigNum, uint heldMs, Action heldAction)
|
||||
{
|
||||
return SetSigHeldAction(tl, sigNum, heldMs, heldAction, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets an action to a held sig as well as a released-without-hold action
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static BoolOutputSig SetSigHeldAction(this BoolOutputSig sig, uint heldMs, Action heldAction, Action holdReleasedAction, Action releaseAction)
|
||||
{
|
||||
CTimer heldTimer = null;
|
||||
bool wasHeld = false;
|
||||
return sig.SetBoolSigAction(press =>
|
||||
{
|
||||
if (press)
|
||||
{
|
||||
wasHeld = false;
|
||||
// Could insert a pressed action here
|
||||
heldTimer = new CTimer(o =>
|
||||
{
|
||||
// if still held and there's an action
|
||||
if (sig.BoolValue && heldAction != null)
|
||||
{
|
||||
wasHeld = true;
|
||||
// Hold action here
|
||||
heldAction();
|
||||
}
|
||||
}, heldMs);
|
||||
}
|
||||
else if (!press && !wasHeld) // released, no hold
|
||||
{
|
||||
heldTimer.Stop();
|
||||
if (releaseAction != null)
|
||||
releaseAction();
|
||||
}
|
||||
else // !press && wasHeld // released after held
|
||||
{
|
||||
heldTimer.Stop();
|
||||
if (holdReleasedAction != null)
|
||||
holdReleasedAction();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets an action to a held sig as well as a released-without-hold action
|
||||
/// </summary>
|
||||
/// <returns>The sig</returns>
|
||||
public static BoolOutputSig SetSigHeldAction(this BasicTriList tl, uint sigNum, uint heldMs, Action heldAction, Action releaseAction)
|
||||
{
|
||||
return tl.BooleanOutput[sigNum].SetSigHeldAction(heldMs, heldAction, null, releaseAction);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets an action to a held sig, an action for the release of hold, as well as a released-without-hold action
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static BoolOutputSig SetSigHeldAction(this BasicTriList tl, uint sigNum, uint heldMs, Action heldAction,
|
||||
Action holdReleasedAction, Action releaseAction)
|
||||
{
|
||||
return tl.BooleanOutput[sigNum].SetSigHeldAction(heldMs, heldAction, holdReleasedAction, releaseAction);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sig"></param>
|
||||
/// <param name="a"></param>
|
||||
/// <returns>The Sig</returns>
|
||||
public static UShortOutputSig SetUShortSigAction(this UShortOutputSig sig, Action<ushort> a)
|
||||
{
|
||||
sig.UserObject = a;
|
||||
return sig;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="tl"></param>
|
||||
/// <param name="sigNum"></param>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
public static UShortOutputSig SetUShortSigAction(this BasicTriList tl, uint sigNum, Action<ushort> a)
|
||||
{
|
||||
return tl.UShortOutput[sigNum].SetUShortSigAction(a);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sig"></param>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
public static StringOutputSig SetStringSigAction(this StringOutputSig sig, Action<string> a)
|
||||
{
|
||||
sig.UserObject = a;
|
||||
return sig;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="tl"></param>
|
||||
/// <param name="sigNum"></param>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
public static StringOutputSig SetStringSigAction(this BasicTriList tl, uint sigNum, Action<string> a)
|
||||
{
|
||||
return tl.StringOutput[sigNum].SetStringSigAction(a);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sig"></param>
|
||||
/// <returns></returns>
|
||||
public static Sig ClearSigAction(this Sig sig)
|
||||
{
|
||||
sig.UserObject = null;
|
||||
return sig;
|
||||
}
|
||||
|
||||
public static BoolOutputSig ClearBoolSigAction(this BasicTriList tl, uint sigNum)
|
||||
{
|
||||
return ClearSigAction(tl.BooleanOutput[sigNum]) as BoolOutputSig;
|
||||
}
|
||||
|
||||
public static UShortOutputSig ClearUShortSigAction(this BasicTriList tl, uint sigNum)
|
||||
{
|
||||
return ClearSigAction(tl.UShortOutput[sigNum]) as UShortOutputSig;
|
||||
}
|
||||
|
||||
public static StringOutputSig ClearStringSigAction(this BasicTriList tl, uint sigNum)
|
||||
{
|
||||
return ClearSigAction(tl.StringOutput[sigNum]) as StringOutputSig;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to set the value of a bool Sig on TriList
|
||||
/// </summary>
|
||||
public static void SetBool(this BasicTriList tl, uint sigNum, bool value)
|
||||
{
|
||||
tl.BooleanInput[sigNum].BoolValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an true-false pulse to the sig
|
||||
/// </summary>
|
||||
/// <param name="tl"></param>
|
||||
/// <param name="sigNum"></param>
|
||||
public static void PulseBool(this BasicTriList tl, uint sigNum)
|
||||
{
|
||||
tl.BooleanInput[sigNum].Pulse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a timed pulse to the sig
|
||||
/// </summary>
|
||||
/// <param name="tl"></param>
|
||||
/// <param name="sigNum"></param>
|
||||
/// <param name="ms"></param>
|
||||
public static void PulseBool(this BasicTriList tl, uint sigNum, int ms)
|
||||
{
|
||||
tl.BooleanInput[sigNum].Pulse(ms);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to set the value of a ushort Sig on TriList
|
||||
/// </summary>
|
||||
public static void SetUshort(this BasicTriList tl, uint sigNum, ushort value)
|
||||
{
|
||||
tl.UShortInput[sigNum].UShortValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to set the value of a string Sig on TriList
|
||||
/// </summary>
|
||||
public static void SetString(this BasicTriList tl, uint sigNum, string value)
|
||||
{
|
||||
tl.StringInput[sigNum].StringValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns bool value of trilist sig
|
||||
/// </summary>
|
||||
/// <param name="tl"></param>
|
||||
/// <param name="sigNum"></param>
|
||||
/// <returns></returns>
|
||||
public static bool GetBool(this BasicTriList tl, uint sigNum)
|
||||
{
|
||||
return tl.BooleanOutput[sigNum].BoolValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns ushort value of trilist sig
|
||||
/// </summary>
|
||||
/// <param name="tl"></param>
|
||||
/// <param name="sigNum"></param>
|
||||
/// <returns></returns>
|
||||
public static ushort GetUshort(this BasicTriList tl, uint sigNum)
|
||||
{
|
||||
return tl.UShortOutput[sigNum].UShortValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns string value of trilist sig.
|
||||
/// </summary>
|
||||
/// <param name="tl"></param>
|
||||
/// <param name="sigNum"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetString(this BasicTriList tl, uint sigNum)
|
||||
{
|
||||
return tl.StringOutput[sigNum].StringValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user