public static SolarSystem parse(String fileName, double systemX, double systemY) { SolarSystem result = new SolarSystem(systemX / 2, systemY / 2); StreamReader reader = new StreamReader(fileName); while (!reader.EndOfStream) { result.add(Planet.parse(result, reader.ReadLine())); } return result; }
public Planet(string name, double distance, int timeInEarthDay, double angle, double radius, byte red, byte green, byte blue, SolarSystem system) { this.name = name; this.distance = distance; this.timeInEarthDay = timeInEarthDay; this.angle = angle; this.radius = radius; this.system = system; this.brush = new SolidColorBrush(Color.FromRgb(red, green, blue)); }
private void windowLoaded(object sender, RoutedEventArgs e) { this.solarSystem = SolarSystem.parse(PLANETS_DATA_INPUT_FILE, this.spaceCanvas.ActualWidth, this.spaceCanvas.ActualHeight); this.image.Source = this.solarSystem.drawOrbits(); foreach (Planet planet in this.solarSystem.Planets) { this.spaceCanvas.Children.Add(planet.buildPlanet()); Label meta = planet.buildMeta(); if (meta != null) { this.spaceCanvas.Children.Add(meta); } } timer.Start(); }
public static Planet parse(SolarSystem system, String line) { String[] items = line.Split(Planet.DELIMITER); String name = items[0]; double distance = Double.Parse(items[1]); int timeInEarthDay = Int32.Parse(items[2]); double angle = Double.Parse(items[3]); double radius = Double.Parse(items[4]); byte red = Byte.Parse(items[5]); byte green = Byte.Parse(items[6]); byte blue = Byte.Parse(items[7]); return new Planet(name, distance, timeInEarthDay, angle, radius, red, green, blue, system); }