Force.NetCF 1.0 Scalable Model for .NetCF 2.0 Application

I have a large application developed in .Net Compact Framework 1.0, developed over the past 9 years with a lot of forms and custom controls. The application is designed for screens 240x320. It scales well to a 480x640 screen when compiled with Compact.Net 1.0 and Visual Studio 2003.

I upgraded the application to .NET 2.0 using the default upgrade wizard in Visual Studio 2008. The application uses full screen and all controls are laid out as designed when using a device with a resolution of 240x320. But when using a device with a resolution of 480x640, the application uses only the upper left 25% of the screen.

I tried to use the code: AutoScaleDimensions = new SizeF (96.96); AutoScaleMode = AutoScaleMode.Dpi;

It works with the form, but does not work with dynamic controls (standard / custom) that fit into the form.

Is there a way to force an application to use scaling similar to what it did when executed with .Net 1.0 without using the AutoScaleDimensions / AutoScaleMode properties.

Thank.

+3
source share
2 answers

I found a peculiar solution to this problem.

, , simons19, control.Scale( ). . , , scale location .

:

Label lblTest = new Label();
lblTest.Text = "A Test Label";
lblTest.Location = new Point(10, 5);  //Designed in relation to a 96 dpi screen
lblTest.Size = new Size(30, 10);      //Size Designed in relation to 96 DPI screen
parentControl.Controls.Add(lblTest);
//Scale Factor is calculated as mentioned by simons19
lblTest.Scale(scaleFactor);           //Scale the control to the screen DPI.
+2

, , DPI, , , 96.

, , - :

const float designResolution = 96.0f; 
float scaleFactor;

System.Drawing.Graphics g = f.CreateGraphics();
float runningResolution = g.DpiX;
scaleFactor = runningResolution / designResolution;
g.Dispose();

, scaleFactor, :

const int controlY = 8;
int yPosition = (int)(controlY * scaleFactor);
+3

Source: https://habr.com/ru/post/1768309/


All Articles