private void SetupPlanetShapes() { foreach (SpaceObject s in solarSystem) { if (s is Planet && s is not Moon) { Planet p = s as Planet; p.orbit = new Ellipse(); p.orbit.Name = "Orbit"; //til bruk for å skjule dei p.orbit.Stroke = new SolidColorBrush(Colors.Black); myCanvas.Children.Add(p.orbit); p.shape = new Ellipse(); p.shape.Name = p.Name; //p.shape.Name = p.Name; p.shape.Fill = new SolidColorBrush(p.Color); int shapeRadius = SpaceScalingHelper.ObjectRadiusScaling(myWindow.Width, p.ObjectRadius); p.shape.Height = shapeRadius; p.shape.Width = shapeRadius; p.shape.MouseDown += Planet_MouseDown; myCanvas.Children.Add(p.shape); //lagar tekstboks for planetnamnet p.shapeText = new TextBlock(); p.shapeText.Background = Brushes.AntiqueWhite; p.shapeText.TextAlignment = TextAlignment.Center; p.shapeText.Inlines.Add(new Bold(new Run(p.Name))); p.shapeText.MouseDown += Planet_MouseDown; myCanvas.Children.Add(p.shapeText); //lagar orbit p.CalcPos(0); //detaljert info: p.infoShape = new Ellipse(); p.infoShape.Fill = new SolidColorBrush(p.Color); //shapeRadius = SpaceScalingHelper.ObjectRadiusScaling(myWindow.Width, p.ObjectRadius); TODO ny metode her!! p.infoShape.Height = 100; p.infoShape.Width = 100; //lagar tekstboks for planetnamnet p.infoText = new TextBlock(); p.infoText.Background = Brushes.AntiqueWhite; //p.shapeText.TextAlignment = TextAlignment.Center; p.infoText.Inlines.Add(new Run(p.Info())); } } }
/// <summary> /// Set opp solsystemet, berre sola + planetane for nå /// </summary> private void SetupSolarSystem() { Star s; Planet p; Moon m; solarSystem = new(); s = new Star("The Sun"); s.ObjectRadius = 695000; //radius i km - bruker polardiameter som utgangspunkt for alle s.Color = Colors.Yellow; solarSystem.Add(s); s.shape = new Ellipse(); s.shape.Fill = new SolidColorBrush(s.Color); int shapeRadius = SpaceScalingHelper.ObjectRadiusScaling(myWindow.Width, s.ObjectRadius); s.shape.Height = shapeRadius; s.shape.Width = shapeRadius; s.shapeText = new TextBlock(); s.shapeText = new TextBlock(); s.shapeText.Background = Brushes.AntiqueWhite; s.shapeText.TextAlignment = TextAlignment.Center; s.shapeText.Inlines.Add(new Bold(new Run(s.Name))); myCanvas.Children.Add(s.shape); myCanvas.Children.Add(s.shapeText); s.CalcPos(0); p = new Planet("Mercury", 57910, 88); p.ObjectRadius = 2440; p.Color = Colors.MediumVioletRed; solarSystem.Add(p); p = new Planet("Venus", 108200, 225); p.ObjectRadius = 6052; p.Color = Colors.Orange; solarSystem.Add(p); //Lagar jorda p = new Planet("Earth", 149600, 365); p.ObjectRadius = 6357; p.Color = Colors.Blue; solarSystem.Add(p); //lagar månen til jorda m = new Moon("The Moon", 384, 27); m.ObjectRadius = 1738; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); //mars p = new Planet("Mars", 227940, 687); p.ObjectRadius = 3378; p.Color = Colors.Red; solarSystem.Add(p); m = new Moon("Phobos", 9, 1); m.ObjectRadius = 11; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); m = new Moon("Deimos", 23, 2); m.ObjectRadius = 6; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); //jupiter, tar berre 4 månar? p = new Planet("Jupiter", 778330, 4333); p.ObjectRadius = 66855; p.Color = Colors.Gray; solarSystem.Add(p); m = new Moon("Io", 422, 2); m.ObjectRadius = 1821; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); m = new Moon("Europa", 671, 4); m.ObjectRadius = 1561; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); m = new Moon("Ganymede", 1070, 7); m.ObjectRadius = 2632; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); m = new Moon("Callisto", 1883, 17); m.ObjectRadius = 2410; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); //saturn + 3 første månar p = new Planet("Saturn", 1429400, 10760); p.ObjectRadius = 54364; p.Color = Colors.LightSlateGray; solarSystem.Add(p); m = new Moon("Mimas", 186, 1); m.ObjectRadius = 196; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); m = new Moon("Enceladus", 238, 1); m.ObjectRadius = 249; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); m = new Moon("Tethys", 295, 2); m.ObjectRadius = 530; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); //uranus + 4 første månar p = new Planet("Uranus", 2879889, 39685); p.ObjectRadius = 24973; p.Color = Colors.Cyan; solarSystem.Add(p); m = new Moon("Ariel", 191, 3); m.ObjectRadius = 579; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); m = new Moon("Umbriel", 266, 4); m.ObjectRadius = 585; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); m = new Moon("Titania", 436, 9); m.ObjectRadius = 789; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); m = new Moon("Oberon", 583, 13); m.ObjectRadius = 762; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); //neptun + 3 første månar p = new Planet("Neptune", 4504300, 60190); p.ObjectRadius = 24341; p.Color = Colors.DarkBlue; solarSystem.Add(p); m = new Moon("Triton", 355, -6); m.ObjectRadius = 1350; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); m = new Moon("Nereid", 5513, 360); m.ObjectRadius = 170; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); m = new Moon("Naiad", 48, 1); m.ObjectRadius = 29; m.Color = Colors.Black; //todo farge! p.Moons.Add(m); solarSystem.Add(m); SetupPlanetShapes(); SetupMoonInfoShapes(); //p = new DwarfPlanet("Pluto", 5913520, 90550); solarSystem.FindAll(s => s is not Moon).ForEach(s => moveSolarSystem += s.CalcPos); }