Пример #1
0
        /// <summary>
        /// Resets this form's controls.
        /// </summary>
        private void Reset()
        {
            PictureBox1.Invoke(new MethodInvoker(delegate
            {
                PictureBox1.Visible = false;
                PictureBox2.Visible = false;
                PictureBox3.Visible = false;

                BtnChat1.Visible = false;
                BtnChat2.Visible = false;
                BtnChat3.Visible = false;

                LblName1.Visible = false;
                LblName2.Visible = false;
                LblName2.Visible = false;

                LblUsername.Visible = true;
                LblPassword.Visible = true;

                BtnLogin.Visible    = true;
                TxtUsername.Visible = true;
                TxtPassword.Visible = true;

                LblStatus.Text    = "Connecting...";
                LblStatus.Visible = false;
            }));
        }
Пример #2
0
        /// <summary>
        /// Received characters from login server.
        /// </summary>
        private void NetworkController_OnReceivedCharacters()
        {
            LblStatus.Invoke(new MethodInvoker(delegate { LblStatus.Text = "Received characters..."; }));

            if (NetworkFacade.Avatars.Count == 0)
            {
                MessageBox.Show("You need to create a character before using this chat client!");
                NetworkFacade.Client.Disconnect();

                return;
            }

            PictureBox1.Invoke(new MethodInvoker(delegate
            {
                PictureBox1.Visible = true;
                PictureBox2.Visible = true;
                PictureBox3.Visible = true;

                LblUsername.Visible = false;
                LblPassword.Visible = false;

                BtnLogin.Visible    = false;
                TxtUsername.Visible = false;
                TxtPassword.Visible = false;
            }));

            switch (NetworkFacade.Avatars.Count)
            {
            case 1:
                LblName1.Invoke(new MethodInvoker(delegate
                {
                    LblName1.Visible  = true;
                    LblName1.Text     = NetworkFacade.Avatars[0].Name;
                    LblName1.Location = new Point(this.Width / 2, LblName1.Location.Y);

                    PictureBox1.Image    = NetworkFacade.Avatars[0].Thumbnail;
                    PictureBox1.Location = new Point(this.Width / 2, PictureBox1.Location.Y);

                    BtnChat1.Visible  = true;
                    BtnChat1.Location = new Point((this.Width - 20) / 2, BtnChat1.Location.Y);
                }));
                break;

            case 2:
                LblName1.Invoke(new MethodInvoker(delegate
                {
                    //Enabling LblName3 and PictureBox3 here because it looks prettier...

                    LblName1.Visible = true;
                    LblName1.Text    = NetworkFacade.Avatars[0].Name;

                    LblName3.Visible = true;
                    LblName3.Text    = NetworkFacade.Avatars[1].Name;

                    PictureBox1.Image = NetworkFacade.Avatars[0].Thumbnail;
                    PictureBox3.Image = NetworkFacade.Avatars[1].Thumbnail;

                    BtnChat1.Visible = true;
                    BtnChat3.Visible = true;
                }));
                break;

            case 3:
                LblName1.Invoke(new MethodInvoker(delegate
                {
                    LblName1.Visible = true;
                    LblName1.Text    = NetworkFacade.Avatars[0].Name;

                    LblName2.Visible = true;
                    LblName2.Text    = NetworkFacade.Avatars[1].Name;

                    LblName3.Visible = true;
                    LblName3.Text    = NetworkFacade.Avatars[2].Name;

                    PictureBox1.Image = NetworkFacade.Avatars[0].Thumbnail;
                    PictureBox2.Image = NetworkFacade.Avatars[1].Thumbnail;
                    PictureBox3.Image = NetworkFacade.Avatars[2].Thumbnail;

                    BtnChat1.Visible = true;
                    BtnChat2.Visible = true;
                    BtnChat3.Visible = true;
                }));
                break;
            }
        }