-
-
Save colinkiama/47609f3512a66eaa30d0fc0b08f4854b to your computer and use it in GitHub Desktop.
Detect device type on Universal Windows Platform (UWP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Windows.System.Profile; | |
using Windows.UI.ViewManagement; | |
namespace Wagonli.Tools | |
{ | |
public static class DeviceTypeHelper | |
{ | |
public static DeviceFormFactorType GetDeviceFormFactorType() | |
{ | |
switch (AnalyticsInfo.VersionInfo.DeviceFamily) | |
{ | |
case "Windows.Mobile": | |
return DeviceFormFactorType.Phone; | |
case "Windows.Desktop": | |
return UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse | |
? DeviceFormFactorType.Desktop | |
: DeviceFormFactorType.Tablet; | |
case "Windows.Universal": | |
return DeviceFormFactorType.IoT; | |
case "Windows.Team": | |
return DeviceFormFactorType.SurfaceHub; | |
default: | |
return DeviceFormFactorType.Other; | |
} | |
} | |
} | |
public enum DeviceFormFactorType | |
{ | |
Phone, | |
Desktop, | |
Tablet, | |
IoT, | |
SurfaceHub, | |
Other | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment