public Startup(IDictionary<string,string> initParams) { InitializeComponent(); if (initParams.ContainsKey("authtoken")) { string[] authtoken = initParams["authtoken"].Split(':'); if (authtoken[0] == "true") { EarthwatcherRequests earthwatcherRequest = new EarthwatcherRequests(new Uri(Application.Current.Host.Source, "/api").ToString()); earthwatcherRequest.EarthwatcherReceived += earthwatcherRequest_EarthwatcherReceived; earthwatcherRequest.GetLogged(); } } else if (initParams.ContainsKey("api")) { ApiEw ew = new ApiEw(); ew.Api = initParams["api"]; ew.UserId = initParams["userId"]; ew.NickName = initParams["nickName"]; ew.AccessToken = initParams["accessToken"]; if (initParams.ContainsKey("secretToken")) ew.SecretToken = initParams["secretToken"]; EarthwatcherRequests earthwatcherRequest = new EarthwatcherRequests(new Uri(Application.Current.Host.Source, "/api").ToString()); earthwatcherRequest.LoginWithApi(ew); earthwatcherRequest.ApiEwReceived += earthwatcherRequest_ApiEwReceived; } if (initParams.ContainsKey("credentials")) { string[] credentials = initParams["credentials"].Split(':'); if (credentials.Length >= 2 && !string.IsNullOrEmpty(credentials[0]) && !string.IsNullOrEmpty(credentials[1])) { geohexcode = credentials[2].Trim(); EarthwatcherRequests earthwatcherRequest = new EarthwatcherRequests(new Uri(Application.Current.Host.Source, "/api").ToString()); earthwatcherRequest.EarthwatcherReceived += earthwatcherRequest_EarthwatcherReceived; password = credentials[1].Trim(); earthwatcherRequest.GetByName(credentials[0].Trim(), password); } else { Earthwatchers.UI.App.BackToLoginPage(); } } }
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 OkButton_Click(object sender, RoutedEventArgs e) { this.OkButton.IsEnabled = false; this.ErrorMessage.Foreground = new SolidColorBrush(Colors.Red); this.ErrorMessage.Text = string.Empty; if (step == "ChangePassword") { //Valido que los datos ingresados estén ok if (!this.CurrentPassword.Password.Equals(Current.Instance.Password)) { this.ErrorMessage.Text += Labels.UserPanel22; } if (this.CurrentPassword.Password.Equals(this.NewPassword.Password)) { if (this.ErrorMessage.Text != string.Empty) { this.ErrorMessage.Text += "\n"; } this.ErrorMessage.Text += Labels.UserPanel23; } if (!Regex.IsMatch(this.NewPassword.Password, @"^.*(?=.{6,})(?=.*[a-zA-Z])(?=.*\d).*$")) { if (this.ErrorMessage.Text != string.Empty) { this.ErrorMessage.Text += "\n"; } this.ErrorMessage.Text += Labels.UserPanel24; } if (!this.NewPassword.Password.Equals(this.NewPassword2.Password)) { if (this.ErrorMessage.Text != string.Empty) { this.ErrorMessage.Text += "\n"; } this.ErrorMessage.Text += Labels.UserPanel25; } if (string.IsNullOrEmpty(this.ErrorMessage.Text)) { this.loadinAnim.Visibility = System.Windows.Visibility.Visible; var req = new EarthwatcherRequests(Constants.BaseApiUrl); req.PasswordChanged += req_PasswordChanged; Earthwatcher ew = new Earthwatcher { Name = Current.Instance.Earthwatcher.Name, Password = this.NewPassword.Password }; req.ChangePassword(ew); } else { this.OkButton.IsEnabled = true; } } if (step == "ChangeRegional") { var username = Current.Instance.Username; var name = Current.Instance.Earthwatcher.Name; var ew = this.DataContext as Earthwatcher; // PARA CAMBIAR EL MAIL Current.Instance.Earthwatcher.MailChanged = true; if (Current.Instance.Username.Equals(ew.Name)) //Si no cambio el mail { ew.MailChanged = false; Current.Instance.Earthwatcher.MailChanged = false; } else if (!Regex.IsMatch(this.MailTextBox.Text, "^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$")) //Si no es un formato de mail valido { this.ErrorMessage.Text = "Ingrese un mail valido"; Current.Instance.Earthwatcher.Name = Current.Instance.Username; } if (ew == null) { this.ErrorMessage.Text = Labels.UserPanel26; } if (!Regex.IsMatch(this.NickNameTextBox.Text, "^[0-9a-zA-Z ]{0,20}$")) { if (this.ErrorMessage.Text != string.Empty) { this.ErrorMessage.Text += "\n"; } this.ErrorMessage.Text += Labels.UserPanel27; } if (string.IsNullOrEmpty(this.ErrorMessage.Text)) { this.loadinAnim.Visibility = System.Windows.Visibility.Visible; var req = new EarthwatcherRequests(Constants.BaseApiUrl); req.EarthwatcherUpdated += req_EarthwatcherUpdated; req.Update(ew); } else { this.OkButton.IsEnabled = true; } } }
private void Init() { earthwatcherRequest = new EarthwatcherRequests(Constants.BaseApiUrl); earthwatcherRequest.EarthwatcherReceived += EarthwatcherRequestEarthwatcherReceived; earthwatcherRequest.GetById(land.EarthwatcherId.ToString()); }
void ChangeLand() { this.loadinAnim.Visibility = System.Windows.Visibility.Visible; this.ReassignButtons.IsHitTestVisible = false; EarthwatcherRequests earthwatcherRequest = new EarthwatcherRequests(Constants.BaseApiUrl); earthwatcherRequest.LandReassigned += earthwatcherRequest_LandReassigned; //TODO: cuando este funcionando multiple plots hay que especificar cual reasigno earthwatcherRequest.ReassignLand(Current.Instance.Earthwatcher); }