Windows 10 Version 1709 - March 2018 Update
This commit is contained in:
Родитель
f08e1a928e
Коммит
f6ad9bc1b5
|
@ -328,24 +328,25 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github.
|
|||
<tr>
|
||||
<td><a href="Samples/LampDevice">Lamp device</a></td>
|
||||
<td><a href="Samples/LightSensor">Light sensor</a></td>
|
||||
<td><a href="Samples/MagneticStripeReader">Magnetic stripe reader</a></td>
|
||||
<td><a href="Samples/Magnetometer">Magnetometer</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="Samples/MagneticStripeReader">Magnetic stripe reader</a></td>
|
||||
<td><a href="Samples/Nfc">Near field communication (NFC)</a></td>
|
||||
<td><a href="Samples/NfcProvisioner">NFC enterprise provisioner</a></td>
|
||||
<td><a href="Samples/OrientationSensor">Orientation sensor</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="Samples/OrientationSensor">Orientation sensor</a></td>
|
||||
<td><a href="Samples/Pedometer">Pedometer</a></td>
|
||||
<td><a href="Samples/PosPrinter">POS printer</a></td>
|
||||
<td><a href="Samples/ProximitySensor">Proximity sensor</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="Samples/ProximitySensor">Proximity sensor</a></td>
|
||||
<td><a href="Samples/RadialController">Radial controller</a></td>
|
||||
<td><a href="Samples/RelativeInclinometer">Relative inclinometer</a></td>
|
||||
<td><a href="Samples/SerialArduino">Serial Arduino</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="Samples/SerialArduino">Serial Arduino</a></td>
|
||||
<td><a href="Samples/IoT-SPI">Serial Peripheral Interface (SPI)</a></td>
|
||||
<td><a href="Samples/SimpleOrientationSensor">Simple orientation sensor</a></td>
|
||||
</tr>
|
||||
|
|
|
@ -47,8 +47,6 @@ This sample shows how to:
|
|||
|
||||
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.
|
||||
|
||||
For a list of compatible barcode scanners, see [Supported Point of Service Peripherals](https://docs.microsoft.com/windows/uwp/devices-sensors/pos-device-support).
|
||||
|
||||
**Note** The Universal Windows app samples require Visual Studio 2017 to build and Windows 10 to execute.
|
||||
|
||||
To obtain information about Windows 10 development, go to the [Windows Dev Center](http://go.microsoft.com/fwlink/?LinkID=532421)
|
||||
|
@ -60,7 +58,7 @@ To obtain information about Microsoft Visual Studio and the tools for developing
|
|||
### Reference
|
||||
|
||||
[Windows.Devices.PointOfService namespace](http://msdn.microsoft.com/library/windows/apps/dn298071)
|
||||
[Barcode Scanner Compatible Hardware](https://docs.microsoft.com/windows/uwp/devices-sensors/barcode-scanner#compatible-hardware)
|
||||
[Supported Point of Service Peripherals](https://docs.microsoft.com/windows/uwp/devices-sensors/pos-device-support)
|
||||
[USB HID POS Scanner specification](http://go.microsoft.com/fwlink/p/?linkid=309230)
|
||||
[Windows app samples](http://go.microsoft.com/fwlink/p/?LinkID=227694)
|
||||
|
||||
|
|
|
@ -100,13 +100,11 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<IgnoreImportLibrary>false</IgnoreImportLibrary>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<IgnoreImportLibrary>false</IgnoreImportLibrary>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.12
|
||||
VisualStudioVersion = 15.0.27130.2026
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CustomCapability", "CustomCapability.vcxproj", "{F655DED8-41FA-5704-A228-20E83EAB795C}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
|
@ -16,7 +16,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RpcServer", "..\Service\Ser
|
|||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RpcClient", "..\Service\Client\RpcClient.vcxproj", "{86B5561E-46B3-5DDE-9121-423803DA2807}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C} = {E70C6CFC-C72D-54DE-9729-B3594113D55C}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -49,14 +49,12 @@ Global
|
|||
{F655DED8-41FA-5704-A228-20E83EAB795C}.Release|x86.Build.0 = Release|Win32
|
||||
{F655DED8-41FA-5704-A228-20E83EAB795C}.Release|x86.Deploy.0 = Release|Win32
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x64.Build.0 = Debug|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|ARM.Build.0 = Release|ARM
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|x64.ActiveCfg = Release|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|x64.Build.0 = Release|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|x86.ActiveCfg = Release|Win32
|
||||
|
@ -72,13 +70,11 @@ Global
|
|||
{D61475C4-185E-50F6-8FAD-A0163961B3B3}.Release|x86.ActiveCfg = Release|Win32
|
||||
{D61475C4-185E-50F6-8FAD-A0163961B3B3}.Release|x86.Build.0 = Release|Win32
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|x64.Build.0 = Debug|x64
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|x86.Build.0 = Debug|Win32
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|ARM.Build.0 = Release|ARM
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|x64.ActiveCfg = Release|x64
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|x64.Build.0 = Release|x64
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|x86.ActiveCfg = Release|Win32
|
||||
|
|
|
@ -101,24 +101,28 @@
|
|||
<IncludePath>$(IncludePath);..\..\..\SharedContent\cpp</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)</OutDir>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)</OutDir>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)</OutDir>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)</OutDir>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)</OutDir>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)</OutDir>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -128,7 +132,7 @@
|
|||
<ShowIncludes>false</ShowIncludes>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib;$(OutDir)rpcclient.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib;$(IntDir)rpcclient.lib</AdditionalDependencies>
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -140,7 +144,7 @@
|
|||
<ShowIncludes>false</ShowIncludes>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib;$(OutDir)rpcclient.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib</AdditionalDependencies>
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -152,7 +156,7 @@
|
|||
<ShowIncludes>false</ShowIncludes>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib;$(OutDir)rpcclient.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib;$(IntDir)rpcclient.lib</AdditionalDependencies>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -164,7 +168,7 @@
|
|||
<ShowIncludes>false</ShowIncludes>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib;$(OutDir)rpcclient.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib</AdditionalDependencies>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -176,7 +180,7 @@
|
|||
<ShowIncludes>false</ShowIncludes>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib;$(OutDir)rpcclient.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib;$(IntDir)rpcclient.lib</AdditionalDependencies>
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -188,7 +192,7 @@
|
|||
<ShowIncludes>false</ShowIncludes>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib;$(OutDir)rpcclient.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib;$(IntDir)rpcclient.lib</AdditionalDependencies>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -307,7 +311,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Service\Client\RpcClient.vcxproj">
|
||||
<ProjectReference Condition="'$(Platform)' == 'x86' Or '$(Platform)' == 'x64'" Include="..\Service\Client\RpcClient.vcxproj">
|
||||
<Project>{86B5561E-46B3-5DDE-9121-423803DA2807}</Project>
|
||||
<Name>RpcClient</Name>
|
||||
</ProjectReference>
|
||||
|
|
|
@ -11,6 +11,10 @@ using namespace Windows::UI::Xaml;
|
|||
using namespace Windows::UI::Xaml::Data;
|
||||
using namespace Windows::ApplicationModel;
|
||||
|
||||
#if defined (_M_IX86) || defined(_M_AMD64)
|
||||
#define SERVICE_SUPPORTED 1
|
||||
#endif
|
||||
|
||||
ServiceViewModel::ServiceViewModel()
|
||||
{
|
||||
// Set default rate
|
||||
|
@ -184,6 +188,7 @@ void ServiceViewModel::StartMetering(int sampleRate)
|
|||
StopButtonEnabled = true;
|
||||
stopMeteringRequested = false;
|
||||
|
||||
#ifdef SERVICE_SUPPORTED
|
||||
if (NotifyIfAnyError(RpcClientInitialize(&rpcclient))) return;
|
||||
|
||||
meteringOn = true;
|
||||
|
@ -272,6 +277,9 @@ void ServiceViewModel::StartMetering(int sampleRate)
|
|||
}
|
||||
RpcClientClose(this->rpcclient);
|
||||
}
|
||||
#else
|
||||
NotifyStatusMessage("NT service support has not been compiled for this architecture.", NotifyType::ErrorMessage);
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -286,12 +294,14 @@ void ServiceViewModel::StopMetering()
|
|||
SliderEnabled = false;
|
||||
stopMeteringRequested = true;
|
||||
|
||||
#ifdef SERVICE_SUPPORTED
|
||||
__int64 retCode = StopMeteringData(this->rpcclient);
|
||||
if (!NotifyIfAnyError(retCode))
|
||||
{
|
||||
NotifyStatusMessage("Metering stop command sent successfully",
|
||||
NotifyType::StatusMessage);
|
||||
}
|
||||
#endif
|
||||
|
||||
SliderEnabled = true;
|
||||
StartButtonEnabled = true;
|
||||
|
@ -306,6 +316,7 @@ void ServiceViewModel::SetSamplePeriod(int samplePeriod)
|
|||
create_task([this, samplePeriod]
|
||||
{
|
||||
this->samplePeriod = samplePeriod;
|
||||
#ifdef SERVICE_SUPPORTED
|
||||
if (meteringOn)
|
||||
{
|
||||
_int64 retCode = SetSampleRate(rpcclient, samplePeriod);
|
||||
|
@ -316,5 +327,6 @@ void ServiceViewModel::SetSamplePeriod(int samplePeriod)
|
|||
NotifyType::StatusMessage);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
});
|
||||
}
|
|
@ -195,7 +195,7 @@
|
|||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Service\Client\RpcClient.vcxproj">
|
||||
<ProjectReference Condition="'$(Platform)' == 'x86' Or '$(Platform)' == 'x64'" Include="..\Service\Client\RpcClient.vcxproj">
|
||||
<Project>{2c78f411-866b-472d-9c28-75d59f179525}</Project>
|
||||
<Name>RpcClient</Name>
|
||||
</ProjectReference>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.12
|
||||
VisualStudioVersion = 15.0.27130.2026
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RpcInterface", "..\Service\Interface\RpcInterface.vcxproj", "{E70C6CFC-C72D-54DE-9729-B3594113D55C}"
|
||||
EndProject
|
||||
|
@ -11,7 +11,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RpcServer", "..\Service\Ser
|
|||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RpcClient", "..\Service\Client\RpcClient.vcxproj", "{86B5561E-46B3-5DDE-9121-423803DA2807}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C} = {E70C6CFC-C72D-54DE-9729-B3594113D55C}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -28,14 +28,12 @@ Global
|
|||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x64.Build.0 = Debug|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|ARM.Build.0 = Release|ARM
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|x64.ActiveCfg = Release|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|x64.Build.0 = Release|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|x86.ActiveCfg = Release|Win32
|
||||
|
@ -51,13 +49,11 @@ Global
|
|||
{D61475C4-185E-50F6-8FAD-A0163961B3B3}.Release|x86.ActiveCfg = Release|Win32
|
||||
{D61475C4-185E-50F6-8FAD-A0163961B3B3}.Release|x86.Build.0 = Release|Win32
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|x64.Build.0 = Debug|x64
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|x86.Build.0 = Debug|Win32
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|ARM.Build.0 = Release|ARM
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|x64.ActiveCfg = Release|x64
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|x64.Build.0 = Release|x64
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|x86.ActiveCfg = Release|Win32
|
||||
|
|
|
@ -55,6 +55,9 @@ namespace SDKTemplate
|
|||
[DllImport("api-ms-win-core-sysinfo-l1-2-1.dll")]
|
||||
static extern void GetSystemTimeAsFileTime(ref FILETIME lpSystemTimeAsFileTime);
|
||||
|
||||
[DllImport("api-ms-win-core-libraryloader-l2-1.dll")]
|
||||
static extern IntPtr LoadPackagedLibrary(string filename, uint reserved);
|
||||
|
||||
public static ServiceViewModel Current { get; private set; }
|
||||
|
||||
static ServiceViewModel()
|
||||
|
@ -84,6 +87,7 @@ namespace SDKTemplate
|
|||
deferral.Complete();
|
||||
}
|
||||
|
||||
Lazy<bool> isSupported = new Lazy<bool>(() => LoadPackagedLibrary("RpcClient.dll", 0) != IntPtr.Zero);
|
||||
volatile bool meteringOn;
|
||||
volatile bool meteringOnWhileSuspension;
|
||||
Windows.UI.Core.CoreDispatcher dispatcher;
|
||||
|
@ -205,6 +209,12 @@ namespace SDKTemplate
|
|||
StopButtonEnabled = true;
|
||||
stopMeteringRequested = false;
|
||||
|
||||
if (!isSupported.Value)
|
||||
{
|
||||
NotifyStatusMessage("NT service support has not been compiled for this architecture.", NotifyType.ErrorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (NotifyIfAnyError(RpcClientInitialize(out rpcClient))) return;
|
||||
|
||||
meteringOn = true;
|
||||
|
@ -328,11 +338,14 @@ namespace SDKTemplate
|
|||
SliderEnabled = false;
|
||||
stopMeteringRequested = true;
|
||||
|
||||
long retCode = StopMeteringData(rpcClient);
|
||||
if (!NotifyIfAnyError(retCode))
|
||||
if (isSupported.Value)
|
||||
{
|
||||
NotifyStatusMessage("Metering stop command sent successfully",
|
||||
NotifyType.StatusMessage);
|
||||
long retCode = StopMeteringData(rpcClient);
|
||||
if (!NotifyIfAnyError(retCode))
|
||||
{
|
||||
NotifyStatusMessage("Metering stop command sent successfully",
|
||||
NotifyType.StatusMessage);
|
||||
}
|
||||
}
|
||||
|
||||
SliderEnabled = true;
|
||||
|
|
|
@ -170,7 +170,7 @@
|
|||
<Content Include="js\scenario5_deviceReadWrite.js" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="RpcClientRt\RpcClientRt.vcxproj" />
|
||||
<ProjectReference Condition="'$(Platform)' == 'x86' Or '$(Platform)' == 'x64'" Include="RpcClientRt\RpcClientRt.vcxproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below then uncomment
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.12
|
||||
VisualStudioVersion = 15.0.27130.2026
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RpcInterface", "..\Service\Interface\RpcInterface.vcxproj", "{E70C6CFC-C72D-54DE-9729-B3594113D55C}"
|
||||
EndProject
|
||||
|
@ -30,14 +30,12 @@ Global
|
|||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x64.Build.0 = Debug|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|ARM.Build.0 = Release|ARM
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|x64.ActiveCfg = Release|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|x64.Build.0 = Release|x64
|
||||
{E70C6CFC-C72D-54DE-9729-B3594113D55C}.Release|x86.ActiveCfg = Release|Win32
|
||||
|
@ -53,13 +51,11 @@ Global
|
|||
{D61475C4-185E-50F6-8FAD-A0163961B3B3}.Release|x86.ActiveCfg = Release|Win32
|
||||
{D61475C4-185E-50F6-8FAD-A0163961B3B3}.Release|x86.Build.0 = Release|Win32
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|x64.Build.0 = Debug|x64
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Debug|x86.Build.0 = Debug|Win32
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|ARM.Build.0 = Release|ARM
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|x64.ActiveCfg = Release|x64
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|x64.Build.0 = Release|x64
|
||||
{86B5561E-46B3-5DDE-9121-423803DA2807}.Release|x86.ActiveCfg = Release|Win32
|
||||
|
@ -83,13 +79,11 @@ Global
|
|||
{F05E646B-C598-596A-896E-96F31C14B27E}.Release|x86.Build.0 = Release|x86
|
||||
{F05E646B-C598-596A-896E-96F31C14B27E}.Release|x86.Deploy.0 = Release|x86
|
||||
{9D2FC693-5081-54F7-BC52-73052E49743A}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{9D2FC693-5081-54F7-BC52-73052E49743A}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{9D2FC693-5081-54F7-BC52-73052E49743A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9D2FC693-5081-54F7-BC52-73052E49743A}.Debug|x64.Build.0 = Debug|x64
|
||||
{9D2FC693-5081-54F7-BC52-73052E49743A}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{9D2FC693-5081-54F7-BC52-73052E49743A}.Debug|x86.Build.0 = Debug|Win32
|
||||
{9D2FC693-5081-54F7-BC52-73052E49743A}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{9D2FC693-5081-54F7-BC52-73052E49743A}.Release|ARM.Build.0 = Release|ARM
|
||||
{9D2FC693-5081-54F7-BC52-73052E49743A}.Release|x64.ActiveCfg = Release|x64
|
||||
{9D2FC693-5081-54F7-BC52-73052E49743A}.Release|x64.Build.0 = Release|x64
|
||||
{9D2FC693-5081-54F7-BC52-73052E49743A}.Release|x86.ActiveCfg = Release|Win32
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
// Instance of WinRT component that implements
|
||||
// RPC metering service client
|
||||
var rpcClient = new RpcClientRt.RpcClient;
|
||||
var rpcClient = window.RpcClientRt && new RpcClientRt.RpcClient;
|
||||
var meteringOn = false;
|
||||
var meteringPageInForeground = false;
|
||||
var samplePeriod = 100;
|
||||
|
@ -93,7 +93,7 @@
|
|||
meteringIntervalId = 0;
|
||||
}
|
||||
var currentCallbackCount = rpcClient.getCallbackCount();
|
||||
if (currentCallbackCount != meteringCallbackCount) {
|
||||
if (currentCallbackCount !== meteringCallbackCount) {
|
||||
|
||||
var now = (new Date()).getTime();
|
||||
var diff = now - lastMeteringCallbackTime;
|
||||
|
@ -113,10 +113,10 @@
|
|||
// Called when the user drags the scale factor slider control.
|
||||
function onSampleSliderChange(args) {
|
||||
samplePeriod = Math.floor(document.getElementById("SamplePeriodSlider").value);
|
||||
document.getElementById("SamplePeriod").innerHTML = "Sample Period (ms): " + samplePeriod
|
||||
document.getElementById("SamplePeriod").innerHTML = "Sample Period (ms): " + samplePeriod;
|
||||
if (meteringOn) {
|
||||
var ret = rpcClient.setSampleRate(samplePeriod);
|
||||
if (ret != 0) {
|
||||
if (ret) {
|
||||
WinJS.log && WinJS.log("Error occured while communicating with RPC server: " + ret, "sample", "error");
|
||||
}
|
||||
else {
|
||||
|
@ -133,10 +133,14 @@
|
|||
meteringOn = true;
|
||||
updateStartStopButtons();
|
||||
samplePeriod = Math.floor(document.getElementById("SamplePeriodSlider").value);
|
||||
rpcClient.startMeteringAsync(samplePeriod);
|
||||
CheckMeteringStatusAsync();
|
||||
if (rpcClient) {
|
||||
rpcClient.startMeteringAsync(samplePeriod);
|
||||
CheckMeteringStatusAsync();
|
||||
|
||||
WinJS.log && WinJS.log("Metering start command sent successfully", "sample", "status");
|
||||
WinJS.log && WinJS.log("Metering start command sent successfully", "sample", "status");
|
||||
} else {
|
||||
WinJS.log && WinJS.log("NT service support has not been compiled for this architecture.", "sample", "error");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -146,12 +150,13 @@
|
|||
function onStopButtonClick(args) {
|
||||
clearInterval(meteringIntervalId);
|
||||
meteringIntervalId = 0;
|
||||
var ret = rpcClient.stopMeteringData();
|
||||
if (ret != 0) {
|
||||
WinJS.log && WinJS.log("Error occured while communicating with RPC server: " + ret, "sample", "error");
|
||||
}
|
||||
else {
|
||||
WinJS.log && WinJS.log("Metering stop command sent successfully", "sample", "status");
|
||||
if (rpcClient) {
|
||||
var ret = rpcClient.stopMeteringData();
|
||||
if (ret) {
|
||||
WinJS.log && WinJS.log("Error occured while communicating with RPC server: " + ret, "sample", "error");
|
||||
} else {
|
||||
WinJS.log && WinJS.log("Metering stop command sent successfully", "sample", "status");
|
||||
}
|
||||
}
|
||||
|
||||
meteringOn = false;
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
<!---
|
||||
category: DevicesSensorsAndPower
|
||||
samplefwlink: http://go.microsoft.com/fwlink/p/?LinkId=869539
|
||||
--->
|
||||
|
||||
# Magnetometer sample
|
||||
|
||||
Shows how to use the [Magnetometer](http://msdn.microsoft.com/library/windows/apps/br225687) class.
|
||||
|
||||
> **Note:** This sample is part of a large collection of UWP feature samples.
|
||||
> If you are unfamiliar with Git and GitHub, you can download the entire collection as a
|
||||
> [ZIP file](https://github.com/Microsoft/Windows-universal-samples/archive/master.zip), but be
|
||||
> sure to unzip everything to access shared dependencies. For more info on working with the ZIP file,
|
||||
> the samples collection, and GitHub, see [Get the UWP samples from GitHub](https://aka.ms/ovu2uq).
|
||||
> For more samples, see the [Samples portal](https://aka.ms/winsamples) on the Windows Dev Center.
|
||||
|
||||
The sample asks you to choose an magnetometer.
|
||||
|
||||
After choosing your magnetometer, you can choose one of these scenarios:
|
||||
|
||||
- Magnetometer data events
|
||||
- Poll magnetometer readings
|
||||
|
||||
### Magnetometer Data Events
|
||||
|
||||
When you choose the **Enable** button for the **Data Events** option, the app begins streaming magnetometer readings in real time.
|
||||
|
||||
### Poll Magnetometer Readings
|
||||
|
||||
When you choose the **Enable** button for the **Polling** option, the app will retrieve the sensor readings at a fixed interval.
|
||||
|
||||
### Magnetometer data events batching
|
||||
|
||||
When you choose the **Enable** button for the **Data Events** option, the app begins streaming magnetometer readings. The readings may be delivered in batches if the device supports data batching.
|
||||
|
||||
## Related topics
|
||||
|
||||
### Reference
|
||||
|
||||
[Magnetometer Class](https://docs.microsoft.com/en-us/uwp/api/Windows.Devices.Sensors.Magnetometer)
|
||||
|
||||
[Magnetometer.ReadingChanged event handler](https://docs.microsoft.com/en-us/uwp/api/windows.devices.sensors.magnetometerreadingchangedeventargs)
|
||||
|
||||
[Calibrate sensors](https://docs.microsoft.com/en-us/windows/uwp/devices-sensors/calibrate-sensors)
|
||||
|
||||
[Windows.Devices.Sensors namespace](http://go.microsoft.com/fwlink/p/?linkid=241981)
|
||||
|
||||
## System requirements
|
||||
|
||||
**Client:** Windows 10 build 14295
|
||||
|
||||
**Server:** Windows Server 2016 Technical Preview
|
||||
|
||||
**Phone:** Windows 10 build 14295
|
||||
|
||||
## Build the sample
|
||||
|
||||
1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build.
|
||||
2. Start Microsoft Visual Studio 2017 and select **File** \> **Open** \> **Project/Solution**.
|
||||
3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for your preferred language. Double-click the Visual Studio Solution (.sln) file.
|
||||
4. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**.
|
||||
|
||||
## Run the sample
|
||||
|
||||
The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.
|
||||
|
||||
### Deploying the sample
|
||||
|
||||
- Select Build > Deploy Solution.
|
||||
|
||||
### Deploying and running the sample
|
||||
|
||||
- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging.
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProjectGuid>{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}</ProjectGuid>
|
||||
<OutputType>AppContainerExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MagnetometerCS</RootNamespace>
|
||||
<AssemblyName>MagnetometerCS</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UAP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UAP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UAP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UAP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UAP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UAP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<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>
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\SharedContent\cs\MainPage.xaml.cs">
|
||||
<Link>MainPage.xaml.cs</Link>
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\SharedContent\cs\AssemblyInfo.cs">
|
||||
<Link>Properties\AssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="SampleConfiguration.cs" />
|
||||
<Compile Include="Scenario1_DataEvents.xaml.cs" />
|
||||
<Compile Include="Scenario2_Polling.xaml.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="..\..\..\SharedContent\xaml\App.xaml">
|
||||
<Link>App.xaml</Link>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="..\..\..\SharedContent\cs\MainPage.xaml">
|
||||
<Link>MainPage.xaml</Link>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Scenario1_DataEvents.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Scenario2_Polling.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="..\..\..\SharedContent\xaml\Styles.xaml">
|
||||
<Link>Styles\Styles.xaml</Link>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\..\..\SharedContent\cs\Default.rd.xml">
|
||||
<Link>Properties\Default.rd.xml</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\microsoft-sdk.png">
|
||||
<Link>Assets\microsoft-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\smalltile-sdk.png">
|
||||
<Link>Assets\smallTile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\splash-sdk.png">
|
||||
<Link>Assets\splash-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
|
||||
<Link>Assets\squareTile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
|
||||
<Link>Assets\storeLogo-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
|
||||
<Link>Assets\tile-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\..\SharedContent\media\windows-sdk.png">
|
||||
<Link>Assets\windows-sdk.png</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26228.4
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Magnetometer", "Magnetometer.csproj", "{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}"
|
||||
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
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Debug|x64.Build.0 = Debug|x64
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Debug|x86.Build.0 = Debug|x86
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Release|ARM.Build.0 = Release|ARM
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Release|x64.ActiveCfg = Release|x64
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Release|x64.Build.0 = Release|x64
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Release|x64.Deploy.0 = Release|x64
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Release|x86.ActiveCfg = Release|x86
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Release|x86.Build.0 = Release|x86
|
||||
{88FCB170-E82A-5EAC-9826-EAC78AABFE6D}.Release|x86.Deploy.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
IgnorableNamespaces="uap mp">
|
||||
|
||||
<Identity
|
||||
Name="Microsoft.SDKSamples.MagnetometerCS.CS"
|
||||
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="7fd9fdb3-10a3-4ec1-9a57-8622d85e2af0" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>Magnetometer C# Sample</DisplayName>
|
||||
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo-sdk.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.10240.0" MaxVersionTested="10.0.16299.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="MagnetometerCS.App">
|
||||
<uap:VisualElements
|
||||
DisplayName="MagnetometerCS"
|
||||
Square150x150Logo="Assets\SquareTile-sdk.png"
|
||||
Square44x44Logo="Assets\SmallTile-sdk.png"
|
||||
Description="MagnetometerCS"
|
||||
BackgroundColor="#00b2f0">
|
||||
<uap:SplashScreen Image="Assets\Splash-sdk.png" />
|
||||
<uap:DefaultTile>
|
||||
<uap:ShowNameOnTiles>
|
||||
<uap:ShowOn Tile="square150x150Logo" />
|
||||
</uap:ShowNameOnTiles>
|
||||
</uap:DefaultTile>
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
</Package>
|
|
@ -0,0 +1,34 @@
|
|||
//*********************************************************
|
||||
//
|
||||
// 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.Generic;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace SDKTemplate
|
||||
{
|
||||
public partial class MainPage : Page
|
||||
{
|
||||
public const string FEATURE_NAME = "Magnetometer";
|
||||
|
||||
List<Scenario> scenarios = new List<Scenario>
|
||||
{
|
||||
new Scenario() { Title = "Data Events", ClassType = typeof(SDKTemplate.Scenario1_DataEvents) },
|
||||
new Scenario() { Title = "Polling", ClassType = typeof(SDKTemplate.Scenario2_Polling) },
|
||||
};
|
||||
}
|
||||
|
||||
public class Scenario
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public Type ClassType { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<!--
|
||||
//*********************************************************
|
||||
//
|
||||
// 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.Scenario1_DataEvents"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<Grid x:Name="LayoutRoot" HorizontalAlignment="Left" VerticalAlignment="Top">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock x:Name="InputTextBlock" TextWrapping="Wrap" Grid.Row="0" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" Text="Registers an event listener for magnetometer data and displays the X, Y and Z magnetic field values as they are reported."/>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0" Grid.Row="1">
|
||||
<Button x:Name="ScenarioEnableButton" Content="Enable" Margin="0,0,10,0" Click="ScenarioEnable"/>
|
||||
<Button x:Name="ScenarioDisableButton" Content="Disable" Margin="0,0,10,0" Click="ScenarioDisable"/>
|
||||
</StackPanel>
|
||||
<Grid HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="20"/>
|
||||
<ColumnDefinition Width="Auto" MinWidth="60"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock TextWrapping="Wrap" Grid.Row="0" Grid.Column="0" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" Text="X:"/>
|
||||
<TextBlock TextWrapping="Wrap" Grid.Row="1" Grid.Column="0" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" Text="Y:"/>
|
||||
<TextBlock TextWrapping="Wrap" Grid.Row="2" Grid.Column="0" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" Text="Z:"/>
|
||||
<TextBlock x:Name="ScenarioOutput_X" TextWrapping="Wrap" Grid.Row="0" Grid.Column="1" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" Text="No data"/>
|
||||
<TextBlock x:Name="ScenarioOutput_Y" TextWrapping="Wrap" Grid.Row="1" Grid.Column="1" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" Text="No data"/>
|
||||
<TextBlock x:Name="ScenarioOutput_Z" TextWrapping="Wrap" Grid.Row="2" Grid.Column="1" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" Text="No data"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,162 @@
|
|||
//*********************************************************
|
||||
//
|
||||
// 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 Windows.Devices.Sensors;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace SDKTemplate
|
||||
{
|
||||
public sealed partial class Scenario1_DataEvents : Page
|
||||
{
|
||||
// A pointer back to the main page. This is needed if you want to call methods in MainPage such
|
||||
// as NotifyUser()
|
||||
MainPage rootPage = MainPage.Current;
|
||||
|
||||
private Magnetometer _magnetometer;
|
||||
private uint _desiredReportInterval;
|
||||
|
||||
public Scenario1_DataEvents()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
_magnetometer = Magnetometer.GetDefault();
|
||||
if (_magnetometer != null)
|
||||
{
|
||||
// Select a report interval that is both suitable for the purposes of the app and supported by the sensor.
|
||||
// This value will be used later to activate the sensor.
|
||||
uint minReportInterval = _magnetometer.MinimumReportInterval;
|
||||
_desiredReportInterval = minReportInterval > 16 ? minReportInterval : 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
rootPage.NotifyUser("No magnetometer found", NotifyType.ErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when this page is about to be displayed in a Frame.
|
||||
/// </summary>
|
||||
/// <param name="e">Event data that describes how this page was reached. The Parameter
|
||||
/// property is typically used to configure the page.</param>
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
ScenarioEnableButton.IsEnabled = true;
|
||||
ScenarioDisableButton.IsEnabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame.
|
||||
/// </summary>
|
||||
/// <param name="e">
|
||||
/// Event data that can be examined by overriding code. The event data is representative
|
||||
/// of the navigation that will unload the current Page unless canceled. The
|
||||
/// navigation can potentially be canceled by setting Cancel.
|
||||
/// </param>
|
||||
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
|
||||
{
|
||||
if (ScenarioDisableButton.IsEnabled)
|
||||
{
|
||||
Window.Current.VisibilityChanged -= VisibilityChanged;
|
||||
_magnetometer.ReadingChanged -= ReadingChanged;
|
||||
|
||||
// Restore the default report interval to release resources while the sensor is not in use
|
||||
_magnetometer.ReportInterval = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the event handler for VisibilityChanged events. You would register for these notifications
|
||||
/// if handling sensor data when the app is not visible could cause unintended actions in the app.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e">
|
||||
/// Event data that can be examined for the current visibility state.
|
||||
/// </param>
|
||||
private void VisibilityChanged(object sender, VisibilityChangedEventArgs e)
|
||||
{
|
||||
if (ScenarioDisableButton.IsEnabled)
|
||||
{
|
||||
if (e.Visible)
|
||||
{
|
||||
// Re-enable sensor input (no need to restore the desired reportInterval... it is restored for us upon app resume)
|
||||
_magnetometer.ReadingChanged += ReadingChanged;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disable sensor input (no need to restore the default reportInterval... resources will be released upon app suspension)
|
||||
_magnetometer.ReadingChanged -= ReadingChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the event handler for ReadingChanged events.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
async private void ReadingChanged(object sender, MagnetometerReadingChangedEventArgs e)
|
||||
{
|
||||
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
|
||||
{
|
||||
MagnetometerReading reading = e.Reading;
|
||||
ScenarioOutput_X.Text = String.Format("{0,5:0.00}", reading.MagneticFieldX);
|
||||
ScenarioOutput_Y.Text = String.Format("{0,5:0.00}", reading.MagneticFieldY);
|
||||
ScenarioOutput_Z.Text = String.Format("{0,5:0.00}", reading.MagneticFieldZ);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the click handler for the 'Enable' button.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ScenarioEnable(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_magnetometer != null)
|
||||
{
|
||||
// Establish the report interval
|
||||
_magnetometer.ReportInterval = _desiredReportInterval;
|
||||
|
||||
Window.Current.VisibilityChanged += VisibilityChanged;
|
||||
_magnetometer.ReadingChanged += ReadingChanged;
|
||||
|
||||
ScenarioEnableButton.IsEnabled = false;
|
||||
ScenarioDisableButton.IsEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
rootPage.NotifyUser("No magnetometer found", NotifyType.ErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the click handler for the 'Disable' button.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ScenarioDisable(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Window.Current.VisibilityChanged -= VisibilityChanged;
|
||||
_magnetometer.ReadingChanged -= ReadingChanged;
|
||||
|
||||
// Restore the default report interval to release resources while the sensor is not in use
|
||||
_magnetometer.ReportInterval = 0;
|
||||
|
||||
ScenarioEnableButton.IsEnabled = true;
|
||||
ScenarioDisableButton.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<!--
|
||||
//*********************************************************
|
||||
//
|
||||
// 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.Scenario2_Polling"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<Grid x:Name="LayoutRoot" HorizontalAlignment="Left" VerticalAlignment="Top">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock x:Name="InputTextBlock" TextWrapping="Wrap" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" Text="Polls for magnetometer data and displays the X, Y and Z magnetic field values at a set interval."/>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Button x:Name="ScenarioEnableButton" Content="Enable" Margin="0,0,10,0" Click="ScenarioEnable"/>
|
||||
<Button x:Name="ScenarioDisableButton" Content="Disable" Margin="0,0,10,0" Click="ScenarioDisable"/>
|
||||
</StackPanel>
|
||||
<Grid HorizontalAlignment="Left" VerticalAlignment="Top">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="20"/>
|
||||
<ColumnDefinition Width="Auto" MinWidth="60"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock TextWrapping="Wrap" Grid.Row="0" Grid.Column="0" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" Text="X:"/>
|
||||
<TextBlock TextWrapping="Wrap" Grid.Row="1" Grid.Column="0" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" Text="Y:"/>
|
||||
<TextBlock TextWrapping="Wrap" Grid.Row="2" Grid.Column="0" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Left" Text="Z:"/>
|
||||
<TextBlock x:Name="ScenarioOutput_X" TextWrapping="Wrap" Grid.Row="0" Grid.Column="1" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" Text="No data"/>
|
||||
<TextBlock x:Name="ScenarioOutput_Y" TextWrapping="Wrap" Grid.Row="1" Grid.Column="1" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" Text="No data"/>
|
||||
<TextBlock x:Name="ScenarioOutput_Z" TextWrapping="Wrap" Grid.Row="2" Grid.Column="1" Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" Text="No data"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,173 @@
|
|||
//*********************************************************
|
||||
//
|
||||
// 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 Windows.Devices.Sensors;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace SDKTemplate
|
||||
{
|
||||
public sealed partial class Scenario2_Polling : Page
|
||||
{
|
||||
// A pointer back to the main page. This is needed if you want to call methods in MainPage such
|
||||
// as NotifyUser()
|
||||
MainPage rootPage = MainPage.Current;
|
||||
|
||||
private Magnetometer _magnetometer;
|
||||
private uint _desiredReportInterval;
|
||||
private DispatcherTimer _dispatcherTimer;
|
||||
|
||||
public Scenario2_Polling()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
_magnetometer = Magnetometer.GetDefault();
|
||||
if (_magnetometer != null)
|
||||
{
|
||||
// Select a report interval that is both suitable for the purposes of the app and supported by the sensor.
|
||||
// This value will be used later to activate the sensor.
|
||||
uint minReportInterval = _magnetometer.MinimumReportInterval;
|
||||
_desiredReportInterval = minReportInterval > 16 ? minReportInterval : 16;
|
||||
|
||||
// Set up a DispatchTimer
|
||||
_dispatcherTimer = new DispatcherTimer();
|
||||
_dispatcherTimer.Tick += DisplayCurrentReading;
|
||||
_dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, (int)_desiredReportInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
rootPage.NotifyUser("No magnetometer found", NotifyType.ErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when this page is about to be displayed in a Frame.
|
||||
/// </summary>
|
||||
/// <param name="e">Event data that describes how this page was reached. The Parameter
|
||||
/// property is typically used to configure the page.</param>
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
ScenarioEnableButton.IsEnabled = true;
|
||||
ScenarioDisableButton.IsEnabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame.
|
||||
/// </summary>
|
||||
/// <param name="e">
|
||||
/// Event data that can be examined by overriding code. The event data is representative
|
||||
/// of the navigation that will unload the current Page unless canceled. The
|
||||
/// navigation can potentially be canceled by setting Cancel.
|
||||
/// </param>
|
||||
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
|
||||
{
|
||||
if (ScenarioDisableButton.IsEnabled)
|
||||
{
|
||||
Window.Current.VisibilityChanged -= VisibilityChanged;
|
||||
|
||||
// Stop the dispatcher
|
||||
_dispatcherTimer.Stop();
|
||||
|
||||
// Restore the default report interval to release resources while the sensor is not in use
|
||||
_magnetometer.ReportInterval = 0;
|
||||
}
|
||||
|
||||
base.OnNavigatingFrom(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the event handler for VisibilityChanged events. You would register for these notifications
|
||||
/// if handling sensor data when the app is not visible could cause unintended actions in the app.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e">
|
||||
/// Event data that can be examined for the current visibility state.
|
||||
/// </param>
|
||||
private void VisibilityChanged(object sender, VisibilityChangedEventArgs e)
|
||||
{
|
||||
if (ScenarioDisableButton.IsEnabled)
|
||||
{
|
||||
if (e.Visible)
|
||||
{
|
||||
// Re-enable sensor input (no need to restore the desired reportInterval... it is restored for us upon app resume)
|
||||
_dispatcherTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disable sensor input (no need to restore the default reportInterval... resources will be released upon app suspension)
|
||||
_dispatcherTimer.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the dispatcher callback.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
private void DisplayCurrentReading(object sender, object args)
|
||||
{
|
||||
MagnetometerReading reading = _magnetometer.GetCurrentReading();
|
||||
if (reading != null)
|
||||
{
|
||||
ScenarioOutput_X.Text = String.Format("{0,5:0.00}", reading.MagneticFieldX);
|
||||
ScenarioOutput_Y.Text = String.Format("{0,5:0.00}", reading.MagneticFieldY);
|
||||
ScenarioOutput_Z.Text = String.Format("{0,5:0.00}", reading.MagneticFieldZ);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the click handler for the 'Enable' button.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ScenarioEnable(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_magnetometer != null)
|
||||
{
|
||||
// Set the report interval to enable the sensor for polling
|
||||
_magnetometer.ReportInterval = _desiredReportInterval;
|
||||
|
||||
Window.Current.VisibilityChanged += VisibilityChanged;
|
||||
_dispatcherTimer.Start();
|
||||
|
||||
ScenarioEnableButton.IsEnabled = false;
|
||||
ScenarioDisableButton.IsEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
rootPage.NotifyUser("No magnetometer found", NotifyType.ErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the click handler for the 'Disable' button.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ScenarioDisable(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Window.Current.VisibilityChanged -= VisibilityChanged;
|
||||
|
||||
// Stop the dispatcher
|
||||
_dispatcherTimer.Stop();
|
||||
|
||||
// Restore the default report interval to release resources while the sensor is not in use
|
||||
_magnetometer.ReportInterval = 0;
|
||||
|
||||
ScenarioEnableButton.IsEnabled = true;
|
||||
ScenarioDisableButton.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"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": {}
|
||||
}
|
||||
}
|
|
@ -205,14 +205,14 @@ void Scenario3::OnSaveAsync(Object^ sender, RoutedEventArgs^ e)
|
|||
.then([this](IRandomAccessStream^ stream)
|
||||
{
|
||||
return create_task(inkCanvas->InkPresenter->StrokeContainer->SaveAsync(stream))
|
||||
.then([this, stream](task<std::size_t> saveTask)
|
||||
.then([this, stream](task<unsigned int> saveTask)
|
||||
{
|
||||
// Always close the stream, even if an error occurs.
|
||||
delete stream;
|
||||
|
||||
return saveTask;
|
||||
});
|
||||
}).then([this, file](task<std::size_t> openSaveTask)
|
||||
}).then([this, file](task<unsigned int> openSaveTask)
|
||||
{
|
||||
// Report whether the file was successfully saved.
|
||||
try
|
||||
|
|
Двоичные данные
Samples/SplashScreen/cs/Assets/smalltile-Phone-sdk.png
Двоичные данные
Samples/SplashScreen/cs/Assets/smalltile-Phone-sdk.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 428 B |
Двоичные данные
Samples/SplashScreen/cs/Assets/splash-Phone-sdk.png
Двоичные данные
Samples/SplashScreen/cs/Assets/splash-Phone-sdk.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 10 KiB |
Двоичные данные
Samples/SplashScreen/cs/Assets/splash-Windows-sdk.png
Двоичные данные
Samples/SplashScreen/cs/Assets/splash-Windows-sdk.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 9.1 KiB |
|
@ -155,7 +155,6 @@
|
|||
<Content Include="..\..\..\SharedContent\media\microsoft-sdk.png">
|
||||
<Link>Assets\microsoft-sdk.png</Link>
|
||||
</Content>
|
||||
<Content Include="Assets\smalltile-Phone-sdk.png" />
|
||||
<Content Include="..\..\..\SharedContent\media\smalltile-sdk.png">
|
||||
<Link>Assets\smallTile-sdk.png</Link>
|
||||
</Content>
|
||||
|
|
Загрузка…
Ссылка в новой задаче