示例#1
0
        public static string GetNameForMaterial(IMaterial material)
        {
            string name;

            if (material == null)
            {
                name = "<<null>>";
            }
            else if (material is MaterialWithUniformColor)
            {
                name = string.Format("{0} S={1}, M={2}, N={3}", material.Color.Name, material.Smoothness, material.Metalness, material.IndexOfRefraction);
            }
            else if (material is MaterialWithoutColorOrTexture)
            {
                name = string.Format("{0} S={1}, M={2}, N={3}", "NotColored", material.Smoothness, material.Metalness, material.IndexOfRefraction);
            }
            else if (material is MaterialInvisible)
            {
                name = "Invisible (No material)";
            }
            else
            {
                name = material.GetType().Name;
            }

            return(name);
        }
示例#2
0
        private bool AttemptExecution(IResourceRequest request)
        {
            double proposedNewAmountAvailable = m_material.Mass - request.QuantityDesired;

            if (proposedNewAmountAvailable < (-PermissibleOverbook) || proposedNewAmountAvailable > m_capacity)
            {
                return(false);
            }
            request.QuantityObtained = request.QuantityDesired;
            request.ResourceObtained = this;
            Substance material = m_material as Substance;

            if (material != null)
            {
                material.Remove(request.QuantityDesired);
            }
            else if (m_material is Mixture)
            {
                ((Mixture)m_material).RemoveMaterial(request.QuantityDesired);
            }
            else
            {
                Debug.Assert(false, "Unknown IMaterial type : " + m_material.GetType().Name);
            }
            request.ResourceObtainedFrom = this;
            return(true);
        }
        public static void AddMaterial(this ModelEnergyProperties modelEnergyCollection, IMaterial material)
        {
            modelEnergyCollection.Materials = modelEnergyCollection.Materials ?? new List <AnyOf <EnergyMaterial, EnergyMaterialNoMass, EnergyWindowMaterialGas, EnergyWindowMaterialGasCustom, EnergyWindowMaterialGasMixture, EnergyWindowMaterialSimpleGlazSys, EnergyWindowMaterialBlind, EnergyWindowMaterialGlazing, EnergyWindowMaterialShade> >();
            var exist = modelEnergyCollection.Materials.OfType <IMaterial>().Any(_ => _.Identifier == material.Identifier);

            if (exist)
            {
                return;
            }

            switch (material)
            {
            case EnergyMaterial em:
                modelEnergyCollection.Materials.Add(em);
                break;

            case EnergyMaterialNoMass em:
                modelEnergyCollection.Materials.Add(em);
                break;

            case EnergyWindowMaterialBlind em:
                modelEnergyCollection.Materials.Add(em);
                break;

            case EnergyWindowMaterialGas em:
                modelEnergyCollection.Materials.Add(em);
                break;

            case EnergyWindowMaterialGasCustom em:
                modelEnergyCollection.Materials.Add(em);
                break;

            case EnergyWindowMaterialGasMixture em:
                modelEnergyCollection.Materials.Add(em);
                break;

            case EnergyWindowMaterialGlazing em:
                modelEnergyCollection.Materials.Add(em);
                break;

            case EnergyWindowMaterialShade em:
                modelEnergyCollection.Materials.Add(em);
                break;

            case EnergyWindowMaterialSimpleGlazSys em:
                modelEnergyCollection.Materials.Add(em);
                break;

            default:
                throw new ArgumentException($"{material.GetType()}({material.Identifier}) is not added to model");
            }
        }
示例#4
0
		public static string GetNameForMaterial(IMaterial material)
		{
			string name;
			if (material == null)
			{
				name = "<<null>>";
			}
			else if (material is MaterialWithUniformColor)
			{
				name = string.Format("{0} S={1}, M={2}, N={3}", material.Color.Name, material.Smoothness, material.Metalness, material.IndexOfRefraction);
			}
			else if (material is MaterialWithoutColorOrTexture)
			{
				name = string.Format("{0} S={1}, M={2}, N={3}", "NotColored", material.Smoothness, material.Metalness, material.IndexOfRefraction);
			}
			else if (material is MaterialInvisible)
			{
				name = "Invisible (No material)";
			}
			else
			{
				name = material.GetType().Name;
			}

			return name;
		}