I'm currently tearing my hair out with this problem.
Where I'm up to:
I can
- Generate an image for each screen
- Create a mega-image for two screens next to each other.
- Setting this as a tiled wallpaper.
What I want to do:
- Support any number of monitors
- Support all offsets of monitors, such as monitors above, or below, or diagonal.
I have read this MSDN article and found it very helpful:
http://blogs.msdn.com/b/oldnewthing/archive/2007/09/24/5083738.aspx
But I am still stuck on the logic I need to use to:
- Calculate what size image I need for any variation of monitors
- Create the wallpaper applying the offset of monitors
My program is laid out as follows:
ScreenInfo Class:
public Bitmap ChosenWallPaper { get; private set; }
public Rectangle ScreenArea { get; private set; }
int ScreenNumber { get; set; }
public string ScreenDescription { get { return "Screen: " + ScreenNumber + " " + ScreenArea.ToString(); } }
public ScreenInfo(int screenNumber)
{
this.ScreenNumber = screenNumber;
ScreenArea = new Rectangle(Screen.AllScreens[screenNumber].Bounds.X, Screen.AllScreens[screenNumber].Bounds.Y, Screen.AllScreens[screenNumber].Bounds.Width, Screen.AllScreens[screenNumber].Bounds.Height);
}
ScreenCollection Class
public List<ScreenInfo> ScreenList { get; private set; }
public ScreenCollection()
{
ScreenList = new List<ScreenInfo>();
for (int i = 0; i < Screen.AllScreens.Count(); i++)
{
ScreenList.Add(new ScreenInfo(i));
}
}
public Rectangle CalculateMainBitmapSize()
{
}
The rest of my source code hasn't been implemented yet.
Thanks!
EDIT:
I've figured out how to represent two monitors with each other with some REALLY hacky, horrible code, but I'm starting to understand how the monitors are laid out a bit more...
private void SizeScreens()
{
pictureBox1.Height = Desktops.ScreenList[0].ScreenArea.Height / 10;
pictureBox1.Width = Desktops.ScreenList[0].ScreenArea.Width / 10;
pictureBox2.Height = Desktops.ScreenList[1].ScreenArea.Height / 10;
pictureBox2.Width = Desktops.ScreenList[1].ScreenArea.Width / 10;
}
private void PositionScreens()
{
Point Screen1Location = new Point(Desktops.ScreenList[0].ScreenArea.X,Desktops.ScreenList[0].ScreenArea.Y);
Point Screen2Location = new Point(Origin.X + (Desktops.ScreenList[1].ScreenArea.X / 10),Origin.Y + (Desktops.ScreenList[1].ScreenArea.Y / 10));
pictureBox1.Location = Origin;
pictureBox2.Location = Screen2Location;
}