Windows 10 Version 1803 - BarcodeScanner video preview and JS fixes
This commit is contained in:
Родитель
96d2394fa1
Коммит
fe8567faf2
|
@ -75,6 +75,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
DisplayName="Accelerometer JS Sample"
|
||||
Description="Accelerometer JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
|
|
|
@ -65,6 +65,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
DisplayName="Activity Sensor JS Sample"
|
||||
Description="Activity Sensor JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
|
|
|
@ -68,6 +68,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -67,6 +67,9 @@
|
|||
<Content Include="..\..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
DisplayName="AllJoyn Consumer Experiences JS Sample"
|
||||
Description="AllJoyn Consumer Experiences JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
|
|
|
@ -69,6 +69,9 @@
|
|||
<Content Include="..\..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</Resources>
|
||||
<Applications>
|
||||
<Application Id="App" StartPage="default.html">
|
||||
<uap:VisualElements DisplayName="AllJoyn Producer Experiences JS Sample" Description="AllJoyn Producer Experiences JS Sample" BackgroundColor="#00b2f0" Square150x150Logo="images\storelogo-sdk.png" Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:VisualElements DisplayName="AllJoyn Producer Experiences JS Sample" Description="AllJoyn Producer Experiences JS Sample" BackgroundColor="#00b2f0" Square150x150Logo="images\squaretile-sdk.png" Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
<uap:ShowNameOnTiles>
|
||||
|
|
|
@ -73,6 +73,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
DisplayName="Altimeter JS sample"
|
||||
Description="Altimeter JS sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
|
|
|
@ -111,6 +111,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -70,6 +70,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
DisplayName="Animation Metrics JS Sample"
|
||||
Description="Animation Metrics JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\smallTile-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smallTile-sdk.png">
|
||||
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
|
|
|
@ -237,6 +237,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</Resources>
|
||||
<Applications>
|
||||
<Application Id="App" StartPage="default.html">
|
||||
<uap:VisualElements DisplayName="ApplicationResources JS Sample" Description="ApplicationResources JS Sample" BackgroundColor="#00b2f0" Square150x150Logo="images\storelogo-sdk.png" Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:VisualElements DisplayName="ApplicationResources JS Sample" Description="ApplicationResources JS Sample" BackgroundColor="#00b2f0" Square150x150Logo="images\squaretile-sdk.png" Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
<uap:ShowNameOnTiles>
|
||||
|
|
|
@ -101,6 +101,9 @@
|
|||
<Content Include="..\..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
DisplayName="AudioCategoryApp JS Sample"
|
||||
Description="AudioCategoryApp JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
|
|
|
@ -114,6 +114,9 @@
|
|||
<Content Include="..\..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storelogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
DisplayName="AudioCategoryCompanion JS Sample"
|
||||
Description="AudioCategoryCompanion JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
|
|
|
@ -79,6 +79,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
DisplayName="Background Media Playback JS Sample"
|
||||
Description="Background Media Playback JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png"
|
||||
>
|
||||
<uap:SplashScreen Image="images\splash-sdk.png"/>
|
||||
|
|
|
@ -69,6 +69,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
DisplayName="BackgroundTransfer JS Sample"
|
||||
Description="BackgroundTransfer JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
|
|
|
@ -45,6 +45,15 @@ This sample shows how to:
|
|||
and the [SetSymbologyAttributesAsync](https://msdn.microsoft.com/library/windows/apps/windows.devices.pointofservice.claimedbarcodescanner.setsymbologyattributesasync) method
|
||||
to enable or disable them.
|
||||
|
||||
6. **Control camera-based barcode scanners**
|
||||
|
||||
Detects camera-based barcode scanners by checking the [VideoDeviceId](https://docs.microsoft.com/en-us/uwp/api/windows.devices.pointofservice.barcodescanner.videodeviceid) property
|
||||
and shows an in-app preview of the barcode camera.
|
||||
Shows and hides the video preview window with the [ShowVideoPreviewAsync](https://docs.microsoft.com/en-us/uwp/api/windows.devices.pointofservice.claimedbarcodescanner.showvideopreviewasync)
|
||||
and [HideVideoPreview](https://docs.microsoft.com/en-us/uwp/api/windows.devices.pointofservice.claimedbarcodescanner.hidevideopreview) methods.
|
||||
Controls the software trigger with the [StartSoftwareTriggerAsync](https://docs.microsoft.com/en-us/uwp/api/windows.devices.pointofservice.claimedbarcodescanner.startsoftwaretriggerasync)
|
||||
and [StopSoftwareTrigger](https://docs.microsoft.com/en-us/uwp/api/windows.devices.pointofservice.claimedbarcodescanner.stopsoftwaretriggerasync) methods.
|
||||
|
||||
The app package manifest shows how to specify the device capability name for the Point of Service (POS) devices. All POS apps are required declare [DeviceCapability](http://msdn.microsoft.com/library/windows/apps/br211430) in the app package manifest, either by using "PointofService" as shown in this sample or by using a device specific GUID, such as "C243FFBD-3AFC-45E9-B3D3-2BA18BC7EBC5" for a barcode scanner.
|
||||
|
||||
**Note** The Universal Windows app samples require Visual Studio 2017 to build and Windows 10 to execute.
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26228.4
|
||||
VisualStudioVersion = 15.0.27130.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BarcodeScanner", "BarcodeScanner.vcxproj", "{9C98C452-42BA-59F7-96F8-369D796094A4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9C98C452-42BA-59F7-96F8-369D796094A4}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{9C98C452-42BA-59F7-96F8-369D796094A4}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{9C98C452-42BA-59F7-96F8-369D796094A4}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
|
@ -33,8 +33,11 @@ Global
|
|||
{9C98C452-42BA-59F7-96F8-369D796094A4}.Release|x86.ActiveCfg = Release|Win32
|
||||
{9C98C452-42BA-59F7-96F8-369D796094A4}.Release|x86.Build.0 = Release|Win32
|
||||
{9C98C452-42BA-59F7-96F8-369D796094A4}.Release|x86.Deploy.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {5AA22096-88EF-4847-B9F9-9A224ABFCDE2}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -159,6 +159,9 @@
|
|||
<ClInclude Include="Scenario4_SymbologyAttributes.xaml.h">
|
||||
<DependentUpon>..\shared\Scenario4_SymbologyAttributes.xaml</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Scenario5_DisplayingBarcodePreview.xaml.h">
|
||||
<DependentUpon>..\shared\Scenario5_DisplayingBarcodePreview.xaml</DependentUpon>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="..\..\..\SharedContent\xaml\App.xaml">
|
||||
|
@ -171,6 +174,7 @@
|
|||
<Page Include="..\shared\Scenario2_MultipleScanners.xaml" />
|
||||
<Page Include="..\shared\Scenario3_ActiveSymbologies.xaml" />
|
||||
<Page Include="..\shared\Scenario4_SymbologyAttributes.xaml" />
|
||||
<Page Include="..\shared\Scenario5_DisplayingBarcodePreview.xaml" />
|
||||
<Page Include="..\..\..\SharedContent\xaml\Styles.xaml">
|
||||
<Link>Styles\Styles.xaml</Link>
|
||||
</Page>
|
||||
|
@ -208,6 +212,9 @@
|
|||
<ClCompile Include="Scenario4_SymbologyAttributes.xaml.cpp">
|
||||
<DependentUpon>..\shared\Scenario4_SymbologyAttributes.xaml</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Scenario5_DisplayingBarcodePreview.xaml.cpp">
|
||||
<DependentUpon>..\shared\Scenario5_DisplayingBarcodePreview.xaml</DependentUpon>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\..\..\SharedContent\media\microsoft-sdk.png">
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<ClCompile Include="Scenario2_MultipleScanners.xaml.cpp" />
|
||||
<ClCompile Include="Scenario3_ActiveSymbologies.xaml.cpp" />
|
||||
<ClCompile Include="Scenario4_SymbologyAttributes.xaml.cpp" />
|
||||
<ClCompile Include="Scenario5_DisplayingBarcodePreview.xaml.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
|
@ -33,6 +34,7 @@
|
|||
<ClInclude Include="DataHelpers.h" />
|
||||
<ClInclude Include="Scenario3_ActiveSymbologies.xaml.h" />
|
||||
<ClInclude Include="Scenario4_SymbologyAttributes.xaml.h" />
|
||||
<ClInclude Include="Scenario5_DisplayingBarcodePreview.xaml.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest" />
|
||||
|
@ -46,6 +48,7 @@
|
|||
<Page Include="..\shared\Scenario2_MultipleScanners.xaml" />
|
||||
<Page Include="..\shared\Scenario3_ActiveSymbologies.xaml" />
|
||||
<Page Include="..\shared\Scenario4_SymbologyAttributes.xaml" />
|
||||
<Page Include="..\shared\Scenario5_DisplayingBarcodePreview.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\..\..\SharedContent\media\microsoft-sdk.png">
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.15063.0" MaxVersionTested="10.0.17134.0" />
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17134.0" MaxVersionTested="10.0.17134.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
|
@ -50,5 +50,7 @@
|
|||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
<DeviceCapability Name="pointOfService" />
|
||||
<!-- Scenario 5 accesses the camera -->
|
||||
<DeviceCapability Name="webcam" />
|
||||
</Capabilities>
|
||||
</Package>
|
|
@ -25,11 +25,12 @@ Platform::Array<Scenario>^ MainPage::scenariosInner = ref new Platform::Array<Sc
|
|||
{ "DataReceived Event", "SDKTemplate.Scenario1_BasicFunctionality" },
|
||||
{ "Release/Retain Functionality", "SDKTemplate.Scenario2_MultipleScanners" },
|
||||
{ "Active Symbologies", "SDKTemplate.Scenario3_ActiveSymbologies" },
|
||||
{ "Symbology Attributes", "SDKTemplate.Scenario4_SymbologyAttributes" }
|
||||
{ "Symbology Attributes", "SDKTemplate.Scenario4_SymbologyAttributes" },
|
||||
{ "Displaying a Barcode Preview", "SDKTemplate.Scenario5_DisplayingBarcodePreview" }
|
||||
};
|
||||
|
||||
task<BarcodeScanner^> DeviceHelpers::GetFirstBarcodeScannerAsync(PosConnectionTypes connectionTypes)
|
||||
{
|
||||
return DeviceHelpers::GetFirstDeviceAsync(BarcodeScanner::GetDeviceSelector(connectionTypes),
|
||||
[](String^ id) { return create_task(BarcodeScanner::FromIdAsync(id)); });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,59 @@ namespace SDKTemplate
|
|||
Windows::Devices::PointOfService::PosConnectionTypes connectionTypes = Windows::Devices::PointOfService::PosConnectionTypes::All);
|
||||
}
|
||||
|
||||
[Windows::UI::Xaml::Data::Bindable]
|
||||
public ref class BindingHelpers sealed
|
||||
{
|
||||
public:
|
||||
// Inverters for binding.
|
||||
static bool Not(bool value)
|
||||
{
|
||||
return !value;
|
||||
}
|
||||
|
||||
static Windows::UI::Xaml::Visibility CollapsedIf(bool value)
|
||||
{
|
||||
return value ? Windows::UI::Xaml::Visibility::Collapsed : Windows::UI::Xaml::Visibility::Visible;
|
||||
}
|
||||
};
|
||||
|
||||
// Creates a completed Concurrency::task<void> that is based on an IAsyncAction,
|
||||
// so that it can be used easily from UI threads.
|
||||
inline Concurrency::task<void> completed_ui_task()
|
||||
{
|
||||
return Concurrency::create_task(concurrency::create_async([] {}));
|
||||
}
|
||||
|
||||
[Windows::UI::Xaml::Data::Bindable]
|
||||
public ref class BarcodeScannerInfo sealed
|
||||
{
|
||||
public:
|
||||
property Platform::String^ Name
|
||||
{
|
||||
Platform::String^ get()
|
||||
{
|
||||
return deviceName + L" (" + deviceId + L")";
|
||||
}
|
||||
}
|
||||
|
||||
property Platform::String^ DeviceId
|
||||
{
|
||||
Platform::String^ get()
|
||||
{
|
||||
return deviceId;
|
||||
}
|
||||
}
|
||||
|
||||
BarcodeScannerInfo(Platform::String^ deviceName, Platform::String^ deviceId)
|
||||
{
|
||||
this->deviceName = deviceName;
|
||||
this->deviceId = deviceId;
|
||||
}
|
||||
private:
|
||||
Platform::String^ deviceName;
|
||||
Platform::String^ deviceId;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The class is used for data-binding.
|
||||
/// </summary>
|
||||
|
@ -100,4 +153,5 @@ namespace SDKTemplate
|
|||
uint32_t id;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ void Scenario1_BasicFunctionality::ScenarioStartScanButton_Click(Platform::Objec
|
|||
claimedScanner = _claimedScanner;
|
||||
if (claimedScanner)
|
||||
{
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// claim ownsership of the barcode scanner.
|
||||
releaseDeviceRequestedToken = claimedScanner->ReleaseDeviceRequested += ref new EventHandler<ClaimedBarcodeScanner^>(this, &Scenario1_BasicFunctionality::OnReleaseDeviceRequested);
|
||||
|
||||
|
@ -65,13 +65,13 @@ void Scenario1_BasicFunctionality::ScenarioStartScanButton_Click(Platform::Objec
|
|||
claimedScanner->IsDecodeDataEnabled = true;
|
||||
|
||||
// enable the scanner.
|
||||
// Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// if the claimedScanner has not beed Enabled
|
||||
create_task(claimedScanner->EnableAsync()).then([this](void)
|
||||
{
|
||||
rootPage->NotifyUser("Ready to scan. Device ID: " + claimedScanner->DeviceId, NotifyType::StatusMessage);
|
||||
ScenarioEndScanButton->IsEnabled = true;
|
||||
}, task_continuation_context::use_current());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ void Scenario1_BasicFunctionality::ScenarioStartScanButton_Click(Platform::Objec
|
|||
rootPage->NotifyUser("Barcode scanner not found. Please connect a barcode scanner.", NotifyType::ErrorMessage);
|
||||
ScenarioStartScanButton->IsEnabled = true;
|
||||
}
|
||||
}, task_continuation_context::use_current());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ void Scenario1_BasicFunctionality::OnReleaseDeviceRequested(Platform::Object ^se
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"> Contains the BarcodeScannerReport which contains the data obtained in the scan</param>
|
||||
|
@ -134,7 +134,6 @@ void Scenario1_BasicFunctionality::OnDataReceived(Windows::Devices::PointOfServi
|
|||
void Scenario1_BasicFunctionality::OnNavigatedTo(NavigationEventArgs^ e)
|
||||
{
|
||||
ResetTheScenarioState();
|
||||
Page::OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -144,11 +143,10 @@ void Scenario1_BasicFunctionality::OnNavigatedTo(NavigationEventArgs^ e)
|
|||
void Scenario1_BasicFunctionality::OnNavigatedFrom(NavigationEventArgs^ e)
|
||||
{
|
||||
ResetTheScenarioState();
|
||||
Page::OnNavigatedFrom(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for End Scan Button Click.
|
||||
/// Event handler for End Scan Button Click.
|
||||
/// Releases the Barcode Scanner and resets the text in the UI
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
|
@ -180,14 +178,17 @@ void Scenario1_BasicFunctionality::ResetTheScenarioState()
|
|||
scanner = nullptr;
|
||||
}
|
||||
|
||||
// Reset the strings in the UI
|
||||
rootPage->NotifyUser("Click the start scanning button to begin.", NotifyType::StatusMessage);
|
||||
// Reset the UI if we are still the current page.
|
||||
if (Frame->Content == this)
|
||||
{
|
||||
rootPage->NotifyUser("Click the start scanning button to begin.", NotifyType::StatusMessage);
|
||||
|
||||
ScenarioOutputScanData->Text = "No data";
|
||||
ScenarioOutputScanDataLabel->Text = "No data";
|
||||
ScenarioOutputScanDataType->Text = "No data";
|
||||
ScenarioOutputScanData->Text = "No data";
|
||||
ScenarioOutputScanDataLabel->Text = "No data";
|
||||
ScenarioOutputScanDataType->Text = "No data";
|
||||
|
||||
// reset the button state
|
||||
ScenarioEndScanButton->IsEnabled = false;
|
||||
ScenarioStartScanButton->IsEnabled = true;
|
||||
// reset the button state
|
||||
ScenarioEndScanButton->IsEnabled = false;
|
||||
ScenarioStartScanButton->IsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ task<void> Scenario2_MultipleScanners::EnableScanner(BarcodeScannerInstance inst
|
|||
break;
|
||||
}
|
||||
// enable the barcode scanner
|
||||
return create_task(claimedBarcodeScanner->EnableAsync()).then([this, strInstance, claimedBarcodeScanner](void)
|
||||
return create_task(claimedBarcodeScanner->EnableAsync()).then([this, strInstance, claimedBarcodeScanner]()
|
||||
{
|
||||
rootPage->NotifyUser(strInstance + " ready to scan. Device ID: " + claimedBarcodeScanner->DeviceId, NotifyType::StatusMessage);
|
||||
});
|
||||
|
@ -206,7 +206,7 @@ void Scenario2_MultipleScanners::OnDataReceivedInstance1(Windows::Devices::Point
|
|||
ScanData1->Text = GetDataString(args->Report->ScanData);
|
||||
|
||||
ScanDataType1->Text = BarcodeSymbologies::GetName(args->Report->ScanDataType);
|
||||
|
||||
|
||||
rootPage->NotifyUser("Instance 1 received data from the barcode scanner.", NotifyType::StatusMessage);
|
||||
}));
|
||||
}
|
||||
|
@ -293,24 +293,24 @@ void Scenario2_MultipleScanners::OnReleaseDeviceRequestedInstance2(Platform::Obj
|
|||
/// <param name="e"></param>
|
||||
void Scenario2_MultipleScanners::ButtonStartScanningInstance1_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
{
|
||||
create_task(CreateDefaultScannerObject(BarcodeScannerInstance::Instance1)).then([this](void)
|
||||
CreateDefaultScannerObject(BarcodeScannerInstance::Instance1).then([this]()
|
||||
{
|
||||
if (scannerInstance1 != nullptr)
|
||||
{
|
||||
//after successful creation, claim the scanner for exclusive use and enable it so that data received events are received.
|
||||
create_task(ClaimScanner(BarcodeScannerInstance::Instance1)).then([this](void)
|
||||
create_task(ClaimScanner(BarcodeScannerInstance::Instance1)).then([this]()
|
||||
{
|
||||
if (claimedBarcodeScannerInstance1 != nullptr)
|
||||
{
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// send the ScanDataLabel and ScanDataType in the DataReceived event
|
||||
claimedBarcodeScannerInstance1->IsDecodeDataEnabled = true;
|
||||
|
||||
create_task(EnableScanner(BarcodeScannerInstance::Instance1)).then([this](void)
|
||||
create_task(EnableScanner(BarcodeScannerInstance::Instance1)).then([this]()
|
||||
{
|
||||
|
||||
// after successfully claiming and enabling, attach the datareceived event handler.
|
||||
// Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// if the activeClaimedBarcodeScanner has not been Enabled
|
||||
|
||||
dataReceivedTokenInstance1 = claimedBarcodeScannerInstance1->DataReceived += ref new TypedEventHandler<ClaimedBarcodeScanner^, BarcodeScannerDataReceivedEventArgs^>(this, &Scenario2_MultipleScanners::OnDataReceivedInstance1);
|
||||
|
@ -341,24 +341,24 @@ void Scenario2_MultipleScanners::ButtonStartScanningInstance1_Click(Platform::Ob
|
|||
/// <param name="e"></param>
|
||||
void Scenario2_MultipleScanners::ButtonStartScanningInstance2_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
{
|
||||
create_task(CreateDefaultScannerObject(BarcodeScannerInstance::Instance2)).then([this](void)
|
||||
CreateDefaultScannerObject(BarcodeScannerInstance::Instance2).then([this]()
|
||||
{
|
||||
if (scannerInstance2 != nullptr)
|
||||
{
|
||||
//after successful creation, claim the scanner for exclusive use and enable it so that data received events are received.
|
||||
create_task(ClaimScanner(BarcodeScannerInstance::Instance2)).then([this](void)
|
||||
create_task(ClaimScanner(BarcodeScannerInstance::Instance2)).then([this]()
|
||||
{
|
||||
if (claimedBarcodeScannerInstance2 != nullptr)
|
||||
{
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// send the ScanDataLabel and ScanDataType in the DataReceived event
|
||||
claimedBarcodeScannerInstance2->IsDecodeDataEnabled = true;
|
||||
|
||||
create_task(EnableScanner(BarcodeScannerInstance::Instance2)).then([this](void)
|
||||
create_task(EnableScanner(BarcodeScannerInstance::Instance2)).then([this]()
|
||||
{
|
||||
|
||||
// after successfully claiming and enabling, attach the datareceived event handler.
|
||||
// Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// if the activeClaimedBarcodeScanner has not been Enabled
|
||||
|
||||
dataReceivedTokenInstance2 = claimedBarcodeScannerInstance2->DataReceived::add(ref new TypedEventHandler<ClaimedBarcodeScanner^, BarcodeScannerDataReceivedEventArgs^>(this, &Scenario2_MultipleScanners::OnDataReceivedInstance2));
|
||||
|
@ -463,9 +463,13 @@ void Scenario2_MultipleScanners::ResetTheScenarioState()
|
|||
scannerInstance2 = nullptr;
|
||||
}
|
||||
|
||||
rootPage->NotifyUser("Click the start scanning button to begin.", NotifyType::StatusMessage);
|
||||
// Reset the UI if we are still the current page.
|
||||
if (Frame->Content == this)
|
||||
{
|
||||
rootPage->NotifyUser("Click the start scanning button to begin.", NotifyType::StatusMessage);
|
||||
|
||||
ResetUI();
|
||||
ResetUI();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
#include "Scenario2_MultipleScanners.g.h"
|
||||
#include "MainPage.xaml.h"
|
||||
|
||||
using namespace Windows::Devices::PointOfService;
|
||||
|
||||
namespace SDKTemplate
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -31,10 +29,10 @@ namespace SDKTemplate
|
|||
|
||||
private:
|
||||
MainPage^ rootPage;
|
||||
ClaimedBarcodeScanner^ claimedBarcodeScannerInstance1;
|
||||
ClaimedBarcodeScanner^ claimedBarcodeScannerInstance2;
|
||||
BarcodeScanner^ scannerInstance1;
|
||||
BarcodeScanner^ scannerInstance2;
|
||||
Windows::Devices::PointOfService::ClaimedBarcodeScanner^ claimedBarcodeScannerInstance1;
|
||||
Windows::Devices::PointOfService::ClaimedBarcodeScanner^ claimedBarcodeScannerInstance2;
|
||||
Windows::Devices::PointOfService::BarcodeScanner^ scannerInstance1;
|
||||
Windows::Devices::PointOfService::BarcodeScanner^ scannerInstance2;
|
||||
|
||||
// tokens for instance1
|
||||
Windows::Foundation::EventRegistrationToken dataReceivedTokenInstance1;
|
||||
|
|
|
@ -43,29 +43,20 @@ void Scenario3_ActiveSymbologies::ScenarioStartScanButton_Click(Object^ sender,
|
|||
|
||||
rootPage->NotifyUser("Acquiring barcode scanner object...", NotifyType::StatusMessage);
|
||||
|
||||
// create the barcode scanner.
|
||||
// create the barcode scanner.
|
||||
create_task(DeviceHelpers::GetFirstBarcodeScannerAsync()).then([this](BarcodeScanner^ newScanner)
|
||||
{
|
||||
scanner = newScanner;
|
||||
|
||||
if (scanner != nullptr)
|
||||
{
|
||||
// after successful creation, list supported symbologies
|
||||
create_task(scanner->GetSupportedSymbologiesAsync()).then([this](IVectorView<uint32_t>^ supportedSymbologies)
|
||||
{
|
||||
for (uint32_t symbology : supportedSymbologies)
|
||||
{
|
||||
this->listOfSymbologies->Append(ref new SymbologyListEntry(symbology));
|
||||
}
|
||||
|
||||
// claim the scanner for exclusive use.
|
||||
return create_task(scanner->ClaimScannerAsync());
|
||||
}).then([this](ClaimedBarcodeScanner^ _claimedScanner)
|
||||
// claim the scanner for exclusive use.
|
||||
create_task(scanner->ClaimScannerAsync()).then([this](ClaimedBarcodeScanner^ _claimedScanner)
|
||||
{
|
||||
claimedScanner = _claimedScanner;
|
||||
if (claimedScanner)
|
||||
{
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// claim ownership of the barcode scanner.
|
||||
releaseDeviceRequestedToken = claimedScanner->ReleaseDeviceRequested += ref new EventHandler<ClaimedBarcodeScanner^>(this, &Scenario3_ActiveSymbologies::OnReleaseDeviceRequested);
|
||||
|
||||
|
@ -80,6 +71,15 @@ void Scenario3_ActiveSymbologies::ScenarioStartScanButton_Click(Object^ sender,
|
|||
// Do this after adding the DataReceived event handler.
|
||||
create_task(claimedScanner->EnableAsync()).then([this]()
|
||||
{
|
||||
// after successful claim, list supported symbologies
|
||||
return create_task(scanner->GetSupportedSymbologiesAsync());
|
||||
}).then([this](IVectorView<uint32_t>^ supportedSymbologies)
|
||||
{
|
||||
for (uint32_t symbology : supportedSymbologies)
|
||||
{
|
||||
this->listOfSymbologies->Append(ref new SymbologyListEntry(symbology));
|
||||
}
|
||||
|
||||
rootPage->NotifyUser("Ready to scan. Device ID: " + claimedScanner->DeviceId, NotifyType::StatusMessage);
|
||||
|
||||
// reset the button state
|
||||
|
@ -101,7 +101,7 @@ void Scenario3_ActiveSymbologies::ScenarioStartScanButton_Click(Object^ sender,
|
|||
rootPage->NotifyUser("Barcode scanner not found. Please connect a barcode scanner.", NotifyType::ErrorMessage);
|
||||
ScenarioStartScanButton->IsEnabled = true;
|
||||
}
|
||||
}, concurrency::task_continuation_context::use_current());
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -118,7 +118,7 @@ void Scenario3_ActiveSymbologies::OnReleaseDeviceRequested(Object^ sender, Claim
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"> Contains the BarcodeScannerReport which contains the data obtained in the scan</param>
|
||||
|
@ -144,7 +144,7 @@ void Scenario3_ActiveSymbologies::OnNavigatedFrom(NavigationEventArgs^ e)
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for End Scan Button Click.
|
||||
/// Event handler for End Scan Button Click.
|
||||
/// Releases the Barcode Scanner and resets the text in the UI
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
|
@ -176,20 +176,23 @@ void Scenario3_ActiveSymbologies::ResetTheScenarioState()
|
|||
scanner = nullptr;
|
||||
}
|
||||
|
||||
// Reset the strings in the UI
|
||||
rootPage->NotifyUser("Click the start scanning button to begin.", NotifyType::StatusMessage);
|
||||
// Reset the UI if we are still the current page.
|
||||
if (Frame->Content == this)
|
||||
{
|
||||
rootPage->NotifyUser("Click the start scanning button to begin.", NotifyType::StatusMessage);
|
||||
|
||||
ScenarioOutputScanData->Text = "No data";
|
||||
ScenarioOutputScanDataLabel->Text = "No data";
|
||||
ScenarioOutputScanDataType->Text = "No data";
|
||||
ScenarioOutputScanData->Text = "No data";
|
||||
ScenarioOutputScanDataLabel->Text = "No data";
|
||||
ScenarioOutputScanDataType->Text = "No data";
|
||||
|
||||
// reset the button state
|
||||
SetActiveSymbologiesButton->IsEnabled = false;
|
||||
ScenarioEndScanButton->IsEnabled = false;
|
||||
ScenarioStartScanButton->IsEnabled = true;
|
||||
// reset the button state
|
||||
SetActiveSymbologiesButton->IsEnabled = false;
|
||||
ScenarioEndScanButton->IsEnabled = false;
|
||||
ScenarioStartScanButton->IsEnabled = true;
|
||||
|
||||
// reset symbology list
|
||||
listOfSymbologies->Clear();
|
||||
// reset symbology list
|
||||
listOfSymbologies->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Scenario3_ActiveSymbologies::SetActiveSymbologies_Click(Object^ sender, RoutedEventArgs^ e)
|
||||
|
|
|
@ -54,29 +54,20 @@ void Scenario4_SymbologyAttributes::ScenarioStartScanButton_Click(Object^ sender
|
|||
|
||||
rootPage->NotifyUser("Acquiring barcode scanner object...", NotifyType::StatusMessage);
|
||||
|
||||
// create the barcode scanner.
|
||||
// create the barcode scanner.
|
||||
create_task(DeviceHelpers::GetFirstBarcodeScannerAsync()).then([this](BarcodeScanner^ newScanner)
|
||||
{
|
||||
scanner = newScanner;
|
||||
|
||||
if (scanner != nullptr)
|
||||
{
|
||||
// after successful creation, list supported symbologies
|
||||
create_task(scanner->GetSupportedSymbologiesAsync()).then([this](IVectorView<uint32_t>^ supportedSymbologies)
|
||||
{
|
||||
for (uint32_t symbology : supportedSymbologies)
|
||||
{
|
||||
this->listOfSymbologies->Append(ref new SymbologyListEntry(symbology));
|
||||
}
|
||||
|
||||
// Claim the scanner for exclusive use.
|
||||
return create_task(scanner->ClaimScannerAsync());
|
||||
}).then([this](ClaimedBarcodeScanner^ _claimedScanner)
|
||||
// Claim the scanner for exclusive use.
|
||||
create_task(scanner->ClaimScannerAsync()).then([this](ClaimedBarcodeScanner^ _claimedScanner)
|
||||
{
|
||||
claimedScanner = _claimedScanner;
|
||||
if (claimedScanner)
|
||||
{
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// claim ownership of the barcode scanner.
|
||||
releaseDeviceRequestedToken = claimedScanner->ReleaseDeviceRequested += ref new EventHandler<ClaimedBarcodeScanner^>(this, &Scenario4_SymbologyAttributes::OnReleaseDeviceRequested);
|
||||
|
||||
|
@ -88,10 +79,19 @@ void Scenario4_SymbologyAttributes::ScenarioStartScanButton_Click(Object^ sender
|
|||
claimedScanner->IsDecodeDataEnabled = true;
|
||||
|
||||
// enable the scanner.
|
||||
// Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// if the claimedScanner has not been Enabled
|
||||
create_task(claimedScanner->EnableAsync()).then([this](void)
|
||||
create_task(claimedScanner->EnableAsync()).then([this]()
|
||||
{
|
||||
// after successful claim, list supported symbologies
|
||||
return create_task(scanner->GetSupportedSymbologiesAsync());
|
||||
}).then([this](IVectorView<uint32_t>^ supportedSymbologies)
|
||||
{
|
||||
for (uint32_t symbology : supportedSymbologies)
|
||||
{
|
||||
this->listOfSymbologies->Append(ref new SymbologyListEntry(symbology));
|
||||
}
|
||||
|
||||
rootPage->NotifyUser("Ready to scan. Device ID: " + claimedScanner->DeviceId, NotifyType::StatusMessage);
|
||||
|
||||
// reset the button state
|
||||
|
@ -113,7 +113,7 @@ void Scenario4_SymbologyAttributes::ScenarioStartScanButton_Click(Object^ sender
|
|||
rootPage->NotifyUser("Barcode scanner not found. Please connect a barcode scanner.", NotifyType::ErrorMessage);
|
||||
ScenarioStartScanButton->IsEnabled = true;
|
||||
}
|
||||
}, concurrency::task_continuation_context::use_current());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ void Scenario4_SymbologyAttributes::OnReleaseDeviceRequested(Object^ sender, Cla
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"> Contains the BarcodeScannerReport which contains the data obtained in the scan</param>
|
||||
|
@ -148,7 +148,7 @@ void Scenario4_SymbologyAttributes::OnDataReceived(ClaimedBarcodeScanner^ sender
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for End Scan Button Click.
|
||||
/// Event handler for End Scan Button Click.
|
||||
/// Releases the Barcode Scanner and resets the text in the UI
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
|
@ -182,27 +182,30 @@ void Scenario4_SymbologyAttributes::ResetTheScenarioState()
|
|||
|
||||
symbologyAttributes = nullptr;
|
||||
|
||||
// Reset the strings in the UI
|
||||
rootPage->NotifyUser("Click the start scanning button to begin.", NotifyType::StatusMessage);
|
||||
// Reset the UI if we are still the current page.
|
||||
if (Frame->Content == this)
|
||||
{
|
||||
rootPage->NotifyUser("Click the start scanning button to begin.", NotifyType::StatusMessage);
|
||||
|
||||
ScenarioOutputScanData->Text = "No data";
|
||||
ScenarioOutputScanDataLabel->Text = "No data";
|
||||
ScenarioOutputScanDataType->Text = "No data";
|
||||
ScenarioOutputScanData->Text = "No data";
|
||||
ScenarioOutputScanDataLabel->Text = "No data";
|
||||
ScenarioOutputScanDataType->Text = "No data";
|
||||
|
||||
// reset the button state
|
||||
ScenarioEndScanButton->IsEnabled = false;
|
||||
ScenarioStartScanButton->IsEnabled = true;
|
||||
SetSymbologyAttributesButton->IsEnabled = false;
|
||||
EnableCheckDigit->IsEnabled = false;
|
||||
TransmitCheckDigit->IsEnabled = false;
|
||||
SetDecodeRangeLimits->IsEnabled = false;
|
||||
// reset the button state
|
||||
ScenarioEndScanButton->IsEnabled = false;
|
||||
ScenarioStartScanButton->IsEnabled = true;
|
||||
SetSymbologyAttributesButton->IsEnabled = false;
|
||||
EnableCheckDigit->IsEnabled = false;
|
||||
TransmitCheckDigit->IsEnabled = false;
|
||||
SetDecodeRangeLimits->IsEnabled = false;
|
||||
|
||||
// reset symbology list
|
||||
listOfSymbologies->Clear();
|
||||
// reset symbology list
|
||||
listOfSymbologies->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for Symbology listbox selection changed.
|
||||
/// Event handler for Symbology listbox selection changed.
|
||||
/// Get symbology attributes and populate attribute UI components
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
|
|
|
@ -0,0 +1,452 @@
|
|||
//*********************************************************
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// This code is licensed under the MIT License (MIT).
|
||||
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
|
||||
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
|
||||
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
|
||||
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
|
||||
//
|
||||
//*********************************************************
|
||||
#include "pch.h"
|
||||
#include "Scenario5_DisplayingBarcodePreview.xaml.h"
|
||||
|
||||
using namespace SDKTemplate;
|
||||
|
||||
using namespace Concurrency;
|
||||
using namespace Platform;
|
||||
using namespace Platform::Collections;
|
||||
using namespace Windows::Devices::Enumeration;
|
||||
using namespace Windows::Devices::PointOfService;
|
||||
using namespace Windows::Foundation::Collections;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::Foundation::Collections;
|
||||
using namespace Windows::Graphics::Display;
|
||||
using namespace Windows::Media::Capture;
|
||||
using namespace Windows::UI::Core;
|
||||
using namespace Windows::UI::Xaml;
|
||||
using namespace Windows::UI::Xaml::Data;
|
||||
using namespace Windows::UI::Xaml::Controls;
|
||||
using namespace Windows::UI::Xaml::Navigation;
|
||||
using namespace Windows::Storage::Streams;
|
||||
using namespace Windows::System::Display;
|
||||
|
||||
const GUID Scenario5_DisplayingBarcodePreview::rotationGuid = { 0xC380465D, 0x2271, 0x428C, 0x9B, 0x83, 0xEC, 0xEA, 0x3B, 0x4A, 0x85, 0xC1 };
|
||||
|
||||
Scenario5_DisplayingBarcodePreview::Scenario5_DisplayingBarcodePreview()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ScannerListSource->Source = barcodeScanners;
|
||||
|
||||
watcher = DeviceInformation::CreateWatcher(BarcodeScanner::GetDeviceSelector());
|
||||
watcher->Added += ref new TypedEventHandler<DeviceWatcher^, DeviceInformation^>(this, &Scenario5_DisplayingBarcodePreview::Watcher_Added);
|
||||
watcher->Removed += ref new TypedEventHandler<DeviceWatcher^, DeviceInformationUpdate^>(this, &Scenario5_DisplayingBarcodePreview::Watcher_Removed);
|
||||
watcher->Updated += ref new TypedEventHandler<DeviceWatcher^, DeviceInformationUpdate^>(this, &Scenario5_DisplayingBarcodePreview::Watcher_Updated);
|
||||
|
||||
watcher->Start();
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
void Scenario5_DisplayingBarcodePreview::Watcher_Added(DeviceWatcher^ sender, DeviceInformation^ args)
|
||||
{
|
||||
Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, args]()
|
||||
{
|
||||
BarcodeScannerInfo^ scannerInfo = ref new BarcodeScannerInfo(args->Name, args->Id);
|
||||
barcodeScanners->Append(scannerInfo);
|
||||
|
||||
// Select the first scanner by default.
|
||||
if (barcodeScanners->Size == 1)
|
||||
{
|
||||
ScannerListBox->SelectedIndex = 0;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void Scenario5_DisplayingBarcodePreview::Watcher_Removed(DeviceWatcher^ sender, DeviceInformationUpdate^ args)
|
||||
{
|
||||
// We don't do anything here, but this event needs to be handled to enable realtime updates.
|
||||
// See https://aka.ms/devicewatcher_added.
|
||||
}
|
||||
|
||||
void Scenario5_DisplayingBarcodePreview::Watcher_Updated(DeviceWatcher^ sender, DeviceInformationUpdate^ args)
|
||||
{
|
||||
// We don't do anything here, but this event needs to be handled to enable realtime updates.
|
||||
// See https://aka.ms/devicewatcher_added.
|
||||
}
|
||||
|
||||
void Scenario5_DisplayingBarcodePreview::OnNavigatedFrom(NavigationEventArgs^ e)
|
||||
{
|
||||
watcher->Stop();
|
||||
|
||||
if (isSelectionChanging)
|
||||
{
|
||||
// If selection is changing, then let it know to stop media capture
|
||||
// when it's done.
|
||||
isStopPending = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If selection is not changing, then it's safe to stop immediately.
|
||||
CloseScannerResourcesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts previewing the selected scanner's video feed and prevents the display from going to sleep.
|
||||
/// </summary>
|
||||
task<void> Scenario5_DisplayingBarcodePreview::StartMediaCaptureAsync(String^ videoDeviceId)
|
||||
{
|
||||
mediaCapture = ref new MediaCapture;
|
||||
mediaCapture->Failed += ref new MediaCaptureFailedEventHandler(this, &Scenario5_DisplayingBarcodePreview::MediaCapture_Failed);
|
||||
|
||||
auto settings = ref new MediaCaptureInitializationSettings();
|
||||
settings->VideoDeviceId = videoDeviceId;
|
||||
settings->StreamingCaptureMode = StreamingCaptureMode::Video;
|
||||
|
||||
return create_task(mediaCapture->InitializeAsync(settings)).then([this]
|
||||
{
|
||||
// Prevent the device from sleeping while the preview is running.
|
||||
displayRequest->RequestActive();
|
||||
PreviewControl->Source = mediaCapture.Get();
|
||||
return mediaCapture->StartPreviewAsync();
|
||||
}).then([this] {
|
||||
return SetPreviewRotationAsync(DisplayInformation::GetForCurrentView()->CurrentOrientation);
|
||||
}).then([this](task<void> task)
|
||||
{
|
||||
IsPreviewing = false;
|
||||
try
|
||||
{
|
||||
task.get();
|
||||
IsPreviewing = true;
|
||||
}
|
||||
catch (AccessDeniedException^)
|
||||
{
|
||||
rootPage->NotifyUser("The app was denied access to the camera", NotifyType::ErrorMessage);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
rootPage->NotifyUser("Failed to initialize the camera: " + e->Message, NotifyType::ErrorMessage);
|
||||
}
|
||||
|
||||
RaisePropertyChanged(L"IsPreviewing");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close the scanners and stop the preview.
|
||||
/// </summary>
|
||||
task<void> Scenario5_DisplayingBarcodePreview::CloseScannerResourcesAsync()
|
||||
{
|
||||
delete claimedScanner;
|
||||
claimedScanner = nullptr;
|
||||
|
||||
delete selectedScanner;
|
||||
selectedScanner = nullptr;
|
||||
|
||||
SoftwareTriggerStarted = false;
|
||||
RaisePropertyChanged(L"SoftwareTriggerStarted");
|
||||
|
||||
if (!IsPreviewing)
|
||||
{
|
||||
return completed_ui_task();
|
||||
}
|
||||
|
||||
return completed_ui_task().then([this]
|
||||
{
|
||||
if (mediaCapture != nullptr)
|
||||
{
|
||||
return create_task(mediaCapture->StopPreviewAsync());
|
||||
}
|
||||
return completed_ui_task();
|
||||
}).then([this]
|
||||
{
|
||||
delete mediaCapture.Get();
|
||||
mediaCapture.Release();
|
||||
|
||||
// Allow the display to go to sleep.
|
||||
displayRequest->RequestRelease();
|
||||
IsPreviewing = false;
|
||||
RaisePropertyChanged(L"IsPreviewing");
|
||||
});
|
||||
}
|
||||
|
||||
task<void> Scenario5_DisplayingBarcodePreview::SetPreviewRotationAsync(DisplayOrientations displayOrientation)
|
||||
{
|
||||
// Figure out where the camera is located to account for mirroring and later adjust rotation accordingly.
|
||||
return create_task(DeviceInformation::CreateFromIdAsync(selectedScanner->DeviceId)).then([this, displayOrientation](DeviceInformation^ cameraInformation)
|
||||
{
|
||||
bool isExternalCamera;
|
||||
bool isPreviewMirrored;
|
||||
|
||||
if ((cameraInformation->EnclosureLocation == nullptr) || (cameraInformation->EnclosureLocation->Panel == Windows::Devices::Enumeration::Panel::Unknown))
|
||||
{
|
||||
isExternalCamera = true;
|
||||
isPreviewMirrored = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
isExternalCamera = false;
|
||||
isPreviewMirrored = (cameraInformation->EnclosureLocation->Panel == Windows::Devices::Enumeration::Panel::Front);
|
||||
}
|
||||
|
||||
PreviewControl->FlowDirection = isPreviewMirrored ? Windows::UI::Xaml::FlowDirection::RightToLeft : Windows::UI::Xaml::FlowDirection::LeftToRight;
|
||||
|
||||
if (!isExternalCamera)
|
||||
{
|
||||
// Calculate which way and how far to rotate the preview
|
||||
int rotationDegrees = 0;
|
||||
switch (displayOrientation)
|
||||
{
|
||||
case DisplayOrientations::Portrait:
|
||||
rotationDegrees = 90;
|
||||
break;
|
||||
case DisplayOrientations::LandscapeFlipped:
|
||||
rotationDegrees = 180;
|
||||
break;
|
||||
case DisplayOrientations::PortraitFlipped:
|
||||
rotationDegrees = 270;
|
||||
break;
|
||||
case DisplayOrientations::Landscape:
|
||||
default:
|
||||
rotationDegrees = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// The rotation direction needs to be inverted if the preview is being mirrored
|
||||
if (isPreviewMirrored)
|
||||
{
|
||||
rotationDegrees = (360 - rotationDegrees) % 360;
|
||||
}
|
||||
|
||||
// Add rotation metadata to the preview stream to make sure the aspect ratio / dimensions match when rendering and getting preview frames
|
||||
auto streamProperties = mediaCapture->VideoDeviceController->GetMediaStreamProperties(MediaStreamType::VideoPreview);
|
||||
streamProperties->Properties->Insert(rotationGuid, rotationDegrees);
|
||||
return create_task(mediaCapture->SetEncodingPropertiesAsync(MediaStreamType::VideoPreview, streamProperties, nullptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
return task_from_result();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Media capture failed, potentially due to the camera being unplugged.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="errorEventArgs"></param>
|
||||
void Scenario5_DisplayingBarcodePreview::MediaCapture_Failed(MediaCapture^ sender, MediaCaptureFailedEventArgs^ errorEventArgs)
|
||||
{
|
||||
rootPage->NotifyUser("Media capture failed. Make sure the camera is still connected.", NotifyType::ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows a preview window for the selected scanner.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void Scenario5_DisplayingBarcodePreview::ShowPreviewButton_Click(Object^ sender, RoutedEventArgs^ args)
|
||||
{
|
||||
if (claimedScanner != nullptr)
|
||||
{
|
||||
create_task(claimedScanner->ShowVideoPreviewAsync());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hides the selected scanner's preview window.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void Scenario5_DisplayingBarcodePreview::HidePreviewButton_Click(Object^ sender, RoutedEventArgs^ args)
|
||||
{
|
||||
if (claimedScanner != nullptr)
|
||||
{
|
||||
claimedScanner->HideVideoPreview();
|
||||
}
|
||||
}
|
||||
|
||||
// <summary>
|
||||
/// Setup the barcode scanner to be ready to receive the data events from the scan.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void Scenario5_DisplayingBarcodePreview::StartSoftwareTriggerButton_Click(Object^ sender, RoutedEventArgs^ args)
|
||||
{
|
||||
if (claimedScanner != nullptr)
|
||||
{
|
||||
create_task(claimedScanner->StartSoftwareTriggerAsync()).then([this]
|
||||
{
|
||||
SoftwareTriggerStarted = true;
|
||||
RaisePropertyChanged(L"SoftwareTriggerStarted");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the selected scanner's software trigger.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void Scenario5_DisplayingBarcodePreview::StopSoftwareTriggerButton_Click(Object^ sender, RoutedEventArgs^ args)
|
||||
{
|
||||
if (claimedScanner != nullptr)
|
||||
{
|
||||
create_task(claimedScanner->StopSoftwareTriggerAsync()).then([this]
|
||||
{
|
||||
SoftwareTriggerStarted = false;
|
||||
RaisePropertyChanged(L"SoftwareTriggerStarted");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flips the mirroring of the preview.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
|
||||
void Scenario5_DisplayingBarcodePreview::FlipPreview_Click(Object^ sender, RoutedEventArgs^ args)
|
||||
{
|
||||
if (PreviewControl->FlowDirection == Windows::UI::Xaml::FlowDirection::LeftToRight)
|
||||
{
|
||||
PreviewControl->FlowDirection = Windows::UI::Xaml::FlowDirection::RightToLeft;
|
||||
}
|
||||
else
|
||||
{
|
||||
PreviewControl->FlowDirection = Windows::UI::Xaml::FlowDirection::LeftToRight;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for scanner listbox selection changed.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
void Scenario5_DisplayingBarcodePreview::ScannerSelection_Changed(Object^ sender, SelectionChangedEventArgs^ args)
|
||||
{
|
||||
auto selectedScannerInfo = safe_cast<BarcodeScannerInfo^>(args->AddedItems->GetAt(0));
|
||||
auto scannerDeviceId = selectedScannerInfo->DeviceId;
|
||||
|
||||
if (isSelectionChanging)
|
||||
{
|
||||
// Keep the most recent selection.
|
||||
pendingSelectionDeviceId = scannerDeviceId;
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessScannerChangesAsync(scannerDeviceId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process changes in the selected scanner until the selection stabilizes or we are asked to shut down.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
task<void> Scenario5_DisplayingBarcodePreview::ProcessScannerChangesAsync(String^ scannerDeviceId)
|
||||
{
|
||||
return SelectScannerAsync(scannerDeviceId).then([this]
|
||||
{
|
||||
// Stop takes precedence over updating the selection.
|
||||
if (isStopPending)
|
||||
{
|
||||
return CloseScannerResourcesAsync();
|
||||
}
|
||||
|
||||
String^ deviceId = pendingSelectionDeviceId;
|
||||
pendingSelectionDeviceId = nullptr;
|
||||
|
||||
if (deviceId->IsEmpty())
|
||||
{
|
||||
// No more processing to do.
|
||||
return task_from_result();
|
||||
}
|
||||
|
||||
// Process the next one.
|
||||
return ProcessScannerChangesAsync(deviceId);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Select the scanner specified by its device ID.
|
||||
/// </summary>
|
||||
/// <param name="scannerDeviceId"></param>
|
||||
task<void> Scenario5_DisplayingBarcodePreview::SelectScannerAsync(String^ scannerDeviceId)
|
||||
{
|
||||
isSelectionChanging = true;
|
||||
|
||||
return CloseScannerResourcesAsync().then([scannerDeviceId]
|
||||
{
|
||||
return BarcodeScanner::FromIdAsync(scannerDeviceId);
|
||||
}).then([this](BarcodeScanner^ scanner)
|
||||
{
|
||||
selectedScanner = scanner;
|
||||
if (selectedScanner != nullptr)
|
||||
{
|
||||
return create_task(selectedScanner->ClaimScannerAsync());
|
||||
}
|
||||
else
|
||||
{
|
||||
rootPage->NotifyUser(L"Failed to create a barcode scanner object", NotifyType::ErrorMessage);
|
||||
return task_from_result<ClaimedBarcodeScanner^>(nullptr);
|
||||
}
|
||||
}).then([this](ClaimedBarcodeScanner^ newClaimedScanner)
|
||||
{
|
||||
claimedScanner = newClaimedScanner;
|
||||
if (claimedScanner != nullptr)
|
||||
{
|
||||
return create_task(claimedScanner->EnableAsync());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectedScanner != nullptr)
|
||||
{
|
||||
rootPage->NotifyUser(L"Failed to claim the selected barcode scanner", NotifyType::ErrorMessage);
|
||||
}
|
||||
return task_from_result();
|
||||
}
|
||||
}).then([this]
|
||||
{
|
||||
if (claimedScanner != nullptr)
|
||||
{
|
||||
ScannerSupportsPreview = !selectedScanner->VideoDeviceId->IsEmpty();
|
||||
RaisePropertyChanged(L"ScannerSupportsPreview");
|
||||
|
||||
claimedScanner->DataReceived += ref new TypedEventHandler<ClaimedBarcodeScanner^, BarcodeScannerDataReceivedEventArgs^>(this, &Scenario5_DisplayingBarcodePreview::OnDataReceived);
|
||||
|
||||
if (ScannerSupportsPreview)
|
||||
{
|
||||
return StartMediaCaptureAsync(selectedScanner->VideoDeviceId);
|
||||
}
|
||||
}
|
||||
return task_from_result();
|
||||
}).then([this]
|
||||
{
|
||||
IsScannerClaimed = (claimedScanner != nullptr);
|
||||
RaisePropertyChanged("IsScannerClaimed");
|
||||
|
||||
isSelectionChanging = false;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"> Contains the BarcodeScannerReport which contains the data obtained in the scan</param>
|
||||
void Scenario5_DisplayingBarcodePreview::OnDataReceived(ClaimedBarcodeScanner^ sender, BarcodeScannerDataReceivedEventArgs^ args)
|
||||
{
|
||||
Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, args]()
|
||||
{
|
||||
ScenarioOutputScanDataLabel->Text = GetDataLabelString(args->Report->ScanDataLabel, args->Report->ScanDataType);
|
||||
ScenarioOutputScanData->Text = GetDataString(args->Report->ScanData);
|
||||
ScenarioOutputScanDataType->Text = BarcodeSymbologies::GetName(args->Report->ScanDataType);
|
||||
}));
|
||||
}
|
||||
|
||||
void Scenario5_DisplayingBarcodePreview::RaisePropertyChanged(String^ name)
|
||||
{
|
||||
PropertyChanged(this, ref new PropertyChangedEventArgs(name));
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
//*********************************************************
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// This code is licensed under the MIT License (MIT).
|
||||
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
|
||||
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
|
||||
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
|
||||
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
|
||||
//
|
||||
//*********************************************************
|
||||
#pragma once
|
||||
|
||||
#include "Scenario5_DisplayingBarcodePreview.g.h"
|
||||
#include "MainPage.xaml.h"
|
||||
|
||||
namespace SDKTemplate
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
[Windows::UI::Xaml::Data::Bindable]
|
||||
public ref class Scenario5_DisplayingBarcodePreview sealed : Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
Scenario5_DisplayingBarcodePreview();
|
||||
|
||||
property bool IsScannerClaimed;
|
||||
property bool ScannerSupportsPreview;
|
||||
property bool IsPreviewing;
|
||||
property bool SoftwareTriggerStarted;
|
||||
|
||||
virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler^ PropertyChanged;
|
||||
|
||||
protected:
|
||||
virtual void OnNavigatedFrom(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
|
||||
|
||||
private:
|
||||
MainPage ^ rootPage = MainPage::Current;
|
||||
Windows::Foundation::Collections::IObservableVector<BarcodeScannerInfo^>^ barcodeScanners = ref new Platform::Collections::Vector<BarcodeScannerInfo^>();
|
||||
Windows::Devices::PointOfService::BarcodeScanner^ selectedScanner;
|
||||
Windows::Devices::PointOfService::ClaimedBarcodeScanner^ claimedScanner;
|
||||
Windows::Devices::Enumeration::DeviceWatcher^ watcher;
|
||||
|
||||
Windows::System::Display::DisplayRequest^ displayRequest = ref new Windows::System::Display::DisplayRequest();
|
||||
Platform::Agile<Windows::Media::Capture::MediaCapture> mediaCapture;
|
||||
|
||||
bool isSelectionChanging = false;
|
||||
Platform::String^ pendingSelectionDeviceId;
|
||||
bool isStopPending = false;
|
||||
|
||||
static const GUID rotationGuid;
|
||||
|
||||
Concurrency::task<void> StartMediaCaptureAsync(Platform::String^ videoDeviceId);
|
||||
Concurrency::task<void> CloseScannerResourcesAsync();
|
||||
Concurrency::task<void> SetPreviewRotationAsync(Windows::Graphics::Display::DisplayOrientations displayOrientation);
|
||||
Concurrency::task<void> ProcessScannerChangesAsync(Platform::String^ scannerDeviceId);
|
||||
Concurrency::task<void> SelectScannerAsync(Platform::String^ scannerDeviceId);
|
||||
|
||||
void RaisePropertyChanged(Platform::String^ name);
|
||||
|
||||
void Watcher_Added(Windows::Devices::Enumeration::DeviceWatcher^ sender, Windows::Devices::Enumeration::DeviceInformation^ args);
|
||||
void Watcher_Removed(Windows::Devices::Enumeration::DeviceWatcher^ sender, Windows::Devices::Enumeration::DeviceInformationUpdate^ args);
|
||||
void Watcher_Updated(Windows::Devices::Enumeration::DeviceWatcher^ sender, Windows::Devices::Enumeration::DeviceInformationUpdate^ args);
|
||||
void MediaCapture_Failed(Windows::Media::Capture::MediaCapture^ sender, Windows::Media::Capture::MediaCaptureFailedEventArgs^ errorEventArgs);
|
||||
void StartSoftwareTriggerButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ args);
|
||||
void StopSoftwareTriggerButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ args);
|
||||
void ShowPreviewButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ args);
|
||||
void HidePreviewButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ args);
|
||||
void FlipPreview_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ args);
|
||||
void ScannerSelection_Changed(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ args);
|
||||
void OnDataReceived(Windows::Devices::PointOfService::ClaimedBarcodeScanner^ sender, Windows::Devices::PointOfService::BarcodeScannerDataReceivedEventArgs^ args);
|
||||
};
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
<EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<RuntimeIdentifiers>win10-arm;win10-arm-aot;win10-x86;win10-x86-aot;win10-x64;win10-x64-aot</RuntimeIdentifiers>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -81,9 +82,6 @@
|
|||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="project.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\..\SharedContent\cs\App.xaml.cs">
|
||||
<Link>App.xaml.cs</Link>
|
||||
|
@ -112,6 +110,9 @@
|
|||
<Compile Include="Scenario4_SymbologyAttributes.xaml.cs">
|
||||
<DependentUpon>Scenario4_SymbologyAttributes.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Scenario5_DisplayingBarcodePreview.xaml.cs">
|
||||
<DependentUpon>Scenario5_DisplayingBarcodePreview.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
|
@ -149,6 +150,11 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="..\shared\Scenario5_DisplayingBarcodePreview.xaml">
|
||||
<Link>Scenario5_DisplayingBarcodePreview.xaml</Link>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="..\..\..\SharedContent\xaml\Styles.xaml">
|
||||
<Link>Styles\Styles.xaml</Link>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -181,6 +187,11 @@
|
|||
<Link>Assets\windows-sdk.png</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||
<Version>5.0.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26228.4
|
||||
VisualStudioVersion = 15.0.27130.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BarcodeScanner", "BarcodeScanner.csproj", "{2DDA58E7-3F10-5DE7-98D1-090A0BA4BCC3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2DDA58E7-3F10-5DE7-98D1-090A0BA4BCC3}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{2DDA58E7-3F10-5DE7-98D1-090A0BA4BCC3}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{2DDA58E7-3F10-5DE7-98D1-090A0BA4BCC3}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
|
@ -33,8 +33,11 @@ Global
|
|||
{2DDA58E7-3F10-5DE7-98D1-090A0BA4BCC3}.Release|x86.ActiveCfg = Release|x86
|
||||
{2DDA58E7-3F10-5DE7-98D1-090A0BA4BCC3}.Release|x86.Build.0 = Release|x86
|
||||
{2DDA58E7-3F10-5DE7-98D1-090A0BA4BCC3}.Release|x86.Deploy.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {D4C0F747-9DD7-42BC-ABB0-9CDC95ADC404}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.15063.0" MaxVersionTested="10.0.17134.0" />
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17134.0" MaxVersionTested="10.0.17134.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
|
@ -50,5 +50,7 @@
|
|||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
<DeviceCapability Name="pointOfService" />
|
||||
<!-- Scenario 5 accesses the camera -->
|
||||
<DeviceCapability Name="webcam" />
|
||||
</Capabilities>
|
||||
</Package>
|
|
@ -15,7 +15,9 @@ using System.Threading.Tasks;
|
|||
using Windows.Devices.PointOfService;
|
||||
using Windows.Security.Cryptography;
|
||||
using Windows.Storage.Streams;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
namespace SDKTemplate
|
||||
{
|
||||
|
@ -29,6 +31,7 @@ namespace SDKTemplate
|
|||
new Scenario() { Title = "Release/Retain functionality", ClassType = typeof(Scenario2_MultipleScanners) },
|
||||
new Scenario() { Title = "Active Symbologies", ClassType = typeof(Scenario3_ActiveSymbologies) },
|
||||
new Scenario() { Title = "Symbology Attributes", ClassType = typeof(Scenario4_SymbologyAttributes) },
|
||||
new Scenario() { Title = "Displaying a Barcode Preview", ClassType = typeof(Scenario5_DisplayingBarcodePreview) },
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -95,8 +98,31 @@ namespace SDKTemplate
|
|||
}
|
||||
}
|
||||
|
||||
public partial class BindingHelpers
|
||||
{
|
||||
// Inverters for binding.
|
||||
public static bool Not(bool value) => !value;
|
||||
public static Visibility CollapsedIf(bool value) => value ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The class is used for data-binding.
|
||||
/// This class is used for data-binding.
|
||||
/// </summary>
|
||||
public class BarcodeScannerInfo
|
||||
{
|
||||
public BarcodeScannerInfo(String deviceName, String deviceId)
|
||||
{
|
||||
DeviceName = deviceName;
|
||||
DeviceId = deviceId;
|
||||
}
|
||||
|
||||
public String Name => $"{DeviceName} ({DeviceId})";
|
||||
public String DeviceId { get; private set; }
|
||||
private string DeviceName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This class is used for data-binding.
|
||||
/// </summary>
|
||||
public class SymbologyListEntry
|
||||
{
|
||||
|
|
|
@ -45,7 +45,6 @@ namespace SDKTemplate
|
|||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
ResetTheScenarioState();
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -56,7 +55,6 @@ namespace SDKTemplate
|
|||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
{
|
||||
ResetTheScenarioState();
|
||||
base.OnNavigatedFrom(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -80,19 +78,19 @@ namespace SDKTemplate
|
|||
|
||||
if (claimedScanner != null)
|
||||
{
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// claim ownsership of the barcode scanner.
|
||||
claimedScanner.ReleaseDeviceRequested += claimedScanner_ReleaseDeviceRequested;
|
||||
|
||||
// after successfully claiming, attach the datareceived event handler.
|
||||
claimedScanner.DataReceived += claimedScanner_DataReceived;
|
||||
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// send the ScanDataLabel and ScanDataType in the DataReceived event
|
||||
claimedScanner.IsDecodeDataEnabled = true;
|
||||
|
||||
// enable the scanner.
|
||||
// Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// if the claimedScanner has not beed Enabled
|
||||
await claimedScanner.EnableAsync();
|
||||
|
||||
|
@ -129,7 +127,7 @@ namespace SDKTemplate
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"> Contains the BarcodeScannerReport which contains the data obtained in the scan</param>
|
||||
|
@ -167,19 +165,22 @@ namespace SDKTemplate
|
|||
scanner = null;
|
||||
}
|
||||
|
||||
// Reset the strings in the UI
|
||||
rootPage.NotifyUser("Click the start scanning button to begin.", NotifyType.StatusMessage);
|
||||
this.ScenarioOutputScanData.Text = "No data";
|
||||
this.ScenarioOutputScanDataLabel.Text = "No data";
|
||||
this.ScenarioOutputScanDataType.Text = "No data";
|
||||
// Reset the UI if we are still the current page.
|
||||
if (Frame.Content == this)
|
||||
{
|
||||
rootPage.NotifyUser("Click the start scanning button to begin.", NotifyType.StatusMessage);
|
||||
this.ScenarioOutputScanData.Text = "No data";
|
||||
this.ScenarioOutputScanDataLabel.Text = "No data";
|
||||
this.ScenarioOutputScanDataType.Text = "No data";
|
||||
|
||||
// reset the button state
|
||||
ScenarioEndScanButton.IsEnabled = false;
|
||||
ScenarioStartScanButton.IsEnabled = true;
|
||||
// reset the button state
|
||||
ScenarioEndScanButton.IsEnabled = false;
|
||||
ScenarioStartScanButton.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for End Scan Button Click.
|
||||
/// Event handler for End Scan Button Click.
|
||||
/// Releases the Barcode Scanner and resets the text in the UI
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
|
|
|
@ -75,14 +75,12 @@ namespace SDKTemplate
|
|||
|
||||
/// <summary>
|
||||
/// This is the click handler for the 'ScenarioStartScanningInstance1' button. It initiates creation of scanner instance 1.
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
///
|
||||
private async void ButtonStartScanningInstance1_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//Get the handle to the default scanner
|
||||
//Get the handle to the default scanner
|
||||
if (await CreateDefaultScannerObjectAsync(BarcodeScannerInstance.Instance1))
|
||||
{
|
||||
//Claim the scanner
|
||||
|
@ -158,10 +156,9 @@ namespace SDKTemplate
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
///
|
||||
private async void ButtonStartScanningInstance2_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//Get the handle to the default scanner
|
||||
//Get the handle to the default scanner
|
||||
if (await CreateDefaultScannerObjectAsync(BarcodeScannerInstance.Instance2))
|
||||
{
|
||||
//Claim the scanner
|
||||
|
@ -235,12 +232,11 @@ namespace SDKTemplate
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the click handler for the 'ScenarioEndScanningInstance1' button.
|
||||
/// This is the click handler for the 'ScenarioEndScanningInstance1' button.
|
||||
/// Initiates the disposal of scanner instance 1.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
///
|
||||
private void ButtonEndScanningInstance1_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (claimedBarcodeScannerInstance1 != null)
|
||||
|
@ -268,12 +264,11 @@ namespace SDKTemplate
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the click handler for the 'ScenarioEndScanningInstance2' button.
|
||||
/// This is the click handler for the 'ScenarioEndScanningInstance2' button.
|
||||
/// Initiates the disposal fo scanner instance 2.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
///
|
||||
private void ButtonEndScanningInstance2_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (claimedBarcodeScannerInstance2 != null)
|
||||
|
|
|
@ -69,18 +69,11 @@ namespace SDKTemplate
|
|||
|
||||
rootPage.NotifyUser("Acquiring barcode scanner object.", NotifyType.StatusMessage);
|
||||
|
||||
// create the barcode scanner.
|
||||
// create the barcode scanner.
|
||||
scanner = await DeviceHelpers.GetFirstBarcodeScannerAsync();
|
||||
|
||||
if (scanner != null)
|
||||
{
|
||||
// after successful creation, list supported symbologies
|
||||
IReadOnlyList<uint> supportedSymbologies = await scanner.GetSupportedSymbologiesAsync();
|
||||
foreach (uint symbology in supportedSymbologies)
|
||||
{
|
||||
listOfSymbologies.Add(new SymbologyListEntry(symbology));
|
||||
}
|
||||
|
||||
// Claim the scanner for exclusive use and enable it so raises DataReceived events.
|
||||
claimedScanner = await scanner.ClaimScannerAsync();
|
||||
if (claimedScanner != null)
|
||||
|
@ -101,6 +94,13 @@ namespace SDKTemplate
|
|||
// Do this after adding the DataReceived event handler.
|
||||
await claimedScanner.EnableAsync();
|
||||
|
||||
// after successful claim, list supported symbologies
|
||||
IReadOnlyList<uint> supportedSymbologies = await scanner.GetSupportedSymbologiesAsync();
|
||||
foreach (uint symbology in supportedSymbologies)
|
||||
{
|
||||
listOfSymbologies.Add(new SymbologyListEntry(symbology));
|
||||
}
|
||||
|
||||
// reset the button state
|
||||
ScenarioEndScanButton.IsEnabled = true;
|
||||
SetActiveSymbologiesButton.IsEnabled = true;
|
||||
|
@ -135,7 +135,7 @@ namespace SDKTemplate
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"> Contains the BarcodeScannerReport which contains the data obtained in the scan</param>
|
||||
|
@ -173,23 +173,26 @@ namespace SDKTemplate
|
|||
scanner = null;
|
||||
}
|
||||
|
||||
// Reset the strings in the UI
|
||||
rootPage.NotifyUser("Click the start scanning button to begin.", NotifyType.StatusMessage);
|
||||
this.ScenarioOutputScanData.Text = "No data";
|
||||
this.ScenarioOutputScanDataLabel.Text = "No data";
|
||||
this.ScenarioOutputScanDataType.Text = "No data";
|
||||
// Reset the UI if we are still the current page.
|
||||
if (Frame.Content == this)
|
||||
{
|
||||
rootPage.NotifyUser("Click the start scanning button to begin.", NotifyType.StatusMessage);
|
||||
this.ScenarioOutputScanData.Text = "No data";
|
||||
this.ScenarioOutputScanDataLabel.Text = "No data";
|
||||
this.ScenarioOutputScanDataType.Text = "No data";
|
||||
|
||||
// reset the button state
|
||||
SetActiveSymbologiesButton.IsEnabled = false;
|
||||
ScenarioEndScanButton.IsEnabled = false;
|
||||
ScenarioStartScanButton.IsEnabled = true;
|
||||
// reset the button state
|
||||
SetActiveSymbologiesButton.IsEnabled = false;
|
||||
ScenarioEndScanButton.IsEnabled = false;
|
||||
ScenarioStartScanButton.IsEnabled = true;
|
||||
|
||||
// reset symbology list
|
||||
listOfSymbologies.Clear();
|
||||
// reset symbology list
|
||||
listOfSymbologies.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for End Scan Button Click.
|
||||
/// Event handler for End Scan Button Click.
|
||||
/// Releases the Barcode Scanner and resets the text in the UI
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
|
|
|
@ -60,38 +60,38 @@ namespace SDKTemplate
|
|||
|
||||
rootPage.NotifyUser("Acquiring barcode scanner object.", NotifyType.StatusMessage);
|
||||
|
||||
// create the barcode scanner.
|
||||
// create the barcode scanner.
|
||||
scanner = await DeviceHelpers.GetFirstBarcodeScannerAsync();
|
||||
|
||||
if (scanner != null)
|
||||
{
|
||||
// after successful creation, list supported symbologies
|
||||
IReadOnlyList<uint> supportedSymbologies = await scanner.GetSupportedSymbologiesAsync();
|
||||
foreach (uint symbology in supportedSymbologies)
|
||||
{
|
||||
listOfSymbologies.Add(new SymbologyListEntry(symbology));
|
||||
}
|
||||
|
||||
// claim the scanner for exclusive use and enable it so that data received events are received.
|
||||
claimedScanner = await scanner.ClaimScannerAsync();
|
||||
if (claimedScanner != null)
|
||||
{
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// claim ownership of the barcode scanner.
|
||||
claimedScanner.ReleaseDeviceRequested += claimedScanner_ReleaseDeviceRequested;
|
||||
|
||||
// after successfully claiming, attach the datareceived event handler.
|
||||
claimedScanner.DataReceived += claimedScanner_DataReceived;
|
||||
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// send the ScanDataLabel and ScanDataType in the DataReceived event
|
||||
claimedScanner.IsDecodeDataEnabled = true;
|
||||
|
||||
// enable the scanner.
|
||||
// Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// Note: If the scanner is not enabled (i.e. EnableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// if the claimedScanner has not been Enabled
|
||||
await claimedScanner.EnableAsync();
|
||||
|
||||
// after successful claim, list supported symbologies
|
||||
IReadOnlyList<uint> supportedSymbologies = await scanner.GetSupportedSymbologiesAsync();
|
||||
foreach (uint symbology in supportedSymbologies)
|
||||
{
|
||||
listOfSymbologies.Add(new SymbologyListEntry(symbology));
|
||||
}
|
||||
|
||||
// reset the button state
|
||||
ScenarioEndScanButton.IsEnabled = true;
|
||||
|
||||
|
@ -125,7 +125,7 @@ namespace SDKTemplate
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"> Contains the BarcodeScannerReport which contains the data obtained in the scan</param>
|
||||
|
@ -165,26 +165,29 @@ namespace SDKTemplate
|
|||
|
||||
symbologyAttributes = null;
|
||||
|
||||
// Reset the strings in the UI
|
||||
rootPage.NotifyUser("Click the start scanning button to begin.", NotifyType.StatusMessage);
|
||||
this.ScenarioOutputScanData.Text = "No data";
|
||||
this.ScenarioOutputScanDataLabel.Text = "No data";
|
||||
this.ScenarioOutputScanDataType.Text = "No data";
|
||||
// Reset the UI if we are still the current page.
|
||||
if (Frame.Content == this)
|
||||
{
|
||||
rootPage.NotifyUser("Click the start scanning button to begin.", NotifyType.StatusMessage);
|
||||
this.ScenarioOutputScanData.Text = "No data";
|
||||
this.ScenarioOutputScanDataLabel.Text = "No data";
|
||||
this.ScenarioOutputScanDataType.Text = "No data";
|
||||
|
||||
// reset the button state
|
||||
ScenarioEndScanButton.IsEnabled = false;
|
||||
ScenarioStartScanButton.IsEnabled = true;
|
||||
SetSymbologyAttributesButton.IsEnabled = false;
|
||||
EnableCheckDigit.IsEnabled = false;
|
||||
TransmitCheckDigit.IsEnabled = false;
|
||||
SetDecodeRangeLimits.IsEnabled = false;
|
||||
// reset the button state
|
||||
ScenarioEndScanButton.IsEnabled = false;
|
||||
ScenarioStartScanButton.IsEnabled = true;
|
||||
SetSymbologyAttributesButton.IsEnabled = false;
|
||||
EnableCheckDigit.IsEnabled = false;
|
||||
TransmitCheckDigit.IsEnabled = false;
|
||||
SetDecodeRangeLimits.IsEnabled = false;
|
||||
|
||||
// reset symbology list
|
||||
listOfSymbologies.Clear();
|
||||
// reset symbology list
|
||||
listOfSymbologies.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for End Scan Button Click.
|
||||
/// Event handler for End Scan Button Click.
|
||||
/// Releases the Barcode Scanner and resets the text in the UI
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
|
@ -196,7 +199,7 @@ namespace SDKTemplate
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for Symbology listbox selection changed.
|
||||
/// Event handler for Symbology listbox selection changed.
|
||||
/// Get symbology attributes and populate attribute UI components
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
|
|
|
@ -0,0 +1,436 @@
|
|||
//*********************************************************
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// This code is licensed under the MIT License (MIT).
|
||||
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
|
||||
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
|
||||
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
|
||||
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
|
||||
//
|
||||
//*********************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Devices.Enumeration;
|
||||
using Windows.Devices.PointOfService;
|
||||
using Windows.Graphics.Display;
|
||||
using Windows.Media.Capture;
|
||||
using Windows.System.Display;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace SDKTemplate
|
||||
{
|
||||
public sealed partial class Scenario5_DisplayingBarcodePreview : Page, INotifyPropertyChanged
|
||||
{
|
||||
public bool IsScannerClaimed { get; set; } = false;
|
||||
public bool IsPreviewing { get; set; } = false;
|
||||
public bool ScannerSupportsPreview { get; set; } = false;
|
||||
public bool SoftwareTriggerStarted { get; set; } = false;
|
||||
|
||||
MainPage rootPage = MainPage.Current;
|
||||
ObservableCollection<BarcodeScannerInfo> barcodeScanners = new ObservableCollection<BarcodeScannerInfo>();
|
||||
BarcodeScanner selectedScanner = null;
|
||||
ClaimedBarcodeScanner claimedScanner = null;
|
||||
DeviceWatcher watcher;
|
||||
|
||||
static readonly Guid rotationGuid = new Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1");
|
||||
|
||||
DisplayRequest displayRequest = new DisplayRequest();
|
||||
MediaCapture mediaCapture;
|
||||
|
||||
bool isSelectionChanging = false;
|
||||
string pendingSelectionDeviceId = null;
|
||||
bool isStopPending = false;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public Scenario5_DisplayingBarcodePreview()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
ScannerListSource.Source = barcodeScanners;
|
||||
|
||||
watcher = DeviceInformation.CreateWatcher(BarcodeScanner.GetDeviceSelector());
|
||||
watcher.Added += Watcher_Added;
|
||||
watcher.Removed += Watcher_Removed;
|
||||
watcher.Updated += Watcher_Updated;
|
||||
watcher.Start();
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
private async void Watcher_Added(DeviceWatcher sender, DeviceInformation args)
|
||||
{
|
||||
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
|
||||
{
|
||||
barcodeScanners.Add(new BarcodeScannerInfo(args.Name, args.Id));
|
||||
|
||||
// Select the first scanner by default.
|
||||
if (barcodeScanners.Count == 1)
|
||||
{
|
||||
ScannerListBox.SelectedIndex = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void Watcher_Removed(DeviceWatcher sender, DeviceInformationUpdate args)
|
||||
{
|
||||
// We don't do anything here, but this event needs to be handled to enable realtime updates.
|
||||
// See https://aka.ms/devicewatcher_added.
|
||||
}
|
||||
|
||||
private void Watcher_Updated(DeviceWatcher sender, DeviceInformationUpdate args)
|
||||
{
|
||||
// We don't do anything here, but this event needs to be handled to enable realtime updates.
|
||||
//See https://aka.ms/devicewatcher_added.
|
||||
}
|
||||
|
||||
protected async override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
{
|
||||
watcher.Stop();
|
||||
|
||||
if (isSelectionChanging)
|
||||
{
|
||||
// If selection is changing, then let it know to stop media capture
|
||||
// when it's done.
|
||||
isStopPending = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If selection is not changing, then it's safe to stop immediately.
|
||||
await CloseScannerResourcesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts previewing the selected scanner's video feed and prevents the display from going to sleep.
|
||||
/// </summary>
|
||||
private async Task StartMediaCaptureAsync(string videoDeviceId)
|
||||
{
|
||||
mediaCapture = new MediaCapture();
|
||||
|
||||
// Register for a notification when something goes wrong
|
||||
mediaCapture.Failed += MediaCapture_Failed;
|
||||
|
||||
var settings = new MediaCaptureInitializationSettings
|
||||
{
|
||||
VideoDeviceId = videoDeviceId,
|
||||
StreamingCaptureMode = StreamingCaptureMode.Video,
|
||||
};
|
||||
|
||||
// Initialize MediaCapture
|
||||
bool captureInitialized = false;
|
||||
try
|
||||
{
|
||||
await mediaCapture.InitializeAsync(settings);
|
||||
captureInitialized = true;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
rootPage.NotifyUser("The app was denied access to the camera", NotifyType.ErrorMessage);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
rootPage.NotifyUser("Failed to initialize the camera: " + e.Message, NotifyType.ErrorMessage);
|
||||
}
|
||||
|
||||
if (captureInitialized)
|
||||
{
|
||||
// Prevent the device from sleeping while the preview is running.
|
||||
displayRequest.RequestActive();
|
||||
|
||||
PreviewControl.Source = mediaCapture;
|
||||
await mediaCapture.StartPreviewAsync();
|
||||
await SetPreviewRotationAsync(DisplayInformation.GetForCurrentView().CurrentOrientation);
|
||||
IsPreviewing = true;
|
||||
RaisePropertyChanged(nameof(IsPreviewing));
|
||||
}
|
||||
else
|
||||
{
|
||||
mediaCapture.Dispose();
|
||||
mediaCapture = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close the scanners and stop the preview.
|
||||
/// </summary>
|
||||
private async Task CloseScannerResourcesAsync()
|
||||
{
|
||||
claimedScanner?.Dispose();
|
||||
claimedScanner = null;
|
||||
|
||||
selectedScanner?.Dispose();
|
||||
selectedScanner = null;
|
||||
|
||||
SoftwareTriggerStarted = false;
|
||||
RaisePropertyChanged(nameof(SoftwareTriggerStarted));
|
||||
|
||||
if (IsPreviewing)
|
||||
{
|
||||
if (mediaCapture != null)
|
||||
{
|
||||
await mediaCapture.StopPreviewAsync();
|
||||
mediaCapture.Dispose();
|
||||
mediaCapture = null;
|
||||
}
|
||||
|
||||
// Allow the display to go to sleep.
|
||||
displayRequest.RequestRelease();
|
||||
|
||||
IsPreviewing = false;
|
||||
RaisePropertyChanged(nameof(IsPreviewing));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set preview rotation and mirroring state to adjust for the orientation of the camera, and for embedded cameras, the rotation of the device.
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="type"></param>
|
||||
private async Task SetPreviewRotationAsync(DisplayOrientations displayOrientation)
|
||||
{
|
||||
bool isExternalCamera;
|
||||
bool isPreviewMirrored;
|
||||
|
||||
// Figure out where the camera is located to account for mirroring and later adjust rotation accordingly.
|
||||
DeviceInformation cameraInformation = await DeviceInformation.CreateFromIdAsync(selectedScanner.VideoDeviceId);
|
||||
|
||||
if ((cameraInformation.EnclosureLocation == null) || (cameraInformation.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Unknown))
|
||||
{
|
||||
isExternalCamera = true;
|
||||
isPreviewMirrored = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
isExternalCamera = false;
|
||||
isPreviewMirrored = (cameraInformation.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front);
|
||||
}
|
||||
|
||||
PreviewControl.FlowDirection = isPreviewMirrored ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
|
||||
|
||||
if (!isExternalCamera)
|
||||
{
|
||||
// Calculate which way and how far to rotate the preview.
|
||||
int rotationDegrees = 0;
|
||||
switch (displayOrientation)
|
||||
{
|
||||
case DisplayOrientations.Portrait:
|
||||
rotationDegrees = 90;
|
||||
break;
|
||||
case DisplayOrientations.LandscapeFlipped:
|
||||
rotationDegrees = 180;
|
||||
break;
|
||||
case DisplayOrientations.PortraitFlipped:
|
||||
rotationDegrees = 270;
|
||||
break;
|
||||
case DisplayOrientations.Landscape:
|
||||
default:
|
||||
rotationDegrees = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// The rotation direction needs to be inverted if the preview is being mirrored.
|
||||
if (isPreviewMirrored)
|
||||
{
|
||||
rotationDegrees = (360 - rotationDegrees) % 360;
|
||||
}
|
||||
|
||||
// Add rotation metadata to the preview stream to make sure the aspect ratio / dimensions match when rendering and getting preview frames.
|
||||
var streamProperties = mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview);
|
||||
streamProperties.Properties[rotationGuid] = rotationDegrees;
|
||||
await mediaCapture.SetEncodingPropertiesAsync(MediaStreamType.VideoPreview, streamProperties, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Media capture failed, potentially due to the camera being unplugged.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="errorEventArgs"></param>
|
||||
private void MediaCapture_Failed(MediaCapture sender, MediaCaptureFailedEventArgs errorEventArgs)
|
||||
{
|
||||
rootPage.NotifyUser("Media capture failed. Make sure the camera is still connected.", NotifyType.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event Handler for Show Preview Button Click.
|
||||
/// Displays the preview window for the selected barcode scanner.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private async void ShowPreviewButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await claimedScanner?.ShowVideoPreviewAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event Handler for Hide Preview Button Click.
|
||||
/// Hides the preview window for the selected barcode scanner.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void HidePreviewButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
claimedScanner?.HideVideoPreview();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event Handler for Start Software Trigger Button Click.
|
||||
/// Starts scanning.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private async void StartSoftwareTriggerButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (claimedScanner != null)
|
||||
{
|
||||
await claimedScanner.StartSoftwareTriggerAsync();
|
||||
|
||||
SoftwareTriggerStarted = true;
|
||||
RaisePropertyChanged(nameof(SoftwareTriggerStarted));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event Handler for Stop Software Trigger Button Click.
|
||||
/// Stops scanning.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private async void StopSoftwareTriggerButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (claimedScanner != null)
|
||||
{
|
||||
await claimedScanner.StopSoftwareTriggerAsync();
|
||||
SoftwareTriggerStarted = false;
|
||||
RaisePropertyChanged(nameof(SoftwareTriggerStarted));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event Handler for Flip Preview Button Click.
|
||||
/// Stops scanning.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void FlipPreview_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (PreviewControl.FlowDirection == FlowDirection.LeftToRight)
|
||||
{
|
||||
PreviewControl.FlowDirection = FlowDirection.RightToLeft;
|
||||
}
|
||||
else
|
||||
{
|
||||
PreviewControl.FlowDirection = FlowDirection.LeftToRight;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for scanner listbox selection changed
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
private async void ScannerSelection_Changed(object sender, SelectionChangedEventArgs args)
|
||||
{
|
||||
var selectedScannerInfo = (BarcodeScannerInfo)args.AddedItems[0];
|
||||
var deviceId = selectedScannerInfo.DeviceId;
|
||||
|
||||
if (isSelectionChanging)
|
||||
{
|
||||
pendingSelectionDeviceId = deviceId;
|
||||
return;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
await SelectScannerAsync(deviceId);
|
||||
|
||||
// Stop takes precedence over updating the selection.
|
||||
if (isStopPending)
|
||||
{
|
||||
await CloseScannerResourcesAsync();
|
||||
break;
|
||||
}
|
||||
|
||||
deviceId = pendingSelectionDeviceId;
|
||||
pendingSelectionDeviceId = null;
|
||||
} while (!String.IsNullOrEmpty(deviceId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Select the scanner specified by its device ID.
|
||||
/// </summary>
|
||||
/// <param name="scannerDeviceId"></param>
|
||||
private async Task SelectScannerAsync(string scannerDeviceId)
|
||||
{
|
||||
isSelectionChanging = true;
|
||||
|
||||
await CloseScannerResourcesAsync();
|
||||
|
||||
selectedScanner = await BarcodeScanner.FromIdAsync(scannerDeviceId);
|
||||
|
||||
if (selectedScanner != null)
|
||||
{
|
||||
claimedScanner = await selectedScanner.ClaimScannerAsync();
|
||||
if (claimedScanner != null)
|
||||
{
|
||||
await claimedScanner.EnableAsync();
|
||||
ScannerSupportsPreview = !String.IsNullOrEmpty(selectedScanner.VideoDeviceId);
|
||||
RaisePropertyChanged(nameof(ScannerSupportsPreview));
|
||||
|
||||
claimedScanner.DataReceived += ClaimedScanner_DataReceived;
|
||||
|
||||
if (ScannerSupportsPreview)
|
||||
{
|
||||
await StartMediaCaptureAsync(selectedScanner.VideoDeviceId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rootPage.NotifyUser("Failed to claim the selected barcode scanner", NotifyType.ErrorMessage);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
rootPage.NotifyUser("Failed to create a barcode scanner object", NotifyType.ErrorMessage);
|
||||
}
|
||||
|
||||
IsScannerClaimed = claimedScanner != null;
|
||||
RaisePropertyChanged(nameof(IsScannerClaimed));
|
||||
|
||||
isSelectionChanging = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scan data was received from the selected scanner.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
private async void ClaimedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
|
||||
{
|
||||
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
|
||||
{
|
||||
ScenarioOutputScanDataLabel.Text = DataHelpers.GetDataLabelString(args.Report.ScanDataLabel, args.Report.ScanDataType);
|
||||
ScenarioOutputScanData.Text = DataHelpers.GetDataString(args.Report.ScanData);
|
||||
ScenarioOutputScanDataType.Text = BarcodeSymbologies.GetName(args.Report.ScanDataType);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update listeners that a property was changed so that data bindings can be updated.
|
||||
/// </summary>
|
||||
/// <param name="propertyName"></param>
|
||||
public void RaisePropertyChanged(string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
|
||||
},
|
||||
"frameworks": {
|
||||
"uap10.0": {}
|
||||
},
|
||||
"runtimes": {
|
||||
"win10-arm": {},
|
||||
"win10-arm-aot": {},
|
||||
"win10-x86": {},
|
||||
"win10-x86-aot": {},
|
||||
"win10-x64": {},
|
||||
"win10-x64-aot": {}
|
||||
}
|
||||
}
|
|
@ -61,6 +61,7 @@
|
|||
<Content Include="..\..\..\SharedContent\js\default.html">
|
||||
<Link>default.html</Link>
|
||||
</Content>
|
||||
<Content Include="css\scenario5_DisplayingBarcodePreview.css" />
|
||||
<Content Include="html\scenario1_BasicFunctionality.html" />
|
||||
<Content Include="html\scenario2_MultipleScanners.html" />
|
||||
<Content Include="html\scenario3_ActiveSymbologies.html" />
|
||||
|
@ -77,6 +78,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
@ -92,11 +96,13 @@
|
|||
<Content Include="..\..\..\SharedContent\js\css\default.css">
|
||||
<Link>css\default.css</Link>
|
||||
</Content>
|
||||
<Content Include="html\scenario5_DisplayingBarcodePreview.html" />
|
||||
<Content Include="js\sample-configuration.js" />
|
||||
<Content Include="js\scenario1_BasicFunctionality.js" />
|
||||
<Content Include="js\scenario2_MultipleScanners.js" />
|
||||
<Content Include="js\scenario3_ActiveSymbologies.js" />
|
||||
<Content Include="js\scenario4_SymbologyAttributes.js" />
|
||||
<Content Include="js\scenario5_DisplayingBarcodePreview.js" />
|
||||
<Content Include="js\util.js" />
|
||||
<Content Include="..\..\..\SharedContent\js\Microsoft.WinJS\css\ui-dark.css">
|
||||
<Link>Microsoft.WinJS.4.0\css\ui-dark.css</Link>
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26228.4
|
||||
VisualStudioVersion = 15.0.27130.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "BarcodeScanner", "BarcodeScanner.jsproj", "{C8BDFC8D-E353-5B24-AB7B-A9E1E658BB4A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C8BDFC8D-E353-5B24-AB7B-A9E1E658BB4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C8BDFC8D-E353-5B24-AB7B-A9E1E658BB4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C8BDFC8D-E353-5B24-AB7B-A9E1E658BB4A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
|
@ -41,8 +41,11 @@ Global
|
|||
{C8BDFC8D-E353-5B24-AB7B-A9E1E658BB4A}.Release|x86.ActiveCfg = Release|x86
|
||||
{C8BDFC8D-E353-5B24-AB7B-A9E1E658BB4A}.Release|x86.Build.0 = Release|x86
|
||||
{C8BDFC8D-E353-5B24-AB7B-A9E1E658BB4A}.Release|x86.Deploy.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {05492F48-74FF-4B0F-879F-07CD24A126BB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.15063.0" MaxVersionTested="10.0.17134.0" />
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17134.0" MaxVersionTested="10.0.17134.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
|
@ -35,7 +35,7 @@
|
|||
DisplayName="BarcodeScanner JS Sample"
|
||||
Description="POS Barcode Scanner JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
|
@ -51,6 +51,8 @@
|
|||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
<DeviceCapability Name="pointOfService" />
|
||||
<!-- Scenario 5 accesses the camera -->
|
||||
<DeviceCapability Name="webcam" />
|
||||
</Capabilities>
|
||||
|
||||
</Package>
|
|
@ -0,0 +1,59 @@
|
|||
/**********************************************************
|
||||
|
||||
Copyright (c) Microsoft. All rights reserved.
|
||||
This code is licensed under the MIT License (MIT).
|
||||
THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
|
||||
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
|
||||
IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
|
||||
PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
|
||||
|
||||
**********************************************************/
|
||||
|
||||
/* styles */
|
||||
|
||||
table.fixed {
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.listViewTitle {
|
||||
align-content:flex-start;
|
||||
width: 240px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.listViewContainer {
|
||||
border: 1px solid gray;
|
||||
margin: 5px 5px 5px 0px;
|
||||
width: 100%;
|
||||
height: 320px;
|
||||
}
|
||||
|
||||
.buttonRow {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
#cameraPreview {
|
||||
width: 265px;
|
||||
height: 200px;
|
||||
border: solid 1px white;
|
||||
}
|
||||
|
||||
#previewNotSupportedNotice {
|
||||
color: red;
|
||||
}
|
||||
|
||||
#scannerResultsBlock:not([data-is-scanner-claimed="true"]) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#scannerResultsBlock:not([data-is-previewing="true"]) #previewBlock {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#scannerResultsBlock[data-scanner-supports-preview="true"] #previewNotSupportedNotice {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#scannerResultsBlock:not([data-scanner-supports-preview="true"]) .ifScannerSupportsPreview {
|
||||
display: none;
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
<!--
|
||||
//*********************************************************
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// This code is licensed under the MIT License (MIT).
|
||||
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
|
||||
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
|
||||
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
|
||||
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
|
||||
//
|
||||
//*********************************************************
|
||||
-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head>
|
||||
<title></title>
|
||||
<link rel="stylesheet" href="/css/scenario5_DisplayingBarcodePreview.css">
|
||||
<script src="/js/scenario5_DisplayingBarcodePreview.js"></script>
|
||||
<script src="/js/util.js"></script>
|
||||
</head>
|
||||
|
||||
<body class="win-type-body">
|
||||
<h2 id="sampleHeader" class="win-type-subheader">Description:</h2>
|
||||
<div id="scenarioDescription">
|
||||
<p>Demonstrates how to interact with barcode scanners that support video previewing</p>
|
||||
</div>
|
||||
<p>Select a Scanner</p>
|
||||
<div id="scannerTemplate" data-win-control="WinJS.Binding.Template">
|
||||
<span data-win-bind="textContent: name"></span>
|
||||
</div>
|
||||
<div id="scannerListView" class="listViewContainer" style="width: 100%"
|
||||
data-win-control="WinJS.UI.ListView" data-win-options="{
|
||||
itemTemplate: select('#scannerTemplate'),
|
||||
selectionMode: 'single',
|
||||
tapBehavior: 'directSelect',
|
||||
layout: {type: WinJS.UI.ListLayout}}">
|
||||
</div>
|
||||
<div id="scannerResultsBlock">
|
||||
<p id="previewNotSupportedNotice">*The selected barcode scanner does not have a camera, so a preview cannot be displayed.</p>
|
||||
<div id="previewSupportedButtons" class="buttonRow ifScannerSupportsPreview">
|
||||
<button id="showPreviewButton" class="win-button">Show Preview</button>
|
||||
<button id="hidePreviewButton" class="win-button">Hide Preview</button>
|
||||
</div>
|
||||
<div class="buttonRow">
|
||||
<button id="startSoftwareTriggerButton" class="win-button">Start Software Trigger</button>
|
||||
<button id="stopSoftwareTriggerButton" class="win-button" disabled="disabled">Stop Software Trigger</button>
|
||||
</div>
|
||||
<div class="ifScannerSupportsPreview" style="float: left">
|
||||
<video id="cameraPreview" class="cameraPreview"></video>
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Scan Data Type (Symbology):</td>
|
||||
<td id="scenarioOutputScanDataType">No Data</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Scan Data (Unformatted data):</td>
|
||||
<td id="scenarioOutputScanData">No Data</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Scan Data Label (Formatted data):</td>
|
||||
<td id="scenarioOutputScanDataFormatted">No Data</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -19,6 +19,7 @@
|
|||
{ url: "/html/scenario2_MultipleScanners.html", title: "Release/Retain functionality" },
|
||||
{ url: "/html/scenario3_ActiveSymbologies.html", title: "Active Symbologies" },
|
||||
{ url: "/html/scenario4_SymbologyAttributes.html", title: "Symbology Attributes" },
|
||||
{ url: "/html/scenario5_DisplayingBarcodePreview.html", title: "Displaying Barcode Preview" },
|
||||
];
|
||||
|
||||
var BarcodeScanner = Windows.Devices.PointOfService.BarcodeScanner;
|
||||
|
|
|
@ -71,22 +71,22 @@
|
|||
if (claimedScanner) {
|
||||
_claimedScanner = claimedScanner;
|
||||
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// send the ScanDataLabel and ScanDataType in the DataReceived event
|
||||
claimedScanner.isDecodeDataEnabled = true;
|
||||
|
||||
// After successfully claiming, attach the datareceived event handler.
|
||||
claimedScanner.addEventListener("datareceived", onDataReceived);
|
||||
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// claim ownsership of the barcode scanner.
|
||||
claimedScanner.addEventListener("releasedevicerequested", onReleasedeviceRequested);
|
||||
|
||||
// Enable the scanner.
|
||||
// Note: If the scanner is not enabled (i.e. enableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// Note: If the scanner is not enabled (i.e. enableAsync not called), attaching the event handler will not be any useful because the API will not fire the event
|
||||
// if the claimedScanner has not beed Enabled
|
||||
claimedScanner.enableAsync().done(function () {
|
||||
WinJS.log("Ready to scan. Device ID: " + _claimedScanner.deviceId, "sample", "status");
|
||||
WinJS.log("Ready to scan. Device ID: " + claimedScanner.deviceId, "sample", "status");
|
||||
scenarioEndScanButton.disabled = false;
|
||||
});
|
||||
} else {
|
||||
|
@ -107,7 +107,7 @@
|
|||
WinJS.log("Event ReleaseDeviceRequested received. Retaining the barcode scanner.", "sample", "status");
|
||||
}
|
||||
|
||||
// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
function onDataReceived(args) {
|
||||
var tempScanType = Windows.Devices.PointOfService.BarcodeSymbologies.getName(args.report.scanDataType);
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
// Page elements
|
||||
var scenarioStartScanningInstance1;
|
||||
var scenaioEndScanningInstance1;
|
||||
var scenarioEndScanningInstance1;
|
||||
var scenarioStartScanningInstance2;
|
||||
var scenaioEndScanningInstance2;
|
||||
var scenarioEndScanningInstance2;
|
||||
|
||||
var retain1;
|
||||
var scanDataType1;
|
||||
|
@ -80,7 +80,7 @@
|
|||
// Create scanner instance 1 and claim and enable it.
|
||||
function buttonStartScanningInstance1() {
|
||||
|
||||
// Create the barcode scanner.
|
||||
// Create the barcode scanner.
|
||||
createScanner(_activeBarcodeScannerInstance.instance1).then(function(success) {
|
||||
if (success) {
|
||||
// Claim the scanner and enable
|
||||
|
@ -101,7 +101,7 @@
|
|||
// Create scanner instance 2 and claim and enable it.
|
||||
function buttonStartScanningInstance2() {
|
||||
|
||||
// Create the barcode scanner.
|
||||
// Create the barcode scanner.
|
||||
createScanner(_activeBarcodeScannerInstance.instance2).then(function(success) {
|
||||
if (success) {
|
||||
// Claim the scanner and enable
|
||||
|
@ -227,7 +227,7 @@
|
|||
}
|
||||
|
||||
function createScanner(instance) {
|
||||
return SdkSample.getFirstBarcodeScannerAsync().done(function (scanner) {
|
||||
return SdkSample.getFirstBarcodeScannerAsync().then(function (scanner) {
|
||||
if (scanner) {
|
||||
switch (instance) {
|
||||
case _activeBarcodeScannerInstance.instance1:
|
||||
|
|
|
@ -68,51 +68,48 @@
|
|||
// Create the barcode scanner.
|
||||
WinJS.log("Creating barcode scanner object.", "sample", "status");
|
||||
|
||||
SdkSample.getFirstBarcodeScannerAsync().then(function (scanner) {
|
||||
SdkSample.getFirstBarcodeScannerAsync().done(function (scanner) {
|
||||
_scanner = scanner;
|
||||
if (scanner) {
|
||||
// After successful creation, fill the list with supported symbologies.
|
||||
return _scanner.getSupportedSymbologiesAsync().then(function (symbologies) {
|
||||
var listOfSymbologies = new WinJS.Binding.List(symbologies.map(function (symbology) {
|
||||
return { id: symbology, name: BarcodeSymbologies.getName(symbology) };
|
||||
}));
|
||||
symbologyListViewControl.itemDataSource = listOfSymbologies.dataSource;
|
||||
// Claim the scanner for exclusive use.
|
||||
_scanner.claimScannerAsync().done(function (claimedScanner) {
|
||||
_claimedScanner = claimedScanner;
|
||||
if (claimedScanner) {
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// send the ScanDataLabel and ScanDataType in the DataReceived event
|
||||
claimedScanner.isDecodeDataEnabled = true;
|
||||
|
||||
// Claim the scanner for exclusive use.
|
||||
return _scanner.claimScannerAsync();
|
||||
//// After successfully claiming, attach the datareceived event handler.
|
||||
claimedScanner.addEventListener("datareceived", onDataReceived);
|
||||
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// claim ownership of the barcode scanner.
|
||||
claimedScanner.addEventListener("releasedevicerequested", onReleasedeviceRequested);
|
||||
|
||||
// Enable the scanner so it starts raising events.
|
||||
claimedScanner.enableAsync().then(function () {
|
||||
// After successful claim, fill the list with supported symbologies.
|
||||
return _scanner.getSupportedSymbologiesAsync();
|
||||
}).done(function (symbologies) {
|
||||
var listOfSymbologies = new WinJS.Binding.List(symbologies.map(function (symbology) {
|
||||
return { id: symbology, name: BarcodeSymbologies.getName(symbology) };
|
||||
}));
|
||||
symbologyListViewControl.itemDataSource = listOfSymbologies.dataSource;
|
||||
|
||||
WinJS.log("Ready to scan. Device ID: " + _claimedScanner.deviceId, "sample", "status");
|
||||
scenarioEndScanButton.disabled = false;
|
||||
setActiveSymbologiesButton.disabled = false;
|
||||
});
|
||||
} else {
|
||||
_scanner.close();
|
||||
_scanner = null;
|
||||
scenarioStartScanButton.disabled = false;
|
||||
WinJS.log("Claim barcode scanner failed.", "sample", "error");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
WinJS.log("Barcode scanner not found. Please connect a barcode scanner.", "sample", "error");
|
||||
}
|
||||
}).then(function (claimedScanner) {
|
||||
_claimedScanner = claimedScanner;
|
||||
if (claimedScanner) {
|
||||
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// send the ScanDataLabel and ScanDataType in the DataReceived event
|
||||
claimedScanner.isDecodeDataEnabled = true;
|
||||
|
||||
//// After successfully claiming, attach the datareceived event handler.
|
||||
claimedScanner.addEventListener("datareceived", onDataReceived);
|
||||
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// claim ownership of the barcode scanner.
|
||||
claimedScanner.addEventListener("releasedevicerequested", onReleasedeviceRequested);
|
||||
|
||||
// Enable the scanner so it starts raising events.
|
||||
return claimedScanner.enableAsync();
|
||||
} else if (_scanner) {
|
||||
_scanner.close();
|
||||
_scanner = null;
|
||||
WinJS.log("Claim barcode scanner failed.", "sample", "error");
|
||||
}
|
||||
}).done(function () {
|
||||
if (_claimedScanner) {
|
||||
WinJS.log("Ready to scan. Device ID: " + _claimedScanner.deviceId, "sample", "status");
|
||||
scenarioEndScanButton.disabled = false;
|
||||
setActiveSymbologiesButton.disabled = false;
|
||||
} else {
|
||||
scenarioStartScanButton.disabled = false;
|
||||
WinJS.log("Barcode scanner not found. Please connect a barcode scanner.", "sample", "error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -123,7 +120,7 @@
|
|||
WinJS.log("Event ReleaseDeviceRequested received. Retaining the barcode scanner.", "sample", "status");
|
||||
}
|
||||
|
||||
// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
function onDataReceived(args) {
|
||||
scenarioOutputScanDataType.textContent = BarcodeSymbologies.getName(args.report.scanDataType);
|
||||
scenarioOutputScanData.textContent = getDataString(args.report.scanData);
|
||||
|
|
|
@ -79,51 +79,50 @@
|
|||
// Create the barcode scanner.
|
||||
WinJS.log("Creating barcode scanner object.", "sample", "status");
|
||||
|
||||
SdkSample.getFirstBarcodeScannerAsync().then(function (scanner) {
|
||||
SdkSample.getFirstBarcodeScannerAsync().done(function (scanner) {
|
||||
_scanner = scanner;
|
||||
if (scanner) {
|
||||
_scanner = scanner;
|
||||
// Claim the scanner for exclusive use.
|
||||
_scanner.claimScannerAsync().done(function (claimedScanner) {
|
||||
_claimedScanner = claimedScanner;
|
||||
if (claimedScanner) {
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// send the ScanDataLabel and ScanDataType in the DataReceived event
|
||||
claimedScanner.isDecodeDataEnabled = true;
|
||||
|
||||
// After successful creation, fill the list with supported symbologies.
|
||||
return _scanner.getSupportedSymbologiesAsync().then(function (symbologies) {
|
||||
var listOfSymbologies = new WinJS.Binding.List(symbologies.map(function (symbology) {
|
||||
return { id: symbology, name: BarcodeSymbologies.getName(symbology) };
|
||||
}));
|
||||
symbologyListViewControl.itemDataSource = listOfSymbologies.dataSource;
|
||||
//// After successfully claiming, attach the datareceived event handler.
|
||||
claimedScanner.addEventListener("datareceived", onDataReceived);
|
||||
|
||||
// Claim the scanner for exclusive use.
|
||||
return _scanner.claimScannerAsync();
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// claim ownership of the barcode scanner.
|
||||
claimedScanner.addEventListener("releasedevicerequested", onReleasedeviceRequested);
|
||||
|
||||
// Enable the scanner so it starts raising events.
|
||||
claimedScanner.enableAsync().then(function () {
|
||||
// After successful claim, fill the list with supported symbologies.
|
||||
return _scanner.getSupportedSymbologiesAsync();
|
||||
}).done(function (symbologies) {
|
||||
if (symbologies) {
|
||||
var listOfSymbologies = new WinJS.Binding.List(symbologies.map(function (symbology) {
|
||||
return { id: symbology, name: BarcodeSymbologies.getName(symbology) };
|
||||
}));
|
||||
symbologyListViewControl.itemDataSource = listOfSymbologies.dataSource;
|
||||
|
||||
WinJS.log("Ready to scan. Device ID: " + _claimedScanner.deviceId, "sample", "status");
|
||||
scenarioEndScanButton.disabled = false;
|
||||
setSymbologyAttributesButton.disabled = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
_scanner.close();
|
||||
_scanner = null;
|
||||
scenarioStartScanButton.disabled = false;
|
||||
WinJS.log("Claim barcode scanner failed.", "sample", "error");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
WinJS.log("Barcode scanner not found. Please connect a barcode scanner.", "sample", "error");
|
||||
}
|
||||
}).then(function (claimedScanner) {
|
||||
_claimedScanner = claimedScanner;
|
||||
if (claimedScanner) {
|
||||
|
||||
// Ask the API to decode the data by default. By setting this, API will decode the raw data from the barcode scanner and
|
||||
// send the ScanDataLabel and ScanDataType in the DataReceived event
|
||||
claimedScanner.isDecodeDataEnabled = true;
|
||||
|
||||
//// After successfully claiming, attach the datareceived event handler.
|
||||
claimedScanner.addEventListener("datareceived", onDataReceived);
|
||||
|
||||
// It is always a good idea to have a release device requested event handler. If this event is not handled, there are chances of another app can
|
||||
// claim ownership of the barcode scanner.
|
||||
claimedScanner.addEventListener("releasedevicerequested", onReleasedeviceRequested);
|
||||
|
||||
// Enable the scanner so it starts raising events.
|
||||
return claimedScanner.enableAsync();
|
||||
} else if (_scanner) {
|
||||
_scanner.close();
|
||||
_scanner = null;
|
||||
WinJS.log("Claim barcode scanner failed.", "sample", "error");
|
||||
}
|
||||
}).done(function () {
|
||||
if (_claimedScanner) {
|
||||
WinJS.log("Ready to scan. Device ID: " + _claimedScanner.deviceId, "sample", "status");
|
||||
scenarioEndScanButton.disabled = false;
|
||||
} else {
|
||||
scenarioStartScanButton.disabled = false;
|
||||
WinJS.log("Barcode scanner not found. Please connect a barcode scanner.", "sample", "error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -134,7 +133,7 @@
|
|||
WinJS.log("Event ReleaseDeviceRequested received. Retaining the barcode scanner.", "sample", "status");
|
||||
}
|
||||
|
||||
// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
|
||||
function onDataReceived(args) {
|
||||
scenarioOutputScanDataType.textContent = BarcodeSymbologies.getName(args.report.scanDataType);
|
||||
scenarioOutputScanData.textContent = getDataString(args.report.scanData);
|
||||
|
|
|
@ -0,0 +1,264 @@
|
|||
//*********************************************************
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// This code is licensed under the MIT License (MIT).
|
||||
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
|
||||
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
|
||||
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
|
||||
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
|
||||
//
|
||||
//*********************************************************
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
// Types
|
||||
var BarcodeScanner = Windows.Devices.PointOfService.BarcodeScanner;
|
||||
var BarcodeSymbologies = Windows.Devices.PointOfService.BarcodeSymbologies;
|
||||
var BarcodeSymbologyDecodeLengthKind = Windows.Devices.PointOfService.BarcodeSymbologyDecodeLengthKind;
|
||||
var DeviceEnumeration = Windows.Devices.Enumeration;
|
||||
var Capture = Windows.Media.Capture;
|
||||
|
||||
// Page elements
|
||||
var startSoftwareTriggerButton;
|
||||
var stopSoftwareTriggerButton;
|
||||
var scenarioOutputScanDataType;
|
||||
var scenarioOutputScanData;
|
||||
var scenarioOutputScanDataFormatted;
|
||||
var scannerResultsBlock;
|
||||
var previewControl;
|
||||
|
||||
// Will be defined when the page is initialized, otherwise we won't be able to find element
|
||||
var scannerListViewControl = null;
|
||||
|
||||
var watcher = null;
|
||||
var observableScanners = new WinJS.Binding.List([]);
|
||||
var selectedScanner = null;
|
||||
var claimedScanner = null;
|
||||
|
||||
var mediaCapture = null;
|
||||
var displayRequest = new Windows.System.Display.DisplayRequest();
|
||||
|
||||
var isSelectionChanging = false;
|
||||
var pendingSelectionDeviceId;
|
||||
var isStopPending = false;
|
||||
|
||||
var page = WinJS.UI.Pages.define("/html/scenario5_DisplayingBarcodePreview.html", {
|
||||
|
||||
ready: function (element, options) {
|
||||
scenarioOutputScanDataType = document.getElementById("scenarioOutputScanDataType");
|
||||
scenarioOutputScanData = document.getElementById("scenarioOutputScanData");
|
||||
scenarioOutputScanDataFormatted = document.getElementById("scenarioOutputScanDataFormatted");
|
||||
scannerResultsBlock = document.getElementById("scannerResultsBlock");
|
||||
previewControl = document.getElementById("cameraPreview");
|
||||
|
||||
var showPreviewButton = document.getElementById("showPreviewButton");
|
||||
showPreviewButton.addEventListener("click", showPreviewButton_Clicked, false);
|
||||
|
||||
var hidePreviewButton = document.getElementById("hidePreviewButton");
|
||||
hidePreviewButton.addEventListener("click", hidePreviewButton_Clicked, false);
|
||||
|
||||
startSoftwareTriggerButton = document.getElementById("startSoftwareTriggerButton");
|
||||
startSoftwareTriggerButton.addEventListener("click", startSoftwareTriggerButton_Clicked, false);
|
||||
|
||||
stopSoftwareTriggerButton = document.getElementById("stopSoftwareTriggerButton");
|
||||
stopSoftwareTriggerButton.addEventListener("click", stopSoftwareTriggerButton_Clicked, false);
|
||||
|
||||
var scannerListView = document.getElementById("scannerListView");
|
||||
scannerListView.addEventListener("selectionchanged", scannerSelectionChanged, false);
|
||||
scannerListViewControl = scannerListView.winControl;
|
||||
scannerListViewControl.itemDataSource = observableScanners.dataSource;
|
||||
|
||||
watcher = DeviceEnumeration.DeviceInformation.createWatcher(BarcodeScanner.getDeviceSelector(), null);
|
||||
watcher.addEventListener("added", watcher_Added);
|
||||
watcher.addEventListener("updated", watcher_Updated);
|
||||
watcher.addEventListener("removed", watcher_Removed);
|
||||
watcher.start();
|
||||
},
|
||||
|
||||
unload: function () {
|
||||
watcher.stop();
|
||||
observableScanners.length = 0;
|
||||
|
||||
if (isSelectionChanging) {
|
||||
// If selection is changing, then let it know to stop media capture
|
||||
// when it's done.
|
||||
isStopPending = true;
|
||||
}
|
||||
else {
|
||||
// If selection is not changing, then it's safe to stop immediately.
|
||||
closeScannerResourcesAsync();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function watcher_Added(deviceInfo) {
|
||||
observableScanners.push({
|
||||
name: `${deviceInfo.name} (${deviceInfo.id})`,
|
||||
id: deviceInfo.id
|
||||
});
|
||||
}
|
||||
|
||||
function watcher_Updated(deviceInfoUpdate) {
|
||||
// We don't do anything here, but this event needs to be handled to enable realtime updates.
|
||||
// See https://aka.ms/devicewatcher_added.
|
||||
}
|
||||
|
||||
function watcher_Removed(deviceInfoUpdate) {
|
||||
// We don't do anything here, but this event needs to be handled to enable realtime updates.
|
||||
// See https://aka.ms/devicewatcher_added.
|
||||
}
|
||||
|
||||
async function startMediaCaptureAsync(videoDeviceId) {
|
||||
mediaCapture = new Capture.MediaCapture();
|
||||
mediaCapture.addEventListener("failed", mediaCapture_Failed);
|
||||
|
||||
var settings = new Capture.MediaCaptureInitializationSettings();
|
||||
settings.videoDeviceId = videoDeviceId;
|
||||
settings.streamingCaptureMode = Capture.StreamingCaptureMode.video;
|
||||
|
||||
var captureInitialized = false;
|
||||
try {
|
||||
await mediaCapture.initializeAsync(settings);
|
||||
captureInitialized = true;
|
||||
} catch (e) {
|
||||
WinJS.log("Failed to initialize the camera preview with: " + e.message, "sample", "error");
|
||||
}
|
||||
|
||||
if (captureInitialized) {
|
||||
// Prevent the device from sleeping while the preview is running.
|
||||
displayRequest.requestActive();
|
||||
|
||||
previewControl.src = URL.createObjectURL(mediaCapture);
|
||||
previewControl.play();
|
||||
scannerResultsBlock.dataset.isPreviewing = true;
|
||||
} else {
|
||||
previewControl.src = null;
|
||||
mediaCapture.close();
|
||||
mediaCapture = null;
|
||||
}
|
||||
}
|
||||
|
||||
function closeScannerResourcesAsync() {
|
||||
if (claimedScanner) {
|
||||
claimedScanner.close();
|
||||
claimedScanner = null;
|
||||
}
|
||||
|
||||
if (selectedScanner) {
|
||||
selectedScanner.close();
|
||||
selectedScanner = null;
|
||||
}
|
||||
|
||||
startSoftwareTriggerButton.disabled = false;
|
||||
stopSoftwareTriggerButton.disabled = true;
|
||||
|
||||
if (previewControl.src) {
|
||||
previewControl.pause();
|
||||
previewControl.src = null;
|
||||
|
||||
// Allow the display to go to sleep.
|
||||
displayRequest.requestRelease();
|
||||
}
|
||||
|
||||
if (mediaCapture) {
|
||||
mediaCapture.removeEventListener("failed", mediaCapture_Failed);
|
||||
mediaCapture.close();
|
||||
mediaCapture = null;
|
||||
}
|
||||
|
||||
scannerResultsBlock.dataset.isPreviewing = false;
|
||||
}
|
||||
|
||||
function mediaCapture_Failed(e) {
|
||||
WinJS.log("Media capture failed. Make sure the camera is still connected.", "sample", "error");
|
||||
}
|
||||
|
||||
function showPreviewButton_Clicked() {
|
||||
claimedScanner && claimedScanner.showVideoPreviewAsync();
|
||||
}
|
||||
|
||||
function hidePreviewButton_Clicked() {
|
||||
claimedScanner && claimedScanner.hideVideoPreview();
|
||||
}
|
||||
|
||||
async function startSoftwareTriggerButton_Clicked() {
|
||||
if (claimedScanner) {
|
||||
await claimedScanner.startSoftwareTriggerAsync();
|
||||
startSoftwareTriggerButton.disabled = true;
|
||||
stopSoftwareTriggerButton.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function stopSoftwareTriggerButton_Clicked() {
|
||||
if (claimedScanner) {
|
||||
await claimedScanner.stopSoftwareTriggerAsync();
|
||||
startSoftwareTriggerButton.disabled = false;
|
||||
stopSoftwareTriggerButton.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function scannerSelectionChanged() {
|
||||
|
||||
var items = await scannerListViewControl.selection.getItems();
|
||||
if (!items.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var deviceId = items[0].data.id;
|
||||
|
||||
if (isSelectionChanging) {
|
||||
pendingSelectionDeviceId = deviceId;
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
await selectScannerAsync(deviceId);
|
||||
|
||||
// Stop takes precedence over updating the selection.
|
||||
if (isStopPending) {
|
||||
await closeScannerResourcesAsync();
|
||||
break;
|
||||
}
|
||||
deviceId = pendingSelectionDeviceId;
|
||||
pendingSelectionDeviceId = null;
|
||||
} while (deviceId);
|
||||
}
|
||||
|
||||
async function selectScannerAsync(scannerDeviceId) {
|
||||
isSelectionChanging = true;
|
||||
|
||||
await closeScannerResourcesAsync();
|
||||
|
||||
selectedScanner = await BarcodeScanner.fromIdAsync(scannerDeviceId);
|
||||
|
||||
if (selectedScanner) {
|
||||
claimedScanner = await selectedScanner.claimScannerAsync();
|
||||
if (claimedScanner) {
|
||||
scannerResultsBlock.dataset.isScannerClaimed = true;
|
||||
await claimedScanner.enableAsync();
|
||||
startSoftwareTriggerButton.disabled = false;
|
||||
claimedScanner.addEventListener("datareceived", dataReceived);
|
||||
|
||||
scannerResultsBlock.dataset.scannerSupportsPreview = (selectedScanner.videoDeviceId != "");
|
||||
if (selectedScanner.videoDeviceId) {
|
||||
await startMediaCaptureAsync(selectedScanner.videoDeviceId);
|
||||
}
|
||||
} else {
|
||||
WinJS.log("Failed to claim the selected barcode scanner.", "sample", "error");
|
||||
}
|
||||
} else {
|
||||
WinJS.log("Failed to create a barcode scanner object", "sample", "error");
|
||||
}
|
||||
|
||||
isSelectionChanging = false;
|
||||
}
|
||||
|
||||
function dataReceived(args) {
|
||||
var tempScanType = BarcodeSymbologies.getName(args.report.scanDataType);
|
||||
|
||||
scenarioOutputScanDataType.textContent = tempScanType;
|
||||
scenarioOutputScanData.textContent = getDataString(args.report.scanData);
|
||||
scenarioOutputScanDataFormatted.textContent = getDataLabelString(args.report.scanDataLabel, args.report.scanDataType);
|
||||
}
|
||||
})();
|
|
@ -0,0 +1,92 @@
|
|||
<!--
|
||||
//*********************************************************
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// This code is licensed under the MIT License (MIT).
|
||||
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
|
||||
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
|
||||
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
|
||||
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
|
||||
//
|
||||
//*********************************************************
|
||||
-->
|
||||
<Page
|
||||
x:Class="SDKTemplate.Scenario5_DisplayingBarcodePreview"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:SDKTemplate"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Page.Resources>
|
||||
<CollectionViewSource x:Name="ScannerListSource"/>
|
||||
</Page.Resources>
|
||||
|
||||
<ScrollViewer Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Padding="12,20,12,12"
|
||||
VerticalScrollBarVisibility="Auto" VerticalScrollMode="Auto">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Description:" Style="{StaticResource SampleHeaderTextStyle}"/>
|
||||
<TextBlock Style="{StaticResource ScenarioDescriptionTextStyle}" TextWrapping="Wrap">
|
||||
Demonstrates how to interact with barcode scanners that support video previewing.
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock Text="Select a scanner" Margin="5,25,5,5" TextAlignment="Left" Style="{StaticResource BasicTextStyle}"/>
|
||||
|
||||
<ListBox Name="ScannerListBox" ItemsSource="{Binding Source={StaticResource ScannerListSource}}" Margin="5,0,10,0"
|
||||
BorderThickness="1" SelectionChanged="ScannerSelection_Changed" Height="200">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="local:BarcodeScannerInfo">
|
||||
<TextBlock Text="{x:Bind Name}" VerticalAlignment="Center"/>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<StackPanel Visibility="{x:Bind IsScannerClaimed, Mode=OneWay}">
|
||||
<TextBlock x:Name="PreviewNotSupportedMessage" Margin="0,10,0,0"
|
||||
Style="{StaticResource BasicTextStyle}"
|
||||
Foreground="Red"
|
||||
Text="*The selected barcode scanner does not have a camera, so a preview cannot be displayed."
|
||||
Visibility="{x:Bind local:BindingHelpers.CollapsedIf(ScannerSupportsPreview), Mode=OneWay}"/>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Visibility="{x:Bind ScannerSupportsPreview, Mode=OneWay}" Margin="0,10,0,0">
|
||||
<Button Content="Show Preview" Click="ShowPreviewButton_Click" Margin="0,0,5,0"/>
|
||||
<Button Content="Hide Preview" Click="HidePreviewButton_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Button Content="Start Software Trigger" Click="StartSoftwareTriggerButton_Click" Margin="0,0,5,0"
|
||||
IsEnabled="{x:Bind local:BindingHelpers.Not(SoftwareTriggerStarted), Mode=OneWay}" />
|
||||
<Button Content="Stop Software Trigger" Click="StopSoftwareTriggerButton_Click"
|
||||
IsEnabled="{x:Bind SoftwareTriggerStarted, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<StackPanel Visibility="{x:Bind IsPreviewing, Mode=OneWay}" Margin="0,0,20,0">
|
||||
<Border BorderThickness="1" BorderBrush="White" HorizontalAlignment="Left" VerticalAlignment="Center">
|
||||
<CaptureElement x:Name="PreviewControl" Stretch="Uniform" ManipulationMode="Scale" Width="265" Height="200"/>
|
||||
</Border>
|
||||
<Button Content="Flip Preview" Click="FlipPreview_Click" Margin="0,10,0,0"/>
|
||||
</StackPanel>
|
||||
<Grid VerticalAlignment="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="200"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="Scan Data Type (Symbology):" TextWrapping="Wrap" Grid.Row="0" Grid.Column="0" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" Margin="0,0,5,0"/>
|
||||
<TextBlock x:Name="ScenarioOutputScanDataType" TextWrapping="Wrap" Grid.Row="0" Grid.Column="1" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" Text="No data" />
|
||||
<TextBlock Text="Scan Data (Unformatted data):" TextWrapping="Wrap" Grid.Row="1" Grid.Column="0" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" Margin="0,0,5,0"/>
|
||||
<TextBlock x:Name="ScenarioOutputScanDataLabel" TextWrapping="Wrap" Grid.Row="2" Grid.Column="1" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" Text="No data" />
|
||||
<TextBlock Text="Scan Data Label (Formatted data):" TextWrapping="Wrap" Grid.Row="2" Grid.Column="0" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" Margin="0,0,5,0"/>
|
||||
<TextBlock x:Name="ScenarioOutputScanData" TextWrapping="Wrap" Grid.Row="1" Grid.Column="1" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" Text="No data" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Page>
|
|
@ -73,6 +73,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
DisplayName="Barometer JS sample"
|
||||
Description="Barometer JS sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
|
|
|
@ -80,6 +80,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<Properties>
|
||||
<DisplayName>Bluetooth Advertisement JS Sample</DisplayName>
|
||||
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo-sdk.png</Logo>
|
||||
<Logo>images\StoreLogo-sdk.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
|
@ -45,7 +45,7 @@
|
|||
</Extensions>
|
||||
<uap:VisualElements
|
||||
DisplayName="Bluetooth Advertisement JS Sample"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png"
|
||||
Description="Bluetooth Advertisement JS Sample"
|
||||
BackgroundColor="#00b2f0">
|
||||
|
|
|
@ -74,6 +74,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
DisplayName="Calendar JS Sample"
|
||||
Description="Calendar JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
|
|
|
@ -59,6 +59,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
<uap:VisualElements
|
||||
DisplayName="CameraAdvancedCapture"
|
||||
Square150x150Logo="images\StoreLogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\SmallTile-sdk.png"
|
||||
Description="Camera Advanced Capture JS Sample"
|
||||
BackgroundColor="#00b2f0">
|
||||
|
|
|
@ -59,6 +59,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
<uap:VisualElements
|
||||
DisplayName="CameraFaceDetection"
|
||||
Square150x150Logo="images\StoreLogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\SmallTile-sdk.png"
|
||||
Description="CameraFaceDetection"
|
||||
BackgroundColor="#00b2f0">
|
||||
|
|
|
@ -59,6 +59,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
<uap:VisualElements
|
||||
DisplayName="CameraGetPreviewFrame"
|
||||
Square150x150Logo="images\StoreLogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\SmallTile-sdk.png"
|
||||
Description="CameraGetPreviewFrame"
|
||||
BackgroundColor="#00b2f0">
|
||||
|
|
|
@ -75,6 +75,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
DisplayName="CameraProfile"
|
||||
Description="CameraProfile"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
|
|
|
@ -75,6 +75,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</Resources>
|
||||
<Applications>
|
||||
<Application Id="CameraProfile.App" StartPage="default.html">
|
||||
<uap:VisualElements DisplayName="Camera Resolution JS Sample" Description="Camera Resolution JS Sample" BackgroundColor="#00b2f0" Square150x150Logo="images\storelogo-sdk.png" Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:VisualElements DisplayName="Camera Resolution JS Sample" Description="Camera Resolution JS Sample" BackgroundColor="#00b2f0" Square150x150Logo="images\squaretile-sdk.png" Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
<uap:ShowNameOnTiles>
|
||||
|
|
|
@ -59,6 +59,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
<uap:VisualElements
|
||||
DisplayName="CameraStarterKit"
|
||||
Square150x150Logo="images\StoreLogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\SmallTile-sdk.png"
|
||||
Description="CameraStarterKit"
|
||||
BackgroundColor="#00b2f0">
|
||||
|
|
|
@ -59,6 +59,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
<uap:VisualElements
|
||||
DisplayName="CameraVideoStabilization"
|
||||
Square150x150Logo="images\StoreLogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\SmallTile-sdk.png"
|
||||
Description="CameraVideoStabilization"
|
||||
BackgroundColor="#00b2f0">
|
||||
|
|
|
@ -75,6 +75,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
DisplayName="CashDrawer"
|
||||
Description="Microsoft SDK Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
|
|
|
@ -70,6 +70,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
Description="Client Device Information JS Sample"
|
||||
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
|
|
|
@ -73,6 +73,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -80,6 +80,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
DisplayName="Compass JS sample"
|
||||
Description="Compass JS sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
|
|
|
@ -73,6 +73,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
DisplayName="Compression JS Sample"
|
||||
Description="Compression JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
|
|
|
@ -72,6 +72,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
DisplayName="Contact Cards JS Sample"
|
||||
Description="Contact Cards JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
|
|
|
@ -71,6 +71,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
DisplayName="Contact Picker JS Sample"
|
||||
Description="Contact Picker JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
|
|
|
@ -85,6 +85,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -72,6 +72,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -72,6 +72,9 @@
|
|||
<Content Include="..\..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
DisplayName="AdventureWorks JS Sample"
|
||||
Description="AdventureWorks JS Sample"
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
|
|
|
@ -72,6 +72,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
Description="Microsoft SDK Sample - Credential Picker"
|
||||
|
||||
BackgroundColor="#00b2f0"
|
||||
Square150x150Logo="images\storelogo-sdk.png"
|
||||
Square150x150Logo="images\squaretile-sdk.png"
|
||||
Square44x44Logo="images\smalltile-sdk.png">
|
||||
|
||||
<uap:SplashScreen Image="images\splash-sdk.png" />
|
||||
|
|
|
@ -102,6 +102,9 @@
|
|||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>images\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>images\squaretile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>images\tile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче