Extensive keyboard development

This commit is contained in:
Heath Volmer
2017-09-25 17:23:04 -06:00
parent 1c63e506b8
commit a262dfdf5b
7 changed files with 375 additions and 110 deletions

View File

@@ -9,13 +9,28 @@ namespace PepperDash.Essentials.Core.Touchpanels.Keyboards
{ {
public class HabaneroKeyboardController 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 BasicTriList TriList { get; private set; }
public StringFeedback OutputFeedback { get; private set; } public StringFeedback OutputFeedback { get; private set; }
public bool IsVisible { get; private set; } public bool IsVisible { get; private set; }
int ShiftMode; 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; StringBuilder Output;
@@ -30,7 +45,7 @@ namespace PepperDash.Essentials.Core.Touchpanels.Keyboards
TriList = trilist; TriList = trilist;
Output = new StringBuilder(); Output = new StringBuilder();
OutputFeedback = new StringFeedback(() => Output.ToString()); OutputFeedback = new StringFeedback(() => Output.ToString());
DotComButtonString = ".com";
} }
/// <summary> /// <summary>
@@ -41,42 +56,51 @@ namespace PepperDash.Essentials.Core.Touchpanels.Keyboards
if (IsVisible) if (IsVisible)
return; return;
TriList.SetSigTrueAction(KeyboardClosePress, Hide); TriList.SetSigTrueAction(ClosePressJoin, Hide);
TriList.SetSigTrueAction(2921, () => Append(A(ShiftMode))); TriList.SetSigTrueAction(GoButtonPressJoin, () => OnKeyPress(KeyboardSpecialKey.GoButton));
TriList.SetSigTrueAction(2922, () => Append(B(ShiftMode))); TriList.SetSigTrueAction(SecondaryButtonPressJoin, () => OnKeyPress(KeyboardSpecialKey.SecondaryButton));
TriList.SetSigTrueAction(2923, () => Append(C(ShiftMode))); TriList.SetSigTrueAction(2921, () => Press(A(ShiftMode)));
TriList.SetSigTrueAction(2924, () => Append(D(ShiftMode))); TriList.SetSigTrueAction(2922, () => Press(B(ShiftMode)));
TriList.SetSigTrueAction(2925, () => Append(E(ShiftMode))); TriList.SetSigTrueAction(2923, () => Press(C(ShiftMode)));
TriList.SetSigTrueAction(2926, () => Append(F(ShiftMode))); TriList.SetSigTrueAction(2924, () => Press(D(ShiftMode)));
TriList.SetSigTrueAction(2927, () => Append(G(ShiftMode))); TriList.SetSigTrueAction(2925, () => Press(E(ShiftMode)));
TriList.SetSigTrueAction(2928, () => Append(H(ShiftMode))); TriList.SetSigTrueAction(2926, () => Press(F(ShiftMode)));
TriList.SetSigTrueAction(2929, () => Append(I(ShiftMode))); TriList.SetSigTrueAction(2927, () => Press(G(ShiftMode)));
TriList.SetSigTrueAction(2930, () => Append(J(ShiftMode))); TriList.SetSigTrueAction(2928, () => Press(H(ShiftMode)));
TriList.SetSigTrueAction(2931, () => Append(K(ShiftMode))); TriList.SetSigTrueAction(2929, () => Press(I(ShiftMode)));
TriList.SetSigTrueAction(2932, () => Append(L(ShiftMode))); TriList.SetSigTrueAction(2930, () => Press(J(ShiftMode)));
TriList.SetSigTrueAction(2933, () => Append(M(ShiftMode))); TriList.SetSigTrueAction(2931, () => Press(K(ShiftMode)));
TriList.SetSigTrueAction(2934, () => Append(N(ShiftMode))); TriList.SetSigTrueAction(2932, () => Press(L(ShiftMode)));
TriList.SetSigTrueAction(2935, () => Append(O(ShiftMode))); TriList.SetSigTrueAction(2933, () => Press(M(ShiftMode)));
TriList.SetSigTrueAction(2936, () => Append(P(ShiftMode))); TriList.SetSigTrueAction(2934, () => Press(N(ShiftMode)));
TriList.SetSigTrueAction(2937, () => Append(Q(ShiftMode))); TriList.SetSigTrueAction(2935, () => Press(O(ShiftMode)));
TriList.SetSigTrueAction(2938, () => Append(R(ShiftMode))); TriList.SetSigTrueAction(2936, () => Press(P(ShiftMode)));
TriList.SetSigTrueAction(2939, () => Append(S(ShiftMode))); TriList.SetSigTrueAction(2937, () => Press(Q(ShiftMode)));
TriList.SetSigTrueAction(2940, () => Append(T(ShiftMode))); TriList.SetSigTrueAction(2938, () => Press(R(ShiftMode)));
TriList.SetSigTrueAction(2941, () => Append(U(ShiftMode))); TriList.SetSigTrueAction(2939, () => Press(S(ShiftMode)));
TriList.SetSigTrueAction(2942, () => Append(V(ShiftMode))); TriList.SetSigTrueAction(2940, () => Press(T(ShiftMode)));
TriList.SetSigTrueAction(2943, () => Append(W(ShiftMode))); TriList.SetSigTrueAction(2941, () => Press(U(ShiftMode)));
TriList.SetSigTrueAction(2944, () => Append(X(ShiftMode))); TriList.SetSigTrueAction(2942, () => Press(V(ShiftMode)));
TriList.SetSigTrueAction(2945, () => Append(Y(ShiftMode))); TriList.SetSigTrueAction(2943, () => Press(W(ShiftMode)));
TriList.SetSigTrueAction(2946, () => Append(Z(ShiftMode))); TriList.SetSigTrueAction(2944, () => Press(X(ShiftMode)));
TriList.SetSigTrueAction(2947, () => Append('.')); TriList.SetSigTrueAction(2945, () => Press(Y(ShiftMode)));
TriList.SetSigTrueAction(2948, () => Append('@')); TriList.SetSigTrueAction(2946, () => Press(Z(ShiftMode)));
TriList.SetSigTrueAction(2949, () => Append(' ')); TriList.SetSigTrueAction(2947, () => Press('.'));
TriList.SetSigTrueAction(2948, () => Press('@'));
TriList.SetSigTrueAction(2949, () => Press(' '));
TriList.SetSigTrueAction(2950, Backspace); TriList.SetSigTrueAction(2950, Backspace);
TriList.SetSigTrueAction(2951, Clear); TriList.SetSigTrueAction(2951, Shift);
TriList.SetSigTrueAction(2952, Shift); TriList.SetSigTrueAction(2952, NumShift);
TriList.SetSigTrueAction(2953, 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); TriList.SetBool(KeyboardVisible, true);
ShowKeys();
IsVisible = true; IsVisible = true;
} }
@@ -103,20 +127,54 @@ namespace PepperDash.Essentials.Core.Touchpanels.Keyboards
/// ///
/// </summary> /// </summary>
/// <param name="c"></param> /// <param name="c"></param>
public void Append(char c) public void Press(char c)
{ {
OnKeyPress(c.ToString());
Output.Append(c); Output.Append(c);
OutputFeedback.FireUpdate(); OutputFeedback.FireUpdate();
ResetShift();
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="s"></param> /// <param name="s"></param>
public void Append(string s) public void Press(string s)
{ {
OnKeyPress(s);
Output.Append(s); Output.Append(s);
OutputFeedback.FireUpdate(); 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 A(int i) { return new char[] { 'a', 'A', '?', '?' }[i]; }
@@ -146,8 +204,11 @@ namespace PepperDash.Essentials.Core.Touchpanels.Keyboards
char Y(int i) { return new char[] { 'y', 'Y', '6', '^' }[i]; } char Y(int i) { return new char[] { 'y', 'Y', '6', '^' }[i]; }
char Z(int i) { return new char[] { 'z', 'Z', ',', ',' }[i]; } char Z(int i) { return new char[] { 'z', 'Z', ',', ',' }[i]; }
void Backspace() void Backspace()
{ {
OnKeyPress(KeyboardSpecialKey.Backspace);
if (Output.Length > 0) if (Output.Length > 0)
{ {
Output.Remove(Output.Length - 1, 1); Output.Remove(Output.Length - 1, 1);
@@ -157,10 +218,46 @@ namespace PepperDash.Essentials.Core.Touchpanels.Keyboards
void Clear() void Clear()
{ {
OnKeyPress(KeyboardSpecialKey.Clear);
Output.Remove(0, Output.Length); Output.Remove(0, Output.Length);
OutputFeedback.FireUpdate(); 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() void Shift()
{ {
if (ShiftMode == 0) if (ShiftMode == 0)
@@ -172,18 +269,72 @@ namespace PepperDash.Essentials.Core.Touchpanels.Keyboards
else else
ShiftMode = 2; ShiftMode = 2;
TriList.SetUshort(2951, 0); // 0 = up, 1 = down, 2 = #, 3 = 123 ShowKeys();
TriList.SetUshort(2952, 0); // 0 = #, 1 = abc
} }
void NumShift() void NumShift()
{ {
if (ShiftMode == 0 || ShiftMode == 1) if (ShiftMode == 0 || ShiftMode == 1)
ShiftMode = 2; ShiftMode = 2;
else if (ShiftMode == 2) else if (ShiftMode == 2 || ShiftMode == 3)
ShiftMode = 3;
else
ShiftMode = 0; 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));
} }
@@ -194,58 +345,67 @@ namespace PepperDash.Essentials.Core.Touchpanels.Keyboards
/// <summary> /// <summary>
/// 2902 /// 2902
/// </summary> /// </summary>
public const uint KeyboardClosePress = 2902; public const uint ClosePressJoin = 2902;
/// <summary> /// <summary>
/// 2903 /// 2903
/// </summary> /// </summary>
public const uint KeyboardButton1Press = 2903; public const uint GoButtonPressJoin = 2903;
/// <summary>
/// 2903
/// </summary>
public const uint GoButtonTextJoin = 2903;
/// <summary> /// <summary>
/// 2904 /// 2904
/// </summary> /// </summary>
public const uint KeyboardButton2Press = 2904; 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> /// <summary>
/// 2910 /// 2910
/// </summary> /// </summary>
public const uint KeyboardClearPress = 2910; public const uint ClearPressJoin = 2910;
/// <summary> /// <summary>
/// 2911 /// 2911
/// </summary> /// </summary>
public const uint KeyboardClearVisible = 2911; public const uint ClearVisibleJoin = 2911;
} }
/* When in mode 0 (lowercase): /// <summary>
* shift button: up arrow 0 ///
* numShift button: 123/#$@#$ 0 /// </summary>
* public class KeyboardControllerPressEventArgs : EventArgs
* - shift --> mode 1 {
* - double-tap shift --> caps lock public string Text { get; private set; }
* - numShift --> mode 2 public KeyboardSpecialKey SpecialKey { get; private set; }
*
* mode 1 (uppercase) public KeyboardControllerPressEventArgs(string text)
* shift button: down arrow 1 {
* numShift button: 123/##$# 0 Text = text;
* }
* - shift --> mode 0
* - numShift --> mode 2 public KeyboardControllerPressEventArgs(KeyboardSpecialKey key)
* {
* - Tapping any key will go back to mode 0 SpecialKey = key;
* }
* mode 2 (numbers-sym) }
* Shift button: #$#$#$ 2
* numShift: ABC 1 public enum KeyboardSpecialKey
* {
* - shift --> mode 3 None = 0, Backspace, Clear, GoButton, SecondaryButton
* - 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
*/
} }

View File

@@ -164,6 +164,18 @@ namespace PepperDash.Essentials
/// 1236 /// 1236
/// </summary> /// </summary>
public const uint VCStagingConnectEnable = 1236; public const uint VCStagingConnectEnable = 1236;
/// <summary>
/// 1237 - When the user touches the text field, should trigger keyboard
/// </summary>
public const uint VCKeypadTextPress = 1237;
/// <summary>
/// 1238
/// </summary>
public const uint VCKeypadBackspacePress = 1238;
/// <summary>
/// 1239
/// </summary>
public const uint VCKeypadBackspaceVisible = 1239;
//****************************************************** //******************************************************
// Keyboard // Keyboard
@@ -183,16 +195,14 @@ namespace PepperDash.Essentials
/// 2904 /// 2904
/// </summary> /// </summary>
public const uint KeyboardButton2Press = 2904; public const uint KeyboardButton2Press = 2904;
/// <summary> /// <summary>
/// 2910 /// 2910
/// </summary> /// </summary>
public const uint KeyboardClearPress = 2910; //public const uint KeyboardClearPress = 2910;
/// <summary> /// <summary>
/// 2911 /// 2911
/// </summary> /// </summary>
public const uint KeyboardClearVisible = 2911; //public const uint KeyboardClearVisible = 2911;
// Letter joins start at 2921; // Letter joins start at 2921;

View File

@@ -13,12 +13,20 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
public class UIStringJoin public class UIStringJoin
{ {
//******************************************************
// Codec
/// <summary>
/// 1001
/// </summary>
public const uint CodecAddressEntryText = 1001;
//****************************************************** //******************************************************
// Keyboard // Keyboard
/// <summary> /// <summary>
/// 1901 /// 1901
/// </summary> /// </summary>
public const uint KeyboardText = 2901; //public const uint KeypadText = 2901;
/// <summary> /// <summary>
/// 3812 /// 3812

View File

@@ -85,11 +85,6 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
SubpageReferenceList ActivityFooterSrl; SubpageReferenceList ActivityFooterSrl;
/// <summary>
/// Tracks which audio page group the UI is in
/// </summary>
UiDisplayMode CurrentDisplayMode;
/// <summary> /// <summary>
/// The AV page mangagers that have been used, to keep them alive for later /// The AV page mangagers that have been used, to keep them alive for later
/// </summary> /// </summary>

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
@@ -9,6 +10,7 @@ using PepperDash.Core;
using PepperDash.Essentials; using PepperDash.Essentials;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.SmartObjects; using PepperDash.Essentials.Core.SmartObjects;
using PepperDash.Essentials.Core.Touchpanels.Keyboards;
using PepperDash.Essentials.Devices.Common.Codec; using PepperDash.Essentials.Devices.Common.Codec;
using PepperDash.Essentials.Devices.Common.VideoCodec; using PepperDash.Essentials.Devices.Common.VideoCodec;
@@ -31,12 +33,6 @@ namespace PepperDash.Essentials.UIDrivers.VC
/// </summary> /// </summary>
VideoCodecBase Codec; VideoCodecBase Codec;
/// <summary>
///
/// </summary>
SmartObjectDynamicList DirectorySrl; // ***************** SRL ???
/// <summary> /// <summary>
/// To drive UI elements outside of this driver that may be dependent on this. /// To drive UI elements outside of this driver that may be dependent on this.
/// </summary> /// </summary>
@@ -90,10 +86,8 @@ namespace PepperDash.Essentials.UIDrivers.VC
InCall = new BoolFeedback(() => false); InCall = new BoolFeedback(() => false);
LocalPrivacyIsMuted = new BoolFeedback(() => false); LocalPrivacyIsMuted = new BoolFeedback(() => false);
//DirectorySrl = new SubpageReferenceList(triList, UISmartObjectJoin.VCDirectoryList, 3, 3, 3);
VCControlsInterlock = new JoinedSigInterlock(triList); VCControlsInterlock = new JoinedSigInterlock(triList);
VCControlsInterlock.SetButDontShow(UIBoolJoin.VCDirectoryVisible); VCControlsInterlock.SetButDontShow(UIBoolJoin.VCKeypadVisible);
StagingBarInterlock = new JoinedSigInterlock(triList); StagingBarInterlock = new JoinedSigInterlock(triList);
StagingBarInterlock.SetButDontShow(UIBoolJoin.VCStagingInactivePopoverVisible); StagingBarInterlock.SetButDontShow(UIBoolJoin.VCStagingInactivePopoverVisible);
@@ -101,13 +95,22 @@ namespace PepperDash.Essentials.UIDrivers.VC
StagingButtonFeedbackInterlock = new JoinedSigInterlock(triList); StagingButtonFeedbackInterlock = new JoinedSigInterlock(triList);
StagingButtonFeedbackInterlock.ShowInterlocked(UIBoolJoin.VCRecentsVisible); StagingButtonFeedbackInterlock.ShowInterlocked(UIBoolJoin.VCRecentsVisible);
DialStringFeedback = new StringFeedback(() => DialStringBuilder.ToString()); // Return formatted when dialing, straight digits when in call
DialStringFeedback.LinkInputSig(triList.StringInput[UIStringJoin.KeyboardText]); DialStringFeedback = new StringFeedback(() =>
{
if (KeypadMode == eKeypadMode.Dial)
return GetFormattedDialString(DialStringBuilder.ToString());
else
return DialStringBuilder.ToString();
});
DialStringFeedback.LinkInputSig(triList.StringInput[UIStringJoin.CodecAddressEntryText]);
DialStringBackspaceVisibleFeedback = new BoolFeedback(() => DialStringBuilder.Length > 0); DialStringBackspaceVisibleFeedback = new BoolFeedback(() => DialStringBuilder.Length > 0);
DialStringBackspaceVisibleFeedback DialStringBackspaceVisibleFeedback
.LinkInputSig(TriList.BooleanInput[UIBoolJoin.KeyboardClearVisible]); .LinkInputSig(TriList.BooleanInput[UIBoolJoin.VCKeypadBackspaceVisible]);
TriList.SetSigFalseAction(UIBoolJoin.VCKeypadTextPress, RevealKeyboard);
} }
/// <summary> /// <summary>
@@ -127,7 +130,7 @@ namespace PepperDash.Essentials.UIDrivers.VC
KeypadMode = eKeypadMode.DTMF; KeypadMode = eKeypadMode.DTMF;
DialStringBuilder.Remove(0, DialStringBuilder.Length); DialStringBuilder.Remove(0, DialStringBuilder.Length);
DialStringFeedback.FireUpdate(); DialStringFeedback.FireUpdate();
TriList.SetBool(UIBoolJoin.KeyboardClearVisible, false); TriList.SetBool(UIBoolJoin.VCKeypadBackspaceVisible, false);
break; break;
case eCodecCallStatus.Connecting: case eCodecCallStatus.Connecting:
// fire at SRL item // fire at SRL item
@@ -297,13 +300,58 @@ namespace PepperDash.Essentials.UIDrivers.VC
DialKeypad.Misc1.SetSigFalseAction(() => DialKeypadPress("*")); DialKeypad.Misc1.SetSigFalseAction(() => DialKeypadPress("*"));
DialKeypad.Misc2SigName = "#"; DialKeypad.Misc2SigName = "#";
DialKeypad.Misc2.SetSigFalseAction(() => DialKeypadPress("#")); DialKeypad.Misc2.SetSigFalseAction(() => DialKeypadPress("#"));
TriList.SetSigFalseAction(UIBoolJoin.KeyboardClearPress, DialKeypadBackspacePress); TriList.SetSigFalseAction(UIBoolJoin.VCKeypadBackspacePress, DialKeypadBackspacePress);
} }
else else
Debug.Console(0, "Trilist {0:x2}, VC dial keypad object {1} not found. Check SGD file or VTP", Debug.Console(0, "Trilist {0:x2}, VC dial keypad object {1} not found. Check SGD file or VTP",
TriList.ID, UISmartObjectJoin.VCDialKeypad); TriList.ID, UISmartObjectJoin.VCDialKeypad);
} }
/// <summary>
///
/// </summary>
void RevealKeyboard()
{
if (KeypadMode == eKeypadMode.Dial)
{
var kb = Parent.Keyboard;
kb.KeyPress += new EventHandler<PepperDash.Essentials.Core.Touchpanels.Keyboards.KeyboardControllerPressEventArgs>(Keyboard_KeyPress);
kb.HideAction = this.DetachKeyboard;
kb.GoButtonText = "Connect";
kb.GoButtonVisible = true;
DialStringKeypadCheckEnables();
kb.Show();
}
}
/// <summary>
///
/// </summary>
void Keyboard_KeyPress(object sender, PepperDash.Essentials.Core.Touchpanels.Keyboards.KeyboardControllerPressEventArgs e)
{
if (e.Text != null)
DialStringBuilder.Append(e.Text);
else
{
if (e.SpecialKey == KeyboardSpecialKey.Backspace)
DialKeypadBackspacePress();
else if (e.SpecialKey == KeyboardSpecialKey.Clear)
DialKeypadClear();
else if (e.SpecialKey == KeyboardSpecialKey.GoButton)
{
ConnectPress();
Parent.Keyboard.Hide();
}
}
DialStringFeedback.FireUpdate();
DialStringKeypadCheckEnables();
}
void DetachKeyboard()
{
Parent.Keyboard.KeyPress -= Keyboard_KeyPress;
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@@ -371,8 +419,7 @@ namespace PepperDash.Essentials.UIDrivers.VC
{ {
DialStringBuilder.Append(i); DialStringBuilder.Append(i);
DialStringFeedback.FireUpdate(); DialStringFeedback.FireUpdate();
TriList.BooleanInput[UIBoolJoin.KeyboardClearVisible].BoolValue = DialStringKeypadCheckEnables();
DialStringBuilder.Length > 0;
} }
else else
{ {
@@ -390,9 +437,54 @@ namespace PepperDash.Essentials.UIDrivers.VC
{ {
DialStringBuilder.Remove(DialStringBuilder.Length - 1, 1); DialStringBuilder.Remove(DialStringBuilder.Length - 1, 1);
DialStringFeedback.FireUpdate(); DialStringFeedback.FireUpdate();
TriList.BooleanInput[UIBoolJoin.KeyboardClearVisible].BoolValue = DialStringKeypadCheckEnables();
DialStringBuilder.Length > 0; }
TriList.SetBool(UIBoolJoin.VCStagingConnectEnable, DialStringBuilder.Length > 0);
/// <summary>
/// Clears the dial keypad
/// </summary>
void DialKeypadClear()
{
DialStringBuilder.Remove(0, DialStringBuilder.Length);
DialStringFeedback.FireUpdate();
DialStringKeypadCheckEnables();
}
/// <summary>
/// Checks the enabled states of various elements around the keypad
/// </summary>
void DialStringKeypadCheckEnables()
{
var textIsEntered = DialStringBuilder.Length > 0;
TriList.SetBool(UIBoolJoin.VCKeypadBackspaceVisible, textIsEntered);
TriList.SetBool(UIBoolJoin.VCStagingConnectEnable, textIsEntered);
if (textIsEntered)
Parent.Keyboard.EnableGoButton();
else
Parent.Keyboard.DisableGoButton();
}
/// <summary>
///
/// </summary>
/// <returns></returns>
string GetFormattedDialString(string ds)
{
if(Regex.Match(ds, @"^\d{4,7}$").Success) // 456-7890
return string.Format("{0}-{1}", ds.Substring(0, 3), ds.Substring(3));
if (Regex.Match(ds, @"^9\d{4,7}$").Success) // 456-7890
return string.Format("9 {0}-{1}", ds.Substring(1, 3), ds.Substring(4));
if (Regex.Match(ds, @"^\d{8,10}$").Success) // 123-456-78
return string.Format("({0}) {1}-{2}", ds.Substring(0, 3), ds.Substring(3, 3), ds.Substring(6));
if (Regex.Match(ds, @"^\d{10}$").Success) // 123-456-7890 full
return string.Format("({0}) {1}-{2}", ds.Substring(0, 3), ds.Substring(3, 3), ds.Substring(6));
if (Regex.Match(ds, @"^1\d{10}$").Success)
return string.Format("+1 ({0}) {1}-{2}", ds.Substring(1, 3), ds.Substring(4, 3), ds.Substring(7));
if (Regex.Match(ds, @"^9\d{10}$").Success)
return string.Format("9 ({0}) {1}-{2}", ds.Substring(1, 3), ds.Substring(4, 3), ds.Substring(7));
if (Regex.Match(ds, @"^91\d{10}$").Success)
return string.Format("9 +1 ({0}) {1}-{2}", ds.Substring(2, 3), ds.Substring(5, 3), ds.Substring(8));
return ds;
} }
enum eKeypadMode enum eKeypadMode