Beispiel #1
0
        public void Initialize(double scale, Canvas canvas, Universe.Universe universe)
        {
            PlanetViewModels    = universe.Planets.Select(p => new PlanetViewModel(scale, p)).ToList();
            SpaceShipViewModels = universe.SpaceShips.Select(s => new SpaceShipViewModel(s)).ToList();
            Center        = MovingBodies[0];
            SelectedBody  = new Label("Current reference:", Center.Name.Text);
            ScaleText     = new Label("Scale:");
            TimeScaleText = new Label("Time scale:");
            Distance      = new Label("Distance:");
            Speed         = new Label("v:");
            Acceleration  = new Label("Δv:");

            AddToCanvas(canvas, SelectedBody, 0);
            AddToCanvas(canvas, ScaleText, 1);
            AddToCanvas(canvas, TimeScaleText, 2);
            AddToCanvas(canvas, Distance, 3);
            AddToCanvas(canvas, Speed, 4);
            AddToCanvas(canvas, Acceleration, 5);
            foreach (var body in MovingBodies)
            {
                body.AddToCanvas(canvas);
                body.Selected += OnSelectionChanged;
            }
        }
Beispiel #2
0
 private void OnSelectionChanged(MovingBodyViewModel sender, object args)
 {
     Center = sender;
     SelectedBody.SetText(sender.Name.Text);
 }