Beispiel #1
0
        /// <summary>
        /// Initialise les PictureBox qui contiennent les images de l'avatar et du fond de l'utilisateur
        /// </summary>
        /// <param name="avatar">Le PictureBox qui contiendra l'avatar</param>
        /// <param name="imgAvatar">L'image de l'avatar</param>
        /// <param name="background">Le PictureBox qui contiendra le fond</param>
        /// <param name="imgBackground">L'image de fond</param>
        private void InitPictureBox(PictureBox avatar, Image imgAvatar, PictureBox background, Image imgBackground)
        {
            // On arrondit le PictureBox l'avatar
            Design.RoundControl(avatar, 0, 0, avatar.Width - 3, avatar.Height - 3);

            // On affiche les images de profil et de fond
            avatar.Image     = imgAvatar;
            background.Image = imgBackground;

            // On stocke les images
            _imgAvatar     = imgAvatar;
            _imgBackground = imgBackground;
        }
Beispiel #2
0
        /// <summary>
        /// Initialise les différents composants de l'interface
        /// </summary>
        private void FrmHome_Load(object sender, EventArgs e)
        {
            // Initialise la date et l'heure
            DateTime dt = new DateTime();

            dt          = DateTime.Now;
            tsDate.Text = dt.ToString("dddd d MMMM yyyy - HH:mm");

            // On arrondit les boutons de l'interface
            Design.RoundControl(btnStatutAvatar, 2, 2, btnStatutAvatar.Width - 5, btnStatutAvatar.Height - 5);
            foreach (Control control in pnlStatus.Controls)
            {
                // Si le contrôle qu'on est en train de parcourir dans notre panel est un boutton, alors on l'arrondit
                // On ne veut pas arrondir les labels présent dans le panel
                if (control.GetType() == typeof(Button))
                {
                    Design.RoundControl(control, 2, 2, btnStatutAvatar.Width - 5, btnStatutAvatar.Height - 5);
                }
            }
            // Initialisation des images des différents onglets
            string[] arrayImg      = _requestsSQL.GetUserImagesIdByUsername(_frmLogin.Username);
            string   idAvatar      = arrayImg[0];
            string   idBackground  = arrayImg[1];
            Image    imgAvatar     = null;
            Image    imgBackground = null;

            // On affiche les images de profil et de fond
            if (idAvatar != null)
            {
                imgAvatar = _requestsSQL.CreateImageById(idAvatar); // Récupère l'avatar de l'utilisateur
            }
            if (idBackground != null)
            {
                imgBackground = _requestsSQL.CreateImageById(idBackground); // Récupère le background de l'utilisateur
            }

            InitPictureBox(pbxAvatar, imgAvatar, pbxBackground, imgBackground);

            // Initialisation du profil de l'utilisateur
            Dictionary <string, string> profil = _requestsSQL.GetProfilByUsername(_frmLogin.Username); // Récupère les informations du profil de l'utilisateur

            InitProfil(pbxAvatar2, imgAvatar, pbxBackground2, imgBackground, lblUsername, _frmLogin.Username, rtbDescription, profil["description"], tbxEmail, profil["email"], tbxPhone, profil["phone"], dgvHobbies, profil["hobbies"]);

            lblHome.Text = "Bienvenue " + _frmLogin.Username + " !";
            // Gestion de la transparence des composants
            lblHome.Parent        = pbxBackground;
            lnkEditProfil.Parent  = pbxBackground;
            lnkEditProfil2.Parent = pbxBackground2;
            lblUsername.Parent    = pbxBackground2;

            // Gestions d'événements & Placeholder
            tbxNewHobbie.LostFocus += TbxNewHobbie_LostFocus;
            Placeholder phNewHobby       = new Placeholder(tbxNewHobbie, PLACEHOLDER_HOBBIES);
            Placeholder phSearchFriends  = new Placeholder(tbxSearchFriend, PLACEHOLDER_SEARCH_FRIENDS);
            Placeholder phSearchFriends2 = new Placeholder(tbxSearchFriend2, PLACEHOLDER_SEARCH_FRIENDS);
            Placeholder phSearchRooms    = new Placeholder(tbxSearchRoom, PLACEHOLDER_SEARCH_ROOMS);

            // Gestion de la liste d'ami
            _friendsList = _requestsSQL.GetFriendsList(_requestsSQL.GetUserIdByUsername(_frmLogin.Username));
            // REMARK : Création de la liste d'ami non satisfaisante (faut-il revoir l'interface ?)
            foreach (string[] friend in _friendsList)
            {
                Image friendAvatar = _requestsSQL.GetFriendAvatarByFriendId(friend[0]); // On récupère l'avatar de notre ami

                // Création d'une ligne et remplissage des données
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dgvFriendsList);                              // Ne pas oublié de créé les cellules
                row.Cells[0].Value = friendAvatar;                            // Ajout de l'image
                row.Cells[1].Value = _requestsSQL.GetUsernameById(friend[0]); // Ajout du nom de l'ami
                row.Cells[2].Value = friend[1];                               // Ajout du message

                dgvFriendsList.Rows.Add(row);                                 // On ajoute la ligne
            }


            // TODO : connexion avec le serveur
            IPAddress address = IPAddress.Parse("127.0.0.1");

            ClientTchat client = new ClientTchat(address, 3001);
        }