private void LogInWithFacebookButton_Click(object sender, RoutedEventArgs e)
        {
            MainWindow.Instance.PanelLoading     = true;
            MainWindow.Instance.PanelMainMessage = "Enregistrement en cours";

            var dialog = new FacebookLoginWindow()
            {
                AppId = "719645478171450"
            };

            if (dialog.ShowDialog() == true)
            {
                // Get the access token from Facebook
                _user.FacebookToken   = dialog.AccessToken;
                _user.PlayerLoginType = User.LoginType.Facebook;

                // Login with facebook credentials
                var inputDialog = new ChatCanalInputWindow("Please enter your username:"******"Facebook User is invalid - frontend");
                        return;
                    }

                    try
                    {
                        var token = _userAccess.Register(username, "", userId);
                        _user.UserToken   = token;
                        _user.FacebookId  = userId;
                        _user.Name        = username;
                        _user.IsConnected = true;

                        // Go to main menu if login is completed
                        Load.LoadOnLogin();
                        MainWindow.Instance.PanelLoading = false;
                        _eventManager.Notice(new ChangeStateEvent()
                        {
                            NextState = Enums.States.MainMenu
                        });


                        FacebookAccess.PostOnWall(_user.FacebookToken, "Je me suis enregistrer a Princess Love balls (Projet 3 informatique)");
                    }
                    catch (Exception exception)
                    {
                        ShowError(exception.Message);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static void CheckAchievement(EnumsModel.Achievement achievement, Bitmap image)
        {
            if (CurrentUserAchievements != null &&
                CurrentUserAchievements.ContainsKey(achievement) &&
                !CurrentUserAchievements[achievement])
            {
                // trigger Achievement
                ProgressManager.TriggerProgress(ProgressManager.ProgressType.DoneAchievement);
                MainWindow.Achievement.ShowAchievement(image);
                CurrentUserAchievements[achievement] = true;
                CheckForAllAchievements();
                StatsManager.UpdateAchievementsUnlocked();

                // Sync achievements
                ProfileAccess.Instance.UpdateUserProfile(Profile.Instance.CurrentProfile);


                // Post on wall
                if (!string.IsNullOrWhiteSpace(User.Instance.FacebookToken))
                {
                    FacebookAccess.PostOnWall(User.Instance.FacebookToken, achievement);
                }
            }
        }