Example #1
0
        public void PinClicked(object sender, EventArgs e, ListViewAddressJson pin)
        {
            // ShowMessage("info", "click", "ok");
            var DetailPin = new DetailPin(pin);

            Navigation.PushAsync(DetailPin);
        }
Example #2
0
        private async void SendNoteAsync(string Arg, ListViewAddressJson pin)
        {
            // DisplayAlert("Infos", Arg, "OK");
            if (Arg == "OK")
            {
                Boolean answer = await DisplayAlert(VariablesGlobal.LanguageApp.Infos, VariablesGlobal.LanguageApp.QuestionVoteOK, VariablesGlobal.LanguageApp.Oui, VariablesGlobal.LanguageApp.Non);

                if (answer == true)
                {
                    // DisplayAlert("Infos", "Super", "OK");
                    int value = Tools.ConvertStringToInt(pin.UsersValidate) + 1;

                    DateTime Today = DateTime.Now;

                    string Date_modification = Today.ToString("dd/MM/yyyy");
                    string AddresseApi       = PrefsApp.ApiAddress + "?api=" + PrefsApp.ApiKey + "&action=updateOK" + "&id=" + pin.IdMysql + "&value=" + value + "&Date_modification=" + Date_modification;
                    Console.WriteLine("AddresseApi=" + AddresseApi);
                    SendUpdate(AddresseApi, Date_modification);
                }
            }
            else
            {
                Boolean answer = await DisplayAlert(VariablesGlobal.LanguageApp.Infos, VariablesGlobal.LanguageApp.QuestionVoteNOTOK, VariablesGlobal.LanguageApp.Oui, VariablesGlobal.LanguageApp.Non);

                if (answer == true)
                {
                    //await DisplayAlert("Infos", "Bof", "OK");
                    int      value = Tools.ConvertStringToInt(pin.UsersUnValidate) + 1;
                    DateTime Today = DateTime.Now;

                    string Date_modification = Today.ToString("dd/MM/yyyy");

                    string AddresseApi = PrefsApp.ApiAddress + "?api=" + PrefsApp.ApiKey + "&action=updateNOTOK" + "&id=" + pin.IdMysql + "&value=" + value + "&Date_modification=" + Date_modification;
                    Console.WriteLine("AddresseApi=" + AddresseApi);
                    SendUpdate(AddresseApi, Date_modification);
                }
            }
        }
Example #3
0
        public DetailPin(ListViewAddressJson Pin)
        {
            InitializeComponent();
            if (!CrossConnectivity.Current.IsConnected)
            {
                DisplayAlert(VariablesGlobal.LanguageApp.Infos, VariablesGlobal.LanguageApp.ProblemConnexionInternet, VariablesGlobal.LanguageApp.Ok);
                // your logic...
            }
            else
            {
                VariablesGlobal.IdMysqlSelect       = Pin.IdMysql;
                VariablesGlobal.EtablissementSelect = Pin.Label;

                var tapGestureRecognizerLink = new TapGestureRecognizer();
                tapGestureRecognizerLink.Tapped += (s, e) => {
                    Device.OpenUri(new Uri(Pin.Url));
                };


                var tapGestureRecognizerOK = new TapGestureRecognizer();
                tapGestureRecognizerOK.Tapped += (s, e) => {
                    // Device.OpenUri(new Uri(Pin.Url));
                    SendNoteAsync("OK", Pin);
                };

                var tapGestureRecognizerNOTOK = new TapGestureRecognizer();
                tapGestureRecognizerNOTOK.Tapped += (s, e) => {
                    // Device.OpenUri(new Uri(Pin.Url));

                    SendNoteAsync("NOTOK", Pin);
                };



                NomEtablissementXAML.Text = Pin.Label;
                IconXAML.Source           = ImageSource.FromFile(Pin.Icon);

                // icon_IdXaml.Source = ImageSource.FromUri(new Uri(Configuration.ServerImages + "images/" + Pin.Icon));
                SiteWebXAML.Source = Pin.Url;

                //  TypeEtablissementXAML.Text = Pin.TypeEtablissement;
                //   LongitudeXAML.Text = Pin.Longitude;
                //   LatitudeXAML.Text = Pin.Latitude;
                //   LabelXAML.Text = Pin.Label;
                AddressXAML.Text = Pin.Address;


                UrlXAML.Text = Pin.Url;
                UrlXAML.GestureRecognizers.Add(tapGestureRecognizerLink);


                PromoXAML.Text = Pin.Promo;

                HeuresXAML.Text = Pin.HeurePromoDebut + " jusqu'à " + Pin.HeurePromoFin;
                //   HeurePromoDebutXAML.Text = Pin.HeurePromoDebut;
                //   HeurePromoFinXAML.Text = Pin.HeurePromoFin;

                string Jours = "";
                if (Pin.Quand.IndexOf("|") != -1)
                {
                    string[] words  = Pin.Quand.Split('|');
                    int      ICount = 0;
                    foreach (string word in words)
                    {
                        ICount = ICount + 1;
                    }

                    int ITemp = 0;
                    foreach (string word in words)
                    {
                        ITemp = ITemp + 1;
                        if (ITemp < ICount)
                        {
                            Jours = Jours + word + " - ";
                        }
                        else
                        {
                            Jours = Jours + word;
                        }



                        // Console.WriteLine(word);
                    }
                }
                else
                {
                    Jours = Pin.Quand;
                }

                QuandXAML.Text = Jours;

                Date_enregistrementXAML.Text = Pin.Date_enregistrement;
                Date_modificationXAML.Text   = Pin.Date_modification;
                // IconLabelXAML.Text = Pin.Icon;


                UsersValidateXAML.Text = Pin.UsersValidate;
                ImageOk.GestureRecognizers.Add(tapGestureRecognizerOK);

                UsersUnValidateXAML.Text = Pin.UsersUnValidate;
                ImageNotok.GestureRecognizers.Add(tapGestureRecognizerNOTOK);
            }
        }
Example #4
0
        private void DoCarte(JToken jsonObj)
        {
            GetPosition();
            var map = new CustomMap
            {
                IsShowingUser   = true,
                HeightRequest   = 100,
                WidthRequest    = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            MapSpan.FromCenterAndRadius(new Xamarin.Forms.Maps.Position(_position.Latitude, _position.Latitude), Distance.FromMiles(0.3));

            map.CustomPins = new List <ListViewAddressJson> {
            };
            Console.WriteLine("jsonObj.First() = " + jsonObj.First.ToString());
            foreach (var item in jsonObj.First)
            {
                Console.WriteLine("item.ToString() = " + item.ToString());
                InfosPinsClass.InfosPinStruct lignePin = (InfosPinsClass.InfosPinStruct)Newtonsoft.Json.JsonConvert.DeserializeObject(item.ToString(), typeof(InfosPinsClass.InfosPinStruct));
                int i = 0;
                Console.Write("InfosPinList.Count = " + InfosPinList.Count);

                /*if (InfosPinList.Count > 0)
                 * {
                 *  for (i = 0; i < InfosPinList.Count; i++)
                 *  {
                 *      Console.WriteLine("nb item = " + i);
                 *  }
                 * }*/


                InfosPinList.Insert(i, new InfosPinsClass.InfosPinStruct()
                {
                    Id = lignePin.Id,
                    TypeEtablissement = lignePin.TypeEtablissement,
                    Longitude         = lignePin.Longitude,
                    Latitude          = lignePin.Latitude,
                    Label             = lignePin.Label,
                    Address           = lignePin.Address,
                    Url                 = lignePin.Url,
                    Promo               = lignePin.Promo,
                    HeurePromoDebut     = lignePin.HeurePromoDebut,
                    HeurePromoFin       = lignePin.HeurePromoFin,
                    Quand               = lignePin.Quand,
                    Date_enregistrement = lignePin.Date_enregistrement,
                    Date_modification   = lignePin.Date_modification,
                    Icon                = lignePin.Icon,
                    UsersValidate       = lignePin.UsersValidate,
                    UsersUnValidate     = lignePin.UsersUnValidate
                });

                double LongitudeDouble = Convert.ToDouble(lignePin.Longitude, CultureInfo.GetCultureInfo("en-us"));
                double LatitudeDouble  = Convert.ToDouble(lignePin.Latitude, CultureInfo.GetCultureInfo("en-us"));


                ///  DisplayAlert("info", "LongitudeDouble:" +  LongitudeDouble + " Latitude:" + LatitudeDouble, "ok");


                var pin = new ListViewAddressJson
                {
                    Type              = PinType.Place,
                    Position          = new Xamarin.Forms.Maps.Position(Convert.ToDouble(lignePin.Latitude, CultureInfo.GetCultureInfo("en-us")), Convert.ToDouble(lignePin.Longitude, CultureInfo.GetCultureInfo("en-us"))),
                    IdMysql           = lignePin.Id,
                    TypeEtablissement = lignePin.TypeEtablissement,
                    Longitude         = lignePin.Longitude,
                    Latitude          = lignePin.Latitude,
                    Label             = lignePin.Label,
                    Address           = lignePin.Address,
                    Url                 = lignePin.Url,
                    Promo               = lignePin.Promo,
                    HeurePromoDebut     = lignePin.HeurePromoDebut,
                    HeurePromoFin       = lignePin.HeurePromoFin,
                    Quand               = lignePin.Quand,
                    Date_enregistrement = lignePin.Date_enregistrement,
                    Date_modification   = lignePin.Date_modification,
                    Icon                = lignePin.Icon,
                    UsersValidate       = lignePin.UsersValidate,
                    UsersUnValidate     = lignePin.UsersUnValidate
                };

                pin.Clicked += (sender, e) => { PinClicked(sender, e, pin); };

                map.CustomPins.Add(pin);

                map.Pins.Add(pin);
            }


            // DisplayAlert("info", map.Pins.Count.ToString(), "ok");

            map.MoveToRegion(MapSpan.FromCenterAndRadius(_position, Distance.FromMiles(1)));
            map.MapType = MapType.Street;
            var stack = new StackLayout {
                Spacing = 0
            };

            stack.Children.Add(map);
            Content = stack;
        }