예제 #1
0
        private void ShowButton()
        {
            button1.Location     = new Point(button1.Location.X, button1.Location.Y + 40);
            pictureBox2.Location = new Point(pictureBox2.Location.X, pictureBox2.Location.Y + 40);
            button1.Visible      = true;
            pictureBox2.Visible  = true;

            Bitmap bitmap = new Bitmap("../../Image/picture_icon.png");

            pictureBox2.Image = CommonHandler.ResizeImage(bitmap, new Size(25, 25));
        }
예제 #2
0
        private void PictureBox2_DoubleClick(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Image|*.jpg;*.png";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                pictureBox2.Image = CommonHandler.ResizeImage(Image.FromFile(openFileDialog.FileName), new Size(75, 75));
                DatabaseHandler.UpdatePicture(username, CommonHandler.ImgToBase64String(pictureBox2.Image), "user_avatar");
                pictureBox2.Image = CommonHandler.ChangeShape(pictureBox2.Image, new Rectangle(0, 0, 75, 75), new Size(75, 75));
            }
        }
예제 #3
0
        public GGNews(string username)
        {
            InitializeComponent();
            this.username = username;

            pictureBox1.Image = Homepage.image;
            label2.Text       = username;
            textBox2.Text     = Homepage.signature;
            pictureBox7.Image = CommonHandler.ResizeImage(new Bitmap("../../Image/left_arrow.png"), new Size(25, 25));
            pictureBox8.Image = CommonHandler.ResizeImage(new Bitmap("../../Image/right_arrow.png"), new Size(25, 25));

            LoadNews();
        }
예제 #4
0
        /// <summary>
        /// 更新交谈队列
        /// </summary>
        public void UpdateTalkingList()
        {
            ArrayList contentList = new ArrayList();

            imageList1.Images.Clear();
            foreach (DataRow row in friends.Rows)
            {
                Image img = CommonHandler.ChangeShape(CommonHandler.ResizeImage(CommonHandler.LoadImage(row[0].ToString(), "user_avatar"), new Size(45, 45)), new Rectangle(0, 0, 45, 45), new Size(45, 45));
                imageList1.Images.Add(img);
                string latestMsg = row[0].ToString() + " says: " + DatabaseHandler.SelectLatestMessage(row[0].ToString(), username);
                if (latestMsg.Length > 30)
                {
                    latestMsg = latestMsg.Substring(0, 30);
                }
                contentList.Add(latestMsg);
            }

            UpdateListView(imageList1, contentList);
        }
예제 #5
0
        /// <summary>
        /// 更新交谈队列
        /// </summary>
        public void UpdateTalkingList()
        {
            ArrayList contentList = new ArrayList();

            imageList1.Images.Clear();
            foreach (string key in Contact.chatKey.Keys)
            {
                Image img = CommonHandler.ChangeShape(CommonHandler.ResizeImage(CommonHandler.LoadImage(key, "user_avatar"), new Size(50, 50)), new Rectangle(0, 0, 50, 50), new Size(50, 50));
                imageList1.Images.Add(img);
                string latestMsg = key + ":\n" + DatabaseHandler.SelectLatestMessage(key, localUser);
                if (latestMsg.Length > 30)
                {
                    latestMsg = latestMsg.Substring(0, 30) + "...";
                }
                contentList.Add(latestMsg);
            }

            UpdateListView(imageList1, contentList);
        }
예제 #6
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;
                }
            }
        }
예제 #7
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);
            }
        }
예제 #8
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));
 }