コード例 #1
0
ファイル: HomePage.xaml.cs プロジェクト: Jack-Wong94/Phase2
        //get the facebook profile and deserialize the json response to build the user profile
        public async Task <FaceBookModel> GetFacebookProfileAsync(string accessToken)
        {
            var requestUrl = "https://graph.facebook.com/v2.7/me/"
                             + "?fields=name,picture,cover,age_range,devices,email,gender,is_verified"
                             + "&access_token=" + accessToken;
            var httpClient = new HttpClient();
            var userJson   = await httpClient.GetStringAsync(requestUrl);

            var facebookProfile = JsonConvert.DeserializeObject <FaceBookModel>(userJson);
            var name            = facebookProfile.Name;
            var id     = facebookProfile.id;
            var email  = facebookProfile.email;
            var gender = facebookProfile.gender;

            //build the user profile
            FaceBookModel model = new FaceBookModel()
            {
                Name   = name,
                id     = id,
                email  = email,
                gender = gender
            };

            //send the data back to the FaceBookModel easy table. Each entry contains one user profile.
            try
            {
                await AzureManager.AzureManagerInstance.AddTimeline(model);
            }
            catch (Microsoft.WindowsAzure.MobileServices.MobileServiceConflictException) { }

            return(facebookProfile);
        }
コード例 #2
0
ファイル: MainPage.xaml.cs プロジェクト: Jack-Wong94/Phase2
        //basic layout of the page
        public MainPage(FaceBookModel profile)
        {
            InitializeComponent();
            NavigationPage.SetHasBackButton(this, false);
            this.profile = profile;
            var layout = new StackLayout {
                Padding = new Thickness(5, 10)
            };

            this.Content = layout;
            var label = new Label {
                Text = "Welcome " + profile.Name, TextColor = Color.FromHex("#77d065"), FontSize = 20
            };

            button = new Button {
                Text = "Take a photo", BackgroundColor = Color.Silver, TextColor = Color.White, BorderRadius = 0
            };
            button2 = new Button {
                Text = "Get the past order", BackgroundColor = Color.Silver, TextColor = Color.White, BorderRadius = 0
            };
            button.Clicked  += TakePicture_Clicked;
            button2.Clicked += ChangeToPreviousOrderPage;
            layout.Children.Add(label);
            layout.Children.Add(button);
            layout.Children.Add(button2);
        }
コード例 #3
0
 //Show the list view of the order
 public PreviousOrderPage(FaceBookModel profile)
 {
     InitializeComponent();
     NavigationPage.SetHasBackButton(this, false);
     this.profile = profile;
     Name         = profile.Name;
     ShowPreviousOrder();
 }
コード例 #4
0
ファイル: HomePage.xaml.cs プロジェクト: Jack-Wong94/Phase2
        //this method use the access token to get the user profile
        private async void WebViewOnNavigated(object sender, WebNavigatedEventArgs e)
        {
            var accessToken = ExtractAccessTokenFromUrl(e.Url);

            if (accessToken != "")
            {
                profile = await GetFacebookProfileAsync(accessToken);

                ChangePage();
            }
        }
コード例 #5
0
ファイル: AzureManager.cs プロジェクト: Jack-Wong94/Phase2
 //HTTP UPDATE method
 public async Task UpdateTimeline(FaceBookModel profile)
 {
     await this.profileTable.UpdateAsync(profile);
 }
コード例 #6
0
ファイル: AzureManager.cs プロジェクト: Jack-Wong94/Phase2
 //The following methods are used for HTTP transport protocol
 //HTTP PUT method
 public async Task AddTimeline(FaceBookModel timeline)
 {
     await this.profileTable.InsertAsync(timeline);
 }
コード例 #7
0
        //basic layout of the page
        public FoodPage(EmotionModel _emotionModel, FaceBookModel profile)
        {
            InitializeComponent();
            NavigationPage.SetHasBackButton(this, false);
            this._emotionModel = _emotionModel;
            this.profile       = profile;
            var image = new Image {
                Aspect = Aspect.AspectFit
            };
            var layout = new StackLayout {
                Padding = new Thickness(5, 10)
            };

            //preview of the dishes based on the emotion
            if (_emotionModel.Emotion.ToLower() == "happiness")
            {
                image.Source = ImageSource.FromFile("happyfood.jpg");
                label        = new Label {
                    Text = "You look happy. Do you want it?", TextColor = Color.FromHex("#77d065"), FontSize = 20
                };
            }
            else if (_emotionModel.Emotion.ToLower() == "anger")
            {
                image.Source = ImageSource.FromFile("angryfood.jpg");
                label        = new Label {
                    Text = "You look angry. Do you want it?", TextColor = Color.FromHex("#77d065"), FontSize = 20
                };
            }
            else if (_emotionModel.Emotion.ToLower() == "contempt")
            {
                image.Source = ImageSource.FromFile("contemptfood.jpg");
                label        = new Label {
                    Text = "You look contempt. Do you want it?", TextColor = Color.FromHex("#77d065"), FontSize = 20
                };
            }
            else if (_emotionModel.Emotion.ToLower() == "disgust")
            {
                image.Source = ImageSource.FromFile("disgustfood.jpg");
                label        = new Label {
                    Text = "You look disgust. Do you want it?", TextColor = Color.FromHex("#77d065"), FontSize = 20
                };
            }
            else if (_emotionModel.Emotion.ToLower() == "fear")
            {
                image.Source = ImageSource.FromFile("fearfood.jpg");
                label        = new Label {
                    Text = "You look fear. Do you want it?", TextColor = Color.FromHex("#77d065"), FontSize = 20
                };
            }
            else if (_emotionModel.Emotion.ToLower() == "neutral")
            {
                image.Source = ImageSource.FromFile("neutralfood.jpg");
                label        = new Label {
                    Text = "You look alright. Do you want it?", TextColor = Color.FromHex("#77d065"), FontSize = 20
                };
            }
            else if (_emotionModel.Emotion.ToLower() == "sadness")
            {
                image.Source = ImageSource.FromFile("sadnessfood.jpg");
                label        = new Label {
                    Text = "You look sad. Do you want it?", TextColor = Color.FromHex("#77d065"), FontSize = 20
                };
            }
            else if (_emotionModel.Emotion.ToLower() == "surprise")
            {
                image.Source = ImageSource.FromFile("surprisefood.jpg");
                label        = new Label {
                    Text = "You look surprised. Do you want it?", TextColor = Color.FromHex("#77d065"), FontSize = 20
                };
            }
            this.Content = layout;
            button       = new Button {
                Text = "Order the food", BackgroundColor = Color.Silver, TextColor = Color.White, BorderRadius = 0
            };
            button.Clicked += SendOrder;
            layout.Children.Add(image);

            layout.Children.Add(label);
            layout.Children.Add(button);
        }