public materials this[materials m]
 {
     get
     {
         if (Materials.Any(l => l == m))
         {
             return(Materials.First(l => l == m));
         }
         return(materials.none);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Transform <see cref="Product"/> and <see cref="Material"/> into <see cref="ElementTemplate"/>
        /// </summary>
        /// <returns>Return a list of <see cref="ElementTemplate"/> based on products and materials</returns>
        private List <ElementTemplate> Convert()
        {
            List <ElementTemplate> elements = new List <ElementTemplate>();

            if (((ComboBoxItem)CurrentPage.FilterbyComboBox.SelectedItem).Content.Equals("Construction materials") || ((ComboBoxItem)CurrentPage.FilterbyComboBox.SelectedItem).Content.Equals("All"))
            {
                foreach (var material in Materials)
                {
                    ElementTemplate element = new ElementTemplate
                    {
                        Label       = material.Label,
                        PriceString = material.Price + " €",
                        Quantity    = material.Quantity
                    };

                    elements.Add(element);
                }
            }

            if (((ComboBoxItem)CurrentPage.FilterbyComboBox.SelectedItem).Content.Equals("Final products") || ((ComboBoxItem)CurrentPage.FilterbyComboBox.SelectedItem).Content.Equals("All"))
            {
                foreach (var product in Products)
                {
                    var listMadeOf = new List <NeededProductTemplate>();
                    foreach (var matprod in MaterialsProducts)
                    {
                        if (matprod.IdProduct == product.Id)
                        {
                            var label    = Materials.First(x => x.Id == matprod.IdMaterial).Label;
                            var quantity = matprod.QuantityNeeded;
                            listMadeOf.Add(new NeededProductTemplate {
                                Material = label, QuantityNeeded = quantity
                            });
                        }
                    }

                    ElementTemplate element = new ElementTemplate
                    {
                        Label                = product.Label,
                        PriceString          = $"{product.Price:C}",
                        Quantity             = product.Quantity,
                        AvailableUntilString = $"⚠ Product available until : {product.AvailableUntil:D} ⚠",
                        ColorDate            = product.AvailableUntil >= DateTime.Today ? Brushes.Lime : Brushes.Red,
                        MadeOf               = listMadeOf
                    };

                    elements.Add(element);
                }
            }

            return(elements);
        }
Esempio n. 3
0
        public void LoadModel()
        {
            // モデルを読込
            Pmx = Args.Host.Connector.Pmx.GetCurrentState();

            // 材質を読込
            if (!Pmx.Material.Any())
            {
                throw new Exception("モデルに材質が含まれていません。");
            }
            Materials        = Pmx.Material.Select((material, i) => new Material(material, Pmx)).ToList();
            Commanders       = Materials.ToDictionary(m => m, _ => new CommandManager());
            Current.Material = Materials.First();
        }
Esempio n. 4
0
        internal void LoadUVMorph(IPXMorph morph)
        {
            if (!morph.IsUV)
            {
                throw new ArgumentException("UVモーフ以外のモーフが指定されました。");
            }

            var materialMap = new ConcurrentDictionary <IPXUVMorphOffset, Material>(morph.Offsets.ToDictionary(o => (IPXUVMorphOffset)o, _ => (Material)null));

            materialMap.Keys.AsParallel().ForAll(offset =>
            {
                materialMap[offset] = Materials.First(m => m.Vertices.Contains(offset.Vertex));
            });

            var offsetsGroupByMaterial = materialMap.GroupBy(p => p.Value, p => p.Key);

            foreach (var offsetGroup in offsetsGroupByMaterial)
            {
                Do(offsetGroup.Key, new CommandMoveVerticesByMorph(offsetGroup));
            }
        }
Esempio n. 5
0
 public static Material GetMaterial(string id) => Materials.Count(mat => mat.Id == id) != 0 ? Materials.First(mat => mat.Id == id) : null;
Esempio n. 6
0
 public Material GetMaterial(int id)
 {
     return(Materials.First(m => m.Id == id));
 }