Exemple #1
0
        async void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            Helper.venues = new List <Venue>();

            var root  = JObject.Parse(e.Result);
            var items = root["response"]["specials"]["items"];

            //MessageBox.Show(String.Format("name: {0}", firstGroup["venue"]["name"]));

            // clear list
            Helper.venues.Clear();

            int i = 0;

            //Random random = new Random();
            //int adIndex = random.Next(0, items.Count()-1 );
            int adIndex = items.Count() - 3;    // temporary, for demo purposes. This will cause error when items are less than 4

            foreach (var item in items)
            {
                if (adIndex >= 2 && i == adIndex)
                {
                    // randomly add an ads for demo purposes
                    Venue venueAds = new Venue();

                    venueAds.index = i;

                    venueAds.name         = "[Ads] Ferrari";
                    venueAds.message      = "Only those who dare... truly live";
                    venueAds.address      = "Only those who dare... truly live";
                    venueAds.imageVenue   = "Images/ads-ferrari.jpg";
                    venueAds.canonicalUrl = "http://www.ferrari.com/English/Pages/home.aspx";

                    venueAds.imageType = "ads";

                    Helper.venues.Add(venueAds);

                    i++;

                    continue;
                }


                Venue venue = new Venue();

                venue.index        = i;
                venue.id           = item["venue"]["id"].ToString();
                venue.name         = item["venue"]["name"].ToString();
                venue.canonicalUrl = item["venue"]["canonicalUrl"].ToString();

                venue.imageType = item["type"].ToString();

                venue.imageVenue = "";

                // location
                venue.address   = item["venue"]["location"]["address"].ToString();
                venue.longitude = item["venue"]["location"]["lng"].ToString();
                venue.latitude  = item["venue"]["location"]["lat"].ToString();

                var sCoord = new GeoCoordinate(Double.Parse(Helper.latitude), Double.Parse(Helper.longitude));
                var eCoord = new GeoCoordinate(Double.Parse(venue.latitude), Double.Parse(venue.longitude));
                venue.distance = Math.Round(sCoord.GetDistanceTo(eCoord) * 0.000621371, 2).ToString();   // convert meters to miles

                // specials
                venue.message     = item["message"].ToString();
                venue.description = item["description"].ToString();

                if (item["finePrint"] != null)
                {
                    venue.fineprint = item["finePrint"].ToString();
                }

                // stats
                venue.checkinsCount = item["venue"]["stats"]["checkinsCount"].ToString();
                venue.usersCount    = item["venue"]["stats"]["usersCount"].ToString();


                Helper.venues.Add(venue);

                i++;
            }


            // stop loading bar
            loadingBar.Visibility      = Visibility.Collapsed;
            loadingBar.IsIndeterminate = false;
        }
Exemple #2
0
        public VenueControl(Venue venue)
        {
            InitializeComponent();

            this.index = venue.index;
            this.imageVenue = venue.imageVenue;

            txtName.Text = venue.name;
            txtMessage.Text = venue.message;

            // temp function to show ads control for demo purposes
            if(venue.imageType == "ads")
            {
                ellipseFeatured.Visibility = Visibility.Visible;

                imgVenue.Source = new BitmapImage(new Uri(venue.imageVenue, UriKind.Relative));

                imgType.Source = new BitmapImage(new Uri("Images/check-in.png", UriKind.Relative));
                ellipseType.Fill = new SolidColorBrush(Helper.ConvertStringToColor("#FF7DDF00"));

                return;
            }

            //arcFeatured.Visibility = Visibility.Collapsed;
            //if (venue.imageVenue != "")
            //    imgVenue.Source = new BitmapImage(new Uri(venue.imageVenue, UriKind.Absolute));

            switch (venue.imageType)
            {
                case "mayor":
                    imgType.Source = new BitmapImage(new Uri("Images/mayor.png", UriKind.Relative));
                    ellipseType.Fill = new SolidColorBrush(Helper.ConvertStringToColor("#FFE8C906"));
                    break;

                case "frequency":
                    imgType.Source = new BitmapImage(new Uri("Images/frequency.png", UriKind.Relative));
                    ellipseType.Fill = new SolidColorBrush(Helper.ConvertStringToColor("#FF8E00DF"));
                    break;

                case "check-in":
                    imgType.Source = new BitmapImage(new Uri("Images/check-in.png", UriKind.Relative));
                    ellipseType.Fill = new SolidColorBrush(Helper.ConvertStringToColor("#FF7DDF00"));
                    break;

                case "swarm":
                    imgType.Source = new BitmapImage(new Uri("Images/swarm.png", UriKind.Relative));
                    ellipseType.Fill = new SolidColorBrush(Helper.ConvertStringToColor("#FFE6D106"));
                    break;

                case "newbie":
                    imgType.Source = new BitmapImage(new Uri("Images/newbie.png", UriKind.Relative));
                    ellipseType.Fill = new SolidColorBrush(Helper.ConvertStringToColor("#FFB0B0B0"));
                    break;

                case "friends":
                    imgType.Source = new BitmapImage(new Uri("Images/friends.png", UriKind.Relative));
                    ellipseType.Fill = new SolidColorBrush(Helper.ConvertStringToColor("#FF00DFAC"));
                    break;

                case "flash":
                    imgType.Source = new BitmapImage(new Uri("Images/flash.png", UriKind.Relative));
                    ellipseType.Fill = new SolidColorBrush(Helper.ConvertStringToColor("#FFD14444"));
                    break;

                case "ads":
                    imgType.Source = new BitmapImage(new Uri("Images/light-bulb.png", UriKind.Relative));
                    ellipseType.Fill = new SolidColorBrush(Helper.ConvertStringToColor("#FFD14444"));                    break;

                default:
                    imgType.Source = new BitmapImage(new Uri("Images/check-in.png", UriKind.Relative));
                    ellipseType.Fill = new SolidColorBrush(Helper.ConvertStringToColor("#FF7DDF00"));
                    break;

            }

            getImage(venue.id);
        }
Exemple #3
0
        async void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            Helper.venues = new List<Venue>();

            var root = JObject.Parse(e.Result);
            var items = root["response"]["specials"]["items"];

            //MessageBox.Show(String.Format("name: {0}", firstGroup["venue"]["name"]));

            // clear list
            Helper.venues.Clear();

            int i = 0;

            //Random random = new Random();
            //int adIndex = random.Next(0, items.Count()-1 );
            int adIndex = items.Count() - 3;    // temporary, for demo purposes. This will cause error when items are less than 4
            
            foreach (var item in items)
            {
                if(adIndex >=2 && i == adIndex)
                {
                    // randomly add an ads for demo purposes
                    Venue venueAds = new Venue();

                    venueAds.index = i;

                    venueAds.name = "[Ads] Ferrari";
                    venueAds.message = "Only those who dare... truly live";
                    venueAds.address = "Only those who dare... truly live";
                    venueAds.imageVenue = "Images/ads-ferrari.jpg";
                    venueAds.canonicalUrl = "http://www.ferrari.com/English/Pages/home.aspx";

                    venueAds.imageType = "ads";

                    Helper.venues.Add(venueAds);

                    i++; 

                    continue;
                }
               

                Venue venue = new Venue();

                venue.index = i;
                venue.id = item["venue"]["id"].ToString();
                venue.name = item["venue"]["name"].ToString();
                venue.canonicalUrl = item["venue"]["canonicalUrl"].ToString();

                venue.imageType = item["type"].ToString();

                venue.imageVenue = "";

                // location
                venue.address = item["venue"]["location"]["address"].ToString();
                venue.longitude = item["venue"]["location"]["lng"].ToString();
                venue.latitude = item["venue"]["location"]["lat"].ToString();

                var sCoord = new GeoCoordinate(Double.Parse(Helper.latitude), Double.Parse(Helper.longitude));
                var eCoord = new GeoCoordinate(Double.Parse(venue.latitude), Double.Parse(venue.longitude));
                venue.distance = Math.Round(sCoord.GetDistanceTo(eCoord) * 0.000621371, 2).ToString();   // convert meters to miles

                // specials
                venue.message = item["message"].ToString();
                venue.description = item["description"].ToString();

                if (item["finePrint"] != null)
                    venue.fineprint = item["finePrint"].ToString();

                // stats
                venue.checkinsCount = item["venue"]["stats"]["checkinsCount"].ToString();
                venue.usersCount = item["venue"]["stats"]["usersCount"].ToString();


                Helper.venues.Add(venue);

                i++;
            }


            // stop loading bar
            loadingBar.Visibility = Visibility.Collapsed;
            loadingBar.IsIndeterminate = false;


        }