void data_arrived2(object sender, DownloadCompleteData e)
        {
            String data = e.data;

            JArray obj = JArray.Parse(data);

            for (int i = 0; i < obj.Count; i++)
            {
                JObject row = JObject.Parse(obj[i].ToString());

                var item = new Place();
                item.name     = row["name"].ToString();
                item.address  = row["address"].ToString();
                item.city     = row["city"].ToString();
                item.category = row["category"].ToString();
                item.img      = new BitmapImage(new Uri("http://thilinim.cnsytex.com/app1/web/" + row["path"].ToString(), UriKind.Absolute));
                double latitude;
                if (double.TryParse(row["latitude"].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out latitude))
                {
                    item.latitude = latitude;
                }

                double longitude;
                if (double.TryParse(row["longitude"].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out longitude))
                {
                    item.longitude = longitude;
                }
                listView2.Items.Add(item);
            }
        }
Esempio n. 2
0
        protected virtual void DownloadDataCompleteEvent(DownloadCompleteData e)
        {
            EventHandler <DownloadCompleteData> handler = downloadDatacomplete;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Esempio n. 3
0
        async void DownloadDataAsync(String url)
        {
            HttpClient    client        = new HttpClient();
            Task <string> getStringTask = client.GetStringAsync(url);
            string        urlContents   = await getStringTask;

            DownloadCompleteData data_to_send = new DownloadCompleteData();

            data_to_send.data = urlContents;

            DownloadDataCompleteEvent(data_to_send);
        }
Esempio n. 4
0
        void data_arrived(object sender, DownloadCompleteData e)
        {
            String data = e.data;

            if (data != "You have no trips yet")
            {
                JArray obj = JArray.Parse(data);

                for (int i = 0; i < obj.Count; i++)
                {
                    JObject row  = JObject.Parse(obj[i].ToString());
                    var     trip = new Trip();
                    trip.id      = Int32.Parse(row["id"].ToString());
                    trip.name    = row["name"].ToString();
                    trip.city_id = Int32.Parse(row["city_id"].ToString());
                    trip.user_id = Int32.Parse(row["user_id"].ToString());
                    TriplistView.Items.Add(trip);
                }
            }
            else
            {
                notrips.Text = data;
            }



            /*JArray obj = JArray.Parse(data);
             * Debug.WriteLine(obj[0].ToString());
             * var trip = new Trip();
             * trip.name = obj[0].ToString();
             *
             * String place_data = obj[1].ToString();
             *
             * JArray place_obj = JArray.Parse(place_data);
             *
             * for (int i = 0; i < place_obj.Count;i++ )
             * {
             *  JObject row = JObject.Parse(place_obj[i].ToString());
             *  var item = new Place();
             *  item.name = row["name"].ToString();
             *  item.address = row["address"].ToString();
             *  item.city = row["city"].ToString();
             *  item.category = row["category"].ToString();
             *  item.img = new BitmapImage(new Uri("http://thilinim.cnsytex.com/app1/web/" + row["path"].ToString(), UriKind.Absolute));
             *  trip.places.Add(item);
             *
             * }
             *
             * String hotel_data = obj[2].ToString();
             * JArray hotel_obj = JArray.Parse(hotel_data);
             *
             * for (int i = 0; i < hotel_obj.Count; i++)
             * {
             *  JObject row = JObject.Parse(hotel_obj[i].ToString());
             *  var item = new Hotel();
             *  item.name = row["name"].ToString();
             *  item.address = row["address"].ToString();
             *  item.city = row["city"].ToString();
             *  item.category = row["category"].ToString();
             *  item.img = new BitmapImage(new Uri("http://thilinim.cnsytex.com/app1/web/" + row["path"].ToString(), UriKind.Absolute));
             *  trip.hotels.Add(item);
             *
             * }*/
        }