Last active
July 21, 2017 09:35
-
-
Save minhphuc429/fbd590eb235fc3866554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct CtrlProportions { | |
public float HeightProportions; | |
public float WidthProportions; | |
public float TopProportions; | |
public float LeftProportions; | |
} | |
CtrlProportions[] ProportionsArray; | |
private void Form1_Load(object sender, EventArgs e) { | |
Application.DoEvents(); | |
ProportionsArray = new CtrlProportions[Controls.Count]; | |
for (int I = 0; I <= Controls.Count - 1; I++) { | |
ProportionsArray[I].HeightProportions = (float) Controls[I].Height / this.Height; | |
ProportionsArray[I].WidthProportions = (float) Controls[I].Width / this.Width; | |
ProportionsArray[I].TopProportions = (float) Controls[I].Top / this.Height; | |
ProportionsArray[I].LeftProportions = (float) Controls[I].Left / this.Width; | |
} | |
} | |
private void Form1_Resize(object sender, System.EventArgs e) { | |
for (int I = 0; I <= Controls.Count - 1; I++) { | |
Controls[I].Left = (int)(ProportionsArray[I].LeftProportions * this.Width); | |
Controls[I].Top = (int)(ProportionsArray[I].TopProportions * this.Height); | |
Controls[I].Width = (int)(ProportionsArray[I].WidthProportions * this.Width); | |
Controls[I].Height = (int)(ProportionsArray[I].HeightProportions * this.Height); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment