Exemple #1
0
        public async void setEvent()
        {
            IEnumerable <getAllEventResult> events = await DatabaseHelper.Client.getAllEventAsync();

            foreach (getAllEventResult e in events)
            {
                Debug.WriteLine(e.beginTime + "  " + e.description);
                EventCard eventCard = new EventCard();
                eventCard.EventTitle = e.title;
                eventCard.EventTime  = e.beginTime.ToString("hh:mm tt");
                eventCard.EventDate  = e.beginTime.ToString("MMM. dd, yyyy");
                eventCard.EventDescription.Document.SetText(TextSetOptions.FormatRtf, e.description);
                //eventCard.Tapped += EventCard_Tapped;
                eventCard.IsTapEnabled = true;
                eventCard.EventId      = e.id;

                // Get poster's name and avatar
                var request  = new GetNameAndAvatarRequest(e.username);
                var response = await DatabaseHelper.Client.GetNameAndAvatarAsync(request);

                // Set poster avatar
                StorageFile file = await StorageFile.GetFileFromPathAsync(response.Avatar);

                BitmapImage bmp = new BitmapImage();
                await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));

                eventCard.AvatarImage.ImageSource = bmp;

                // Set poster's name
                eventCard.UserName.Content = response.Name;
                eventCard.UserName.Click  += (sender, args) => { Frame.Navigate(typeof(ProfilePage), e.username); };

                // Set tapped event for the "More detail" hyperlink
                eventCard.MoreDetail.Click += (sender, args) => { Frame.Navigate(typeof(EventDetailPage), e.id); };

                if (e.thumbnail != "")
                {
                    file = await StorageFile.GetFileFromPathAsync(e.thumbnail);

                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));

                    eventCard.EventImage.Source = bmp;
                }
                eventPanel.Children.Add(eventCard);
            }
        }
Exemple #2
0
        public async void setEvent()
        {
            IEnumerable<getAllEventResult> events = await DatabaseHelper.Client.getAllEventAsync();
            foreach (getAllEventResult e in events)
            {
                Debug.WriteLine(e.beginTime + "  " + e.description);
                EventCard eventCard = new EventCard();
                eventCard.EventTitle = e.title;
                eventCard.EventTime = e.beginTime.ToString("hh:mm tt");
                eventCard.EventDate = e.beginTime.ToString("MMM. dd, yyyy");
                eventCard.EventDescription.Document.SetText(TextSetOptions.FormatRtf, e.description);
                //eventCard.Tapped += EventCard_Tapped;
                eventCard.IsTapEnabled = true;
                eventCard.EventId = e.id;

                // Get poster's name and avatar
                var request = new GetNameAndAvatarRequest(e.username);
                var response = await DatabaseHelper.Client.GetNameAndAvatarAsync(request);

                // Set poster avatar
                StorageFile file = await StorageFile.GetFileFromPathAsync(response.Avatar);
                BitmapImage bmp = new BitmapImage();
                await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));
                eventCard.AvatarImage.ImageSource = bmp;

                // Set poster's name
                eventCard.UserName.Content = response.Name;
                eventCard.UserName.Click += (sender, args) => { Frame.Navigate(typeof(ProfilePage), e.username); };

                // Set tapped event for the "More detail" hyperlink
                eventCard.MoreDetail.Click += (sender, args) => { Frame.Navigate(typeof(EventDetailPage), e.id); };

                if (e.thumbnail != "")
                {
                    file = await StorageFile.GetFileFromPathAsync(e.thumbnail);
                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));
                    eventCard.EventImage.Source = bmp;
                }
                eventPanel.Children.Add(eventCard);
            }
        }