Beispiel #1
0
        private async void map_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            if (useflag == true)
            {
                goalpoint = args.Location;
                using (SQLiteConnection conn = BicycleDatabase.GetDbConnection())
                {
                    TableQuery <Bicycle> t = conn.Table <Bicycle>();
                    var q = (from s in t
                             where s.bicycle_id == str
                             select s).SingleOrDefault();

                    (double x, double y) current_location_parse(string current_location)
                    {
                        var str = current_location.Split(',');

                        double.TryParse(str[0], out var x);
                        double.TryParse(str[1], out var y);
                        return(x, y);
                    }

                    Geopoint startpoint =
                        new Geopoint(new BasicGeoposition()
                    {
                        Latitude  = current_location_parse(q.current_location).x,
                        Longitude = current_location_parse(q.current_location).y
                    });
                    await routeCreateAsync(startpoint, goalpoint); //g1应为当前选择车辆的坐标

                    useflag = false;
                }
            }
        }
Beispiel #2
0
        public string str;           //用于记录输入的车牌号

        private async void UseBicycleButton_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as ToggleButton; //点击之后为ischecked==true
            //button.IsChecked
            string bicycleId = "";

            if (button.IsChecked == true)
            {
                var           content = new MyContentDialog();
                ContentDialog con     = new ContentDialog()
                {
                    Content             = content,
                    PrimaryButtonText   = "确定",
                    SecondaryButtonText = "取消",
                };

                con.PrimaryButtonClick += (s, a) =>
                {
                    button.Content = "结束用车";
                    //获取输入
                    str = content.Text;
                };

                con.SecondaryButtonClick += (s, a) =>
                {
                    button.IsChecked = false;
                };
                await con.ShowAsync();

                useflag = true;
            }

            if (button.IsChecked == false) //结束用车时的点击
            {
                button.Content = "用车";
                map.Routes.Clear();
                using (SQLiteConnection conn = BicycleDatabase.GetDbConnection())
                {
                    TableQuery <Bicycle> t = conn.Table <Bicycle>();
                    var q = (from p in t
                             where p.bicycle_id == str
                             select p).SingleOrDefault();
                    //Debug.WriteLine(goalpoint.Position);
                    q.current_location = goalpoint.Position.Latitude.ToString() + ","
                                         + goalpoint.Position.Longitude.ToString();
                    conn.Update(q);
                }
                Bicycletest();
            }
            //Simulation.bicycleuse(this_account, bicycleId);
        }
Beispiel #3
0
        private void Bicycletest() //单车数据库测试
        {
            using (SQLiteConnection conn = BicycleDatabase.GetDbConnection())
            {
                TableQuery <Bicycle> t = conn.Table <Bicycle>();
                var q = from s in t.AsParallel <Bicycle>()
                        orderby s.bicycle_id
                        select s;
                // 绑定

                bicycle.Clear();
                map.MapElements.Clear();

                foreach (var temp in q)
                {
                    bicycle.Add(temp);
                }


                foreach (var temp in bicycle.Select(temp => current_location_parse(temp.current_location))
                         .Select(temp => new Geopoint(new BasicGeoposition()
                {
                    Latitude = temp.x,
                    Longitude = temp.y,
                })).Select(temp => new MapIcon()
                {
                    Location = temp,
                    Image = RandomAccessStreamReference.
                            CreateFromUri(new Uri("ms-appx:///Assets/Bicycle.png")),
                }))
                {
                    map.MapElements.Add(temp);
                }

                #region
                //List<List<string>> lat_lon = new List<List<string>>();
                ////将现在位置存入
                //foreach (var item in bicycle)
                //{
                //    lat_lon.Add(item.current_location.Split(',').ToList());
                //}


                //List<Geopoint> bikepoint = new List<Geopoint>();

                //foreach (var item in lat_lon)
                //{
                //    bikepoint.Add(new Geopoint(new BasicGeoposition()
                //    {
                //        Latitude = double.Parse(item[0]),
                //        Longitude = double.Parse(item[1]),
                //    }));
                //}

                //List<MapIcon> bikeicon = new List<MapIcon>();

                //foreach (var item in bikepoint)
                //{
                //    bikeicon.Add(new MapIcon() { Location = item }); //单车图标未定

                //}

                //foreach (var item in bikeicon)
                //{
                //    map.MapElements.Add(item);
                //}
                #endregion
            }

            (double x, double y) current_location_parse(string current_location)
            {
                var str = current_location.Split(',');

                double.TryParse(str[0], out var x);
                double.TryParse(str[1], out var y);
                return(x, y);
            }
        }