void ProcessSatellites(IMapIcon parent, IEnumerable<CelestialObject> objects)
 {
     foreach (var body in objects.Where(o => o.ParentObject == parent.Body.CelestialObjectID)) {
         var icon = new PlanetIcon(body, parent, this);
         MapCanvas.Children.Add(icon); // add planet/moon/asteroid to canvas
         if (body.Children.Any()) MapCanvas.Children.Add(new OrbitIcon(icon, this)); // add orbits to canvas
         ProcessSatellites(icon, objects);
     }
 }
Esempio n. 2
0
 void ProcessSatellites(IMapIcon parent, IEnumerable <CelestialObject> objects)
 {
     foreach (var body in objects.Where(o => o.ParentObject == parent.Body))
     {
         var icon = new PlanetIcon(body, parent, this);
         MapCanvas.Children.Add(icon); // add planet/moon/asteroid to canvas
         if (body.Children.Any())
         {
             MapCanvas.Children.Add(new OrbitIcon(icon, this));                      // add orbits to canvas
         }
         ProcessSatellites(icon, objects);
     }
 }
 void mapTab_MouseMove(object sender, MouseEventArgs e)
 {
     cursorPosition = e.GetPosition(mapTab.MapCanvas);
     var cursor = cursorPosition.Value;
     var planets = from planet in mapTab.MapCanvas.Children.OfType<PlanetIcon>()
                   let distance = Math.Sqrt(Math.Pow(cursor.X - planet.X, 2) + Math.Pow(cursor.Y - planet.Y, 2))
                   where distance < orderClickProximity/mapTab.ZoomControl.Zoom
                   orderby distance
                   select planet;
     cursorPlanet = planets.FirstOrDefault();
 }
 void mapTab_MouseLeftButtonDown(object sender, MouseButtonEventArgs _)
 {
     mapTab.MapCanvas.MouseLeftButtonDown -= mapTab_MouseLeftButtonDown;
     Application.Current.RootVisual.MouseMove -= mapTab_MouseMove;
     cursorPosition = null;
     if (cursorPlanet == null) return;
     var destination = cursorPlanet;
     cursorPlanet = null;
     var service = new PlanetWarsServiceClient();
     service.OrderFleetCompleted += (s, e) =>
         {
             transit.Fleets = e.Result;
             MessageBox.Show(cursorPlanet.Name + " called, they want their transit back!");
         };
     service.OrderFleetAsync(App.UserName, App.Password, transit.Fleets.FleetID, destination.Body.CelestialObjectID, 0);
 }