public void AddViewRect(ViewRect viewRect) { ViewRect v = GetViewRect(); v.Add(viewRect); SetViewRect(v); }
static ViewRect() { ViewRect empty = new ViewRect(); empty.IsEmpty = true; Empty = empty; }
public void Add(ViewRect v) { int smallestRight = v.Width + v.X < Width + X ? v.Width + v.X : Width + X; int smallestBottom = v.Height + v.Y < Height + Y ? v.Height + v.Y : Height + Y; X = v.X > X ? v.X : X; Y = v.Y > Y ? v.Y : Y; Width = smallestRight - X; Height = smallestBottom - Y; }
public void SetViewRect(ViewRect viewRect) { Viewport vp = GraphicsDevice.Viewport; vp.X = viewRect.X; vp.Y = viewRect.Y; vp.Width = viewRect.Width; vp.Height = viewRect.Height; if (vp.X < 0) { vp.X = 0; } if (vp.Y < 0) { vp.Y = 0; } if (vp.X >= graphicsManager.ScreenWidth) { vp.X = graphicsManager.ScreenWidth - 2; vp.Width = 1; } if (vp.Y >= graphicsManager.ScreenHeight) { vp.Y = graphicsManager.ScreenHeight - 2; vp.Height = 1; } if (vp.X + vp.Width >= graphicsManager.ScreenWidth) { vp.Width = graphicsManager.ScreenWidth - vp.X - 1; } if (vp.Y + vp.Height >= graphicsManager.ScreenHeight) { vp.Height = graphicsManager.ScreenHeight - vp.Y - 1; } if (vp.Width < 1) { vp.Width = 1; ViewportIsInvalid = true; } if (vp.Height < 1) { vp.Height = 1; ViewportIsInvalid = true; } GraphicsDevice.Viewport = vp; }
public ViewRect AddGet(ViewRect v) { v.Add(this); return(v); }