public void AlgorithmClick(object sender, EventArgs e) { Type selectedType = ((Algorithm)_comboBox.SelectedItem).Value; _algorithm = (IDesignAlgorithm)Activator.CreateInstance(selectedType); // testing code ProductModel chair = new ProductModel { Brand = "Ahrend", Width = 1, Height = 1, Type = "Chair" }; ProductModel table = new ProductModel { Brand = "TableCompany", Width = 2, Height = 1, Type = "Table" }; _products = _algorithm.Design(chair, table, 7, _model.Rows.GetLength(0), _model.Rows.GetLength(1), 0.5f); _panel.Invalidate(); }
/// <summary> /// Starts the selected algorithm. /// </summary> /// <param name="algorithm"></param> /// <param name="model1"></param> /// <param name="model2"></param> /// <param name="people"></param> /// <param name="margin"></param> public void StartAlgorithm(AlgorithmModel algorithm, ProductModel model1, ProductModel model2, int people, float margin) { // clear current placed products placedProducts.RemoveAll(x => x.Product.Name != "Muur" || x.Product.Name != "Raam" || x.Product.Name != "Deur" || x.Product.Name != "Stopcontact"); Type selectedType = algorithm.Value; IDesignAlgorithm algoInstance = (IDesignAlgorithm)Activator.CreateInstance(selectedType); List <ProductModel> result = algoInstance.Design(model1, model2, people, meterWidth, meterHeight, margin); foreach (ProductModel model in result) { // flip width and height, because the algorithm flips those because products are turned sideways int width = model.Width; model.Width = model.Height; model.Height = width; AddNewProduct(model, model.Location.X, model.Location.Y, model.Width, model.Height, true, 0); } }
public void AlgorithmClick(object sender, EventArgs e) { Type selectedType = ((Algorithm) _comboBox.SelectedItem).Value; _algorithm = (IDesignAlgorithm) Activator.CreateInstance(selectedType); // testing code ProductModel chair = new ProductModel { Brand = "Ahrend", Width = 1, Height = 1, Type = "Chair" }; ProductModel table = new ProductModel { Brand = "TableCompany", Width = 2, Height = 1, Type = "Table" }; _products = _algorithm.Design(chair, table, 7, _model.Rows.GetLength(0), _model.Rows.GetLength(1), 0.5f); _panel.Invalidate(); }