High DPI

I am programming for the Compact Frameork 2.0. On a Windows Mobile 5.0 smart phone. I want to provide a different picturebox.image on a High DPI device.

In C# what is the best way to determin that I am running in a High DPI environment.

TIA,
Al

[253 byte] By [AllenAlper] at [2008-2-25]
# 1
I'm not aware of a direct method built into the framework, but you could possibly detect the resolution by checking the .Width of a full-screen form.

-Ryan / Kardax

RyanLamansky at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 2

Yes, I was thinking of this. Also there is a Screen.PrimaryScreen.Bounds.Width that may be better than Form.Width.

I am still hoping for a more direct method.

I would like to know how to differentiate between large-format normal-DPI devices and normal-format High-DPI devices, specifically VGA vs. QVGA devices.

Or is this even an issue?

AllenAlper at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 3

Please take a look at the Graphics.DpiX and Graphics.DpiY properties. You can use them to determine DPI of the screen.

Hope this helps,

Sergey.
SergeyKuryata at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 4
I did see these, but I am not sure how they map to the screen DPI is there an example that you can point me to?

Can I capture the screen's graphics object?

AllenAlper at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 5

I think you can something like the following:

public Form1()

{

Graphics graphics;

graphics = this.CreateGraphics();

this.currentDpiX = graphics.DpiX;

this.currentDpiY = graphics.DpiY;

graphics.Dispose(); // don’t forget to release the unnecessary resources

}

The DPI value for a regular (LowRes) device is 96.


Thank you,
Sergiy.

SergeyKuryata at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 6
I have to say that I think it is a bit of a pain. I was hoping to create a globally available resource which I can setup for the particular resolution, a little like one might do for languages. Then I can just refer to the GlobalGraphics resourcemanager and pull the relevant graphics out of this in a way that would be common to 96 and 192 DPi. Also when different DPis come along, just add a new resource file. This is the way I am going to do it, jsut going too be a pain to initialise with the correct DPi without a Graphics.Dpix inherently available.

You could use the installation helper thingy talked about in Mobile 2003 SE SDK but that sounds about as reliable as an Aston Martin Lagonda.

TomRobson at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...