Example #1
0
 public bool CanDelete <T>(T item) where T : IEntity
 {
     if (typeof(T) == typeof(Aircraft))
     {
         return(Flights.All(x => x.Aircraft != item as Aircraft));
     }
     if (typeof(T) == typeof(AcType))
     {
         return(Lookups.Aircraft.All(x => x.AcType != item as AcType));
     }
     if (typeof(T) == typeof(Airfield))
     {
         return(!Flights.Any(x => x.From == item as Airfield || x.To == item as Airfield));
     }
     return(true);
 }
        private void RenderMap()
        {
            BmpPlanner.Children.Clear();

            if (RenderWeatherConditions)
            {
                BmpPlanner.Children.Add(new MapTileLayer()
                {
                    TileSource = new MSLPTileSource(),
                    Opacity    = 1
                });
            }

            if (RenderFIRMS)
            {
                BmpPlanner.Children.Add(new MapTileLayer()
                {
                    TileSource = new FIRMSTileSource(),
                    Opacity    = 1
                });
            }

            MapLayer labelLayer = new MapLayer();

            int totalFireCount = 0;

            if (_draftMapModel != null)
            {
                RenderMap(_draftMapModel, labelLayer, null, null);
            }

            foreach (var aoi in AreasOfInterest)
            {
                RenderMap(aoi.MapModel, labelLayer, null, null);
            }

            foreach (var flight in Flights)
            {
                totalFireCount += RenderMap(flight.MapModel, labelLayer, "Potential fire", (ControlTemplate)Application.Current.Resources["FirePushPinTemplate"]);
            }

            if (RenderRedFlagAlerts)
            {
                foreach (var redflag in RedFlagsNotifications)
                {
                    RenderMap(redflag.MapModel, labelLayer, "Red flag warning", null);
                }
            }

            if (totalFireCount > 0)
            {
                var centerPoint = Flights.Where((f) => f.FireDetected).First().MapModel.Marks.First();
                BmpPlanner.SetView(new Location(centerPoint.Latitude, centerPoint.Longitude), Math.Max(MAP_ZOOM_LEVEL_AREA, BmpPlanner.ZoomLevel));

                FireAlert  = Visibility.Visible;
                AreaIsGood = Visibility.Collapsed;
                NotifyPropertyChanged("AreaIsGood");
                NotifyPropertyChanged("FireAlert");
            }
            else if (Flights.Any())
            {
                var centerPoint = Flights.First().MapModel.Polygons.First().CenterPosition();
                BmpPlanner.SetView(new Location(centerPoint.Latitude, centerPoint.Longitude), Math.Max(MAP_ZOOM_LEVEL_AREA, BmpPlanner.ZoomLevel));

                AreaIsGood = Visibility.Visible;
                FireAlert  = Visibility.Collapsed;
                NotifyPropertyChanged("AreaIsGood");
                NotifyPropertyChanged("FireAlert");
            }
            else if (AreasOfInterest.Any())
            {
                var centerPoint = AreasOfInterest.First().MapModel.Polygons.First().CenterPosition();
                BmpPlanner.SetView(new Location(centerPoint.Latitude, centerPoint.Longitude), Math.Max(MAP_ZOOM_LEVEL_AREA, BmpPlanner.ZoomLevel));
            }

            BmpPlanner.Children.Add(labelLayer);
        }