Ejemplo n.º 1
0
        private void PictureBox2_Click(object sender, EventArgs e)
        {
            if (!clicked)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter = "Image|*.jpg";
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    pictureBox3.Location = new Point(pictureBox3.Location.X, pictureBox2.Location.Y + 25);
                    pictureBox4.Location = new Point(pictureBox4.Location.X, pictureBox2.Location.Y + 25);

                    pictureBox3.Visible = true;
                    titleImage          = CommonHandler.ResizeImage(Image.FromFile(openFileDialog.FileName), new Size(241, 142));
                    pictureBox3.Image   = CommonHandler.ResizeImage(titleImage, new Size(75, 75));
                    pictureBox4.Visible = true;
                    Bitmap bitmap = new Bitmap("../../Image/cross.png");
                    pictureBox4.Image = CommonHandler.ResizeImage(bitmap, new Size(10, 10));
                    clicked           = true;
                }
            }
        }
Ejemplo n.º 2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if (Valide(tb1.Text, tb2.Text, tb3.Text))
            {
                string ipv4 = NetworkHandler.GetLocalIP();
                string salt = CommonHandler.Get_salt();
                conn.Open();

                SqlCommand cmd = new SqlCommand("insert into user_info(username,salt,hash,status,ip,answer) values(@UN, @SALT, @HASH,0,@IP,@AS)", conn);
                cmd.Parameters.Add("@UN", SqlDbType.VarChar, 50).Value   = tb1.Text;
                cmd.Parameters.Add("@SALT", SqlDbType.VarChar, 50).Value = salt;
                cmd.Parameters.Add("@HASH", SqlDbType.VarChar, 50).Value = CommonHandler.Get_hash(tb2.Text, salt);
                cmd.Parameters.Add("@IP", SqlDbType.VarChar, 50).Value   = ipv4;
                cmd.Parameters.Add("@AS", SqlDbType.VarChar, 50).Value   = tb4.Text;

                cmd.ExecuteNonQuery();
                cmd.Dispose();

                Bitmap bitmap = new Bitmap("../../Image/default_avatar.png");
                bitmap = (Bitmap)CommonHandler.ResizeImage(bitmap, new Size(75, 75));
                string avatarStr     = CommonHandler.ImgToBase64String(bitmap);
                string backgroundStr = CommonHandler.ImgToBase64String("../../Image/default_background.png");

                SqlCommand insert = new SqlCommand("insert into user_picture (username, user_avatar, user_background) values(@UN, @UA, @UB)", conn);
                insert.Parameters.Add("@UN", SqlDbType.VarChar).Value = tb1.Text;
                insert.Parameters.Add("@UA", SqlDbType.VarChar).Value = avatarStr;
                insert.Parameters.Add("@UB", SqlDbType.VarChar).Value = backgroundStr;

                insert.ExecuteNonQuery();
                insert.Dispose();

                conn.Close();

                MessageBox.Show("Register successfully!", "STATE");

                To_HomePage(tb1.Text);
            }
        }
Ejemplo n.º 3
0
 private void Load_imgs()
 {
     pictureBox1.Image = CommonHandler.LoadImage(username, "user_background");
     pictureBox2.Image = CommonHandler.LoadImage(username, "user_avatar");
     pictureBox2.Image = CommonHandler.ChangeShape(CommonHandler.ResizeImage(pictureBox2.Image, new Size(75, 75)), new Rectangle(0, 0, 75, 75), new Size(75, 75));
 }
Ejemplo n.º 4
0
 private void ListView1_MouseClick(object sender, MouseEventArgs e)
 {
     string[] strArr = listView1.SelectedItems[0].SubItems[0].Text.Split(':');
     CommonHandler.UpdateShowing(strArr[0]);
 }
Ejemplo n.º 5
0
        private void RecMsg(object socketReceiverPara)
        {
            Socket socketListener = socketReceiverPara as Socket;

            while (true)
            {
                //创建一个内存缓冲区 其大小为1024*1024字节  即1M
                byte[] arrRecMsg = new byte[1024 * 1024];
                //将接收到的信息存入到内存缓冲区,并返回其字节数组的长度
                int length = socketListener.Receive(arrRecMsg);
                if (length > 0)
                {
                    //将机器接受到的字节数组转换为人可以读懂的字符串
                    string strRecMsg = Encoding.UTF8.GetString(arrRecMsg, 0, length);
                    Dictionary <string, string> messageSet = new Dictionary <string, string>(CommonHandler.ResolveMessage(strRecMsg));
                    if (!Contact.chatKey.ContainsKey(messageSet["sender"]))
                    {
                        MessageBox.Show(messageSet["value"], messageSet["sender"] + "-" + messageSet["time"]);
                    }
                    else
                    {
                        Contact.chatKey[messageSet["sender"]].NewMessage(messageSet);
                    }
                }
                else
                {
                    break;
                }
            }
            socketListener.Close();
        }