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); } }
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); } }
private void LoadElementInfo(Element element) { if (element == null) { throw new PeriodicTableException("Element does not exist!"); } ElementBorder.BorderBrush = new SolidColorBrush(Color.FromArgb(element.GroupBlock.Color.A, element.GroupBlock.Color.R, element.GroupBlock.Color.G, element.GroupBlock.Color.B)); LabelElectronicDistribution.Text = PeriodicTableUtils.GetElectronsPerLevel(element.AtomicNumber); Title = $"{(element.Name ?? "Element")} - Periodic Table"; LabelNumber.Text = element.AtomicNumber.ToString(); if (element.Symbol != null) { LabelSymbol.Text = element.Symbol; } LabelMass.Text = element.AtomicMass.ToString(); if (element.Name != null) { LabelName.Text = element.Name; } if (element.AtomicRadius != null) { LabelAtomicRadius.Text = element.AtomicRadius.ToString(); } if (element.MeltingPoint != null) { LabelMeltingPoint.Text = element.MeltingPoint.ToString() + " K"; } if (element.BoilingPoint != null) { LabelBoilingPoint.Text = element.BoilingPoint.ToString() + " K"; } if (element.Density != null) { LabelDensity.Text = element.Density.ToString() + " g/cm³"; } if (element.ElectronAffinity != null) { LabelElectronAffinity.Text = element.ElectronAffinity.ToString() + " kJ mol⁻¹"; } if (element.Electronegativity != null) { LabelElectronegativity.Text = element.Electronegativity.ToString(); } if (element.ElectronicConfiguration != null) { LabelElectronicConfiguration.Text = element.ElectronicConfiguration; LabelElectronicConfiguration.ToolTip = string.Join(" ", PeriodicTableUtils.APIElectronicDistribution(element.AtomicNumber)); } if (element.GroupBlock != null) { LabelGroupBlock.Text = element.GroupBlock.Name; } if (element.IonRadius != null) { LabelIonRadius.Text = element.IonRadius + " pm"; } if (element.IonizationEnergy != null) { LabelIonizationEnergy.Text = element.IonizationEnergy.ToString() + " kJ mol⁻¹"; } if (element.OxidationStates != null) { var oxStates = new List <string>(); foreach (var oxState in element.OxidationStates) { oxStates.Add(oxState > 0 ? $"+{oxState}" : $"{oxState}"); } LabelOxidationStates.Text = string.Join(", ", oxStates); } if (element.StandardState != null) { LabelStandardStates.Text = element.StandardState.Value; } if (element.VanDerWaalsRadius != null) { LabelVanDerWallsRadius.Text = element.VanDerWaalsRadius.ToString() + " pm"; } if (element.YearDiscovered != null) { LabelYearDiscovered.Text = element.YearDiscovered.ToString(); } else { LabelYearDiscovered.Text = "Ancient"; } }