コード例 #1
0
        //Action Clicks
        private void ReportButton_Click(object sender, RoutedEventArgs e)
        {
            if (Current.Instance.TutorialStarted)
            {
                reportWindow_Closed(null, null); //close the report window and excecute callback on mainpage
                return;
            }

            this.ValidateMessageText.Visibility = System.Windows.Visibility.Collapsed;

            if (Current.Instance.Earthwatcher.Lands != null)
            {
                //Si es tu propia Parcela
                if (Current.Instance.Earthwatcher.Lands.Any(x => x.Id == selectedLand.Id))
                {
                    ConfirmationSort confirmationSort = ConfirmationSort.Confirm;

                    int statusNumber = 0;
                    if (this.AlertButton.BorderThickness.Left > 0)
                    {
                        statusNumber     = 4;
                        confirmationSort = ConfirmationSort.Deconfirm; //Alert
                    }

                    if (this.OkButton.BorderThickness.Left > 0)
                    {
                        statusNumber     = 3;
                        confirmationSort = ConfirmationSort.Confirm; //OK
                    }

                    if (statusNumber == 0)
                    {
                        statusNumber = 2; //Not Checked
                    }

                    status = (LandStatus)statusNumber;

                    if (selectedLand.LandStatus != status)
                    {
                        //Cambio el color de la parcela, segun el reporte del usuario
                        Current.Instance.Earthwatcher.Lands.Where(x => x.Id == selectedLand.Id).First().LandStatus = status;

                        loadinAnim.Visibility          = System.Windows.Visibility.Visible;
                        this.MainGrid.IsHitTestVisible = false;
                        landRequests.Confirm(selectedLand, confirmationSort, Current.Instance.Username, Current.Instance.Password);
                        landRequests.UpdateStatus(selectedLand.Id, status, Current.Instance.Username, Current.Instance.Password);
                    }
                }
                else //Si es la parcela de otro usuario
                {
                    ConfirmationSort confirmationSort = ConfirmationSort.Confirm;
                    bool             hasAction        = false;
                    if (this.ConfirmButton.BorderThickness.Left > 0)
                    {
                        if (!selectedLand.OKs.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                        {
                            confirmationSort = ConfirmationSort.Confirm;
                            hasAction        = true;
                        }
                    }

                    if (this.DeconfirmButton.BorderThickness.Left > 0)
                    {
                        if (!selectedLand.Alerts.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                        {
                            confirmationSort = ConfirmationSort.Deconfirm;
                            hasAction        = true;
                        }
                    }

                    if (hasAction)
                    {
                        loadinAnim.Visibility          = System.Windows.Visibility.Visible;
                        this.MainGrid.IsHitTestVisible = false;
                        landRequests.Confirm(selectedLand, confirmationSort, Current.Instance.Username, Current.Instance.Password);
                    }
                    else
                    {
                        this.ValidateMessageText.Visibility = System.Windows.Visibility.Visible;
                    }
                }
            }
        }
コード例 #2
0
        private void ReportButton_Click(object sender, RoutedEventArgs e)
        {
            bool closeWindow = true;

            if (Current.Instance.Earthwatcher.LandId.HasValue)
            {
                if (Current.Instance.Earthwatcher.LandId == selectedLand.Id)
                {
                    int statusNumber = 0;
                    if (this.AlertButton.BorderThickness.Left > 0)
                    {
                        statusNumber = 4;
                    }

                    if (this.OkButton.BorderThickness.Left > 0)
                    {
                        statusNumber = 3;
                    }

                    if (statusNumber == 0)
                    {
                        statusNumber = 2; //Not Checked
                    }

                    status = (LandStatus)statusNumber;

                    if (selectedLand.LandStatus != status)
                    {
                        closeWindow = false;
                        landRequests.StatusChanged += SetLandStatusStatusChanged;
                        landRequests.UpdateStatus(selectedLand.Id, status, Current.Instance.Username, Current.Instance.Password);

                        Current.Instance.EarthwatcherLand.LandStatus = status;
                    }
                }
                else
                {
                    ConfirmationSort confirmationSort = ConfirmationSort.Confirm;
                    bool             hasAction        = false;
                    if (this.ConfirmButton.BorderThickness.Left > 0)
                    {
                        if (!selectedLand.DeforestationConfirmers.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                        {
                            confirmationSort = ConfirmationSort.Confirm;
                            hasAction        = true;
                        }
                    }

                    if (this.DeconfirmButton.BorderThickness.Left > 0)
                    {
                        if (!selectedLand.DeforestationDeconfirmers.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                        {
                            confirmationSort = ConfirmationSort.Deconfirm;
                            hasAction        = true;
                        }
                    }

                    if (hasAction)
                    {
                        closeWindow = false;

                        landRequests.ConfirmationAdded += landRequests_ConfirmationAdded;
                        landRequests.Confirm(selectedLand.Id, Current.Instance.Earthwatcher.Id, confirmationSort, Current.Instance.Username, Current.Instance.Password);
                    }
                }
            }

            if (closeWindow)
            {
                this.Close();
            }
        }