git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1244 993157c7-ee19-0410-b2c4-bb4e9862e678

This commit is contained in:
chrisf
2007-07-14 09:40:10 +00:00
parent 4f500bff26
commit 1bb569e277
5 changed files with 49 additions and 22 deletions

View File

@@ -12,7 +12,47 @@ namespace OpenRa.Game
Size size;
MethodInvoker drawFunction;
public Region(Point location, Size size, MethodInvoker drawFunction)
static Size MakeSize(Viewport v, DockStyle d, int size)
{
switch (d)
{
case DockStyle.Top:
case DockStyle.Bottom:
return new Size(v.Width, size);
case DockStyle.Left:
case DockStyle.Right:
return new Size(size, v.Height);
default:
throw new NotImplementedException();
}
}
public static Region Create(Viewport v, DockStyle d, int size, MethodInvoker f)
{
Point topLeft = new Point(0, 0);
Point bottomRight = new Point(v.ClientSize);
Size s = MakeSize(v, d, size);
switch (d)
{
case DockStyle.Top:
case DockStyle.Left:
return new Region(topLeft, s, f);
case DockStyle.Right:
case DockStyle.Bottom:
Point origin = bottomRight; origin.Offset( -s.Width, -s.Height );
return new Region(origin, s, f);
default:
throw new NotImplementedException();
}
}
Region(Point location, Size size, MethodInvoker drawFunction)
{
this.location = location;
this.size = size;