Farben eingefügt, aber Grid passt noch garnicht

This commit is contained in:
OliverT87 2025-04-15 16:57:26 +02:00
parent 88d1580fe7
commit 3c9c8f0f7e
14 changed files with 343 additions and 274 deletions

View File

@ -1,19 +1,17 @@
using System.Collections.Generic; using System.Collections.ObjectModel;
using Project_Periodensystem.Model; using Project_Periodensystem.Model;
using Project_Periodensystem.Persistence; using Project_Periodensystem.Persistence;
namespace Project_Periodensystem.Controller namespace Project_Periodensystem.Controller
{ {
// Der Controller stellt der View Daten zur Verfügung und verwaltet die Verbindung zur Datenquelle.
public class PeriodensystemController public class PeriodensystemController
{ {
// Öffentliche Liste aller Elemente, die an die View gebunden werden kann public ObservableCollection<Element> Elements { get; }
public List<Element> Elements { get; }
// Konstruktor lädt beim Start alle Elemente aus der Persistence
public PeriodensystemController() public PeriodensystemController()
{ {
Elements = PeriodicTableData.Elements; // Gießt die statische List<> in eine ObservableCollection
Elements = new ObservableCollection<Element>(PeriodicTableData.Elements);
} }
} }
} }

View File

@ -25,10 +25,12 @@ namespace Project_Periodensystem.Model
// Serie oder Gruppe, zu der das Element gehört (z.B. "Halogen", "Alkalimetall") // Serie oder Gruppe, zu der das Element gehört (z.B. "Halogen", "Alkalimetall")
public string Series { get; set; } public string Series { get; set; }
public int Row { get; set; }
public int Column { get; set; }
// Konstruktor: Erzeugt ein neues Element-Objekt mit allen relevanten Eigenschaften. // Konstruktor: Erzeugt ein neues Element-Objekt mit allen relevanten Eigenschaften.
public Element(int atomicNumber, string symbol, string elementname, double atomicWeight, public Element(int atomicNumber, string symbol, string elementname, double atomicWeight,
double electronegativity, double density, string series) double electronegativity, double density, string series, int row, int column)
{ {
// Weist den Eigenschaften beim Erzeugen eines Objekts die übergebenen Werte zu // Weist den Eigenschaften beim Erzeugen eines Objekts die übergebenen Werte zu
AtomicNumber = atomicNumber; AtomicNumber = atomicNumber;
@ -38,6 +40,8 @@ namespace Project_Periodensystem.Model
Electronegativity = electronegativity; Electronegativity = electronegativity;
Density = density; Density = density;
Series = series; Series = series;
Row = row;
Column = column;
} }
} }
} }

View File

@ -1,132 +1,150 @@
using System.Collections.Generic; // Importiert die Generics-Bibliothek, die für die Verwendung von Listen und anderen generischen Datentypen erforderlich ist using System.Collections.Generic;
using Project_Periodensystem.Model; // Importiert das Projektperiodensystem.Model-Namespace using Project_Periodensystem.Model;
namespace Project_Periodensystem.Persistence // Definiert den Namespace für die Datenpersistenz des Periodensystems namespace Project_Periodensystem.Persistence
{ {
public static class PeriodicTableData // Definiert eine statische Klasse für die Daten des Periodensystems public static class PeriodicTableData
{ {
// Eine statische Liste von Elementen, die das Periodensystem repräsentieren
public static List<Element> Elements { get; } = new List<Element> public static List<Element> Elements { get; } = new List<Element>
{ {
// Initialisierung der Elemente mit ihren Eigenschaften (Ordnungszahl, Symbol, Name, Atommasse, Elektronegativität, Dichte, Klassifikation) // Erste Periode
new Element(1, "H", "Wasserstoff", 1.008, 2.2, 8.988e-05, "Nichtmetall"), new Element(1, "H", "Wasserstoff", 1.008, 2.2, 0.000, "Nichtmetall", 0, 0),
new Element(2, "He", "Helium", 4.0026, 0.0, 0.0001786, "Edelgas"), new Element(2, "He", "Helium", 4.003, 0.0, 0.001, "Edelgas", 0, 17),
new Element(3, "Li", "Lithium", 6.94, 0.98, 0.534, "Metall"),
new Element(4, "Be", "Beryllium", 9.0122, 1.57, 1.85, "Metall"), // Zweite Periode
new Element(5, "B", "Bor", 10.81, 2.04, 2.34, "Halbmetall"), new Element(3, "Li", "Lithium", 6.940, 0.98, 0.534, "Metall", 1, 0),
new Element(6, "C", "Kohlenstoff", 12.011, 2.55, 2.267, "Nichtmetall"), new Element(4, "Be", "Beryllium", 9.012, 1.57, 1.850, "Metall", 1, 1),
new Element(7, "N", "Stickstoff", 14.007, 3.04, 0.0012506, "Nichtmetall"), new Element(5, "B", "Bor", 10.810, 2.04, 2.340, "Halbmetall", 1, 12),
new Element(8, "O", "Sauerstoff", 15.999, 3.44, 0.001429, "Nichtmetall"), new Element(6, "C", "Kohlenstoff", 12.011, 2.55, 2.267, "Nichtmetall", 1, 13),
new Element(9, "F", "Fluor", 18.998, 3.98, 0.001696, "Halogen"), new Element(7, "N", "Stickstoff", 14.007, 3.04, 0.001, "Nichtmetall", 1, 14),
new Element(10, "Ne", "Neon", 20.18, 0.0, 0.0008999, "Edelgas"), new Element(8, "O", "Sauerstoff", 15.999, 3.44, 0.001, "Nichtmetall", 1, 15),
new Element(11, "Na", "Natrium", 22.989, 0.93, 0.971, "Metall"), new Element(9, "F", "Fluor", 18.998, 3.98, 0.002, "Halogen", 1, 16),
new Element(12, "Mg", "Magnesium", 24.305, 1.31, 1.738, "Metall"), new Element(10, "Ne", "Neon", 20.180, 0.0, 0.001, "Edelgas", 1, 17),
new Element(13, "Al", "Aluminium", 26.982, 1.61, 2.698, "Metall"),
new Element(14, "Si", "Silizium", 28.085, 1.90, 2.329, "Halbmetall"), // Dritte Periode
new Element(15, "P", "Phosphor", 30.974, 2.19, 1.82, "Nichtmetall"), new Element(11, "Na", "Natrium", 22.990, 0.93, 0.971, "Metall", 2, 0),
new Element(16, "S", "Schwefel", 32.06, 2.58, 2.067, "Nichtmetall"), new Element(12, "Mg", "Magnesium", 24.305, 1.31, 1.738, "Metall", 2, 1),
new Element(17, "Cl", "Chlor", 35.45, 3.16, 0.003214, "Halogen"), new Element(13, "Al", "Aluminium", 26.982, 1.61, 2.698, "Metall", 2, 12),
new Element(18, "Ar", "Argon", 39.948, 0.0, 0.001784, "Edelgas"), new Element(14, "Si", "Silizium", 28.085, 1.90, 2.329, "Halbmetall", 2, 13),
new Element(19, "K", "Kalium", 39.098, 0.82, 0.862, "Metall"), new Element(15, "P", "Phosphor", 30.974, 2.19, 1.820, "Nichtmetall", 2, 14),
new Element(20, "Ca", "Calcium", 40.078, 1.0, 1.54, "Metall"), new Element(16, "S", "Schwefel", 32.060, 2.58, 2.067, "Nichtmetall", 2, 15),
new Element(21, "Sc", "Scandium", 44.956, 1.36, 2.989, "Metall"), new Element(17, "Cl", "Chlor", 35.450, 3.16, 0.003, "Halogen", 2, 16),
new Element(22, "Ti", "Titan", 47.867, 1.54, 4.54, "Metall"), new Element(18, "Ar", "Argon", 39.948, 0.0, 0.002, "Edelgas", 2, 17),
new Element(23, "V", "Vanadium", 50.942, 1.63, 6.11, "Metall"),
new Element(24, "Cr", "Chrom", 51.996, 1.66, 7.15, "Metall"), // Vierte Periode
new Element(25, "Mn", "Mangan", 54.938, 1.55, 7.44, "Metall"), new Element(19, "K", "Kalium", 39.098, 0.82, 0.862, "Metall", 3, 0),
new Element(26, "Fe", "Eisen", 55.845, 1.83, 7.874, "Metall"), new Element(20, "Ca", "Calcium", 40.078, 1.00, 1.540, "Metall", 3, 1),
new Element(27, "Co", "Cobalt", 58.933, 1.88, 8.86, "Metall"), new Element(21, "Sc", "Scandium", 44.956, 1.36, 2.989, "Metall", 3, 2),
new Element(28, "Ni", "Nickel", 58.693, 1.91, 8.912, "Metall"), new Element(22, "Ti", "Titan", 47.867, 1.54, 4.540, "Metall", 3, 3),
new Element(29, "Cu", "Kupfer", 63.546, 1.90, 8.96, "Metall"), new Element(23, "V", "Vanadium", 50.942, 1.63, 6.110, "Metall", 3, 4),
new Element(30, "Zn", "Zink", 65.38, 1.65, 7.14, "Metall"), new Element(24, "Cr", "Chrom", 51.996, 1.66, 7.150, "Metall", 3, 5),
new Element(31, "Ga", "Gallium", 69.723, 1.81, 5.91, "Metall"), new Element(25, "Mn", "Mangan", 54.938, 1.55, 7.440, "Metall", 3, 6),
new Element(32, "Ge", "Germanium", 72.63, 2.01, 5.323, "Halbmetall"), new Element(26, "Fe", "Eisen", 55.845, 1.83, 7.874, "Metall", 3, 7),
new Element(33, "As", "Arsen", 74.922, 2.18, 5.776, "Halbmetall"), new Element(27, "Co", "Cobalt", 58.933, 1.88, 8.860, "Metall", 3, 8),
new Element(34, "Se", "Selen", 78.971, 2.55, 4.809, "Nichtmetall"), new Element(28, "Ni", "Nickel", 58.693, 1.91, 8.912, "Metall", 3, 9),
new Element(35, "Br", "Brom", 79.904, 2.96, 3.122, "Halogen"), new Element(29, "Cu", "Kupfer", 63.546, 1.90, 8.960, "Metall", 3, 10),
new Element(36, "Kr", "Krypton", 83.798, 3.0, 0.003733, "Edelgas"), new Element(30, "Zn", "Zink", 65.380, 1.65, 7.140, "Metall", 3, 11),
new Element(37, "Rb", "Rubidium", 85.468, 0.82, 1.532, "Metall"), new Element(31, "Ga", "Gallium", 69.723, 1.81, 5.910, "Metall", 3, 12),
new Element(38, "Sr", "Strontium", 87.62, 0.95, 2.64, "Metall"), new Element(32, "Ge", "Germanium", 72.630, 2.01, 5.323, "Halbmetall", 3, 13),
new Element(39, "Y", "Yttrium", 88.906, 1.22, 4.472, "Metall"), new Element(33, "As", "Arsen", 74.922, 2.18, 5.776, "Halbmetall", 3, 14),
new Element(40, "Zr", "Zirconium", 91.224, 1.33, 6.52, "Metall"), new Element(34, "Se", "Selen", 78.971, 2.55, 4.809, "Nichtmetall", 3, 15),
new Element(41, "Nb", "Niob", 92.906, 1.6, 8.57, "Metall"), new Element(35, "Br", "Brom", 79.904, 2.96, 3.122, "Halogen", 3, 16),
new Element(42, "Mo", "Molybdän", 95.95, 2.16, 10.22, "Metall"), new Element(36, "Kr", "Krypton", 83.798, 3.00, 0.004, "Edelgas", 3, 17),
new Element(43, "Tc", "Technetium", 98, 1.9, 11, "Metall"), // Fünfte Periode
new Element(44, "Ru", "Ruthenium", 101.07, 2.2, 12.37, "Metall"), new Element(37, "Rb", "Rubidium", 85.468, 0.82, 1.532, "Metall", 4, 0),
new Element(45, "Rh", "Rhodium", 102.91, 2.28, 12.41, "Metall"), new Element(38, "Sr", "Strontium", 87.620, 0.95, 2.640, "Metall", 4, 1),
new Element(46, "Pd", "Palladium", 106.42, 2.20, 12.02, "Metall"), new Element(39, "Y", "Yttrium", 88.906, 1.22, 4.472, "Metall", 4, 2),
new Element(47, "Ag", "Silber", 107.87, 1.93, 10.49, "Metall"), new Element(40, "Zr", "Zirconium", 91.224, 1.33, 6.520, "Metall", 4, 3),
new Element(48, "Cd", "Cadmium", 112.41, 1.69, 8.65, "Metall"), new Element(41, "Nb", "Niob", 92.906, 1.60, 8.570, "Metall", 4, 4),
new Element(49, "In", "Indium", 114.82, 1.78, 7.31, "Metall"), new Element(42, "Mo", "Molybdän", 95.950, 2.16, 10.220, "Metall", 4, 5),
new Element(50, "Sn", "Zinn", 118.71, 1.96, 7.287, "Metall"), new Element(43, "Tc", "Technetium", 98.000, 1.90, 11.000, "Metall", 4, 6),
new Element(51, "Sb", "Antimon", 121.76, 2.05, 6.685, "Halbmetall"), new Element(44, "Ru", "Ruthenium", 101.070, 2.20, 12.370, "Metall", 4, 7),
new Element(52, "Te", "Tellur", 127.60, 2.1, 6.232, "Halbmetall"), new Element(45, "Rh", "Rhodium", 102.910, 2.28, 12.410, "Metall", 4, 8),
new Element(53, "I", "Iod", 126.90, 2.66, 4.93, "Halogen"), new Element(46, "Pd", "Palladium", 106.420, 2.20, 12.020, "Metall", 4, 9),
new Element(54, "Xe", "Xenon", 131.29, 2.6, 0.005887, "Edelgas"), new Element(47, "Ag", "Silber", 107.870, 1.93, 10.490, "Metall", 4, 10),
new Element(55, "Cs", "Caesium", 132.91, 0.79, 1.93, "Metall"), new Element(48, "Cd", "Cadmium", 112.410, 1.69, 8.650, "Metall", 4, 11),
new Element(56, "Ba", "Barium", 137.33, 0.89, 3.62, "Metall"), new Element(49, "In", "Indium", 114.820, 1.78, 7.310, "Metall", 4, 12),
new Element(57, "La", "Lanthan", 138.91, 1.10, 6.145, "Lanthanoid"), new Element(50, "Sn", "Zinn", 118.710, 1.96, 7.287, "Metall", 4, 13),
new Element(58, "Ce", "Cer", 140.12, 1.12, 6.770, "Lanthanoid"), new Element(51, "Sb", "Antimon", 121.760, 2.05, 6.685, "Halbmetall", 4, 14),
new Element(59, "Pr", "Praseodym", 140.91, 1.13, 6.773, "Lanthanoid"), new Element(52, "Te", "Tellur", 127.600, 2.10, 6.232, "Halbmetall", 4, 15),
new Element(60, "Nd", "Neodym", 144.24, 1.14, 7.007, "Lanthanoid"), new Element(53, "I", "Iod", 126.900, 2.66, 4.930, "Halogen", 4, 16),
new Element(61, "Pm", "Promethium", 145, 1.13, 7.26, "Lanthanoid"), new Element(54, "Xe", "Xenon", 131.293, 2.60, 0.006, "Edelgas", 4, 17),
new Element(62, "Sm", "Samarium", 150.36, 1.17, 7.52, "Lanthanoid"),
new Element(63, "Eu", "Europium", 151.96, 1.2, 5.243, "Lanthanoid"), // Sechste Periode
new Element(64, "Gd", "Gadolinium", 157.25, 1.2, 7.895, "Lanthanoid"), new Element(55, "Cs", "Caesium", 132.910, 0.79, 1.930, "Metall", 5, 0),
new Element(65, "Tb", "Terbium", 158.93, 1.1, 8.229, "Lanthanoid"), new Element(56, "Ba", "Barium", 137.330, 0.89, 3.620, "Metall", 5, 1),
new Element(66, "Dy", "Dysprosium", 162.50, 1.22, 8.55, "Lanthanoid"), // La-Lu gehört hier dazwischen, aber wir setzen Lanthanoide meist unten
new Element(67, "Ho", "Holmium", 164.93, 1.23, 8.795, "Lanthanoid"), new Element(72, "Hf", "Hafnium", 178.490, 1.30, 13.310, "Metall", 5, 3),
new Element(68, "Er", "Erbium", 167.26, 1.24, 9.066, "Lanthanoid"), new Element(73, "Ta", "Tantal", 180.950, 1.50, 16.654, "Metall", 5, 4),
new Element(69, "Tm", "Thulium", 168.93, 1.25, 9.321, "Lanthanoid"), new Element(74, "W", "Wolfram", 183.840, 2.36, 19.250, "Metall", 5, 5),
new Element(70, "Yb", "Ytterbium", 173.04, 1.1, 6.965, "Lanthanoid"), new Element(75, "Re", "Rhenium", 186.210, 1.90, 21.020, "Metall", 5, 6),
new Element(71, "Lu", "Lutetium", 174.97, 1.27, 9.84, "Lanthanoid"), new Element(76, "Os", "Osmium", 190.230, 2.20, 22.590, "Metall", 5, 7),
new Element(72, "Hf", "Hafnium", 178.49, 1.3, 13.31, "Metall"), new Element(77, "Ir", "Iridium", 192.220, 2.20, 22.560, "Metall", 5, 8),
new Element(73, "Ta", "Tantal", 180.95, 1.5, 16.654, "Metall"), new Element(78, "Pt", "Platin", 195.080, 2.28, 21.450, "Metall", 5, 9),
new Element(74, "W", "Wolfram", 183.84, 2.36, 19.25, "Metall"), new Element(79, "Au", "Gold", 196.970, 2.54, 19.320, "Metall", 5, 10),
new Element(75, "Re", "Rhenium", 186.21, 1.9, 21.02, "Metall"), new Element(80, "Hg", "Quecksilber", 200.590, 2.00, 13.534, "Metall", 5, 11),
new Element(76, "Os", "Osmium", 190.23, 2.2, 22.59, "Metall"), new Element(81, "Tl", "Thallium", 204.380, 1.62, 11.850, "Metall", 5, 12),
new Element(77, "Ir", "Iridium", 192.22, 2.2, 22.56, "Metall"), new Element(82, "Pb", "Blei", 207.200, 2.33, 11.340, "Metall", 5, 13),
new Element(78, "Pt", "Platin", 195.08, 2.28, 21.45, "Metall"), new Element(83, "Bi", "Bismut", 208.980, 2.02, 9.780, "Metall", 5, 14),
new Element(79, "Au", "Gold", 196.97, 2.54, 19.32, "Metall"), new Element(84, "Po", "Polonium", 209.000, 2.00, 9.196, "Metall", 5, 15),
new Element(80, "Hg", "Quecksilber", 200.59, 2.0, 13.534, "Metall"), new Element(85, "At", "Astat", 210.000, 2.20, 7.000, "Halogen", 5, 16),
new Element(81, "Tl", "Thallium", 204.38, 1.62, 11.85, "Metall"), new Element(86, "Rn", "Radon", 222.000, 0.00, 0.010, "Edelgas", 5, 17),
new Element(82, "Pb", "Blei", 207.2, 2.33, 11.34, "Metall"),
new Element(83, "Bi", "Bismut", 208.98, 2.02, 9.78, "Metall"), // Siebte Periode
new Element(84, "Po", "Polonium", 209, 2.0, 9.196, "Metall"), new Element(87, "Fr", "Francium", 223.000, 0.70, 1.870, "Metall", 6, 0),
new Element(85, "At", "Astat", 210, 2.2, 7, "Halogen"), new Element(88, "Ra", "Radium", 226.000, 0.90, 5.500, "Metall", 6, 1),
new Element(86, "Rn", "Radon", 222, 0.0, 0.00973, "Edelgas"), // Ac-Lr gehört hier dazwischen (Actinoide)
new Element(87, "Fr", "Francium", 223, 0.7, 1.87, "Metall"), new Element(104, "Rf", "Rutherfordium", 267.000, 0.00, 23.200, "Metall", 6, 3),
new Element(88, "Ra", "Radium", 226, 0.9, 5.5, "Metall"), new Element(105, "Db", "Dubnium", 270.000, 0.00, 29.300, "Metall", 6, 4),
new Element(89, "Ac", "Actinium", 227, 1.1, 10.07, "Actinoid"), new Element(106, "Sg", "Seaborgium", 271.000, 0.00, 35.000, "Metall", 6, 5),
new Element(90, "Th", "Thorium", 232.04, 1.3, 11.72, "Actinoid"), new Element(107, "Bh", "Bohrium", 270.000, 0.00, 37.100, "Metall", 6, 6),
new Element(91, "Pa", "Protactinium", 231.04, 1.5, 15.37, "Actinoid"), new Element(108, "Hs", "Hassium", 270.000, 0.00, 41.000, "Metall", 6, 7),
new Element(92, "U", "Uran", 238.03, 1.38, 18.95, "Actinoid"), new Element(109, "Mt", "Meitnerium", 278.000, 0.00, 27.000, "Metall", 6, 8),
new Element(93, "Np", "Neptunium", 237, 1.36, 20.45, "Actinoid"), new Element(110, "Ds", "Darmstadtium", 281.000, 0.00, 28.500, "Metall", 6, 9),
new Element(94, "Pu", "Plutonium", 244, 1.28, 19.84, "Actinoid"), new Element(111, "Rg", "Roentgenium", 282.000, 0.00, 32.000, "Metall", 6, 10),
new Element(95, "Am", "Americium", 243, 1.3, 13.67, "Actinoid"), new Element(112, "Cn", "Copernicium", 285.000, 0.00, 23.700, "Metall", 6, 11),
new Element(96, "Cm", "Curium", 247, 1.3, 13.51, "Actinoid"), new Element(113, "Nh", "Nihonium", 286.000, 0.00, 16.000, "Unbekannt", 6, 12),
new Element(97, "Bk", "Berkelium", 247, 1.3, 14.79, "Actinoid"), new Element(114, "Fl", "Flerovium", 289.000, 0.00, 14.000, "Unbekannt", 6, 13),
new Element(98, "Cf", "Californium", 251, 1.3, 15.1, "Actinoid"), new Element(115, "Mc", "Moscovium", 290.000, 0.00, 13.500, "Unbekannt", 6, 14),
new Element(99, "Es", "Einsteinium", 252, 1.3, 8.84, "Actinoid"), new Element(116, "Lv", "Livermorium", 293.000, 0.00, 12.900, "Unbekannt", 6, 15),
new Element(100, "Fm", "Fermium", 257, 1.3, 9.7, "Actinoid"), new Element(117, "Ts", "Tenness", 294.000, 0.00, 7.200, "Halogen", 6, 16),
new Element(101, "Md", "Mendelevium", 258, 1.3, 10.3, "Actinoid"), new Element(118, "Og", "Oganesson", 294.000, 0.00, 4.900, "Unbekannt", 6, 17),
new Element(102, "No", "Nobelium", 259, 1.3, 9.9, "Actinoid"),
new Element(103, "Lr", "Lawrencium", 262, 1.3, 15.6, "Actinoid"), // Lanthanoide (La bis Lu) → in Zeile 8 (4f-Block)
new Element(104, "Rf", "Rutherfordium", 267, 0.0, 23.2, "Metall"), new Element(57, "La", "Lanthan", 138.910, 1.10, 6.145, "Lanthanoid", 8, 0),
new Element(105, "Db", "Dubnium", 270, 0.0, 29.3, "Metall"), new Element(58, "Ce", "Cer", 140.120, 1.12, 6.770, "Lanthanoid", 8, 1),
new Element(106, "Sg", "Seaborgium", 271, 0.0, 35.0, "Metall"), new Element(59, "Pr", "Praseodym", 140.910, 1.13, 6.773, "Lanthanoid", 8, 2),
new Element(107, "Bh", "Bohrium", 270, 0.0, 37.1, "Metall"), new Element(60, "Nd", "Neodym", 144.240, 1.14, 7.007, "Lanthanoid", 8, 3),
new Element(108, "Hs", "Hassium", 270, 0.0, 41.0, "Metall"), new Element(61, "Pm", "Promethium", 145.000, 1.13, 7.260, "Lanthanoid", 8, 4),
new Element(109, "Mt", "Meitnerium", 278, 0.0, 27.0, "Metall"), new Element(62, "Sm", "Samarium", 150.360, 1.17, 7.520, "Lanthanoid", 8, 5),
new Element(110, "Ds", "Darmstadtium", 281, 0.0, 28.5, "Metall"), new Element(63, "Eu", "Europium", 151.960, 1.20, 5.243, "Lanthanoid", 8, 6),
new Element(111, "Rg", "Roentgenium", 282, 0.0, 32.0, "Metall"), new Element(64, "Gd", "Gadolinium", 157.250, 1.20, 7.895, "Lanthanoid", 8, 7),
new Element(112, "Cn", "Copernicium", 285, 0.0, 23.7, "Metall"), new Element(65, "Tb", "Terbium", 158.930, 1.10, 8.229, "Lanthanoid", 8, 8),
new Element(113, "Nh", "Nihonium", 286, 0.0, 16.0, "Unbekannt"), new Element(66, "Dy", "Dysprosium", 162.500, 1.22, 8.550, "Lanthanoid", 8, 9),
new Element(114, "Fl", "Flerovium", 289, 0.0, 14.0, "Unbekannt"), new Element(67, "Ho", "Holmium", 164.930, 1.23, 8.795, "Lanthanoid", 8, 10),
new Element(115, "Mc", "Moscovium", 290, 0.0, 13.5, "Unbekannt"), new Element(68, "Er", "Erbium", 167.260, 1.24, 9.066, "Lanthanoid", 8, 11),
new Element(116, "Lv", "Livermorium", 293, 0.0, 12.9, "Unbekannt"), new Element(69, "Tm", "Thulium", 168.930, 1.25, 9.321, "Lanthanoid", 8, 12),
new Element(117, "Ts", "Tenness", 294, 0.0, 7.2, "Unbekannt"), new Element(70, "Yb", "Ytterbium", 173.040, 1.10, 6.965, "Lanthanoid", 8, 13),
new Element(118, "Og", "Oganesson", 294, 0.0, 4.9, "Unbekannt") new Element(71, "Lu", "Lutetium", 174.970, 1.27, 9.840, "Lanthanoid", 8, 14),
// Actinoide (Ac bis Lr) → in Zeile 9 (5f-Block)
new Element(89, "Ac", "Actinium", 227.000, 1.10, 10.070, "Actinoid", 9, 0),
new Element(90, "Th", "Thorium", 232.040, 1.30, 11.720, "Actinoid", 9, 1),
new Element(91, "Pa", "Protactinium", 231.040, 1.50, 15.370, "Actinoid", 9, 2),
new Element(92, "U", "Uran", 238.030, 1.38, 18.950, "Actinoid", 9, 3),
new Element(93, "Np", "Neptunium", 237.000, 1.36, 20.450, "Actinoid", 9, 4),
new Element(94, "Pu", "Plutonium", 244.000, 1.28, 19.840, "Actinoid", 9, 5),
new Element(95, "Am", "Americium", 243.000, 1.30, 13.670, "Actinoid", 9, 6),
new Element(96, "Cm", "Curium", 247.000, 1.30, 13.510, "Actinoid", 9, 7),
new Element(97, "Bk", "Berkelium", 247.000, 1.30, 14.790, "Actinoid", 9, 8),
new Element(98, "Cf", "Californium", 251.000, 1.30, 15.100, "Actinoid", 9, 9),
new Element(99, "Es", "Einsteinium", 252.000, 1.30, 8.840, "Actinoid", 9, 10),
new Element(100, "Fm", "Fermium", 257.000, 0.00, 9.700, "Actinoid", 9, 11),
new Element(101, "Md", "Mendelevium", 258.000, 0.00, 10.300, "Actinoid", 9, 12),
new Element(102, "No", "Nobelium", 259.000, 0.00, 9.900, "Actinoid", 9, 13),
new Element(103, "Lr", "Lawrencium", 262.000, 0.00, 15.600, "Actinoid", 9, 14)
}; };
} }
} }

View File

@ -0,0 +1,43 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Project_Periodensystem.View.Converters"
x:Class="Project_Periodensystem.View.Components.ElementTile"
Width="100" Height="120">
<UserControl.Resources>
<converters:SeriesToColorConverter x:Key="SeriesToColor" />
<converters:BoolToScaleXConverter x:Key="BoolToScaleXConverter" />
</UserControl.Resources>
<Border RenderTransformOrigin="0.5,0.5"
BorderBrush="Black" BorderThickness="1" CornerRadius="6" Margin="4" Background="{Binding Series, Converter={StaticResource SeriesToColor}}">
<Border.RenderTransform>
<ScaleTransform ScaleX="{Binding IsFlipped, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource BoolToScaleXConverter}}" />
</Border.RenderTransform>
<Grid>
<Grid Name="Front" IsVisible="{Binding !IsFlipped, RelativeSource={RelativeSource AncestorType=UserControl}}">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="4">
<TextBlock Text="{Binding AtomicNumber}" FontSize="12" />
<TextBlock Text="{Binding Symbol}" FontSize="24" FontWeight="Bold" />
<TextBlock Text="{Binding ElementName}" FontSize="12" />
</StackPanel>
</Grid>
<Grid Name="Back" IsVisible="{Binding IsFlipped, RelativeSource={RelativeSource AncestorType=UserControl}}">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="4">
<TextBlock Text="Masse: " FontSize="10"/>
<TextBlock Text="{Binding AtomicWeight}" FontSize="10" />
<TextBlock Text="EN: " FontSize="10"/>
<TextBlock Text="{Binding Electronegativity}" FontSize="10" />
<TextBlock Text="Dichte:" FontSize="10"/>
<TextBlock Text="{Binding Density}" FontSize="10" />
</StackPanel>
</Grid>
</Grid>
</Border>
</UserControl>

View File

@ -0,0 +1,27 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Media;
namespace Project_Periodensystem.View.Components
{
public partial class ElementTile : UserControl
{
public static readonly StyledProperty<bool> IsFlippedProperty =
AvaloniaProperty.Register<ElementTile, bool>(nameof(IsFlipped));
public bool IsFlipped
{
get => GetValue(IsFlippedProperty);
set => SetValue(IsFlippedProperty, value);
}
public ElementTile()
{
InitializeComponent();
// Optional: Klick per Code registrieren
this.PointerPressed += (_, __) => IsFlipped = !IsFlipped;
}
}
}

View File

@ -1,47 +0,0 @@
<!--
Dieses UserControl ist eine "Kachel" für ein einzelnes chemisches Element.
Es wird z.B. 118-mal innerhalb eines ItemsControl verwendet.
-->
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Project_Periodensystem.View.ElementTile"
Width="80" Height="100"> <!-- Feste Größe für eine Kachel -->
<!-- Rahmen um die Kachel -->
<Border Background="LightGray" <!-- Hintergrundfarbe (ggf. später dynamisch je nach Series) -->
BorderBrush="Black" <!-- Farbe des Rahmens -->
BorderThickness="1" <!-- Rahmendicke -->
CornerRadius="4" <!-- Abgerundete Ecken -->
Padding="4"> <!-- Innenabstand zum Rand -->
<!-- Inhalte werden vertikal zentriert angeordnet -->
<StackPanel HorizontalAlignment="Center">
<!-- 1. Zeile: Ordnungszahl (z.B. 1 für Wasserstoff) -->
<TextBlock Text="{Binding AtomicNumber}"
FontSize="12" />
<!-- 2. Zeile: Symbol (z.B. H für Wasserstoff), hervorgehoben -->
<TextBlock Text="{Binding Symbol}"
FontWeight="Bold"
FontSize="16" />
<!-- 3. Zeile: Element-Name (z.B. Wasserstoff) -->
<TextBlock Text="{Binding ElementName}"
FontSize="10" />
<!-- 4. Zeile: Atommasse -->
<TextBlock Text="{Binding AtomicWeight}"
FontSize="10" />
<!-- 5. Zeile: Elektronegativität -->
<TextBlock Text="{Binding Electronegativity}"
FontSize="10" />
<!-- 6. Zeile: Dichte -->
<TextBlock Text="{Binding Density}"
FontSize="10" />
</StackPanel>
</Border>
</UserControl>

View File

@ -1,15 +0,0 @@
// Namespace der Datei muss zu deiner Projektstruktur und XAML-Klasse passen
namespace Project_Periodensystem.View
{
// Diese Klasse ist der "Code-Behind" für die XAML-Datei ElementTile.xaml
// Sie erbt von Avalonia's UserControl und repräsentiert eine einzelne Kachel (ein Element)
public partial class ElementTile : UserControl
{
// Konstruktor wird aufgerufen, wenn ein neues ElementTile erstellt wird
public ElementTile()
{
InitializeComponent(); // Lädt und verbindet die XAML mit dem Code
}
}
}

View File

@ -0,0 +1,20 @@
using Avalonia.Data.Converters;
using System;
using System.Globalization;
namespace Project_Periodensystem.View.Converters
{
public class BoolToScaleXConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
bool flipped = value is bool b && b;
return flipped ? -1 : 1;
}
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}

View File

@ -0,0 +1,38 @@
using System;
using System.Globalization;
using Avalonia.Data.Converters;
namespace Project_Periodensystem.View.Converters
{
public class RowToYConverter : IValueConverter
{
private const double TileHeight = 80;
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is int row)
return row * TileHeight;
return 0;
}
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
throw new NotImplementedException();
}
public class ColumnToXConverter : IValueConverter
{
private const double TileWidth = 80;
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is int column)
return column * TileWidth;
return 0;
}
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Globalization;
using Avalonia.Data.Converters;
using Avalonia.Media;
namespace Project_Periodensystem.View.Converters
{
public class SeriesToColorConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is not string series)
return Brushes.Gray;
return series switch
{
"Nichtmetall" => Brushes.Green,
"Metall" => Brushes.DarkRed,
"Halbmetall" => Brushes.Orange,
"Edelgas" => Brushes.MediumPurple,
"Halogen" => Brushes.DeepPink,
"Lanthanoid" => Brushes.Blue,
"Actinoid" => Brushes.DarkBlue,
"Unbekannt" => Brushes.DimGray,
_ => Brushes.Black
};
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
throw new NotImplementedException();
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

View File

@ -1,59 +1,25 @@
<Window xmlns="https://github.com/avaloniaui" <Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Project_Periodensystem.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:components="clr-namespace:Project_Periodensystem.View.Components"
xmlns:views="clr-namespace:Project_Periodensystem.View"
mc:Ignorable="d" d:DesignWidth="1400" d:DesignHeight="900"
x:Class="Project_Periodensystem.View.MainWindow" x:Class="Project_Periodensystem.View.MainWindow"
Title="Periodensystem"> Width="1600" Height="900" Background="White">
<!-- Haupt-Layout mit Padding für Abstand --> <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<Grid Padding="12">
<!-- Zwei Zeilen: oben Titel + Suche, unten das Periodensystem -->
<Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <!-- Erste Zeile: automatisch so hoch wie nötig -->
<RowDefinition Height="*" /> <!-- Zweite Zeile: nimmt den restlichen Platz ein -->
</Grid.RowDefinitions>
<!-- Kopfzeile mit Titel und Suchfeld -->
<StackPanel Orientation="Horizontal"
Margin="0 0 0 12" <!-- Abstand nach unten -->
Spacing="12" <!-- Abstand zwischen Kind-Elementen -->
Grid.Row="0"> <!-- Platziert dieses Panel in der ersten Zeile -->
<!-- Überschrift -->
<TextBlock Text="Periodensystem der Elemente"
FontSize="24"
FontWeight="Bold" />
<!-- Eingabefeld für zukünftige Suche (noch ohne Funktion) -->
<TextBox Width="200" Watermark="Suche..." />
</StackPanel>
<!-- Hauptbereich mit Kacheln in einem ScrollViewer -->
<ScrollViewer Grid.Row="1"> <!-- Platziert im unteren Bereich -->
<!-- ItemsControl zeigt die Liste aller Elemente an -->
<ItemsControl Items="{Binding Elements}"> <ItemsControl Items="{Binding Elements}">
<!-- ItemsPanel definiert das Layout: hier ein 18-spaltiges Gitter -->
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<UniformGrid Columns="18" /> <Canvas Width="1800" Height="1000"/>
<!-- Wichtig: 18 Spalten, damit das Periodensystem "klassisch" dargestellt wird -->
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
<!-- Definiert, wie jedes einzelne Element aussehen soll -->
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<!-- Nutzt eine eigene Kachel-View für jedes Element --> <components:ElementTile
<views:ElementTile DataContext="{Binding}" /> Canvas.Left="{Binding Column, Converter={StaticResource ColumnToXConverter}}"
<!-- DataContext ist automatisch ein einzelnes Element-Objekt --> Canvas.Top="{Binding Row, Converter={StaticResource RowToYConverter}}"
DataContext="{Binding}" />
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
</ScrollViewer> </ScrollViewer>
</Grid>
</Window> </Window>

View File

@ -11,16 +11,14 @@ namespace Project_Periodensystem.View // Namespace entspricht deinem Projektordn
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
// Der Controller verwaltet die Daten und steuert das Verhalten (MVCP-Prinzip!) // Der Controller verwaltet die Daten und steuert das Verhalten (MVCP-Prinzip!)
private readonly PeriodensystemController _controller; private readonly PeriodensystemController? _controller;
// Konstruktor wird aufgerufen, wenn das Fenster erstellt wird // Konstruktor wird aufgerufen, wenn das Fenster erstellt wird
public MainWindow() public MainWindow()
{ {
InitializeComponent(); // Initialisiert die grafischen Komponenten aus XAML InitializeComponent(); // Initialisiert die grafischen Komponenten aus XAML
_controller = new PeriodensystemController();
_controller = new PeriodensystemController(); // Erstellt eine Instanz des Controllers DataContext = _controller; // <-- wichtig!
DataContext = _controller;
// Das Fenster (und alles darin) bekommt den Controller als Datenquelle (Binding-Kontext) // Das Fenster (und alles darin) bekommt den Controller als Datenquelle (Binding-Kontext)
// Dadurch funktionieren z.B. Bindings wie {Binding Elements} in der XAML // Dadurch funktionieren z.B. Bindings wie {Binding Elements} in der XAML
} }

View File

@ -1,45 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<!-- PropertyGroup enthält verschiedene Projekteinstellungen -->
<PropertyGroup> <PropertyGroup>
<!-- Definiert den Typ der zu erstellenden Anwendung, in diesem Fall eine Windows-Executable -->
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<!-- Gibt die Ziel-.NET-Framework-Version an -->
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<!-- Aktiviert nullable Referenztypen zur Unterstützung der Nullsicherheitsprüfung -->
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<!-- Aktiviert die integrierte COM-Interop-Unterstützung -->
<BuiltInComInteropSupport>true</BuiltInComInteropSupport> <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<!-- Gibt die Anwendungsmanifestdatei an -->
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
<!-- Aktiviert die standardmäßige Verwendung von kompilierten Bindings in Avalonia -->
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault> <!-- Wichtig: Sagt MSBuild, dass Avalonia benutzt wird -->
<UseAvalonia>true</UseAvalonia>
<!-- Optional, für bessere Performance bei Bindings -->
<AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup> </PropertyGroup>
<!-- ItemGroup enthält Verweise auf NuGet-Pakete -->
<ItemGroup> <ItemGroup>
<!-- Verweis auf das Avalonia-Paket zum Erstellen plattformübergreifender UI-Anwendungen -->
<PackageReference Include="Avalonia" Version="11.2.6" /> <PackageReference Include="Avalonia" Version="11.2.6" />
<!-- Verweis auf das Avalonia.Desktop-Paket für Desktop-spezifische Funktionalitäten -->
<PackageReference Include="Avalonia.Desktop" Version="11.2.6" /> <PackageReference Include="Avalonia.Desktop" Version="11.2.6" />
<!-- Verweis auf das Avalonia.Themes.Fluent-Paket für Fluent-Design-System-Themen -->
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.6" /> <PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.6" />
<!-- Verweis auf das Avalonia.Fonts.Inter-Paket für die Inter-Schriftfamilie -->
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.6" /> <PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.6" />
<!-- Die folgende Bedingung ist erforderlich, um das Avalonia.Diagnostics-Paket aus dem Build-Output in der Release-Konfiguration zu entfernen. -->
<!-- Verweis auf das Avalonia.Diagnostics-Paket für Debugging und Diagnose -->
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.6"> <PackageReference Include="Avalonia.Diagnostics" Version="11.2.6">
<!-- Schließt die Avalonia.Diagnostics-Paketressourcen aus dem Build-Output in der Release-Konfiguration aus -->
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets> <IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<!-- Markiert alle Avalonia.Diagnostics-Paketressourcen als privat in der Release-Konfiguration -->
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets> <PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<!-- ItemGroup enthält Verweise auf andere Projekte und Dateien -->
<ItemGroup> <ItemGroup>
<!-- Verweis auf das Project_Periodensystem.Controller-Projekt -->
<ProjectReference Include="..\Project_Periodensystem.Controller\Project_Periodensystem.Controller.csproj" /> <ProjectReference Include="..\Project_Periodensystem.Controller\Project_Periodensystem.Controller.csproj" />
<!-- Verweis auf das Einbinden aller Dateien im Images-Verzeichnis -->
<ProjectReference Include="Images/**" />
</ItemGroup> </ItemGroup>
</Project> </Project>