I have 4 images that are of decreasing size down the screen. The composition of these images and their relation to each other must appear the same on all possible screen resolutions, with specific regards to their size, and their margins. In other words, the height, width and margins must all be factors of the height and width of the screen. What is the generic formula if the only known values are the height and width of the screen?
I use the following to get the screen height and width:
string Width = Convert.ToString(HtmlPage.Window.Eval("screen.width"));
string Height = Convert.ToString(HtmlPage.Window.Eval("screen.height"));
Loading
Mc CombiPosted Mar 31, 2011, 3:15 AM
The images are all square, right-aligned and top-aligned, so I only need to set the margins from the top and right (left and bottom margins = 0), and use a single value for height and width.
I use the following to get the resolution:
string Width = Convert.ToString(HtmlPage.Window.Eval("screen.width"));
string Height = Convert.ToString(HtmlPage.Window.Eval("screen.height"));
Sam HobbsPosted Mar 31, 2011, 2:42 AM
Does that answer your question?
Update: Oooops looks like Frogleg beat me to it. I assume his answer is better than mine.
FroglegPosted Mar 31, 2011, 2:25 AM
public partial class Form1 : Form
{
int deskHeight;
int deskWidth;
double ratio = 0.25;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
deskHeight = Screen.PrimaryScreen.Bounds.Height;
deskWidth = Screen.PrimaryScreen.Bounds.Width;
label3.Text = ("Screen resolution = " + Convert.ToString(deskWidth) + " x "+ Convert.ToString(deskHeight));
pictureBox1.Width = Convert.ToInt32((double)deskWidth * ratio);
pictureBox1.Height = Convert.ToInt32((double)deskHeight * ratio);
}
}