public CountrySelector(string currentPlayingCountry, int currentPlayingRegion) { InitializeComponent(); _worldMapImage = Earthwatchers.UI.Resources.ResourceHelper.GetBitmap("/Resources/Images/world-map.png"); _defaultText = Labels.SelectCountryFromMap; _selectedCountry = null; _mapCoutries = new List<MapCountry>(); _mapCoutries.Add(new MapCountry("AR", Labels.ARGENTINA, Color.FromArgb(255, 0, 73, 126), Color.FromArgb(255, 0, 147, 254))); _mapCoutries.Add(new MapCountry("CA", Labels.CANADA, Color.FromArgb(255, 255, 216, 0), Color.FromArgb(255, 255, 246, 0))); _mapCoutries.Add(new MapCountry("CN", Labels.CHINA, Color.FromArgb(255, 127, 0, 0), Color.FromArgb(255, 224, 0, 0))); var currentCountry = GetCountryByCode(currentPlayingCountry); if (currentCountry == null) { this.mapImage.Source = _worldMapImage; this.txtSelectedCountry.Text = _defaultText; } else { this.mapImage.Source = currentCountry.GetMapImage(); this.txtSelectedCountry.Text = currentCountry.GetDescription(); } this.nextButton.IsEnabled = false; earthwatcherRequests = new EarthwatcherRequests(Constants.BaseApiUrl); landRequests = new LandRequests(Constants.BaseApiUrl); scoreRequests = new ScoreRequests(Constants.BaseApiUrl); regionRequests = new RegionRequests(Constants.BaseApiUrl); earthwatcherRequests.PlayingRegionChanged += earthwatcherRequests_PlayingRegionChanged; earthwatcherRequests.LandReassignedByPlayingRegion += earthwatcherRequest_LandReassignedByPlayingRegion; landRequests.LandsReceived += landRequests_LandsReceived; regionRequests.RegionsReceived += regionRequests_RegionsReceived; }
private void mapImage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { try { Color color = GetColorFromImage(e); MapCountry mapCountry = GetCountryByColor(color); if (mapCountry != null) { _selectedCountry = mapCountry; this.nextButton.IsEnabled = true; this.txtSelectedCountry.Text = mapCountry.GetDescription(); this.mapImage.Source = mapCountry.GetMapImage(); this.refColor.Visibility = System.Windows.Visibility.Visible; this.refColor.Fill = new SolidColorBrush(mapCountry.GetSecondaryColor()); } if (_selectedCountry != null) { if(_selectedCountry.IsOwnCode("AR")) //HACK, Como siempre es argentina, hardcodeo las regiones y sus Ids { _allRegionsForSelectedCountry = new List<Region>(); //Inicializacion de variables var selectRegionOption = new Region(0, Labels.SelectRegion, "AR"); var saltaRegionOption = new Region(1, "Salta", "AR"); var chacoRegionOption = new Region(2, "Chaco", "AR"); _allRegionsForSelectedCountry.Add(selectRegionOption); _allRegionsForSelectedCountry.Add(saltaRegionOption); _allRegionsForSelectedCountry.Add(chacoRegionOption); this.regionsCombo.ItemsSource = _allRegionsForSelectedCountry; this.regionsCombo.SelectedValue = selectRegionOption.Id; this.Regions.Visibility = Visibility.Visible; this.nextButton.IsEnabled = true; } else { regionRequests.GetRegionsByCountryCode(_selectedCountry.GetCode()); this.nextButton.IsEnabled = false; } } } catch(Exception ex) { throw ex; } }