public GridController(IView<string> view, GridFieldModel model)
        {
            _view = view;
            _model = model;
            _zoomCheckbox = false;

            _view.SetController(this);
            _panel = (Panel) _view.Get("Panel");
            _trackBar = (TrackBar) _view.Get("Trackbar");
            _trackBar.Enabled = false;
            _comboBox = (ComboBox) _view.Get("ComboBox");

            float tWidth = _panel.Width/_model.Rows.GetLength(1);
            float tHeight = _panel.Height/_model.Rows.GetLength(0);
            // Doing these checks to make sure that we don't have pixels left

            _tileWidth = (_panel.Width%_model.Rows.GetLength(1) != 0 // if width%length != 0
                ? (int) tWidth++ // then set to width++
                : (int) tWidth) // else set to width
                         *_model.Rows[0, 0].Width; // finally multiply by the tile width
            _tileHeight = (_panel.Width%_model.Rows.GetLength(0) != 0
                ? (int) tHeight++
                : (int) tHeight)
                          *_model.Rows[0, 0].Height;

            // only need to draw the grid once, so we can set it as the panel's background
            _panel.BackgroundImage = PaintBackground();
            _rectangle = new Rectangle(0, 0, 50, 50);
            _buffer = new Bitmap(_panel.Width, _panel.Height);

            PopulateCombobox();
            Resize(this, null);
        }
        public void AddItem_Test() {
            GridFieldModel grid = new GridFieldModel(10, 10, 0.5f);
            //ProductModel i1 = new ProductModel("Chair 1", "Atlas", "Chair", "Chair", "Deskchair", 2, 2, 2, "een stoel", 1);
            ProductModel i1 = new ProductModel(2, 2, 2);

            int x = 5; // x and y have to be the tilenumber that the user wants to add an item to.
            int y = 5; //

            grid.AddItem(5, 2, i1);

            bool found = false;
            for (int i = 0; i < grid.Rows.GetLength(0); i++)
                for (int j = 0; j < grid.Rows.GetLength(1); j++) if (grid[i, j].Product == i1) found = true;
            Assert.IsTrue(found);
        }
 public void ContainsSquares_Test() {
     GridFieldModel grid = new GridFieldModel(10, 10, 0.5f);
     for (int i = 0; i < grid.Rows.GetLength(0); i++)
         for (int j = 0; j < grid.Rows.GetLength(1); j++) Assert.IsInstanceOfType(grid[i, j], typeof (Tile));
 }
 public void CreateGrid_Test() {
     GridFieldModel grid = new GridFieldModel(10, 10, 0.5f); // the size of the room is given in meters
     Assert.IsTrue(grid.Rows.Length == 100);
 }