Skip to content

Commit

Permalink
Updated keyboard entry mode, added empty NDEF record handling, update…
Browse files Browse the repository at this point in the history
…d kiosk/keyboard wedge configuration command (system command family)
  • Loading branch information
dshalaby committed Aug 22, 2017
1 parent 18b5fb5 commit 929668d
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 46 deletions.
8 changes: 6 additions & 2 deletions Example/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
xmlns:gif="http://wpfanimatedgif.codeplex.com"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Title="Tappy Demo 2.3" Height="650" Width="800" Foreground="{x:Null}" Background="{StaticResource LightBackground}">
Title="Tappy Demo 2.4" Height="650" Width="800" Foreground="{x:Null}" Background="{StaticResource LightBackground}">
<Grid Background="{StaticResource LightBackground}">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
Expand Down Expand Up @@ -211,7 +211,7 @@
</TextBlock>
</StackPanel>
<Label Margin="10,10,0,0" Padding="0,0,0,10" Foreground="White" Target="{Binding ElementName=TextBox}" Content="Text"/>
<TextBox Name="TextBox" Margin="10,0,20,20" Foreground="White" Background="{StaticResource LightBackground}" BorderBrush="#595959" BorderThickness="0,0,0,1"/>
<TextBox Name="TextBox" Margin="10,0,20,20" Foreground="White" Background="{StaticResource LightBackground}" BorderBrush="#595959" BorderThickness="0,0,0,1" AcceptsTab="True" AcceptsReturn="True" KeyUp="TextBox_KeyPressed"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Name="writeTextButton" Style="{StaticResource RoundButton}" Click="WriteTextButton_Click">Write</Button>
<CheckBox Name="repeatTextWrite" IsChecked="False" VerticalAlignment="Center"/>
Expand Down Expand Up @@ -464,6 +464,10 @@
<StackPanel Margin="10">
<CheckBox Style="{StaticResource SimpleCheckBox}" Name="chbxAddlineBreak" Content=" Add CR, LF after each record" Foreground="White" Margin="2"
Checked="chbxAddlineBreak_Checked" Unchecked="chbxAddlineBreak_Unchecked"/>
<CheckBox Style="{StaticResource SimpleCheckBox}" Name="chbxAddTab" Content=" Add TAB after each record" Foreground="White" Margin="2"
Checked="chbxAddTab_Checked" Unchecked="chbxAddTab_Unchecked"/>
<CheckBox Style="{StaticResource SimpleCheckBox}" Name="chbxAddTabLineBreakLast" Content=" Add TAB after each record and CR,LF after final record" Foreground="White" Margin="2"
Checked="chbxAddTabLineBreakLast_Checked" Unchecked="chbxAddTabLineBreakLast_Unchecked"/>
</StackPanel>
</StackPanel>
<Grid Background="{StaticResource DarkBackground}">
Expand Down
126 changes: 92 additions & 34 deletions Example/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public partial class MainWindow : Window
TappyReader tappy;
private ObservableCollection<Row> table;
GridLength zeroHeight = new GridLength(0);
bool KeyboardModeLineBreak = false;
bool keyboardModeLineBreak = false;
bool keyboardModeTab = false;
bool keyboardModeTabLineBreakLast = false;

public MainWindow()
{
Expand All @@ -41,7 +43,9 @@ public MainWindow()
table = new ObservableCollection<Row>();
records.ItemsSource = table;
this.Closed += MainWindow_Closed;
}


}

private void MainWindow_Closed(object sender, EventArgs e)
{
Expand Down Expand Up @@ -82,35 +86,43 @@ private void AddNdefContent(ResponseFrame frame, Exception e)
{
ndefData.AppendText("Ndef Record:\n\n");
string type = Encoding.UTF8.GetString(record.Type);
ndefData.AppendText($"TNF: {record.TypeNameFormat.ToString()} ({(byte)record.TypeNameFormat})\n");
ndefData.AppendText($"Type: {type}\n");
if (record.Id != null)
ndefData.AppendText($"Type: {BitConverter.ToString(record.Id)}\n");
if (type.Equals("U"))
{
NdefUriRecord uriRecord = new NdefUriRecord(record);
ndefData.AppendText($"Payload: {uriRecord.Uri}\n");
}
else if (type.Equals("T"))
{
NdefTextRecord textRecord = new NdefTextRecord(record);
ndefData.AppendText($"Encoding: {textRecord.TextEncoding.ToString()}\n");
ndefData.AppendText($"Language: {textRecord.LanguageCode}\n");
ndefData.AppendText($"Payload: {textRecord.Text}\n");
}
else if (type.Contains("text"))
{
ndefData.AppendText($"Payload: {Encoding.UTF8.GetString(record.Payload)}\n");
}
else
{
ndefData.AppendText($"Payload: {BitConverter.ToString(record.Payload)}");
}
ndefData.AppendText($"----------\n");
if (record.TypeNameFormat == NdefRecord.TypeNameFormatType.Empty)
{
ndefData.AppendText("Empty NDEF Record");
}
else
{
string type = Encoding.UTF8.GetString(record.Type);
ndefData.AppendText($"TNF: {record.TypeNameFormat.ToString()} ({(byte)record.TypeNameFormat})\n");
ndefData.AppendText($"Type: {type}\n");
if (record.Id != null)
ndefData.AppendText($"Type: {BitConverter.ToString(record.Id)}\n");
if (type.Equals("U"))
{
NdefUriRecord uriRecord = new NdefUriRecord(record);
ndefData.AppendText($"Payload: {uriRecord.Uri}\n");
}
else if (type.Equals("T"))
{
NdefTextRecord textRecord = new NdefTextRecord(record);
ndefData.AppendText($"Encoding: {textRecord.TextEncoding.ToString()}\n");
ndefData.AppendText($"Language: {textRecord.LanguageCode}\n");
ndefData.AppendText($"Payload: {textRecord.Text}\n");
}
else if (type.Contains("text"))
{
ndefData.AppendText($"Payload: {Encoding.UTF8.GetString(record.Payload)}\n");
}
else
{
ndefData.AppendText($"Payload: {BitConverter.ToString(record.Payload)}");
}
ndefData.AppendText($"----------\n");
}
}
};

Expand Down Expand Up @@ -877,12 +889,12 @@ private string GetBluegigaDevice()

private void chbxAddlineBreak_Checked(object sender, RoutedEventArgs e)
{
KeyboardModeLineBreak = true;
keyboardModeLineBreak = true;
}

private void chbxAddlineBreak_Unchecked(object sender, RoutedEventArgs e)
{
KeyboardModeLineBreak = false;
keyboardModeLineBreak = false;
}

private void tgbtnLaunchKeyboardFeature_Checked(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -912,6 +924,9 @@ private void InvokeKeyboardFeature(ResponseFrame frame, Exception e)

NdefMessage message = NdefMessage.FromByteArray(temp);

int numRecords = message.Count;
int recordNum = 1;

Action EnterKeystrokes = () =>
{
foreach (NdefRecord record in message)
Expand All @@ -921,8 +936,20 @@ private void InvokeKeyboardFeature(ResponseFrame frame, Exception e)
{
NdefTextRecord textRecord = new NdefTextRecord(record);
System.Windows.Forms.SendKeys.SendWait(textRecord.Text);
if (KeyboardModeLineBreak)
if (keyboardModeLineBreak)
System.Windows.Forms.SendKeys.SendWait("{ENTER}");
if (keyboardModeTab)
System.Windows.Forms.SendKeys.SendWait("{TAB}");
if (keyboardModeTabLineBreakLast)
{
if (recordNum == numRecords)
System.Windows.Forms.SendKeys.SendWait("{ENTER}");
else
System.Windows.Forms.SendKeys.SendWait("{TAB}");
}
recordNum++;
}
}
Expand All @@ -938,6 +965,37 @@ private void tgbtnLaunchKeyboardFeature_Unchecked(object sender, RoutedEventArgs
{
tappy.SendCommand<Stop>();
}

void TextBox_KeyPressed(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key.ToString() == "Tab")
{
ShowSuccessStatus("Tab key entered into text record");
}

}


#endregion

private void chbxAddTab_Unchecked(object sender, RoutedEventArgs e)
{
keyboardModeTab = false;
}

private void chbxAddTab_Checked(object sender, RoutedEventArgs e)
{
keyboardModeTab = true;
}

private void chbxAddTabLineBreakLast_Unchecked(object sender, RoutedEventArgs e)
{
keyboardModeTabLineBreakLast = false;
}

private void chbxAddTabLineBreakLast_Checked(object sender, RoutedEventArgs e)
{
keyboardModeTabLineBreakLast = true;
}
}
}
6 changes: 3 additions & 3 deletions Example/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Tappy Demo")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down Expand Up @@ -51,7 +51,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
[assembly: AssemblyVersion("2.4.0.0")]
[assembly: AssemblyFileVersion("2.4.0.0")]
[assembly: NeutralResourcesLanguage("en-CA")]

6 changes: 3 additions & 3 deletions Example/Tappy Tcmp Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TapTrack.Demo</RootNamespace>
<AssemblyName>Tappy Demo 2.3</AssemblyName>
<AssemblyName>Tappy Demo 2.4</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand Down Expand Up @@ -49,7 +49,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Tappy Demo 2.3.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Tappy Demo 2.4.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -59,7 +59,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Tappy Demo 2.3.xml</DocumentationFile>
<DocumentationFile>bin\Release\Tappy Demo 2.4.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>DA55EDA3D657C041EF308F9D8CDF1B5A4950F2E4</ManifestCertificateThumbprint>
Expand Down
4 changes: 2 additions & 2 deletions Tcmp-SDK/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: AssemblyVersion("0.5.1.0")]
[assembly: AssemblyFileVersion("0.5.1.0")]
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace TapTrack.Tcmp.CommandFamilies.System
using System;

namespace TapTrack.Tcmp.CommandFamilies.System
{

/// <summary>
/// Command to configure thee Tappy when in keyboard wedge/ kiosk mode
/// </summary>
Expand All @@ -14,13 +17,25 @@ public override byte CommandCode
return commandCode;
}
}
public ConfigureKioskKeyboardWedgeMode(byte dualTagDetection, byte ndefReading, byte hearbeatPeriod, byte enableScanErrMsgs)
public ConfigureKioskKeyboardWedgeMode(byte dualTagDetection, byte ndefReading, byte hearbeatPeriod, byte enableScanErrMsgs, short postSuccessDelay, short postFailDelay, short postScanStagger)
{
byte[] successMsDelay = BitConverter.GetBytes(postSuccessDelay);
byte[] failMsDelay = BitConverter.GetBytes(postFailDelay);
byte[] staggerMs = BitConverter.GetBytes(postScanStagger);

Array.Reverse(successMsDelay);
Array.Reverse(failMsDelay);
Array.Reverse(staggerMs);

this.parameters.Add(dualTagDetection);
this.parameters.Add(ndefReading);
this.parameters.Add(hearbeatPeriod);
this.parameters.Add(enableScanErrMsgs);

this.parameters.AddRange(successMsDelay);
this.parameters.AddRange(failMsDelay);
this.parameters.AddRange(staggerMs);

}

}
Expand Down

0 comments on commit 929668d

Please sign in to comment.