[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

AutoScaling .NET 2.0

Posted on 2008-02-08
8
Medium Priority
?
384 Views
Last Modified: 2013-12-17
Hi,
In my current Application I have to max  the Windlows Client width and height to the Monitor Size.
If the monitor resolution changes it should scale to the new width and height.
Also the controls within the forms should scale and position automatically.

I have default client size set to 800 * 640 . So when the app loads if the client size is different than
the Monitor Resolution I calcuate the Width Height and Location for each control a

Eg. The function below calcuates the width of control with respectto the Monitor size.
Here width parameter is the actual control width when the size is 800.
 public static int SetWidth(int width)
 {
             decimal scale = Math.Round(((decimal)width/(decimal)800), 4);
            return Convert.ToInt32(System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width * scale);
 }

Is there any other default way in .NET to do  auto scaling of forms & controls.
0
Comment
Question by:AdibRahman77
  • 3
  • 2
5 Comments
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 20856172
Hi AdibRahman77;

What you are talking about is call resolution independence and Microsoft does not support this although I understand that Windows Vista was to support it but do not know if it does.

There are products that give true resolution independence and here are a couple.

For example the produce from Soft-Group Components state the following:

· Gives your Windows Forms applications resolution independence.
· Keep your controls font/size proportion whenever your forms are resized
· Can be easily implemented to already designed forms with 1 line of code
· Support controls nested inside others
· Can centerl form over the Desktop or MDI Parent
· Can save/resotre your form's last size and positions.
· Resizes fonts as well as the controls themselves
· Ability to specify whether the fonts of the controls will be resized or not.
· Control resize of docked controls like ToolStrip and StatusStrip.
· Support of standard .Net Windows Form, MDI child and MDI parent Forms.
· Fast, small and accurate resize engine.

Soft-Group's web site. "You can download a 30 day trial version" of Softgroup .Net Forms Resize
http://www.soft-group.it/net/index.php?c=4

Another such product is Xsize from HALLoGRAM Publishing
http://www.hallogram.com/xsizer/

If you Google the phrase "Resolution Independence" you will find others.

My above statements does not in any way support any of these product.

Fernando
0
 

Author Comment

by:AdibRahman77
ID: 21258773
There is no solution put on. I cannot use third party product.
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 21259409
Go to the below link for Soft-Group's web site. "You can download a 30 day trial version" of Softgroup .Net Forms Resize
And follow the link on the page for "Softgroup .Net Forms Resize"  <<<
http://www.soft-group.it/net/index.php?c=4

The other link seems to no longer be valid since I posted it on 2/08/2008

0
 

Author Comment

by:AdibRahman77
ID: 21286945
I cannot use third party product. Looking for some ideas on manual scaling
0
 

Accepted Solution

by:
AdibRahman77 earned 0 total points
ID: 21314292
I did manual scaling by applying some mathematical logic

It sets size font and location for each control .. attached code
 public static Size GetSize(int width, int height)
        {
            decimal xscale = Math.Round(((decimal)width / (decimal)800), 4);
            decimal yscale = Math.Round((decimal)height / (decimal)610, 4);
            return new Size(Convert.ToInt32(monSize.Width * xscale), Convert.ToInt32(monSize.Height * yscale));
        }
 
 public static Font GetFont(float size, FontStyle fstyle)
        {
            decimal fscale = Math.Round(((decimal)size / (decimal)800), 4);
            return new System.Drawing.Font("Arial", (float)Math.Round(((decimal)monSize.Width * (decimal)fscale), 4), fstyle, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        }
 
        public static Point GetLocation(int X, int Y)
        {
            decimal xscale = Math.Round(((decimal)X / (decimal)800), 4);
            decimal yscale = Math.Round((decimal)Y / (decimal)610, 4);
            return new Point(Convert.ToInt32(monSize.Width * xscale), Convert.ToInt32(monSize.Height * yscale));
        }

Open in new window

0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Native ability to set a user account password via AD GPO was removed because the passwords can be easily decrypted by any authenticated user in the domain. Microsoft recommends LAPS as a replacement and I have written an article that does something …
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question