Exemplo n.º 1
0
        void customizeMaterial_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            int             index           = (sender as CustomizeMaterial).Index;
            Material        oldMaterial     = (sender as CustomizeMaterial).GetCurrentMaterial();
            GenericMaterial genericMaterial = new GenericMaterial(materials, index, false);

            genericMaterial.StatusUpdated += genericMaterial_StatusUpdated;
            genericMaterial.ShowDialog();
            Material currentMaterial = genericMaterial.GetCurrentMaterial();

            if (GenericCategory.GetMaterialByImagePath(materials, currentMaterial.FullPath) != null)
            {
                int i = GetIndexOfMaterial(oldMaterial);
                if (i == -1)
                {
                    i = currentObjectMaterials.Count;
                    currentObjectMaterials.Add(new WorldObjectMaterial(currentMaterial, currentObject.GetTotalAreaPerTextureByPath(currentMaterial.FullPath)));
                }
                else
                {
                    currentObjectMaterials[i] = new WorldObjectMaterial(currentMaterial, currentObjectMaterials[i].SurfaceNeeded);
                }
            }

            currentObject.SetMaterials(currentObjectMaterials);
            //importedObject.Materials[
            //importedObject.Materials.Add(currentMaterial);
            InitializeMaterials();
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        private bool CheckObjectMaterials()
        {
            List <String> textures = currentObject.GetTextures();

            for (int i = 0; i < textures.Count; i++)
            {
                if (GenericCategory.GetMaterialByImagePath(materials, textures[i]) == null)
                {
                    return(false);
                }
            }

            return(true);
        }