Пример #1
0
        public void InitializeMaterials()
        {
            listViewMaterials.Items.Clear();
            currentObjectMaterials.Clear();
            listViewMaterials.Items.Add(new CustomizeHeader("NAME", "IMAGE", "PRICE/M²", "SURFACE", "TOTAL", "IMPORT"));

            if (currentObject.GetMaterials().Count > 0)
            {
                currentObjectMaterials.AddRange(currentObject.GetMaterials());
                for (int i = 0; i < currentObjectMaterials.Count; i++)
                {
                    Material material      = currentObjectMaterials[i].Material;
                    double   surfaceNeeded = currentObject.GetTotalAreaPerTexture(i);
                    materialsPrice += Convert.ToDecimal(surfaceNeeded) * material.Price;
                    CustomizeMaterial customizeMaterial = new CustomizeMaterial(i, material, surfaceNeeded, false, true);

                    customizeMaterial.MouseLeftButtonDown += customizeMaterial_MouseLeftButtonDown;
                    customizeMaterial.StatusUpdated       += customizeMaterial_StatusUpdated;
                    listViewMaterials.Items.Add(customizeMaterial);
                }
            }
            else
            {
                List <String> textures = currentObject.GetTextures();
                materialsPrice = 0;
                for (int i = 0; i < textures.Count; i++)
                {
                    Material material = new Material();
                    material = GenericCategory.GetMaterialByImagePath(materials, textures[i]);
                    double surfaceNeeded = currentObject.GetTotalAreaPerTexture(i);

                    CustomizeMaterial customizeMaterial;
                    if (material != null)
                    {
                        materialsPrice   += Convert.ToDecimal(surfaceNeeded) * material.Price;
                        customizeMaterial = new CustomizeMaterial(i, material, surfaceNeeded, false, true);
                        currentObjectMaterials.Add(new WorldObjectMaterial(material, surfaceNeeded));
                    }
                    else
                    {
                        customizeMaterial = new CustomizeMaterial(i, new Material("", textures[i], 0), surfaceNeeded, true, true);
                    }

                    customizeMaterial.MouseLeftButtonDown += customizeMaterial_MouseLeftButtonDown;
                    customizeMaterial.StatusUpdated       += customizeMaterial_StatusUpdated;
                    listViewMaterials.Items.Add(customizeMaterial);
                }
            }



            Decimal totalPrice = materialsPrice + importedObject.InitialPrice +
                                 Convert.ToDecimal(currentTradeAllowance) * (materialsPrice + importedObject.InitialPrice) / 100;

            textBlockTotalPrice.Text = String.Format("{0:0.000}", totalPrice);
        }
Пример #2
0
        void customizeMaterial_StatusUpdated(object sender, EventArgs e)
        {
            CustomizeMaterial           customizeMaterial = sender as CustomizeMaterial;
            String                      imagePath         = customizeMaterial.ImagePath;
            ImportMaterialAutomatically wndImportMaterialAutomatically = new ImportMaterialAutomatically(materials, imagePath);

            wndImportMaterialAutomatically.ShowDialog();
            materials = wndImportMaterialAutomatically.GetMaterials();
            ExistingImportedMaterials = true;
            InitializeMaterials();
        }