Skip to content

Instantly share code, notes, and snippets.

@polatengin
Created October 4, 2016 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polatengin/1729f964672cacc68d85b6e0f73f6563 to your computer and use it in GitHub Desktop.
Save polatengin/1729f964672cacc68d85b6e0f73f6563 to your computer and use it in GitHub Desktop.
Windows 10 UWP uygulamasının Phone, Tablet veya Desktop cihazda çalıştığını bulmak
public enum DeviceType
{
Phone,
Tablet,
Desktop,
Xbox,
IoT,
Continuum
}
public static DeviceType Detect()
{
if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile")
{
if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
{
KeyboardCapabilities keyboard = new KeyboardCapabilities();
if (keyboard.KeyboardPresent > 0)
{
return DeviceType.Continuum;
}
else
{
return DeviceType.Phone;
}
}
else
{
return DeviceType.Tablet;
}
}
else if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Desktop")
{
KeyboardCapabilities keyboard = new KeyboardCapabilities();
if (keyboard.KeyboardPresent > 0)
{
return DeviceType.Desktop;
}
else
{
return DeviceType.Tablet;
}
}
else if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Xbox")
{
return DeviceType.Xbox;
}
else if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.IoT")
{
return DeviceType.IoT;
}
/// Yukarıdakilerin hiçbiri değilse, Desktop olmalı
return DeviceType.Desktop;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment