How to make compact framework custom controls AutoScale aware?

We generally handle all of the scaling in OnResize in our controls and forms. We also have to support a lot of different devices with crazy dimensions and DPI (some paltforms don't even report the correct DPI! ).

We found with AutoScaleMode off you can proportionaly use a helper like this to scale a form's children in OnResize You simply add a Size _initalSize member set to the form size in the constructor. However I've generally found on most forms I have to write custom layout code to appropriate deal with portrait and landscape displays.

We generally handle all of the scaling in OnResizein our controls and forms. We also have to support a lot of different devices with crazy dimensions and DPI (some paltforms don't even report the correct DPI! ).

We found with AutoScaleMode off you can proportionaly use a helper like this to scale a form's children in OnResize. You simply add a Size _initalSize member set to the form size in the constructor. However I've generally found on most forms I have to write custom layout code to appropriate deal with portrait and landscape displays.

Protected override void OnResize(EventArgs e) { base. OnResize(e); // Scale the control ScaleChildren(this, ref _initialFormSize); } public static void ScaleChildren(Control control, ref Size initialSize, float fontFactor) { if (control == null || control. Size == initialSize) return; SizeF scaleFactor = new SizeF((float)control.

Width / (float)initialSize. Width, (float)control. Height / (float)initialSize.

Height); initialSize = control. Size; if (!float. IsInfinity(scaleFactor.

Width) ||!float. IsInfinity(scaleFactor. Height)) { foreach (Control child in control.

Controls) { child. Scale(scaleFactor); if (child is Panel) continue; try { // scale the font float scaledFontSize = (float)(int)(child.Font. Size * scaleFactor.

Height * fontFactor + 0.5f); System.Diagnostics.Debug. WriteLine( string. Format("ScaleChildren(): scaleFactor = ({0}, {1}); fontFactor = {2}; scaledFontSize = {3}; \"{4}\"", scaleFactor.

Width, scaleFactor. Height, fontFactor, scaledFontSize, child. Text)); child.

Font = new Font(child.Font. Name, scaledFontSize, child.Font. Style); } catch { } } } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions