1 public class Control 2 { 3 private int x = 0; 4 private int y = 0; 5 private int width = 0; 6 private int height = 0; 7 private int bottom, top, left, right; 8 private Rect rectangle; 9 10 public int X { get {return x;} } 11 public int Y { get { return y; } } 12 public int Width { get { return width; } } 13 public int Height { get { return height; } } 14 public int Bottom { get { return bottom; } } 15 public int Top { get { return top; } } 16 public int Left { get { return left; } } 17 public int Right { get { return right; } } 18 public Rect Rectangle { get { return rectangle; } } 19 20 21 public Control(int newW, int newH) 22 { 23 width = newW; 24 height = newH; 25 26 UpdateBounds(); 27 } 28 29 public Control(int newX, int newY, int newW, int newH) 30 { 31 x = newX; 32 y = newY; 33 width = newW; 34 height = newH; 35 36 UpdateBounds(); 37 } 38 39 private void UpdateBounds() 40 { 41 left = x; 42 top = y; 43 bottom = top + height; 44 right = left + width; 45 46 rectangle = new Rect(x, y, width, height); 47 } 48 49 public void SetWidth(int newW) 50 { 51 width = newW; 52 53 UpdateBounds(); 54 } 55 56 public void SetHeight(int newH) 57 { 58 height = newH; 59 60 UpdateBounds(); 61 } 62 63 public void SetX(int newX) 64 { 65 x = newX; 66 67 UpdateBounds(); 68 } 69 70 public void SetY(int newY) 71 { 72 y = newY; 73 74 UpdateBounds(); 75 } 76 } 77