Exemplo n.º 1
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            var elements = await ElementDAO.SelectAsync();

            foreach (var element in elements)
            {
                var gridElement = new GridElement
                {
                    AtomicNumber = element.AtomicNumber.ToString(),
                    Symbol       = element.Symbol,
                    BorderBrush  = new SolidColorBrush(Color.FromArgb(element.GroupBlock.Color.A, element.GroupBlock.Color.R, element.GroupBlock.Color.G, element.GroupBlock.Color.B))
                };

                var column = PeriodicTableUtils.GetGroup(element.AtomicNumber);
                var row    = PeriodicTableUtils.GetPeriod(element.AtomicNumber);

                if ((row == 1 && column >= 2) ||
                    (row <= 5 && column > 2))
                {
                    column += rowLock - PeriodicTableUtils.GetPeriodMaxE(row);
                }
                else if (column > 2)
                {
                    if (column < rowLock)
                    {
                        // Lanthanoid/actinoid are at row 8
                        row += 3;
                        column++;
                    }
                    else
                    {
                        // Bring the elements 14 columns back (removed all the lanthanoid/actinoid)
                        column -= 14;
                    }
                }

                Grid.SetRow(gridElement, (int)row - 1);
                Grid.SetColumn(gridElement, (int)column - 1);

                ElementsGrid.Children.Add(gridElement);
            }
        }
Exemplo n.º 2
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            var elements = await ElementDAO.SelectAsync();

            foreach (var element in elements)
            {
                var gridElement = new GridElement()
                {
                    Symbol      = element.Symbol,
                    BorderColor = Color.FromRgba(element.GroupBlock.Color.R, element.GroupBlock.Color.G, element.GroupBlock.Color.B, element.GroupBlock.Color.A)
                };

                var column = PeriodicTableUtils.GetGroup(element.AtomicNumber);
                var row    = PeriodicTableUtils.GetPeriod(element.AtomicNumber);

                if ((row == 1 && column >= 2) || (row <= 5 && column > 2))
                {
                    column += rowLock - PeriodicTableUtils.GetPeriodMaxE(row);
                }
                else if (column > 2)
                {
                    if (column < rowLock)
                    {
                        // Lanthanoid/actinoid are at row 8
                        row += 3;
                        column++;
                    }
                    else
                    {
                        // Bring the elements 14 columns back (removed all the lanthanoid/actinoid)
                        column -= 14;
                    }
                }

                ElementsGrid.Children.Add(gridElement, (int)column - 1, (int)row - 1);
            }
        }