×
Namespaces

Variants
Actions

Simulate 1080p windows phone emulator

From Nokia Developer Wiki
Jump to: navigation, search

This article explains how to simulate a 1080p emulator to develop application adapted to Lumia 1520 without device

Note.pngNote: This is an entry in the Nokia Imaging and Big UI Wiki Competition 2013Q4.

WP Metro Icon UI.png
WP Metro Icon Tools.png
WP Metro Icon WP8.png
Article Metadata
Tested with
SDK: Windows Phone 8.0 SDK
Devices(s): Nokia Lumia 1520
Compatibility
Platform(s):
Windows Phone 8
Article
Created: (15 Dec 2013)
Last edited: rudyhuyn (15 Dec 2013)

Contents

Introduction

Since the announcement of the Nokia Lumia 1520, the new windows phone featuring a 1080p screen, many developers wait the arrival of a new emulator for windows phone SDK to be able to develop application optimized for this screen size, only problem: it is not available for the moment. We can easily imagine an application displaying more information on a big screen than on a smaller screen like the Lumia 520.

screen size or screen resolution?

When we talk about big UI or taking advantage of large-screen windows phone, we don't speak of its resolution (WVGA, WXGA, 720p, 1080p, etc...) but about its physical size!

One example, the Nokia Lumia 1320 and HTC 8X have the same screen resolution (the number of pixels): 720p (1280x720), however, we want to display more information on the lumia 1320 cause the screen physical size is bigger.


do we need a new emulator?

It can be a good thing, but it's not necessary. The new Nokia Lumia 1520 for example, despite its screen resolution of 1080p is considered by the SDK as a 720p screen (App.Current.Host.Content.ScaleFactor == 1.6 and not 2.25), the only differences are 3 newly available DeviceExtendedProperties values:

  • PhysicalScreenResolution: the actual definition of the screen (1920x1080 for the Nokia Lumia 1520, 1280x720 for the Nokia Lumia 1320)
  • RawDpiX and RawDpiY: the scalefactor horizontal and vertical DPI (the number of physical pixels per inch)

And that's it.

The last two properties are very interesting, for the first time, we don't speak about resolution but physical screen size, how much pixels I have in a inch and this is what interests us, simply multiply RawDpiX/RawDpiY by PhysicalScreenResolution and you will find the physical size of the screen in inches (easily convertible in centimeters for those who prefer). Therefore, it will be very complicated to provide an emulator for each new phone released, because we are no more limited by resolution, but also by the physical size of the phone screen, so we will need a new emulator for each new phone, too complicated.

So, how can I work ?

Cause 1080p resolution is managed as a 720p resolution, we will be able to work an the current 720p emulator, but we will change some things.

We will use a small helper to simulate the Nokia Lumia 1520 on the 720p emulator (reminder: it is seen by the system as a 720p screen). We will just redefine DeviceExtendedProperties via a new custom class named DeviceExtendedPropertiesExt. This class has a property named ActivateFake1080p which will return the new values of the Nokia Lumia 1520 when true.

DeviceExtendedPropertiesExt creation

Here is the interface of DeviceExtendedProperties:

 class DeviceExtendedProperties
 {
        public static object GetValue(string propertyName);
public static bool TryGetValue(string propertyName, out object propertyValue);
}

We just need to use the same interface for our custom class DeviceExtendedPropertiesExt.


We begin by created a property

public class DeviceExtendedPropertiesExt
{
        // Summary:
        //     Activate or not the fake 1080 data.
        //
        public static bool ActivateFake1080p { get; set; }
 }

Now we will redefine the GetValue method. First we check if ActivateFake1080p is true, if it's the case, we will return the Nokia Lumia 1520 right value, else we will return the true DeviceExtendedProperties value.

public static object GetValue(string propertyName)
{
if (ActivateFake1080p)
{
switch (propertyName)
{
case "PhysicalScreenResolution":
return new Size(1080, 1920);
case "RawDpiX":
case "RawDpiY":
return 368d;
}
}
return DeviceExtendedProperties.GetValue(propertyName);
}

TryGetValue is easy, we will use GetValue method.

public static bool TryGetValue(string propertyName, out object propertyValue)
{
if (ActivateFake1080p)
{
try
{
propertyValue = GetValue(propertyName);
return true;
}
catch
{
propertyValue = null;
return false;
}
}
return DeviceExtendedProperties.TryGetValue(propertyName, out propertyValue);
}

Here is the full source code:

using Microsoft.Phone.Info;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
 
namespace FakeEmulator1080p
{
public class DeviceExtendedPropertiesExt
{
// Summary:
// Activate or not the fake 1080 data.
//
public static bool ActivateFake1080p { get; set; }
 
 
// Summary:
// Retrieves an object representing the specified device property.
//
// Parameters:
// propertyName:
// The name of the device property to be retrieved. Property names are case-sensitive.
//
// Returns:
// Returns System.Object.
public static object GetValue(string propertyName)
{
if (ActivateFake1080p)
{
switch (propertyName)
{
case "PhysicalScreenResolution":
return new Size(1080, 1920);
case "RawDpiX":
case "RawDpiY":
return 368d;
}
}
return GetValue(propertyName);
}
//
// Summary:
// Retrieves an object representing the specified device property.
//
// Parameters:
// propertyName:
// The name of the device property to be retrieved. Property names are case-sensitive.
//
// propertyValue:
// The output parameter object in which the value of the device property is
// stored.
//
// Returns:
// Returns System.Boolean.
public static bool TryGetValue(string propertyName, out object propertyValue)
{
if (ActivateFake1080p)
{
try
{
propertyValue = GetValue(propertyName);
return true;
}
catch
{
propertyValue = null;
return false;
}
}
return DeviceExtendedProperties.TryGetValue(propertyName, out propertyValue);
}
 
 
}
}

How to use it?

To use it's simple, use the 720p emulator and replace all DeviceExtendedProperties references by DeviceExtendedPropertiesExt in your code source and set the property ActivateFake1080p to true if you want to simulate the Lumia 1520.

Warning.pngWarning: be careful not to activate it in production.

Note.pngNote: we used the value from Nokia Lumia 1520 on this example, you can easily change the value to match with other devices

Fake Lumia 1520 emulator sample

The Fake Lumia 1520 emulator sample can be downloaded here File:FakeEmulator1080p.zip.

screenshot of fake 1080p emulator

This page was last modified on 15 December 2013, at 06:52.
794 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×