Windows8 App
[Window 8] 기기 해상도와 DPI 값 얻어오기
동동(이재동)
2013. 7. 5. 11:23
void detectScreenType()
{
double dpi = DisplayProperties.LogicalDpi;
var bounds = Window.Current.Bounds;
double h;
switch (ApplicationView.Value)
{
case ApplicationViewState.Filled:
h = bounds.Height;
break;
case ApplicationViewState.FullScreenLandscape:
h = bounds.Height;
break;
case ApplicationViewState.Snapped:
h = bounds.Height;
break;
case ApplicationViewState.FullScreenPortrait:
h = bounds.Width;
break;
default:
return;
}
double inches = h / dpi ;
string screenType = "Slate";
if (inches < 10)
{
screenType = "Slate";
} else if (inches < 14) {
screenType = "WorkHorsePC";
}
else
{
screenType = "FamilyHub";
}
ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
localSettings.Values["screenType"] = screenType;
}
머 거창해 보이지만 실제로는
var bounds = Window.Current.Bounds;
이렇게만 얻어오면 된다.
참조 : http://stackoverflow.com/questions/10828179/how-to-get-the-resolution-of-screen-for-a-winrt-app