Add dual-screen support to Calculator (#1027)

This commit is contained in:
Rudy Huyn 2020-03-24 11:39:59 -07:00 committed by GitHub
parent 980b60f271
commit 15944fcd10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 2411 additions and 1279 deletions

View file

@ -334,6 +334,7 @@
<ClInclude Include="StandardCalculatorViewModel.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="UnitConverterViewModel.h" />
<ClInclude Include="Utils\DeviceFamilyHelper.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ApplicationViewModel.cpp" />
@ -374,6 +375,7 @@
</ClCompile>
<ClCompile Include="StandardCalculatorViewModel.cpp" />
<ClCompile Include="UnitConverterViewModel.cpp" />
<ClCompile Include="Utils\DeviceFamilyHelper.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CalcManager\CalcManager.vcxproj">

View file

@ -13,6 +13,9 @@
<Filter Include="GraphingCalculator">
<UniqueIdentifier>{cf7dca32-9727-4f98-83c3-1c0ca7dd1e0c}</UniqueIdentifier>
</Filter>
<Filter Include="Utils">
<UniqueIdentifier>{68bb415f-fcb1-4759-b0a7-c5caf9d72396}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp" />
@ -86,6 +89,9 @@
<ClCompile Include="GraphingCalculator\GraphingSettingsViewModel.cpp">
<Filter>GraphingCalculator</Filter>
</ClCompile>
<ClCompile Include="Utils\DeviceFamilyHelper.cpp">
<Filter>Utils</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
@ -199,6 +205,9 @@
<ClInclude Include="Common\DelegateCommand.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Utils\DeviceFamilyHelper.h">
<Filter>Utils</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="DataLoaders\DefaultFromToCurrency.json">

View file

@ -0,0 +1,54 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "DeviceFamilyHelper.h"
using namespace CalculatorApp::ViewModel::Utils;
using namespace Windows::System::Profile;
bool DeviceFamilyHelper::m_isInit{ false };
DeviceFamily DeviceFamilyHelper::m_deviceFamily{ DeviceFamily::Unknown };
DeviceFamily DeviceFamilyHelper::GetDeviceFamily()
{
if (!m_isInit)
{
InitDeviceFamily();
m_isInit = true;
}
return m_deviceFamily;
}
void DeviceFamilyHelper::InitDeviceFamily()
{
auto deviceFamily = AnalyticsInfo::VersionInfo->DeviceFamily;
if (deviceFamily == L"Windows.Desktop")
{
m_deviceFamily = DeviceFamily::Desktop;
}
else if (deviceFamily == L"Windows.Core")
{
m_deviceFamily = DeviceFamily::WindowsCore;
}
else if (deviceFamily == L"Windows.Xbox")
{
m_deviceFamily = DeviceFamily::Xbox;
}
else if (deviceFamily == L"Windows.Team")
{
m_deviceFamily = DeviceFamily::SurfaceHub;
}
else if (deviceFamily == L"Windows.Holographic")
{
m_deviceFamily = DeviceFamily::HoloLens;
}
else if (deviceFamily == L"Windows.Mobile")
{
m_deviceFamily = DeviceFamily::Mobile;
}
else
{
m_deviceFamily = DeviceFamily::Unknown;
}
}

View file

@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
namespace CalculatorApp::ViewModel::Utils
{
public enum class DeviceFamily
{
Unknown,
Desktop,
Mobile,
Xbox,
SurfaceHub,
HoloLens,
WindowsCore,
};
public ref class DeviceFamilyHelper sealed
{
private:
DeviceFamilyHelper() {}
public:
static DeviceFamily GetDeviceFamily();
private:
static void InitDeviceFamily();
private:
static bool m_isInit;
static DeviceFamily m_deviceFamily;
};
}