Last active
July 11, 2017 13:15
-
-
Save markjulmar/ff428a370e28467989be54f19908333b to your computer and use it in GitHub Desktop.
Detect UWP device type
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
public enum DeviceType | |
{ | |
Phone, | |
Tablet, | |
Desktop, | |
IoT, | |
Xbox, | |
SurfaceHub, | |
HoloLens, | |
Other | |
} | |
public static class DeviceDetection | |
{ | |
public static DeviceType Detect() | |
{ | |
switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) | |
{ | |
case "Windows.Mobile": | |
return DeviceType.Phone; | |
case "Windows.Desktop": | |
return DeviceType UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse | |
? DeviceType.Desktop : DeviceType.Tablet; | |
break; | |
case "Windows.Universal": | |
return DeviceType.IoT; | |
case "Windows.Team": | |
return DeviceType.SurfaceHub; | |
case "Windows.Xbox": | |
return DeviceType.Xbox; | |
case "Windows.Holographic": | |
return DeviceType.HoloLens; | |
default: | |
return DeviceType.Other; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment