void ModelShotMovedEventHandler(object sender, ShotMovedEventArgs e)
 {
     if (!e.Disappeared)
     {
         if (!_shots.ContainsKey(e.Shot))
         {
             FrameworkElement shotControl = VehicleDefenceHelper.ShotControlFactory(e.Shot, Scale);
             _shots[e.Shot] = shotControl;
             _sprites.Add(shotControl);
         }
         else
         {
             FrameworkElement shotControl = _shots[e.Shot];
             VehicleDefenceHelper.MoveElementOnCanvas(shotControl, e.Shot.Location.X * Scale, e.Shot.Location.Y * Scale);
         }
     }
     else
     {
         if (_shots.ContainsKey(e.Shot))
         {
             FrameworkElement shotControl = _shots[e.Shot];
             _sprites.Remove(shotControl);
             _shots.Remove(e.Shot);
         }
     }
 }
 private void RecreateScanLines()
 {
     foreach (FrameworkElement scanLine in _scanLines)
     {
         if (_sprites.Contains(scanLine))
         {
             _sprites.Remove(scanLine);
         }
     }
     _scanLines.Clear();
     for (int y = 0; y < 300; y += 2)
     {
         FrameworkElement scanLine = VehicleDefenceHelper.ScanLineFactory(y, 400, Scale);
         _scanLines.Add(scanLine);
         _sprites.Add(scanLine);
     }
 }
        void ModelVehicleChangedEventHandler(object sender, MilitaryVehicleChangedEventArgs e)
        {
            if (!e.Killed)
            {
                if (e.MilitaryVehcileUpdated is Aircraft)
                {
                    Aircraft aircraft = e.MilitaryVehcileUpdated as Aircraft;
                    if (!_aircrafts.ContainsKey(aircraft))
                    {
                        FrameworkElement aircraftControl = VehicleDefenceHelper.AircraftControlFactory(aircraft, Scale);
                        _aircrafts[aircraft] = aircraftControl;
                        _sprites.Add(aircraftControl);
                    }
                    else
                    {
                        FrameworkElement aircraftControl = _aircrafts[aircraft];
                        VehicleDefenceHelper.MoveElementOnCanvas(aircraftControl, aircraft.Location.X * Scale, aircraft.Location.Y * Scale);
                        VehicleDefenceHelper.ResizeElement(aircraftControl, aircraft.Size.Width * Scale, aircraft.Size.Height * Scale);
                    }
                }
                else if (e.MilitaryVehcileUpdated is Player)
                {
                    if (_playerFlashing)
                    {
                        _playerFlashing = false;
                        AnimatedImage control = _playerControl as AnimatedImage;
                        if (control != null)
                        {
                            control.StopFlashing();
                        }
                    }

                    Player player = e.MilitaryVehcileUpdated as Player;
                    if (_playerControl == null)
                    {
                        _playerControl = VehicleDefenceHelper.PlayerControlFactory(player, Scale);
                        _sprites.Add(_playerControl);
                    }
                    else
                    {
                        VehicleDefenceHelper.MoveElementOnCanvas(_playerControl, player.Location.X * Scale, player.Location.Y * Scale);
                        VehicleDefenceHelper.ResizeElement(_playerControl, player.Size.Width * Scale, player.Size.Height * Scale);
                    }
                }
            }
            else
            {
                if (e.MilitaryVehcileUpdated is Aircraft)
                {
                    Aircraft aircraft = e.MilitaryVehcileUpdated as Aircraft;
                    if (!_aircrafts.ContainsKey(aircraft))
                    {
                        return;
                    }
                    AnimatedImage aircraftControl = _aircrafts[aircraft] as AnimatedImage;
                    if (aircraftControl != null)
                    {
                        aircraftControl.AircraftShot();
                        _shotAircrafts[aircraftControl] = DateTime.Now;
                        _aircrafts.Remove(aircraft);
                    }
                }
                else if (e.MilitaryVehcileUpdated is Player)
                {
                    AnimatedImage control = _playerControl as AnimatedImage;
                    if (control != null)
                    {
                        control.StartFlashing();
                    }
                    _playerFlashing = true;
                }
            }
        }