private async void CinemaListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MyMap.Routes.Clear();
            ListView Lis = sender as ListView;
            CinemaRecommendViewModel _poi = Lis.DataContext as CinemaRecommendViewModel;

            if (Lis.SelectedIndex == -1)
            {
                return;
            }
            Pois poi = _poi.poiresult[Lis.SelectedIndex] as Pois;

            string[]         arr           = poi.location.Split(',');
            BasicGeoposition startLocation = new BasicGeoposition()
            {
                Latitude = myLocation.Position.Latitude, Longitude = myLocation.Position.Longitude
            };
            BasicGeoposition endLocation = new BasicGeoposition()
            {
                Latitude = Convert.ToDouble(arr[1]), Longitude = Convert.ToDouble(arr[0])
            };
            MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync(new Geopoint(startLocation), new Geopoint(endLocation), MapRouteOptimization.Time, MapRouteRestrictions.None);

            if (routeResult.Status == MapRouteFinderStatus.Success)
            {
                MapRouteView viewOfRoute = new MapRouteView(routeResult.Route);
                viewOfRoute.RouteColor   = Colors.Yellow;
                viewOfRoute.OutlineColor = Colors.Black;
                MyMap.Routes.Add(viewOfRoute);
                await MyMap.TrySetViewBoundsAsync(
                    routeResult.Route.BoundingBox,
                    null,
                    MapAnimationKind.None);
            }
        }
Esempio n. 2
0
        private async void CreateOrUpdatePOIAsync(Pois poi)
        {
            POIService service = new POIService();

            if (!IsConnected())
            {
                Toast toast = Toast.MakeText(this, "Not conntected to internet. Please check your device network settings.", ToastLength.Short);
                toast.Show();
                return;
            }

            string response = await service.CreateOrUpdatePOIAsync(_poi);

            if (!string.IsNullOrEmpty(response))
            {
                Toast toast = Toast.MakeText(this, String.Format("{0} saved.", _poi.Name), ToastLength.Short);
                toast.Show();
                Finish();
            }
            else
            {
                Toast toast = Toast.MakeText(this, "Something went Wrong!", ToastLength.Short);
                toast.Show();
            }
        }
Esempio n. 3
0
        protected void POIClicked(object sender, ListView.ItemClickEventArgs e)
        {
            Pois poi = poiListData.Pois[(int)e.Id];

            Intent poiDetailIntent = new Intent(this, typeof(POIDetailActivity));
            string poiJson         = JsonConvert.SerializeObject(poi);

            poiDetailIntent.PutExtra("poi", poiJson);
            StartActivity(poiDetailIntent);
        }
 public void RemovePoi()
 {
     try
     {
         Logging.LogMethodCall(ClassName);
         if (SelectedPoi != null)
         {
             Pois.Remove(SelectedPoi);
         }
         UpdatePois();
     }
     catch (Exception ex)
     {
         ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, "Error removing points of interest", ex);
     }
 }
        private void UpdatePois()
        {
            try
            {
                Logging.LogMethodCall(ClassName);
                var path  = Path.Combine(ConfigHandler.AssemblyDirectory, "POIS.config");
                var toSer = Pois.ToArray <PointOfInterestSettings>();

                using (var fs = new StreamWriter(path, false))
                {
                    var ser = new XmlSerializer(toSer.GetType());
                    ser.Serialize(fs, toSer);
                }
            }
            catch (Exception ex)
            {
                var message = "Error saving points of interests";
                ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, message, ex);
                Logging.LogMessage(Logging.LogType.Error, message, ex);
            }
        }
 public void AddPoi()
 {
     try
     {
         Logging.LogMethodCall(ClassName);
         MessageBox.Show("Click on the map to specify the location for your new POI.");
         MainView.FindVisible = false;
         MainView.RequestPointFromUser(new Action <MapPoint>(pnt =>
         {
             MainView.FindVisible = true;
             string name          = Interaction.InputBox("Enter a name for the new POI.", "Add POI", null);
             if (!string.IsNullOrWhiteSpace(name))
             {
                 while (!string.IsNullOrWhiteSpace(name) && Pois.Any(poi => poi.Name == name))
                 {
                     MessageBox.Show("The name entered is already being used by another POI.  Please specify another one.");
                     name = Interaction.InputBox("Enter a name for the new POI.", "Add POI", null);
                 }
                 if (!string.IsNullOrWhiteSpace(name))
                 {
                     Pois.Add(new PointOfInterestSettings
                     {
                         Name = name,
                         Lat  = pnt.Y,
                         Long = pnt.X
                     });
                     UpdatePois();
                 }
             }
         }));
     }
     catch (Exception ex)
     {
         ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, "Error adding points of interest", ex);
     }
 }
Esempio n. 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            RequestWindowFeature(WindowFeatures.ActionBar);

            SetContentView(Resource.Layout.POIDetail);
            _nameEditText  = FindViewById <EditText>(Resource.Id.nameEditText);
            _descrEditText = FindViewById <EditText>(Resource.Id.descrEditText);
            _addrEditText  = FindViewById <EditText>(Resource.Id.addrEditText);
            _latEditText   = FindViewById <EditText>(Resource.Id.latEditText);
            _longEditText  = FindViewById <EditText>(Resource.Id.longEditText);

            if (Intent.HasExtra("poi"))
            {
                string poiJson = Intent.GetStringExtra("poi");
                _poi = JsonConvert.DeserializeObject <Pois>(poiJson);
            }
            else
            {
                _poi = new Pois();
            }

            UpdateUI();
        }
Esempio n. 8
0
        private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            double a = double.Parse(textBox1.Text, CultureInfo.InvariantCulture);

            if (comboBox1.SelectedIndex == 0)
            {
                MessageBox.Show("Ви обрали пуасонівський розподіл!");
                //textBox2.Visible = false;
                //label11.Visible = false;
                //label12.Visible = false;
                if (a < 0)
                {
                    MessageBox.Show("Параметр має бути більше 0!");
                }
                else
                {
                    Pois   p1 = new Pois(a);
                    double expv;
                    expv        = p1.Ma();
                    lbl_MO.Text = "Ex = lambda = " + expv;
                    double disp;
                    disp         = p1.Dis();
                    label7.Text  = "Dx = lambda = " + disp;
                    label8.Text  = "Розподіл дискретний!";
                    label9.Text  = "Розподіл дискретний!";
                    label10.Text = "Розподіл дискретний!";
                }
            }

            if (comboBox1.SelectedIndex == 1)
            {
                double b = double.Parse(textBox2.Text, CultureInfo.InvariantCulture);
                MessageBox.Show("Ви обрали рівномірний розподіл!");
                if (a > b)
                {
                    MessageBox.Show("b має бути більше, ніж a!");
                }
                else
                {
                    U      u1 = new U(a, b);
                    double expv;
                    expv        = u1.Ma();
                    lbl_MO.Text = "Ex = (a+b)/2 = " + expv;
                    double disp;
                    disp        = u1.Dis();
                    label7.Text = "Dx = (b-a)^2/12 = " + disp;
                    double c = b - a;
                    label8.Text = "F(x)=(x-a)/(b-a) = (x-" + a + ")/" + c + "";
                    label9.Text = "f=1/(b-a) = 1/" + c;

                    Graphics g = pictureBox1.CreateGraphics();

                    x1 += (a + b) / 2;
                    x2 += (a + b) / 2;
                    y1  = 1 / (b - a) + 1;
                    g.Clear(Color.White);
                    DrawXoY();

                    Pen my = new Pen(Brushes.Blue, 3);
                    g.DrawLine(my, XtoI(a), YtoJ(1 / (b - a)), XtoI(b), YtoJ(1 / (b - a)));
                    g.DrawLine(my, XtoI(x1), YtoJ(0), XtoI(a), YtoJ(0));
                    g.DrawLine(my, XtoI(b), YtoJ(0), XtoI(x2), YtoJ(0));
                }
            }

            if (comboBox1.SelectedIndex == 2)
            {
                MessageBox.Show("Ви обрали експоненціальний розподіл!");
                //textBox2.Visible = false;
                //label11.Visible = false;
                //label12.Visible = false;
                if (a < 0)
                {
                    MessageBox.Show("Параметр має бути більше 0!");
                }
                else
                {
                    Exp    e1 = new Exp(a);
                    double expv;
                    expv        = e1.Ma();
                    lbl_MO.Text = "Ex = 1/lambda = " + expv;
                    double disp;
                    disp        = e1.Dis();
                    label7.Text = "Dx = 1/lambda^2 = " + disp;
                    label8.Text = "F(x) = 1 - e^(-lambda*x) = 1 - e^(-" + a + "*x)";
                    label9.Text = "f = lambda*e^(--lambda*x) = " + a + "*e^(-" + a + "*x)";

                    x1 -= a - 5;
                    x2 += a + 5;
                    y1 += a - 4;
                    //y2-=a+1;
                    Graphics g  = pictureBox1.CreateGraphics();
                    Pen      my = new Pen(Brushes.Red, 2);
                    DrawXoY();

                    for (double i = 0; i <= x2; i += 0.003)
                    {
                        double j = a * Math.Pow(Math.E, -a * i);
                        g.DrawEllipse(my, XtoI(i), YtoJ(j), 1, 1);
                    }
                }
            }

            if (comboBox1.SelectedIndex == 3)
            {
                double b = double.Parse(textBox2.Text, CultureInfo.InvariantCulture);
                MessageBox.Show("Ви обрали гаусівський розподіл!");
                label14.Visible = true;
                if (b < 0)
                {
                    MessageBox.Show("Dx має бути більше 0!");
                }
                else
                {
                    N      n1 = new N(a, b);
                    double expv;
                    expv        = n1.Ma();
                    lbl_MO.Text = "Ex = a = " + expv;
                    double disp;
                    disp        = n1.Dis();
                    label7.Text = "Dx = " + disp;
                    label8.Text = "F(x) = 1/2 + Ф((x-a)/(sqrt(Dx)) = 1/2 + Ф((x-" + a + ")/" + Math.Sqrt(b) + ")";
                    label9.Text = "f = 1/(sqrt(Dx*2*pi)) * e^(-(x-a)^2 / (2 * Dx) = \n = "
                                  + 1 / (Math.Sqrt(b * 2 * Math.PI)) + "*e^(-(x - " + a + ")^2 / " + 2 * b;

                    y1  = 1.5;
                    x1 += a;
                    x2 += a;
                    Graphics g  = pictureBox1.CreateGraphics();
                    Pen      my = new Pen(Brushes.Red, 2);
                    DrawXoY();

                    for (double i = x1; i <= x2; i += 0.003)
                    {
                        double j = 1 / (Math.Sqrt(b * 2 * Math.PI)) * Math.Pow(Math.E, -(Math.Pow((i - a), 2) / (2 * b)));
                        g.DrawEllipse(my, XtoI(i), YtoJ(j), 1, 1);
                    }
                }
            }

            if (comboBox1.SelectedIndex == 4)
            {
                MessageBox.Show("Ви обрали геометричний розподіл!");
                textBox2.Visible = false;
                label11.Visible  = false;
                label12.Visible  = false;
                if (a > 1 || a < 0)
                {
                    MessageBox.Show("p має бути від 0 до 1!");
                }
                else
                {
                    Geom   g1 = new Geom(a);
                    double expv;
                    expv        = g1.Ma();
                    lbl_MO.Text = "Ex = q/p = " + expv;
                    double disp;
                    disp         = g1.Dis();
                    label7.Text  = "Dx = q/p^2 = " + disp;
                    label8.Text  = "Розподіл дискретний!";
                    label9.Text  = "Розподіл дискретний!";
                    label10.Text = "Розподіл дискретний!";
                }
            }

            if (comboBox1.SelectedIndex == 5)
            {
                double b = double.Parse(textBox2.Text, CultureInfo.InvariantCulture);
                MessageBox.Show("Ви обрали біноміальний розподіл!");
                if (a < 0)
                {
                    MessageBox.Show("n має бути більше 0!");
                }
                else
                {
                    if (b > 1 || b < 0)
                    {
                        MessageBox.Show("p має бути від 0 до 1!");
                    }
                    else
                    {
                        Bin    b1 = new Bin(a, b);
                        double expv;
                        expv        = b1.Ma();
                        lbl_MO.Text = "Ex = n*p = " + expv;
                        double disp;
                        disp         = b1.Dis();
                        label7.Text  = "Dx = n*p*q = " + disp;
                        label8.Text  = "Розподіл дискретний!";
                        label9.Text  = "Розподіл дискретний!";
                        label10.Text = "Розподіл дискретний!";
                    }
                }
            }
        }
        protected void HistoriquePoi(object sender, EventArgs e)
        {
            string userDate1 = this.DateField1.Value.ToString();

            string[] du = userDate1.Split(' ');
            userDate1 = du[0] + " " + this.TimeField1.Value.ToString();

            string userDate2 = this.DateField2.Value.ToString();

            string[] du2 = userDate2.Split(' ');
            userDate2 = du2[0] + " " + this.TimeField2.Value.ToString();
            string vehiculeid = "";

            vehiculeid = this.MultiCombo1.SelectedItem.Value;
            if (vehiculeid == "" || userDate1 == "" || userDate2 == "")
            {
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = Resources.Resource.Information,
                    Message = "Veuillez choisir un véhicule, une date début et une date fin pour consulter les trajets",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO
                });
            }
            else
            {
                TimeSpan k = DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) - DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                if (k.TotalDays <= 0)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = Resources.Resource.Information,
                        Message = "La date  début doit être inferieure à la date fin",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO
                    });
                }
                else
                {
                    string        _reqTime = "select * from(select top 1 d.RTCDateTime from Datatracker d order by d.datatrackerid desc) a union select * from (select top 1 d.RTCDateTime from Datatracker d order by d.datatrackerid )b ";
                    SqlDataReader drT      = Select(_reqTime);

                    int m = 0;
                    while (drT.Read())
                    {
                        du[m] = drT[0].ToString();
                        m++;
                    }
                    drT.Close();
                    DateTime dsup = DateTime.ParseExact(du[1], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                    DateTime dinf = DateTime.ParseExact(du[0], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                    if (dsup < dinf)
                    {
                        dinf = DateTime.ParseExact(du[1], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                        dsup = DateTime.ParseExact(du[0], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                    }


                    if (DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) < dinf ||
                        DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) > dsup ||
                        DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) < dinf ||
                        DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) > dsup)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = Resources.Resource.Information,
                            Message = "Les dates début et fin doivent être comprises entre " + dinf + " et " + dsup,
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO
                        });
                    }
                    else
                    {
                        int    Compt    = 0;
                        int    vites    = 0;
                        string c        = "";
                        string _reqlist = "select * from "
                                          + " (select p.libelle as poi, p.type_poi ,p.longitude as lng ,p.latitude as lat,GPSDateTime as date,"
                                          + " per.prenom+' '+per.nom as conducteur,"
                                          + " geography::STGeomFromText('POINT('+convert(varchar(20),p.longitude)+' '+convert(varchar(20),p.latitude)+')',4326).STBuffer(p.tolerance).STIntersects "
                                          + " (geography::STGeomFromText('POINT('+convert(varchar(20),d.longitude)+' '+convert(varchar(20),d.latitude)+')',4326).STBuffer(10)) as inter"
                                          + " from Poi p  CROSS JOIN Datatracker  d "
                                          + "  inner join boitier b on b.imei=d.imei "
                                          + "  inner join affectation_vehicule_boitier abv on abv.boitierid=b.boitierid"
                                          + "  inner join vehicules  v on v.vehiculeid = abv.vehiculeid "
                                          + "  inner join vehicule_personnel vp on vp.vehiculeid=v.vehiculeid"
                                          + "  inner join personnel per on per.personnelid=vp.personnelid"
                                          + " where  cast(d.GPSDateTime AS datetime) >= '" + userDate1 + "' "
                                          + " AND cast(d.GPSDateTime AS datetime) < '" + userDate2 + "'and v.vehiculeid='" + vehiculeid + "'"
                                          + " and p.actif='1' and p.clientid='" + this.getCurrentUser().getClientId() + "' and p.userid ='" + this.getCurrentUser().getUserId() + "'  and d.speed=0) aff where aff.inter=1   ";

                        SqlDataReader drlist = Select(_reqlist);


                        while (drlist.Read())
                        {
                            Pois t = new Pois();
                            t.nom   = drlist[0].ToString();
                            t.lat   = drlist[3].ToString();
                            t.lng   = drlist[2].ToString();
                            t.type  = drlist[1].ToString();
                            t.cond  = drlist[5].ToString();
                            t.dateD = drlist[4].ToString();
                            Listpoi.Add(t);
                        }

                        drlist.Close();

                        for (int i = 0; i < Listpoi.Count - 1; i++)
                        {
                            Pois p = new Pois();
                            p.dateD = Listpoi[i].dateD;
                            int j;
                            for (j = i; j < Listpoi.Count - 1 && Listpoi[j].lat == Listpoi[j + 1].lat && Listpoi[j].lng == Listpoi[j + 1].lng; j++)
                            {
                                ;
                            }
                            i       = j;
                            p.dateF = Listpoi[i].dateD;
                            if (i == Listpoi.Count - 1)
                            {
                                p.dateF = Listpoi[i].dateD;
                            }

                            p.nom  = Listpoi[i].nom;
                            p.lat  = Listpoi[i].lat;
                            p.lng  = Listpoi[i].lng;
                            p.type = Listpoi[i].type;
                            p.cond = Listpoi[i].cond;
                            DateTime d     = DateTime.ParseExact(p.dateD.ToString(), "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                            DateTime dd    = DateTime.ParseExact(p.dateF.ToString(), "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                            TimeSpan duree = dd - d;
                            p.duree = duree.ToString();
                            ListpoiAff.Add(p);
                        }


                        List <object> lo = new List <object>();
                        if (ListpoiAff.Count == 0)
                        {
                            X.Msg.Show(new MessageBoxConfig
                            {
                                Title   = Resources.Resource.Information,
                                Message = "Aucun trajet n'a été parcouru",
                                Buttons = MessageBox.Button.OK,
                                Icon    = MessageBox.Icon.INFO
                            });
                        }
                        else
                        {
                            Store1.RemoveAll();

                            for (int i = 0; i < ListpoiAff.Count; i++)
                            {
                                object[] test = new object[9];
                                test[0] = ListpoiAff[i].cond;
                                test[1] = ListpoiAff[i].nom;
                                test[2] = ListpoiAff[i].type;
                                test[3] = ListpoiAff[i].dateD;
                                test[4] = ListpoiAff[i].dateF;
                                test[5] = ListpoiAff[i].duree;
                                test[6] = ListpoiAff[i].lat;
                                test[7] = ListpoiAff[i].lng;

                                //{ c, "adrD", Listtrajet[i].position[0].GPSDateTime, "adrF", Listtrajet[i].position[Listtrajet[i].position.Count - 1].GPSDateTime, duree.ToString(), Listtrajet[i].vitesse + " Km/H", polyline, color[col], Listtrajet[i].km + " Km" };
                                lo.Add(test);
                                //            lo.Add(new object[] { ListpoiAff[i].cond, ListpoiAff[i].nom,ListpoiAff[i].type, ListpoiAff[i].dateD, ListpoiAff[i].dateF, ListpoiAff[i].duree, ListpoiAff[i].lat, ListpoiAff[i].lng }
                                //);
                            }


                            Store1.Add(lo);
                            Store1.CommitChanges();
                        }
                    }
                }
            }
        }