Ejemplo n.º 1
0
        public ElementsModel()
        {
            List <TableItemModelBase> tableItems = new List <Models.TableItemModelBase>(_elements.ConvertAll(e => new ElementModel(e)));
            List <int> periods = new List <int>(), groups = new List <int>();

            tableItems.ForEach(e =>
            {
                ElementModel em = (ElementModel)e;
                int n           = periods.BinarySearch(em.Qualities.Period);
                if (n < 0)
                {
                    periods.Insert(~n, em.Qualities.Period);
                }
                n = groups.BinarySearch(em.Qualities.GroupBlock.Number);
                if (n < 0)
                {
                    groups.Insert(~n, em.Qualities.GroupBlock.Number);
                }
            });
            tableItems.AddRange(periods.ConvertAll(p => new PeriodLabelModel(p)));
            tableItems.AddRange(groups.ConvertAll(g => new GroupLabelModel(g)));
            tableItems.Add(new ElementCategoryKeyModel());
            tableItems.Add(new FShellPlaceholderModel(ElementCategory.Lanthanide));
            tableItems.Add(new FShellPlaceholderModel(ElementCategory.Actinide));
            tableItems.Add(new ElementDetailModel());
            tableItems.Add(new PPButtonModel());
            TableItems = tableItems;
        }