public LayerElementListItem(DatabaseDataContext database, LayerElement layerElement) { Isotope initialIsotope = layerElement.Isotope; LayerElement = layerElement; Elements = new ObservableCollection<Element>(database.Elements.ToList()); Isotopes = new ObservableCollection<Isotope>(); if (layerElement.Isotope!=null) SelectedElement = layerElement.Isotope.Element; SelectedIsotope = initialIsotope; }
private void detach_LayerElements(LayerElement entity) { this.SendPropertyChanging(); entity.Isotope = null; }
partial void DeleteLayerElement(LayerElement instance);
partial void UpdateLayerElement(LayerElement instance);
partial void InsertLayerElement(LayerElement instance);
private void attach_LayerElements(LayerElement entity) { this.SendPropertyChanging(); entity.Material = this; }
/// <summary> /// Function that calculates the atomic density of an <see cref="LayerElement"/> inside a <see cref="Layer"/>. /// </summary> /// <param name="layer">The <see cref="Layer"/> containing the <see cref="LayerElement"/>.</param> /// <param name="layerElement">The <see cref="LayerElement"/> which atomic density is calulated.</param> /// <returns></returns> private double CalculateAtomicDensity(Layer layer, LayerElement layerElement) { double MassOfMolecule = 0; foreach (LayerElement l in layer.LayerElements) MassOfMolecule += l.Isotope.Mass * l.StoichiometricFactor; double NumberOfMolecules = layer.Density / MassOfMolecule / 1.66053904E-24; double NumberOfAtomsInMolecule = layer.LayerElements.Select(x => x.StoichiometricFactor).ToList().Sum(); double AtomicDensityOfElement = NumberOfMolecules * layerElement.StoichiometricFactor; Console.WriteLine("Atomic density of " + layerElement.Isotope.Element.LongName+ ": " + AtomicDensityOfElement); return AtomicDensityOfElement; }
/// <summary> /// Function that adds a new <see cref="LayerElement"/> to the selected <see cref="Layer"/>. /// </summary> public void _AddLayerElementCommand() { if (SelectedLayer == null) return; LayerElement newLayerElement = new LayerElement { MaterialID = SelectedMaterial.MaterialID, LayerID = SelectedLayer.LayerID, StoichiometricFactor = 1 }; LayerElements.Add(new LayerElementListItem(Database, newLayerElement)); SelectedLayer.LayerElements.Add(newLayerElement); SelectedMaterial.LayerElements.Add(newLayerElement); }