Skip to content

Commit

Permalink
Added UID Keyboard Entry
Browse files Browse the repository at this point in the history
  • Loading branch information
dshalaby committed Sep 24, 2020
1 parent a15349b commit eb6558a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 14 deletions.
18 changes: 11 additions & 7 deletions Example/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
xmlns:demo="clr-namespace:TapTrack.Demo"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Title="Tappy Demo 3.0" Height="650" Width="800" Foreground="{x:Null}" Background="{StaticResource LightBackground}">
Title="Tappy Demo 3.1" Height="650" Width="800" Foreground="{x:Null}" Background="{StaticResource LightBackground}">
<Grid Background="{StaticResource LightBackground}">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
Expand Down Expand Up @@ -382,10 +382,14 @@
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Foreground="White" Text="Activate keyboard wedge mode"/>
<TextBlock Foreground="White" Text="Activate keyboard wedge mode to read NDEF Text" Grid.ColumnSpan="2" Margin="320,0,51.2,0"/>
<ToggleButton Grid.Column="1" HorizontalAlignment="Right" Name="tgbtnLaunchKeyboardFeature"
Width="50" Height="30" Margin="0,0,20,0" Style="{StaticResource AnimatedSwitch }"
Checked="tgbtnLaunchKeyboardFeature_Checked" Unchecked="tgbtnLaunchKeyboardFeature_Unchecked"/>
<TextBlock Foreground="White" Text="Activate keyboard wedge mode to read UIDs" Margin="320,45,51.2,-45" Grid.ColumnSpan="2"/>
<ToggleButton Grid.Column="1" HorizontalAlignment="Right" Name="tgbtnLaunchKeyboardFeatureUid"
Width="50" Height="30" Margin="0,45,20.2,-45" Style="{StaticResource AnimatedSwitch }"
Checked="tgbtnLaunchKeyboardFeatureUid_Checked" Unchecked="tgbtnLaunchKeyboardFeatureUid_Unchecked"/>
<!--Checked="tgbtnLaunchKeyboardFeature_Checked"-->
</Grid>
</StackPanel>
Expand Down Expand Up @@ -471,7 +475,7 @@
Batch Encode NFC Tags
</TextBlock>
<TextBlock Foreground="White" TextWrapping="Wrap">
This is used to encode a batch of tags based on an imported file.
This is used to encode a batch of tags based on an imported file.
</TextBlock>
<TextBlock Foreground="White" TextWrapping="Wrap" Margin="0,10,0,10">
The imported file should be a .csv or .txt file, and contain a single column for the URI or text for the NDEF with each entry appearing on a new line as follows:
Expand Down Expand Up @@ -601,10 +605,10 @@
<DataGridTextColumn Header="Encoded" Binding="{Binding encodedSuccessfully, Converter={StaticResource intToYesNoConverter}}" Width="500"/>
</DataGrid.Columns>
</DataGrid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button HorizontalAlignment="Right" Style="{StaticResource RoundButton}" Click="ExportImportedBatch">
Export to spreadsheet
</Button>
Export to spreadsheet
</Button>
<Button HorizontalAlignment="Right" Style="{StaticResource RoundButton}" Click="ClearImportedBatch">
Delete Imported Batch
</Button>
Expand All @@ -619,7 +623,7 @@
Export a spreadsheet of all tags batch encoded on this station
</TextBlock>
<StackPanel Margin="10" DockPanel.Dock="Top">

<Button HorizontalAlignment="Right" Style="{StaticResource RoundButton}" Click="ExportEncodingEvents">
Export Encoded Tag List
</Button>
Expand Down
36 changes: 34 additions & 2 deletions Example/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public partial class MainWindow : Window
bool keyboardModeLineBreak = false;
bool keyboardModeTab = false;
bool keyboardModeTabLineBreakLast = false;
bool keyboardModeUid = false;

int numTagsEncodedInThisBatch = 0;
string batchPassword = null;
Expand Down Expand Up @@ -897,9 +898,18 @@ private void chbxAddlineBreak_Unchecked(object sender, RoutedEventArgs e)

private void tgbtnLaunchKeyboardFeature_Checked(object sender, RoutedEventArgs e)
{
keyboardModeUid = false;
StreamNdef streamNdef = new StreamNdef(0, DetectTagSetting.Type2Type4AandMifare);
tappy.SendCommand(streamNdef, InvokeKeyboardFeature);


StreamNdef stream = new StreamNdef(0, DetectTagSetting.Type2Type4AandMifare);
tappy.SendCommand(stream, InvokeKeyboardFeature);
}

private void tgbtnLaunchKeyboardFeatureUid_Checked(object sender, RoutedEventArgs e)
{
keyboardModeUid = true;
StreamUid streamUid = new StreamUid(0, DetectTagSetting.Type2Type4AandMifare);
tappy.SendCommand(streamUid, InvokeKeyboardFeature);

}

Expand All @@ -918,6 +928,7 @@ private void InvokeKeyboardFeature(ResponseFrame frame, Exception e)

if (temp.Length > 0)
{
if (keyboardModeUid == false) {
Array.Copy(data, 2 + data[1], temp, 0, temp.Length);

NdefMessage message = NdefMessage.FromByteArray(temp);
Expand Down Expand Up @@ -954,6 +965,21 @@ private void InvokeKeyboardFeature(ResponseFrame frame, Exception e)
};

Dispatcher.BeginInvoke(EnterKeystrokes);
}
else //keyboard UID mode
{
Tag tag = new Tag(frame.Data);

Action EnterKeystrokesUid = () =>
{
System.Windows.Forms.SendKeys.SendWait(BitConverter.ToString(tag.UID));
if (keyboardModeLineBreak)
System.Windows.Forms.SendKeys.SendWait("{ENTER}");
if (keyboardModeTab)
System.Windows.Forms.SendKeys.SendWait("{TAB}");
};
Dispatcher.BeginInvoke(EnterKeystrokesUid);
}
}
}

Expand All @@ -964,6 +990,12 @@ private void tgbtnLaunchKeyboardFeature_Unchecked(object sender, RoutedEventArgs
tappy.SendCommand<Stop>();
}

private void tgbtnLaunchKeyboardFeatureUid_Unchecked(object sender, RoutedEventArgs e)
{
tappy.SendCommand<Stop>();
}


void TextBox_KeyPressed(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key.ToString() == "Tab")
Expand Down
4 changes: 2 additions & 2 deletions Example/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
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("3.0.0.0")]
[assembly: AssemblyFileVersion("3.0.0.0")]
[assembly: AssemblyVersion("3.1.0.0")]
[assembly: AssemblyFileVersion("3.1.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 3.0</AssemblyName>
<AssemblyName>Tappy Demo 3.1</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 3.0.xml</DocumentationFile>
<DocumentationFile>bin\Debug\Tappy Demo 3.1.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 3.0.xml</DocumentationFile>
<DocumentationFile>bin\Release\Tappy Demo 3.1.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>DA55EDA3D657C041EF308F9D8CDF1B5A4950F2E4</ManifestCertificateThumbprint>
Expand Down

0 comments on commit eb6558a

Please sign in to comment.