/// <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 AddToComboBox(AlgorithmModel algorithm) { comboBoxAlgorithms.Add(algorithm); ComboBox comboBox = (ComboBox) view.Get(ProductGrid.PropertyEnum.AlgorithmComboBox); comboBox.DataSource = comboBoxAlgorithms; comboBox.DisplayMember = "Name"; comboBox.ValueMember = "Value"; comboBox.DropDownStyle = ComboBoxStyle.DropDownList; }