예제 #1
0
    private void CreateAndUpdateBar(KeyValuePair <string, float> dataPair)
    {
        var progressBar = FindBar(dataPair.Key);

        var progressBarBarSize = new Vector2((float)Math.Floor(dataPair.Value / MaxValue * RectSize.x), RectSize.y);

        if (progressBar != null)
        {
            progressBar.BarSize = progressBarBarSize;
        }
        else
        {
            progressBar      = (IconProgressBar)iconProgressBarScene.Instance();
            progressBar.Name = dataPair.Key;
            AddChild(progressBar);
            subBars.Add(progressBar);

            progressBar.Color       = BarHelper.GetBarColour(SelectedType, dataPair.Key, IsProduction);
            progressBar.BarSize     = progressBarBarSize;
            progressBar.IconTexture = BarHelper.GetBarIcon(SelectedType, dataPair.Key);

            progressBar.Connect("gui_input", this, nameof(BarToggled), new Array {
                progressBar
            });
        }
    }
        partial void BtnAskForNewCode_TouchUpInside(UIButton sender)
        {
            //send packet to server
            ServerPacketConfirmation serverPacketConfirmation = ServerHelper.AskConfirmUserAccount(Application.ActualUser, Application.UserPassword);

            //if success
            if (serverPacketConfirmation.ActionSuccess)
            {
                BarHelper.DisplayInfoBar(uivMainView, "Compte", $"Un nouveau code d'activation a été envoyé par mail à  {Application.ActualUser.UserEMail}.", 10,
                                         delegate { tfConfirmationCodeField.BecomeFirstResponder(); btnAskForNewCode.Enabled = false; },
                                         delegate { tfConfirmationCodeField.BecomeFirstResponder(); btnAskForNewCode.Enabled = false; });
                return;
            }

            //chose right error message
            String messageError = string.Empty;

            switch (serverPacketConfirmation.NetworkError)
            {
            case NetworkError.GLOBAL_UNKNOWN:
                goto default;

            case NetworkError.SERVER_UNAVAILABLE:
                messageError = MSGBank.ERROR_NO_SERVER;
                break;

            default:
                messageError = MSGBank.ERROR_UNKNOWN;
                break;
            }

            MessageBox.ShowOK(MSGBank.ERROR_TITLE, messageError, this);
        }
예제 #3
0
        partial void BtnDeleteAttribut_TouchUpInside(UIButton sender)
        {
            //if is a new attribute
            if (petAttributeID == -1)
            {
                this.NavigationController.PopViewController(true);
                return;
            }

            //remove attribute
            ServerPacketConfirmation serverPacketConfirmation = ServerHelper.DeleteAttribut(Application.PetManager.SelectedPet.PetID, petAttributeID);

            if (serverPacketConfirmation.ActionSuccess)
            {
                this.NavigationController.PopViewController(true);
                return;
            }

            //chose right error message
            String errorMessage = string.Empty;

            switch (serverPacketConfirmation.NetworkError)
            {
            case NetworkError.SERVER_UNAVAILABLE:
                errorMessage = MSGBank.ERROR_NO_SERVER;
                break;

            default:
                errorMessage = $"Impossible de modifier les attributs";
                break;
            }
            //show error message
            BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, errorMessage);
        }
예제 #4
0
        partial void BtnConfirmDAuth_TouchUpInside(UIButton sender)
        {
            if (String.IsNullOrEmpty(tfCodeField.Text))
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, MSGBank.ERROR_FILL_ALL_FIELDS);
                return;
            }

            String userCode = DAuthHelper.GetUserCode(Application.ActualUserPrivateKey);

            if (tfCodeField.Text.ToLower() != userCode.ToLower())
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, "Ce code est erroné");
                return;
            }

            //load user pets
            Application.PetManager.LoadUserPetList(Application.ActualUser);

            //instantiate main view controller
            UIStoryboard         mainBoard            = UIStoryboard.FromName("Main", null);
            MainTabBarController mainTabBarController = mainBoard.InstantiateViewController("MainTabBarController") as MainTabBarController;

            PresentViewController(mainTabBarController, true, null);
        }
        public void ConfirmAccount()
        {
            //get confirmation code
            String confirmationCode = tfConfirmationCodeField.Text;

            //send packet to server
            ServerPacketConfirmation serverPacketConfirmation = ServerHelper.ConfirmUserAccount(Application.ActualUser, confirmationCode);

            //if success
            if (serverPacketConfirmation.ActionSuccess)
            {
                BarHelper.DisplayInfoBar(uivMainView, "Compte", "Votre compte a été confirmé", 5, delegate
                {
                    //load user pets
                    Application.PetManager.LoadUserPetList(Application.ActualUser);

                    //instantiate main view controller
                    UIStoryboard mainBoard = UIStoryboard.FromName("Main", null);
                    MainTabBarController mainTabBarController = mainBoard.InstantiateViewController("MainTabBarController") as MainTabBarController;
                    PresentViewController(mainTabBarController, true, null);
                }, delegate
                {
                    //load user pets
                    Application.PetManager.LoadUserPetList(Application.ActualUser);

                    //instantiate main view controller
                    UIStoryboard mainBoard = UIStoryboard.FromName("Main", null);
                    MainTabBarController mainTabBarController = mainBoard.InstantiateViewController("MainTabBarController") as MainTabBarController;
                    PresentViewController(mainTabBarController, true, null);
                });

                return;
            }

            //chose right error message
            String messageError = string.Empty;

            switch (serverPacketConfirmation.NetworkError)
            {
            case NetworkError.GLOBAL_UNKNOWN:
                goto default;

            case NetworkError.SQL_USER_WRONG_ACCODE:
                messageError = "Ce code d'activation n'existe pas.";
                break;

            case NetworkError.SERVER_UNAVAILABLE:
                messageError = MSGBank.ERROR_NO_SERVER;
                break;

            default:
                messageError = MSGBank.ERROR_UNKNOWN;
                break;
            }
            BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, messageError);
        }
        partial void BtnSaveEdit_TouchUpInside(UIButton sender)
        {
            //if some fields are empty
            if (String.IsNullOrEmpty(tfUserEmailField.Text) || String.IsNullOrEmpty(tfUserPasswordField.Text))
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, MSGBank.ERROR_FILL_ALL_FIELDS);
                return;
            }

            //if email is valid
            if (!tfUserEmailField.Text.IsValidEmail())
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, MSGBank.ERROR_WRONG_EMAIL);
                return;
            }

            //if the two passwords are the same
            if (tfUserPasswordField.Text != tfUserPasswordConfirmField.Text)
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, MSGBank.ERROR_NOT_SAME_PASSWORD);
                return;
            }

            //change actual user infos
            PLFUser actualUser = Application.ActualUser;

            actualUser.UserName    = tfUserNameField.Text;
            actualUser.UserSurname = tfUserSurnameField.Text;
            actualUser.UserEMail   = tfUserEmailField.Text;

            //send profile update to server
            ServerPacketConfirmation serverPacketConfirmation = ServerHelper.UpdateUserProfile(actualUser, tfUserPasswordField.Text);

            //if success
            if (serverPacketConfirmation.ActionSuccess)
            {
                BarHelper.DisplayInfoBar(uivMainView, "Profil", "Votre profil a correctement été mis à jour.");
            }
            else
            {
                //get the good error message
                String errorMessage = string.Empty;
                switch (serverPacketConfirmation.NetworkError)
                {
                case NetworkError.SERVER_UNAVAILABLE:
                    errorMessage = MSGBank.ERROR_NO_SERVER;
                    break;

                default:
                    errorMessage = $"Impossible de mettre à jour votre profil.";
                    break;
                }
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, errorMessage);
            }
        }
예제 #7
0
    void Start()
    {
        gameHelper    = FindObjectOfType <GameHelper>();
        benefitHelper = FindObjectOfType <BenefitHelper>();
        barHelper     = FindObjectOfType <BarHelper>();

        startHealth = barHelper.MonsterHealthUpdate(startHealth);
        benefitHelper.GoldMonsterUpdateFunction(startHealth);

        barHelper.HealtBar      = startHealth;
        barHelper.HealthBarText = startHealth;
    }
        partial void BtnChangePassword_TouchUpInside(UIButton sender)
        {
            //if fields are empty
            if (String.IsNullOrEmpty(tfNickNameField.Text) || String.IsNullOrEmpty(tfCodeField.Text) ||
                String.IsNullOrEmpty(tfPasswordField.Text))
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, MSGBank.ERROR_FILL_ALL_FIELDS);
                return;
            }

            //if not same password
            if (tfPasswordField.Text != tfPasswordConfirmField.Text)
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, MSGBank.ERROR_NOT_SAME_PASSWORD);
                return;
            }

            //send packet to server
            ServerPacketConfirmation serverPacketConfirmation = ServerHelper.ResetUserPassword(tfNickNameField.Text, tfPasswordField.Text, tfCodeField.Text);

            if (serverPacketConfirmation.ActionSuccess)
            {
                MessageBox.ShowOK("Restauration de mot de passe", "Votre mot de passe a été mis à jour ! Vous pouvez désormais vous connecter avec celui-ci !", this, delegate { this.NavigationController.PopToRootViewController(true); });
                return;
            }

            //chose right error message
            String messageError = string.Empty;

            switch (serverPacketConfirmation.NetworkError)
            {
            case NetworkError.GLOBAL_UNKNOWN:
                goto default;

            case NetworkError.SERVER_UNAVAILABLE:
                messageError = MSGBank.ERROR_NO_SERVER;
                break;

            case NetworkError.SQL_USER_UNKNOWN:
                messageError = MSGBank.ERROR_UNKNOWN_USER;
                break;

            case NetworkError.SQL_USER_WRONG_ACCODE:
                messageError = "Ce code de restauration n'existe pas ou n'est plus valide !";
                break;

            default:
                messageError = MSGBank.ERROR_UNKNOWN;
                break;
            }
            BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, messageError);
        }
예제 #9
0
        private void Connect()
        {
            //if empty fields
            if (String.IsNullOrEmpty(tfNickField.Text) || String.IsNullOrEmpty(tfPasswordField.Text))
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, MSGBank.ERROR_FILL_ALL_FIELDS, 3);
                return;
            }

            ConnectionHelper.SaveConnectionProfile(tfNickField.Text, tfPasswordField.Text);

            Auth(new ConnectionProfile(tfNickField.Text, tfPasswordField.Text.HashSHA256()));
        }
예제 #10
0
    private void HandleBarDisabling(IconProgressBar bar)
    {
        if (bar.Disabled)
        {
            bar.Color = new Color(0.73f, 0.73f, 0.73f);
        }
        else
        {
            bar.Color = BarHelper.GetBarColour(SelectedType, bar.Name, IsProduction);
        }

        MoveBars();
    }
예제 #11
0
        public ActionResult Index(string id)
        {
            // 查询吧信息
            var bar = BarHelper.GetModelByName(id);

            if (bar == null)
            {
                // 吧不存在,创建一个
                bar = new BarModel()
                {
                    Name = id
                };
                BarHelper.Add(bar);
            }
            return(View(bar));
        }
예제 #12
0
        public ActionResult ListMyFollowed()
        {
            var list = UserBarHelper.GetListFollowed(LoginHelper.LoginUser.UserID);
            // »ñÈ¡°ÉÃû
            var barinfo = BarHelper.GetList(list.Select(m => m.BarID).ToArray());

            return(Json(list.Select(m =>
            {
                var bar = barinfo.First(b => b.ID == m.BarID);
                return new
                {
                    m.CreateTime,
                    bar.ID,
                    bar.Name
                };
            })));
        }
예제 #13
0
        /// <summary>
        /// Loads the page.
        /// </summary>
        public void LoadPage()
        {
            //get user share list online
            List <PLFUser> userList = ServerHelper.SharePetList(selectedPet.PetID).UserList;

            //if no
            if (userList.Count <= 0)
            {
                InitUserPicker(new List <PLFUser>());
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, "Ce familier n'est partagé avec personne !");
                return;
            }

            //init user picker with downloaded list
            InitUserPicker(userList);
            selectedUser = userList[0];
            pvUserPicker.SelectedRowInComponent(0);
        }
예제 #14
0
        /// <summary>
        /// Buttons the save pet touch up inside.
        /// </summary>
        /// <param name="sender">Sender.</param>
        partial void BtnSavePet_TouchUpInside(UIButton sender)
        {
            //create new pet with selected type
            PLFPet pet = new PLFPet(selectedType);

            pet.PetName = tfPetNameField.Text;

            //send pet register to server
            ServerPacketAddPet serverPacketAddPet = ServerHelper.AddPet(Application.ActualUser, pet);

            //if register success
            if (serverPacketAddPet.RegisterSuccess)
            {
                //set pet id
                pet.PetID = serverPacketAddPet.PetID;

                //add pet to user pet list
                Application.PetManager.AddPet(pet);

                //reset fields
                selectedType        = PetType.OTHER;
                tfPetNameField.Text = "";

                //pop actual controller
                this.NavigationController.PopViewController(true);
                return;
            }

            //get the good error message
            String errorMessage = string.Empty;

            switch (serverPacketAddPet.NetworkError)
            {
            case NetworkError.SERVER_UNAVAILABLE:
                errorMessage = MSGBank.ERROR_NO_SERVER;
                break;

            default:
                errorMessage = $"Impossible d'ajouter ce familier";
                break;
            }
            BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, errorMessage);
        }
        partial void BtnAskForNewCode_TouchUpInside(UIButton sender)
        {
            //if fields are empty
            if (String.IsNullOrEmpty(tfNickNameField.Text))
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, "Vous devez remplir le champ 'Nom d'utilisateur'");
                return;
            }

            //send packet to server
            ServerPacketConfirmation serverPacketConfirmation = ServerHelper.AskResetUserPassword(tfNickNameField.Text);

            //if success
            if (serverPacketConfirmation.ActionSuccess)
            {
                BarHelper.DisplayInfoBar(uivMainView, "Restauration de mot de passe", "Un nouveau code de restauration de mot de passe vous a été envoyé par mail !");
                btnAskForNewCode.Enabled = false;
                return;
            }

            //chose right error message
            String messageError = string.Empty;

            switch (serverPacketConfirmation.NetworkError)
            {
            case NetworkError.GLOBAL_UNKNOWN:
                goto default;

            case NetworkError.SERVER_UNAVAILABLE:
                messageError = MSGBank.ERROR_NO_SERVER;
                break;

            case NetworkError.SQL_USER_UNKNOWN:
                messageError = MSGBank.ERROR_UNKNOWN_USER;
                break;

            default:
                messageError = MSGBank.ERROR_UNKNOWN;
                break;
            }
            BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, messageError);
        }
예제 #16
0
        partial void BtnSharePet_TouchUpInside(UIButton sender)
        {
            //if try to share to himself
            if (tfShareUserName.Text.ToLower() == Application.ActualUser.UserNickName.ToLower())
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, MSGBank.ERROR_SHARE_YOURSELF);
                return;
            }

            //send share pet packet to server
            ServerPacketConfirmation serverPacketConfirmation = ServerHelper.SharePet(
                Application.ActualUser, selectedPet, tfShareUserName.Text, swAllowModifications.On ? 1 : 0);

            //if success share
            if (serverPacketConfirmation.ActionSuccess)
            {
                this.NavigationController.PopViewController(true);
                MessageBox.ShowOK("Partage", $"Votre familier a bien été partagé avec {tfShareUserName.Text}", this.NavigationController.ParentViewController);
                return;
            }

            //chose right error message
            String errorMessage = string.Empty;

            switch (serverPacketConfirmation.NetworkError)
            {
            case NetworkError.SERVER_UNAVAILABLE:
                errorMessage = MSGBank.ERROR_NO_SERVER;
                break;

            case NetworkError.SQL_USER_UNKNOWN:
                errorMessage = MSGBank.ERROR_UNKNOWN_USER;
                break;

            default:
                errorMessage = $"Impossible de partager ce familier";
                break;
            }
            //show error message
            BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, errorMessage);
        }
예제 #17
0
        /// <summary>
        /// Buttons the delete pet touch up inside.
        /// </summary>
        /// <param name="sender">Sender.</param>
        partial void BtnDeletePet_TouchUpInside(UIButton sender)
        {
            //ask yes no  delete
            MessageBox.ShowYesNo("Suppression de familier", "Etes vous sûr de vouloir supprimer ce familier ?", delegate
            {
                //yes
                //send delete pet to server
                ServerPacketConfirmation serverPacketConfirmation = ServerHelper.DeletePet(Application.ActualUser, actualPet);

                //if pet successfuly delete
                if (serverPacketConfirmation.ActionSuccess)
                {
                    //delete from list
                    Application.PetManager.DeletePet(actualPet);

                    //pop view controller
                    this.NavigationController.PopViewController(true);
                    return;
                }

                //switch for the good error msg
                String errorMessage = string.Empty;
                switch (serverPacketConfirmation.NetworkError)
                {
                case NetworkError.SERVER_UNAVAILABLE:
                    errorMessage = MSGBank.ERROR_NO_SERVER;
                    break;

                default:
                    errorMessage = $"Impossible de supprimer ce familier";
                    break;
                }
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, errorMessage);
                //Show error message
            }, delegate
            {
                //no
                //nothing
            }, this);
        }
        partial void BtnActivateDAuth_TouchUpInside(UIButton sender)
        {
            if (String.IsNullOrEmpty(tfCodeField.Text))
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, MSGBank.ERROR_FILL_ALL_FIELDS);
                return;
            }

            if (googleTOTP.GeneratePin().ToLower() != tfCodeField.Text.ToLower())
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, "Code erroné !");
                return;
            }

            ServerPacketConfirmation serverPacketConfirmation = ServerHelper.EnableUserDAuth(Application.ActualUser, googleTOTP.getPrivateKey());

            //if success
            if (serverPacketConfirmation.ActionSuccess)
            {
                Application.ActualUserPrivateKey = googleTOTP.getPrivateKey();
                MessageBox.ShowOK("Double authentification", "La double authentification a bien été activée.", this,
                                  delegate { this.NavigationController.PopToRootViewController(true); });
            }
            else
            {
                //get the good error message
                String errorMessage = string.Empty;
                switch (serverPacketConfirmation.NetworkError)
                {
                case NetworkError.SERVER_UNAVAILABLE:
                    errorMessage = MSGBank.ERROR_NO_SERVER;
                    break;

                default:
                    errorMessage = $"Impossible d'activer la double authentification.";
                    break;
                }
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, errorMessage);
            }
        }
예제 #19
0
        partial void BtnSaveChanges_TouchUpInside(UIButton sender)
        {
            //set pet attribute fields
            petAttribute.AttributeTitle       = tfAttributName.Text;
            petAttribute.AttributeDescription = tvAttributDescription.Text;
            petAttribute.PetAttributeType     = selectedType;

            //remove old attribute and add new one
            if (petAttributeID != -1)
            {
                ServerHelper.DeleteAttribut(Application.PetManager.SelectedPet.PetID, petAttributeID);
            }

            //send packet to server
            ServerPacketConfirmation serverPacketConfirmation = ServerHelper.AddAttribut(Application.PetManager.SelectedPet.PetID, petAttribute);

            if (serverPacketConfirmation.ActionSuccess)
            {
                this.NavigationController.PopViewController(true);
                return;
            }

            //chose right error message
            String errorMessage = string.Empty;

            switch (serverPacketConfirmation.NetworkError)
            {
            case NetworkError.SERVER_UNAVAILABLE:
                errorMessage = MSGBank.ERROR_NO_SERVER;
                break;

            default:
                errorMessage = $"Impossible de modifier les attributs";
                break;
            }
            //show error message
            BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, errorMessage);
        }
        partial void BtnDesactivateDAuth_TouchUpInside(UIButton sender)
        {
            MessageBox.ShowYesNo("Double Authentification", "Êtes vous sûr de vouloir supprimer la double authentification?",
                                 delegate
            {
                ServerPacketConfirmation serverPacketConfirmation = ServerHelper.DisableUserDAuth(Application.ActualUser);

                //if success
                if (serverPacketConfirmation.ActionSuccess)
                {
                    MessageBox.ShowOK("Double authentification", "La double authentification a bien été désactivée.", this, delegate {
                        Application.ActualUserPrivateKey = null;
                        this.NavigationController.PopToRootViewController(true);
                    });
                }
                else
                {
                    //get the good error message
                    String errorMessage = string.Empty;
                    switch (serverPacketConfirmation.NetworkError)
                    {
                    case NetworkError.SERVER_UNAVAILABLE:
                        errorMessage = MSGBank.ERROR_NO_SERVER;
                        break;

                    default:
                        errorMessage = $"Impossible de désactiver la double authentification.";
                        break;
                    }
                    BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, errorMessage);
                }
            },
                                 delegate
            {
                //no action
            },
                                 this);
        }
예제 #21
0
        private async void LoadData()
        {
            RunOnUiThread(() =>
            {
                progressBar.Visibility    = ViewStates.Visible;
                progressBar.Indeterminate = true;
            });
            try
            {
                var items = await BarHelper.GenerateData(viewModel, Resources.GetColor(Resource.Color.bar_up),
                                                         Resources.GetColor(Resource.Color.bar_down));


                RunOnUiThread(() =>
                {
                    if (items.Count == 0)
                    {
                        MessageDialog.SendMessage(this, "There is no data for this group, please check in a few members first to a meetup.", "No Statistics");
                        return;
                    }
                    else if (viewModel.GroupsEventsCount.ContainsKey(0))
                    {
                        MessageDialog.SendMessage(this, "Data for group needs synced, please re-visit all meetups to synchronize data and return for in depth statistics.", "No Statistics");
                    }

                    barChart.ItemsSource = items;
                    barChart.Invalidate();
                });
            }
            finally
            {
                RunOnUiThread(() =>
                {
                    progressBar.Visibility    = ViewStates.Gone;
                    progressBar.Indeterminate = false;
                });
            }
        }
예제 #22
0
        partial void BtnCancelShare_TouchUpInside(UIButton sender)
        {
            //if no user selected
            if (selectedUser == null)
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, "Il faut sélectionner un utilisateur !");
                return;
            }

            //send kill share pet to server
            ServerPacketConfirmation serverPacketConfirmation = ServerHelper.KillSharePet(selectedPet.PetID, selectedUser.ID);

            //if success
            if (serverPacketConfirmation.ActionSuccess)
            {
                BarHelper.DisplayInfoBar(uivMainView, "Partage", $"Le partage a bien été cessé avec {selectedUser.UserNickName} !");
                //reload page
                LoadPage();
                return;
            }

            //chose right error message
            String errorMessage = string.Empty;

            switch (serverPacketConfirmation.NetworkError)
            {
            case NetworkError.SERVER_UNAVAILABLE:
                errorMessage = MSGBank.ERROR_NO_SERVER;
                break;

            default:
                errorMessage = $"Impossible de césser le partage de ce familier !";
                break;
            }
            //show error message
            BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, errorMessage);
        }
예제 #23
0
    private void CreateAndUpdateBar(KeyValuePair <string, float> dataPair)
    {
        var progressBar = FindBar(dataPair.Key);

        var progressBarBarSize = new Vector2((float)Math.Floor(dataPair.Value / MaxValue * RectSize.x), RectSize.y);

        if (progressBar != null)
        {
            progressBar.BarSize = progressBarBarSize;
        }
        else
        {
            progressBar      = (IconProgressBar)iconProgressBarScene.Instance();
            progressBar.Name = dataPair.Key;
            AddChild(progressBar);
            SubBars.Add(progressBar);

            progressBar.Color          = BarHelper.GetBarColour(SelectedType, dataPair.Key, IsProduction);
            progressBar.HighlightColor = new Color(progressBar.Color.r + 0.5f, progressBar.Color.g + 0.5f,
                                                   progressBar.Color.b + 0.5f, 0.3f);
            progressBar.BarSize        = progressBarBarSize;
            progressBar.IconTexture    = BarHelper.GetBarIcon(SelectedType, dataPair.Key);
            progressBar.IconModulation = BarHelper.GetBarIconColor(SelectedType);

            progressBar.MouseFilter = MouseFilterEnum.Pass;

            progressBar.Connect("gui_input", this, nameof(BarToggled), new Array {
                progressBar
            });
            progressBar.Connect("mouse_entered", this, nameof(OnBarMouseOver), new Array {
                progressBar
            });
            progressBar.Connect("mouse_exited", this, nameof(OnBarMouseExit), new Array {
                progressBar
            });
        }
    }
예제 #24
0
        /// <summary>
        /// Auth the specified connectionProfile.
        /// </summary>
        /// <param name="connectionProfile">Connection profile.</param>
        public void Auth(ConnectionProfile connectionProfile)
        {
            //send login packet
            ServerPacketUserLogin serverPacketUserLogin = ServerHelper.LoginUserHashed(connectionProfile.UserName, connectionProfile.UserPassword);

            //if login success
            if (serverPacketUserLogin.NetworkError == NetworkError.NONE)
            {
                //set actual user infos
                Application.ActualUser   = serverPacketUserLogin.UserProfile;
                Application.UserPassword = tfPasswordField.Text;


                if (serverPacketUserLogin.UserAccountActivate)
                {
                    if (serverPacketUserLogin.UserDAuthPrivateKey != null)
                    {
                        Application.ActualUserPrivateKey = serverPacketUserLogin.UserDAuthPrivateKey;

                        PerformSegue("DAuthLoginSegue", this);
                        return;
                    }


                    //load user pets
                    Application.PetManager.LoadUserPetList(serverPacketUserLogin.UserProfile);

                    //instantiate main view controller
                    UIStoryboard         mainBoard            = UIStoryboard.FromName("Main", null);
                    MainTabBarController mainTabBarController = mainBoard.InstantiateViewController("MainTabBarController") as MainTabBarController;
                    PresentViewController(mainTabBarController, true, null);
                }
                else
                {
                    PerformSegue("ConnectConfirmAccountSegue", this);
                }
                return;
            }

            //chose right error message
            String messageError = string.Empty;

            switch (serverPacketUserLogin.NetworkError)
            {
            case NetworkError.GLOBAL_UNKNOWN:
                goto default;

            case NetworkError.SQL_USER_UNKNOWN:
                messageError = "Utilisateur ou mot de passe incorect";
                break;

            case NetworkError.SERVER_UNAVAILABLE:
                messageError = MSGBank.ERROR_NO_SERVER;
                break;

            default:
                messageError = MSGBank.ERROR_UNKNOWN;
                break;
            }
            BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, messageError, 5);
            //ßMessageBox.ShowOK(MSGBank.ERROR_TITLE, messageError, this);
        }
예제 #25
0
 public ServiceHelper(BarHelper barHelper)
 {
     this.BarHelper = barHelper;
 }
예제 #26
0
        /// <summary>
        /// Register this instance.
        /// </summary>
        void Register()
        {
            //if fields are empty
            if (String.IsNullOrEmpty(tfNickNameField.Text) || String.IsNullOrEmpty(tfEmailField.Text) ||
                String.IsNullOrEmpty(tfPasswordField.Text))
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, MSGBank.ERROR_FILL_ALL_FIELDS);
                return;
            }

            //if invalid email
            if (!tfEmailField.Text.IsValidEmail())
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, MSGBank.ERROR_WRONG_EMAIL);
                return;
            }

            //if not same password
            if (tfPasswordField.Text != tfPasswordConfirmField.Text)
            {
                BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, MSGBank.ERROR_NOT_SAME_PASSWORD);
                return;
            }

            //init new user with register properties
            PLFUser user = new PLFUser();

            user.UserName     = tfNameField.Text;
            user.UserSurname  = tfSurnameField.Text;
            user.UserEMail    = tfEmailField.Text;
            user.UserNickName = tfNickNameField.Text;

            //send register packet
            ServerPacketUserRegister serverPacketUserRegister = ServerHelper.RegisterUser(user, tfPasswordField.Text);

            //if register success
            if (serverPacketUserRegister.RegisterSuccess)
            {
                //Set user id with received user id
                user.ID = serverPacketUserRegister.UserID;

                //set the actual user
                Application.ActualUser   = user;
                Application.UserPassword = tfPasswordField.Text;

                //load user pet list
                Application.PetManager.LoadUserPetList(user);

                BarHelper.DisplayInfoBar(uivMainView, "Inscription", $"Super ! Vous vous êtes bien inscrit sous le nom de {user.UserNickName} !", 3,
                                         delegate {
                    ConnectionHelper.SaveConnectionProfile(tfNickNameField.Text, tfPasswordField.Text);
                    PerformSegue("RegisterConfirmAccountSegue", this);

                    //reset register fields
                    tfNameField.Text            = string.Empty;
                    tfSurnameField.Text         = string.Empty;
                    tfEmailField.Text           = string.Empty;
                    tfNickNameField.Text        = string.Empty;
                    tfPasswordField.Text        = string.Empty;
                    tfPasswordConfirmField.Text = string.Empty;
                },
                                         delegate {
                    ConnectionHelper.SaveConnectionProfile(tfNickNameField.Text, tfPasswordField.Text);
                    PerformSegue("RegisterConfirmAccountSegue", this);

                    //reset register fields
                    tfNameField.Text            = string.Empty;
                    tfSurnameField.Text         = string.Empty;
                    tfEmailField.Text           = string.Empty;
                    tfNickNameField.Text        = string.Empty;
                    tfPasswordField.Text        = string.Empty;
                    tfPasswordConfirmField.Text = string.Empty;
                });

                return;
            }

            //chose right error message
            String messageError = string.Empty;

            switch (serverPacketUserRegister.NetworkError)
            {
            case NetworkError.GLOBAL_UNKNOWN:
                goto default;

            case NetworkError.SERVER_UNAVAILABLE:
                messageError = MSGBank.ERROR_NO_SERVER;
                break;

            case NetworkError.SQL_USER_EXIST:
                messageError = "Ce nom d'utilisateur est deja pris !";
                break;

            default:
                messageError = MSGBank.ERROR_UNKNOWN;
                break;
            }

            BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, messageError);
        }