Esempio n. 1
0
        void HighlightFoundedStoryBoard_Completed(object sender, EventArgs e)
        {
            //TODO: animación y puntaje por si completó la colección
            if (hasCompletedCollection)
            {
                this.CompleteCollectionGrid.Visibility = System.Windows.Visibility.Visible;
                this.CloseButton.Visibility            = System.Windows.Visibility.Visible;
                this.CollectionCompleteStoryBoard.Begin();

                CollectionCompleted(this, new CollectionCompleteEventArgs {
                    CollectionId = _item.CollectionId, Points = ActionPoints.Points(ActionPoints.Action.CollectionComplete)
                });
            }
        }
Esempio n. 2
0
        public HelpWindow()
        {
            InitializeComponent();

            this.Loaded += HelpWindow_Loaded;

            this.txtPointsLogin.Text             = ActionPoints.Points(ActionPoints.Action.Login).ToString();
            this.txtPointsTutorialCompleted.Text = ActionPoints.Points(ActionPoints.Action.TutorialCompleted).ToString();
            this.txtPointsConfirmationAdded.Text = ActionPoints.Points(ActionPoints.Action.ConfirmationAdded).ToString();
            this.txtPointsLandStatusChanged.Text = ActionPoints.Points(ActionPoints.Action.LandStatusChanged).ToString();
            this.txtPointsShared.Text            = ActionPoints.Points(ActionPoints.Action.Shared).ToString();
            this.txtPointsDemandAuthorities.Text = ActionPoints.Points(ActionPoints.Action.DemandAuthorities).ToString();
            this.txtPointsGames.Text             = ActionPoints.Points(ActionPoints.Action.MiniJuegoI).ToString();
            this.txtVersionNumber.Text           = (Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).FirstOrDefault() as AssemblyFileVersionAttribute).Version;
        }
Esempio n. 3
0
        //Land Requests Handlers
        void landRequests_ConfirmationAdded(object sender, EventArgs e)
        {
            if ((ConfirmationSort)sender == ConfirmationSort.Confirm)
            {
                //Si el usuario antes habia dicho que habia desmonte y cambiode opinion, lo borro del listado de confirmaciones de desmontes
                if (selectedLand.Alerts.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                {
                    //Si no es el primero de la lista
                    if (selectedLand.Alerts.IndexOf("," + Current.Instance.Earthwatcher.Id.ToString()) > -1)
                    {
                        selectedLand.Alerts = selectedLand.Alerts.Replace("," + Current.Instance.Earthwatcher.Id.ToString(), "");
                    }
                    else  //Si es el primero
                    if (selectedLand.Alerts.IndexOf(Current.Instance.Earthwatcher.Id.ToString()) > -1)
                    {
                        selectedLand.Alerts = selectedLand.Alerts.Replace(Current.Instance.Earthwatcher.Id.ToString(), "");
                    }
                }
                //Agrego su verificacion
                if (!string.IsNullOrEmpty(selectedLand.OKs))
                {
                    selectedLand.OKs += ",";
                }
                selectedLand.OKs += Current.Instance.Earthwatcher.Id.ToString();
            }
            else
            {
                //Si el usuario antes habia dicho que NO habia desmonte y cambio de opinion, lo borro del listado de confirmaciones de Sin desmontes
                if (selectedLand.OKs.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                {
                    //Si no es el primero de la lista
                    if (selectedLand.OKs.IndexOf("," + Current.Instance.Earthwatcher.Id.ToString()) > -1)
                    {
                        selectedLand.OKs = selectedLand.OKs.Replace("," + Current.Instance.Earthwatcher.Id.ToString(), "");
                    }
                    else  //Si es el primero
                    if (selectedLand.OKs.IndexOf(Current.Instance.Earthwatcher.Id.ToString()) > -1)
                    {
                        selectedLand.OKs = selectedLand.OKs.Replace(Current.Instance.Earthwatcher.Id.ToString(), "");
                    }
                }
                //Agrego su verificacion
                if (!string.IsNullOrEmpty(selectedLand.Alerts))
                {
                    selectedLand.Alerts += ",";
                }
                selectedLand.Alerts += Current.Instance.Earthwatcher.Id.ToString();
            }

            //Si el usuario antes habia tenido actividad en la parcela lo borro del listado
            if (selectedLand.LastUsersWithActivity != null && selectedLand.LastUsersWithActivity.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.FullName)))
            {
                //Si ya estaba en la lista, lo saco
                if (selectedLand.LastUsersWithActivity.IndexOf("," + Current.Instance.Earthwatcher.FullName) > -1)
                {
                    selectedLand.LastUsersWithActivity = selectedLand.LastUsersWithActivity.Replace("," + Current.Instance.Earthwatcher.FullName, "");
                }
                else  //Si ya estaba en la lista y es el primero lo saco
                if (selectedLand.LastUsersWithActivity.IndexOf(Current.Instance.Earthwatcher.FullName) > -1)
                {
                    selectedLand.LastUsersWithActivity = selectedLand.LastUsersWithActivity.Replace(Current.Instance.Earthwatcher.FullName, "");
                }
            }
            //Lo vuelvo a agregar en el orden que corresponda
            if (!string.IsNullOrEmpty(selectedLand.LastUsersWithActivity))
            {
                selectedLand.LastUsersWithActivity += ", ";
            }
            selectedLand.LastUsersWithActivity += Current.Instance.Earthwatcher.FullName;

            bool isUserLand = Current.Instance.Earthwatcher.Lands.Any(x => x.Id == selectedLand.Id);
            bool hasConfirmedThisLandBeforeLastReset = Current.Instance.RegionScores.Any(x => x.Action.Equals(ActionPoints.Action.ConfirmationAdded.ToString()) && x.LandId == selectedLand.Id && x.Published > selectedLand.LastReset);

            if (!isUserLand && !hasConfirmedThisLandBeforeLastReset)
            {
                Current.Instance.AddScore.Add(new Score(Current.Instance.Earthwatcher.Id, ActionPoints.Action.ConfirmationAdded.ToString(), ActionPoints.Points(ActionPoints.Action.ConfirmationAdded), Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore, selectedLand.Id));
            }

            hexagonLayer.UpdateHexagonsInView();

            UpdateInfo(selectedLand.GeohexKey, true);
            ReportWindowConfirmationEnded(this, EventArgs.Empty);

            if (this.ShareGrid.Visibility == System.Windows.Visibility.Collapsed)
            {
                ShowShareControl();
            }
        }
Esempio n. 4
0
        private void DemandButton_Click(object sender, RoutedEventArgs e)
        {
            //Al hacer click redirige a la pagina de denuncias
            string basecamp;
            Uri    demandUri;

            if (Current.Instance.Earthwatcher.PlayingRegion == 1)
            {
                basecamp = "salta01";

                if (selectedLand.BasecampId != null)
                {
                    basecamp = selectedLand.BasecampId.ToString();
                }
                demandUri = new Uri(string.Format("http://greenpeace.org.ar/denuncias/index.php?id_ciberaccion={0}&mail={1}&area={2}&GeohexKey={3}&prev=0&lat={4}&long={5}", 5157, Current.Instance.Earthwatcher.Name, basecamp, selectedLand.GeohexKey, Math.Round(selectedLand.Latitude, 4), Math.Round(selectedLand.Longitude, 4)), UriKind.Absolute);
            }
            else
            {
                if (selectedLand.BasecampId != null)
                {
                    basecamp = selectedLand.BasecampId.ToString();
                }
                basecamp  = "chaco01";
                demandUri = new Uri(string.Format("http://greenpeace.org.ar/denuncias/index.php?id_ciberaccion={0}&mail={1}&area={2}&GeohexKey={3}&prev=0&lat={4}&long={5}", 0, Current.Instance.Earthwatcher.Name, basecamp, selectedLand.GeohexKey, Math.Round(selectedLand.Latitude, 4), Math.Round(selectedLand.Longitude, 4)), UriKind.Absolute);
            }
            this.DemandButton.NavigateUri = demandUri;

            //Agrega el score de demanda
            if (!Current.Instance.RegionScores.Any(x => x.Action.Equals(ActionPoints.Action.DemandAuthorities.ToString()) && x.LandId == selectedLand.Id))
            {
                Current.Instance.AddScore.Add(new Score(Current.Instance.Earthwatcher.Id, ActionPoints.Action.DemandAuthorities.ToString(), ActionPoints.Points(ActionPoints.Action.DemandAuthorities), Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore, selectedLand.Id));
                ReportWindowDemand(this, EventArgs.Empty);
                hexagonLayer.UpdateHexagonsInView();
            }
            //Agrega el score de Share
            else if (!Current.Instance.RegionScores.Any(x => x.Action.Equals(ActionPoints.Action.Shared.ToString()) && x.LandId == selectedLand.Id))
            {
                Current.Instance.AddScore.Add(new Score(Current.Instance.Earthwatcher.Id, ActionPoints.Action.Shared.ToString(), ActionPoints.Points(ActionPoints.Action.Shared), Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore, selectedLand.Id));
                ReportWindowDemand(this, EventArgs.Empty);
            }
        }
Esempio n. 5
0
 private void AddTwFbSharePoints()
 {
     if (!Current.Instance.RegionScores.Any(x => x.Action.Equals(ActionPoints.Action.Shared.ToString()) && x.LandId == selectedLand.Id && x.Published > DateTime.UtcNow.AddDays(-7)))
     {
         Current.Instance.AddScore.Add(new Score(Current.Instance.Earthwatcher.Id, ActionPoints.Action.Shared.ToString(), ActionPoints.Points(ActionPoints.Action.Shared), Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore, selectedLand.Id));
         ReportWindowDemand(this, EventArgs.Empty);
     }
 }
Esempio n. 6
0
        //public void Move()
        //{
        //    if (selectedLand == null)
        //        return;

        //    var spherical = SphericalMercator.FromLonLat(selectedLand.Longitude, selectedLand.Latitude);
        //    var point = Current.Instance.MapControl.Viewport.WorldToScreen(spherical.x, spherical.y);
        //    Margin = new Thickness(point.X + 70, point.Y - 30, 0, 0);
        //}
        private void SetLandStatusStatusChanged(object sender, EventArgs e)
        {
            if (status == LandStatus.Alert || status == LandStatus.Ok)
            {
                bool hasCheckedThisLandBeforeLastReset = Current.Instance.RegionScores.Any(x => x.Action.Equals(ActionPoints.Action.LandStatusChanged.ToString()) && x.LandId == selectedLand.Id && x.Published > selectedLand.LastReset);

                if (!hasCheckedThisLandBeforeLastReset)
                {
                    Current.Instance.AddScore.Add(new Score(Current.Instance.Earthwatcher.Id, ActionPoints.Action.LandStatusChanged.ToString(), ActionPoints.Points(ActionPoints.Action.LandStatusChanged), Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore, selectedLand.Id));
                }
            }

            ReportWindowLandStatusChanged(this, EventArgs.Empty);
            if (this.ShareGrid.Visibility == System.Windows.Visibility.Collapsed)
            {
                ShowShareControl();
            }
        }
Esempio n. 7
0
        void earthwatcherRequest_LandReassignedByPlayingRegion(object sender, EventArgs e)
        {
            Land land = sender as Land;

            try
            {
                if (land != null)
                {
                    //Cambios en memoria de lands
                    var oldLand = Current.Instance.Lands.Where(x => x.Id == Current.Instance.Earthwatcher.Lands.FirstOrDefault().Id).FirstOrDefault();
                    if (oldLand != null)
                    {
                        //Si no está en amarillo o en verde la saco
                        if (oldLand.LandStatus != LandStatus.Alert && oldLand.LandStatus != LandStatus.Ok)
                        {
                            Current.Instance.Lands.Remove(oldLand);
                            Current.Instance.LandInView.Remove(oldLand);
                        }
                        else
                        {   //Si es amarilla o verde la paso a greenpeace
                            oldLand.EarthwatcherId   = Configuration.GreenpeaceId;
                            oldLand.EarthwatcherName = Configuration.GreenpeaceName;
                            oldLand.IsPowerUser      = true;
                        }
                        //Saco del current instance del Ew la land que quiero cambiar
                        var oldEarthwatcherLand = Current.Instance.Earthwatcher.Lands.Where(x => x.Id == oldLand.Id).FirstOrDefault();
                        Current.Instance.Earthwatcher.Lands.Remove(oldEarthwatcherLand);
                    }
                    //si la land que me asignaron no esta en el current instance de lands, la agrega y se la agrega al Ew
                    if (!Current.Instance.Lands.Any(x => x.Id == land.Id))
                    {
                        Current.Instance.Lands.Add(land);
                        Current.Instance.Earthwatcher.Lands.Add(land);
                    }

                    //Actualizo en memoria la nueva region
                    Current.Instance.Region = _selectedRegion;

                    var hexagonLayer = Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername) as Earthwatchers.UI.Layers.HexagonLayer;

                    if (hexagonLayer != null)
                    {
                        hexagonLayer.AddHexagon(land);
                    }

                    if (land.IsTutorLand) //Is Tutor Land - All region is complete
                    {
                        //Muestro el mensaje, Deshabilito mi parcela
                        NotificationsWindow notificationsWindow = new NotificationsWindow(ActionPoints.Action.RegionCompleted.ToString());
                        notificationsWindow.Show();
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                //Traigo nuevamente las lands para el pais que estoy jugando
                landRequests.GetAll(Current.Instance.Earthwatcher.Id, Current.Instance.Earthwatcher.PlayingRegion);

                Earthwatcher earthwatcher = Current.Instance.Earthwatcher;

                if (land == null)
                {
                    MessageBox.Show(Labels.NoMoreLands);
                    ChangeCompleted(this, EventArgs.Empty);
                }
                else
                {
                    //Logueo el cambio de pais de juego
                    MapHelper.ZoomToHexagon(Current.Instance.MapControl, land.GeohexKey);
                    Current.Instance.AddScore.Add(new Score(earthwatcher.Id, ActionPoints.Action.PlayingRegionChanged.ToString(), ActionPoints.Points(ActionPoints.Action.PlayingRegionChanged), earthwatcher.PlayingRegion, Current.Instance.PrecisionScore, earthwatcher.Lands.FirstOrDefault().Id));
                    // Recibe el evento en mainpage y le asigna el puntaje
                    ChangeCompleted(this, EventArgs.Empty);
                }
            }
        }
Esempio n. 8
0
 private void NextButton_Click(object sender, EventArgs e)
 {
     step++;
     if (step > 2)
     {
         Current.Instance.AddScore.Add(new Score(Current.Instance.Earthwatcher.Id, ActionPoints.Action.ContextTutorialCompleted.ToString(), ActionPoints.Points(ActionPoints.Action.ContextTutorialCompleted), Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore));
         PointsAdded(this, EventArgs.Empty);
         this.Close();
     }
     else
     {
         TutorialText1.Visibility    = Visibility.Collapsed;
         TutorialText2.Visibility    = Visibility.Visible;
         DeforestationImg.Visibility = Visibility.Visible;
     }
 }
Esempio n. 9
0
        public void logSlInstall()
        {
            var connectionstring  = System.Configuration.ConfigurationManager.ConnectionStrings["EarthwatchersConnection"].ConnectionString;
            IScoreRepository repo = new ScoreRepository(connectionstring);
            Score            s    = new Score(17, ActionPoints.Action.Log.ToString(), ActionPoints.Points(ActionPoints.Action.Log), 0, 100, null, null, "SL_Install");

            repo.PostScore(s);
        }
Esempio n. 10
0
        private void Next1_Click(object sender, RoutedEventArgs e)
        {
            this.Next1.IsHitTestVisible = false;

            currentStep++;
            if (currentStep == 2)
            {
                this.Welcome2.Visibility = System.Windows.Visibility.Visible;
                this.Welcome2StoryBoard.Begin();

                Current.Instance.AddScore.Add(new Score(Current.Instance.Earthwatcher.Id, ActionPoints.Action.PreTutorialStep2.ToString(), ActionPoints.Points(ActionPoints.Action.PreTutorialStep2), Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore));
                PointsAdded(this, EventArgs.Empty);
            }
            else if (currentStep == 3)
            {
                this.Welcome1.Visibility = System.Windows.Visibility.Collapsed;
                this.Welcome3.Visibility = System.Windows.Visibility.Visible;
                this.Welcome3StoryBoard.Begin();

                Current.Instance.AddScore.Add(new Score(Current.Instance.Earthwatcher.Id, ActionPoints.Action.PreTutorialStep3.ToString(), ActionPoints.Points(ActionPoints.Action.PreTutorialStep3), Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore));
                PointsAdded(this, EventArgs.Empty);
            }
            else if (currentStep == 4)
            {
                this.Welcome2.Visibility = System.Windows.Visibility.Collapsed;
                this.Welcome4.Visibility = System.Windows.Visibility.Visible;
                this.Welcome4StoryBoard.Begin();

                Current.Instance.AddScore.Add(new Score(Current.Instance.Earthwatcher.Id, ActionPoints.Action.PreTutorialStep4.ToString(), ActionPoints.Points(ActionPoints.Action.PreTutorialStep4), Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore));
                PointsAdded(this, EventArgs.Empty);
            }
            else
            {
                this.Close();
            }
        }
Esempio n. 11
0
        //Button's Click
        private void ButtonStart_Click(object sender, RoutedEventArgs e)
        {
            currentStep++;
            this.StartStoryBoard.Begin();

            Current.Instance.AddScore.Add(new Score(Current.Instance.Earthwatcher.Id, ActionPoints.Action.PreTutorialStep1.ToString(), ActionPoints.Points(ActionPoints.Action.PreTutorialStep1), Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore));
            PointsAdded(this, EventArgs.Empty);
        }
Esempio n. 12
0
        /// <summary>
        /// Busca al primer usuario que reporto esa parcela con 30 verif, le asigna los puntos, lockea la parcela y la pasa a greenpeace.
        /// </summary>
        /// <param name="land"></param>
        /// <param name="verifications"></param>
        /// <returns></returns>
        private LandMini VerificationScoring(LandMini land, int verifications)
        {
            if (verifications >= 30) //cantidad de Verifications
            {
                //Si es el usuario de Greenpeace debería buscar el owner original
                if (land.EarthwatcherId == Configuration.GreenpeaceId)
                {
                    connection.Open();

                    int?ewId = connection.Query <int>(string.Format("EXEC Land_VerificationScoring {0}, {1}", land.LandId, Configuration.GreenpeaceId)).SingleOrDefault();
                    if (ewId != null)
                    {
                        land.EarthwatcherId = Convert.ToInt32(ewId);
                    }
                    connection.Close();
                }

                //Obtengo el mail del owner original para mandarle la notificacion por mail
                connection.Open();
                string idobjMail = connection.Query <string>(string.Format("EXEC Land_VerificationScoring_2 {0}, {1}", land.LandId, Configuration.GreenpeaceId)).SingleOrDefault();
                if (idobjMail != null)
                {
                    land.Email = idobjMail;
                }
                connection.Close();

                //Obtengo el earthwatcher para agregarle los puntos
                connection.Open();
                Earthwatcher earthwatcher = connection.Query <Earthwatcher>(string.Format("EXEC Earthwatcher_GetEarthwatcher {0}", land.EarthwatcherId)).FirstOrDefault();
                connection.Close();

                //Le asigno los 2000 puntos
                var scoreRepository = new ScoreRepository(connection.ConnectionString);
                scoreRepository.PostScore(new Score(earthwatcher.Id, ActionPoints.Action.LandVerified.ToString(), ActionPoints.Points(ActionPoints.Action.LandVerified), earthwatcher.PlayingRegion, land.LandId));

                //El owner de la parcela pasa a ser Greenpeace y la parcela se lockea
                connection.Open();
                var cmd = connection.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "Land_VerificationScoring_3";
                cmd.Parameters.Add(new SqlParameter("@LandId", land.LandId));
                cmd.ExecuteNonQuery();
                connection.Close();
                return(land);
            }
            return(null);
        }
Esempio n. 13
0
        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement elem = sender as FrameworkElement;

            if (elem.Name == "HelpButton")
            {
                this.MainGrid.Visibility = System.Windows.Visibility.Collapsed;
                this.FAQGrid.Visibility  = System.Windows.Visibility.Visible;
            }
            else if (elem.Name == "ScoresButton")
            {
                this.MainGrid.Visibility    = System.Windows.Visibility.Collapsed;
                this.ScoringGrid.Visibility = System.Windows.Visibility.Visible;
                if (!Current.Instance.RegionScores.Any(x => x.EarthwatcherId == Current.Instance.Earthwatcher.Id && x.Action == ActionPoints.Action.ScoringHelp.ToString()))
                {
                    Current.Instance.AddScore.Add(new Score(Current.Instance.Earthwatcher.Id, ActionPoints.Action.ScoringHelp.ToString(), ActionPoints.Points(ActionPoints.Action.ScoringHelp), Current.Instance.Earthwatcher.PlayingRegion, Current.Instance.PrecisionScore));
                    PointsAdded(this, EventArgs.Empty);
                }
            }
            else if (elem.Name == "AboutButton")
            {
                this.MainGrid.Visibility  = System.Windows.Visibility.Collapsed;
                this.AboutGrid.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                this.SelectedOption = elem.Name;
                this.Close();
            }
        }
Esempio n. 14
0
        void landRequests_PollAdded(object sender, EventArgs e)
        {
            answers++;
            if (moreThan5)
            {
                //Pinto de verde los circulos
                var ellipse = this.FindName("Circle" + answers) as System.Windows.Shapes.Ellipse;
                if (ellipse != null)
                {
                    ellipse.Fill = App.Current.Resources["BackGroundEllipseGreen"] as System.Windows.Media.RadialGradientBrush;
                }
                var rectangle = this.FindName("Rectangle" + answers) as System.Windows.Shapes.Rectangle;
                if (rectangle != null)
                {
                    rectangle.Fill = App.Current.Resources["BackGroundRectGreen"] as System.Windows.Media.LinearGradientBrush;
                }

                //Si llegué a las 5 le doy un puntaje
                if (answers == 5)
                {
                    this.BonusStoryBoard.Begin();

                    BonusReached(this, new SharedEventArgs {
                        Action = ActionPoints.Action.FivePollAnswersBonus.ToString(), Points = ActionPoints.Points(ActionPoints.Action.FivePollAnswersBonus)
                    });
                }
            }

            LoadNextImage();
        }