/// <summary>
        /// Rafraichit les différentes variables affichés sur la map
        /// </summary>
        public void RefreshMarkers()
        {
            /*if (ZonePolygon == null || ZonePolygon.Points.Count == 0)
             * {
             *  CountOfPointsTextView.Text = "0";
             *  SurfaceTextView.Text = string.Format("0 {0}", Resources.GetString(Resource.String.unit_squarre));
             *  //BottomLayout.Visibility = ViewStates.Gone;
             *  ExplanationTextView.Visibility = ViewStates.Visible;
             *  return;
             * }
             * BottomLayout.Visibility = ViewStates.Visible;
             * ExplanationTextView.Visibility = ViewStates.Gone;
             *
             * if (ZonePolygon.Points.Count == 1) CountOfPointsTextView.Text = "1";
             * else CountOfPointsTextView.Text = (ZonePolygon.Points.Count - 1).ToString();
             */
            var surface = AreaHelper.CalculateAreaOfGPSPolygonOnEarthInSquareMeters(ZonePolygon.Points.ToList());

            SurfaceTextView.Text = AreaHelper.SerializeArea(surface);
        }
        /// <summary>
        ///
        /// </summary>
        private void InitializeSurfaceStatTextView()
        {
            if (ZonePolygon == null)
            {
                return;
            }
            if (SurfaceStatTextView == null)
            {
                return;
            }

            var surface         = AreaHelper.CalculateAreaOfGPSPolygonOnEarthInSquareMeters(ZonePolygon.Points.ToList());
            var surfaceStat     = AreaHelper.SerializeArea(surface);
            var textSurfaceStat = string.Format(Resources.GetString(Resource.String.modeZone_surfaceStr), surfaceStat);

            var resultTuple = SeekiosApp.Helper.StringHelper.GetStartAndEndIndexOfNumberInString(textSurfaceStat);
            var formattedTextSurfaceStat = new SpannableString(textSurfaceStat);

            formattedTextSurfaceStat.SetSpan(new ForegroundColorSpan(Color.ParseColor(App.MainColor)), resultTuple.Item1, resultTuple.Item2, 0);
            SurfaceStatTextView.SetText(formattedTextSurfaceStat, TextView.BufferType.Spannable);
        }
Example #3
0
        /// <summary>
        /// Initialise la popup de l'ajout d'une zone en favoris
        /// </summary>
        private void BuildAreaAddFavorisPopup()
        {
            // création d'une alerte dialog
            _addModeZoneFavorisAlertDialog = new AlertDialog.Builder(this);

            var editText       = new EditText(this);
            var editTextLayout = new LinearLayout(this);

            var editTextParam = new Android.Widget.LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            editTextParam.SetMargins(25, 5, 25, 5);
            editText.InputType = Android.Text.InputTypes.TextVariationUri;
            editText.SetHint(Resource.String.addFavoriteArea_areaName);
            editText.SetTextColor(Android.Graphics.Color.ParseColor("#cccccc"));     // TODO : dans fichier ressource
            editText.SetHintTextColor(Android.Graphics.Color.ParseColor("#888888")); // TODO : dans fichier ressource
            editText.LayoutParameters = editTextParam;

            var editTextLayoutParam = new Android.Widget.LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);

            editTextLayoutParam.SetMargins(20, 5, 20, 5);
            editTextLayout.LayoutParameters = editTextLayoutParam;
            editTextLayout.AddView(editText);

            // titre de l'alerte
            _addModeZoneFavorisAlertDialog.SetTitle(Resource.String.modeZone_addAreaFavorisTitle);

            // bouton ajouter
            _addModeZoneFavorisAlertDialog.SetPositiveButton(Resource.String.popup_add, async(o, e) =>
            {
                if (string.IsNullOrEmpty(editText.Text))
                {
                    return;
                }

                var pointCount = 0;

                if (_mapControlManager.ZonePolygon != null)
                {
                    if (_mapControlManager.ZonePolygon.Points.Count == 1)
                    {
                        pointCount = 1;
                    }
                    else
                    {
                        pointCount = _mapControlManager.ZonePolygon.Points.Count - 1;
                    }
                    var trame = GetTrame(_mapControlManager.ZonePolygon.Points.ToList());

                    var surface = AreaHelper.CalculateAreaOfGPSPolygonOnEarthInSquareMeters(_mapControlManager.ZonePolygon.Points.ToList());

                    LoadingLayout.Visibility = ViewStates.Visible;
                    var result = await App.Locator.ModeZone.AddFavoriteArea(new FavoriteAreaDTO
                    {
                        Trame        = trame,
                        PointsCount  = pointCount,
                        AreaGeodesic = surface,
                        AreaName     = editText.Text.ToUpperCaseFirst(),
                    });
                    if (result)
                    {
                        var textAddedAreaToast = string.Format(Resources.GetString(Resource.String.modeZone_toast_AddedArea), editText.Text.ToUpperCaseFirst());
                        Toast.MakeText(this, textAddedAreaToast, ToastLength.Long).Show();
                    }
                    LoadingLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    string error             = Resources.GetString(Resource.String.addFavoriteArea_errorZone);
                    AlertDialog alertMessage = new AlertDialog.Builder(this).Create();
                    alertMessage.SetTitle("Error: ");
                    alertMessage.SetMessage(error);
                    alertMessage.Show();
                }
                _addModeZoneFavorisDialog.Dismiss();
            });

            // bouton annuler
            _addModeZoneFavorisAlertDialog.SetNegativeButton(Resource.String.popup_cancelled, (o, e) =>
            {
                _addModeZoneFavorisDialog.Dismiss();
            });

            // ajout de la vue dans l'alerte
            _addModeZoneFavorisAlertDialog.SetView(editTextLayout);

            // instatiation de notre popup dans un objet dialog
            _addModeZoneFavorisDialog = _addModeZoneFavorisAlertDialog.Create();
            _addModeZoneFavorisAlertDialog.Show();
        }