Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 494b70a

Browse files
committed
Merge pull request #3 from lisaong/uwp
Uwp
2 parents bd16ca7 + a41bb3f commit 494b70a

31 files changed

Lines changed: 1513 additions & 1251 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,5 @@ $RECYCLE.BIN/
154154

155155
# Mac desktop service store files
156156
.DS_Store
157+
/Steps/project.lock.json
158+
/Steps/.vs/config

BackgroundTasks/BackgroundTasks.csproj

Lines changed: 83 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,121 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProductVersion>8.0.30703</ProductVersion>
8-
<SchemaVersion>2.0</SchemaVersion>
9-
<ProjectGuid>{139193F3-9FEF-4C44-9655-213648597A09}</ProjectGuid>
7+
<ProjectGuid>{086C4C13-0C8E-4275-A196-42CD28A4E523}</ProjectGuid>
108
<OutputType>winmdobj</OutputType>
119
<AppDesignerFolder>Properties</AppDesignerFolder>
1210
<RootNamespace>BackgroundTasks</RootNamespace>
1311
<AssemblyName>BackgroundTasks</AssemblyName>
1412
<DefaultLanguage>en-US</DefaultLanguage>
15-
<TargetPlatformVersion>8.1</TargetPlatformVersion>
16-
<MinimumVisualStudioVersion>12</MinimumVisualStudioVersion>
13+
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
14+
<TargetPlatformVersion>10.0.10586.0</TargetPlatformVersion>
15+
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
16+
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
1717
<FileAlignment>512</FileAlignment>
18-
<ProjectTypeGuids>{76F1466A-8B6D-4E39-A767-685A06062A39};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
19-
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
20-
<NuGetPackageImportStamp>3ddbf11a</NuGetPackageImportStamp>
21-
<RestorePackages>true</RestorePackages>
18+
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
19+
<AllowCrossPlatformRetargeting>false</AllowCrossPlatformRetargeting>
20+
</PropertyGroup>
21+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
22+
<PlatformTarget>AnyCPU</PlatformTarget>
23+
<DebugSymbols>true</DebugSymbols>
24+
<DebugType>full</DebugType>
25+
<Optimize>false</Optimize>
26+
<OutputPath>bin\Debug\</OutputPath>
27+
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
28+
<ErrorReport>prompt</ErrorReport>
29+
<WarningLevel>4</WarningLevel>
30+
</PropertyGroup>
31+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
32+
<PlatformTarget>AnyCPU</PlatformTarget>
33+
<DebugType>pdbonly</DebugType>
34+
<Optimize>true</Optimize>
35+
<OutputPath>bin\Release\</OutputPath>
36+
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
37+
<ErrorReport>prompt</ErrorReport>
38+
<WarningLevel>4</WarningLevel>
2239
</PropertyGroup>
2340
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
41+
<PlatformTarget>ARM</PlatformTarget>
2442
<DebugSymbols>true</DebugSymbols>
2543
<OutputPath>bin\ARM\Debug\</OutputPath>
26-
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
44+
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
2745
<NoWarn>;2008</NoWarn>
2846
<DebugType>full</DebugType>
2947
<PlatformTarget>ARM</PlatformTarget>
3048
<UseVSHostingProcess>false</UseVSHostingProcess>
3149
<ErrorReport>prompt</ErrorReport>
32-
<Prefer32Bit>true</Prefer32Bit>
3350
</PropertyGroup>
3451
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
52+
<PlatformTarget>ARM</PlatformTarget>
3553
<OutputPath>bin\ARM\Release\</OutputPath>
36-
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
54+
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
3755
<Optimize>true</Optimize>
3856
<NoWarn>;2008</NoWarn>
3957
<DebugType>pdbonly</DebugType>
4058
<PlatformTarget>ARM</PlatformTarget>
4159
<UseVSHostingProcess>false</UseVSHostingProcess>
4260
<ErrorReport>prompt</ErrorReport>
43-
<Prefer32Bit>true</Prefer32Bit>
61+
</PropertyGroup>
62+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
63+
<PlatformTarget>x64</PlatformTarget>
64+
<DebugSymbols>true</DebugSymbols>
65+
<OutputPath>bin\x64\Debug\</OutputPath>
66+
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
67+
<NoWarn>;2008</NoWarn>
68+
<DebugType>full</DebugType>
69+
<PlatformTarget>x64</PlatformTarget>
70+
<UseVSHostingProcess>false</UseVSHostingProcess>
71+
<ErrorReport>prompt</ErrorReport>
72+
</PropertyGroup>
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
74+
<PlatformTarget>x64</PlatformTarget>
75+
<OutputPath>bin\x64\Release\</OutputPath>
76+
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
77+
<Optimize>true</Optimize>
78+
<NoWarn>;2008</NoWarn>
79+
<DebugType>pdbonly</DebugType>
80+
<PlatformTarget>x64</PlatformTarget>
81+
<UseVSHostingProcess>false</UseVSHostingProcess>
82+
<ErrorReport>prompt</ErrorReport>
83+
</PropertyGroup>
84+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
85+
<PlatformTarget>x86</PlatformTarget>
86+
<DebugSymbols>true</DebugSymbols>
87+
<OutputPath>bin\x86\Debug\</OutputPath>
88+
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
89+
<NoWarn>;2008</NoWarn>
90+
<DebugType>full</DebugType>
91+
<PlatformTarget>x86</PlatformTarget>
92+
<UseVSHostingProcess>false</UseVSHostingProcess>
93+
<ErrorReport>prompt</ErrorReport>
94+
</PropertyGroup>
95+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
96+
<PlatformTarget>x86</PlatformTarget>
97+
<OutputPath>bin\x86\Release\</OutputPath>
98+
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
99+
<Optimize>true</Optimize>
100+
<NoWarn>;2008</NoWarn>
101+
<DebugType>pdbonly</DebugType>
102+
<PlatformTarget>x86</PlatformTarget>
103+
<UseVSHostingProcess>false</UseVSHostingProcess>
104+
<ErrorReport>prompt</ErrorReport>
44105
</PropertyGroup>
45106
<ItemGroup>
46-
<Compile Include="OEMTask.cs" />
47-
<Compile Include="Properties\AssemblyInfo.cs" />
107+
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
108+
<None Include="project.json" />
48109
</ItemGroup>
49110
<ItemGroup>
50-
<None Include="packages.config" />
111+
<Compile Include="Converters.cs" />
112+
<Compile Include="OEMTask.cs" />
113+
<Compile Include="Properties\AssemblyInfo.cs" />
51114
</ItemGroup>
52-
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '12.0' ">
53-
<VisualStudioVersion>12.0</VisualStudioVersion>
54-
</PropertyGroup>
55-
<PropertyGroup Condition=" '$(TargetPlatformIdentifier)' == '' ">
56-
<TargetPlatformIdentifier>WindowsPhoneApp</TargetPlatformIdentifier>
115+
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
116+
<VisualStudioVersion>14.0</VisualStudioVersion>
57117
</PropertyGroup>
58-
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\$(TargetPlatformVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
118+
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
59119
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
60120
Other similar extension points exist, see Microsoft.Common.targets.
61121
<Target Name="BeforeBuild">

BackgroundTasks/Converters.cs

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* Copyright (c) 2015 Microsoft
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"), to deal
5+
* in the Software without restriction, including without limitation the rights
6+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
* copies of the Software, and to permit persons to whom the Software is
8+
* furnished to do so, subject to the following conditions:
9+
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19+
*/
20+
using System.Collections.Generic;
21+
using Windows.Devices.Sensors;
22+
using Lumia.Sense;
23+
24+
namespace BackgroundTasks.Converters
25+
{
26+
/// <summary>
27+
/// Extracts the step counts from pedometer readings or Lumia StepCountData
28+
/// </summary>
29+
public sealed class StepCountData
30+
{
31+
public uint RunningCount { get; private set; }
32+
public uint WalkingCount { get; private set; }
33+
public uint UnknownCount { get; private set; }
34+
35+
public uint TotalCount
36+
{
37+
get
38+
{
39+
return RunningCount + WalkingCount + UnknownCount;
40+
}
41+
}
42+
43+
/// <summary>
44+
/// Factory that creates a StepCountData object from PedometerReadings
45+
/// </summary>
46+
/// <param name="readings"></param>
47+
/// <returns></returns>
48+
public static StepCountData FromPedometerReadings(IReadOnlyList<PedometerReading> readings)
49+
{
50+
StepCountData steps = new StepCountData();
51+
// Get the most recent batch of 3 readings (one per StepKind)
52+
for (int i = 0; i < readings.Count && i < 3; i++)
53+
{
54+
var reading = readings[readings.Count - i - 1];
55+
switch (reading.StepKind)
56+
{
57+
case PedometerStepKind.Running:
58+
steps.RunningCount = (uint)reading.CumulativeSteps;
59+
break;
60+
case PedometerStepKind.Walking:
61+
steps.WalkingCount = (uint)reading.CumulativeSteps;
62+
break;
63+
case PedometerStepKind.Unknown:
64+
steps.UnknownCount = (uint)reading.CumulativeSteps;
65+
break;
66+
default:
67+
break;
68+
}
69+
}
70+
71+
// Subtract the counts from the earliest batch of 3 readings (one per StepKind)
72+
for (int i = 0; i < readings.Count && i < 3; i++)
73+
{
74+
var reading = readings[i];
75+
switch (reading.StepKind)
76+
{
77+
case PedometerStepKind.Running:
78+
steps.RunningCount -= (uint)reading.CumulativeSteps;
79+
break;
80+
case PedometerStepKind.Walking:
81+
steps.WalkingCount -= (uint)reading.CumulativeSteps;
82+
break;
83+
case PedometerStepKind.Unknown:
84+
steps.UnknownCount -= (uint)reading.CumulativeSteps;
85+
break;
86+
default:
87+
break;
88+
}
89+
}
90+
91+
return steps;
92+
}
93+
94+
/// <summary>
95+
/// Factory that creates a StepCountData object from a Lumia StepCount
96+
/// </summary>
97+
/// <param name="stepCount"></param>
98+
/// <returns></returns>
99+
public static StepCountData FromLumiaStepCount(StepCount stepCount)
100+
{
101+
StepCountData steps = new StepCountData();
102+
103+
steps.RunningCount = stepCount.RunningStepCount;
104+
steps.WalkingCount = stepCount.WalkingStepCount;
105+
steps.UnknownCount = 0;
106+
107+
return steps;
108+
}
109+
}
110+
}

0 commit comments

Comments
 (0)