示例#1
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            if (this.Controls.ContainsKey("hmw"))
            {
                this.Controls.RemoveByKey("hmw");
            }
            if (this.Controls.ContainsKey("wthvid"))
            {
                this.Controls.RemoveByKey("wthvid");
            }
            if (this.Controls.ContainsKey("channel"))
            {
                this.Controls.RemoveByKey("channel");
            }

            Subscriptions sbs = new Subscriptions();

            sbs.Name = "hmw";

            var connectionn = DBFunctions.OpenConnection();

            if (connectionn == null)
            {
                return;
            }

            int y = 10;

            string sqlText = string.Format("SELECT videos.name,videos.views,videos.ChannelID,videos.videolink,videos.uploaddate,logins.username, videos.description FROM videos JOIN logins ON videos.channelid = logins.ID WHERE videos.name LIKE '%{0}%' ORDER BY uploaddate DESC limit 12 ;", textBox1.Text);
            var    readerr = DBFunctions.ExecuteSqlSelect(sqlText, connectionn);

            if (readerr == null)
            {
                return;
            }

            while (readerr.Read())
            {
                //string sqlText3 = string.Format("SELECT username from logins where ID = {0};", readerr[2] );
                //  string name = (string)DBFunctions.ExecuteSqlScalar(sqlText3, connectionn);

                vid_his_sub vidsub = new vid_his_sub();

                vidsub.label1.Text     = readerr[1].ToString() + " views";
                vidsub.linkLabel1.Text = readerr[0].ToString();
                vidsub.linkLabel3.Hide();
                vidsub.linkLabel2.Text = readerr[5].ToString();
                vidsub.linkLabel1.Name = readerr[3].ToString();
                vidsub.textBox3.Text   = readerr[6].ToString();

                vidsub.linkLabel2.Name   = readerr[2].ToString();
                vidsub.linkLabel1.Click += LinkLabel1_Click;
                vidsub.linkLabel2.Click += LinkLabel2_Click;

                string a = getYouTubeThumbnail(readerr[3].ToString());

                var request = WebRequest.Create(a);

                using (var response = request.GetResponse())
                    using (var stream = response.GetResponseStream())
                    {
                        vidsub.pictureBox1.Image = Bitmap.FromStream(stream);
                    }

                vidsub.Location   = new Point(0, y);
                sbs.panel1.Height = this.Height - groupBox1.Height - 80;
                sbs.panel1.Controls.Add(vidsub);

                y += 200;
            }
            sbs.Location = new Point(259, 124);
            this.Controls.Add(sbs);
            readerr.Close();
            readerr.Dispose();
        }
示例#2
0
        private void historyBtn_Click(object sender, EventArgs e)
        {
            MessageBox.Show("COMING SOON!!!!");
            return;

            if (this.Controls.ContainsKey("hmw"))
            {
                this.Controls.RemoveByKey("hmw");
            }
            if (this.Controls.ContainsKey("wthvid"))
            {
                this.Controls.RemoveByKey("wthvid");
            }
            if (this.Controls.ContainsKey("channel"))
            {
                this.Controls.RemoveByKey("channel");
            }

            Subscriptions sbs = new Subscriptions();

            sbs.Name = "hmw";

            var connectionn = DBFunctions.OpenConnection();

            if (connectionn == null)
            {
                return;
            }

            int y = 10;

            string sqlText1 = string.Format("SELECT videos.name,videos.views,videos.ChannelID,videos.videolink,videos.uploaddate,historyvideo.videoid FROM video JOIN historyvideo ON historyvideo.userid = {0};", user.user_ID);
            var    readerr  = DBFunctions.ExecuteSqlSelect(sqlText1, connectionn);

            if (readerr == null)
            {
                return;
            }

            while (readerr.Read())
            {
                //string sqlText3 = string.Format("SELECT username from logins where ID = {0};", readerr[2] );
                //  string name = (string)DBFunctions.ExecuteSqlScalar(sqlText3, connectionn);

                vid_his_sub vidsub = new vid_his_sub();

                vidsub.label1.Text     = readerr[1].ToString();
                vidsub.linkLabel1.Text = readerr[0].ToString();
                vidsub.linkLabel3.Text = readerr[5].ToString();
                vidsub.linkLabel2.Text = readerr[5].ToString();
                vidsub.linkLabel1.Name = readerr[3].ToString();
                vidsub.textBox3.Text   = readerr[6].ToString();

                //vidsub.linkLabel1.Click += LinkLabel1_Click;
                vidsub.linkLabel1.Click += LinkLabel1_Click;

                string a = getYouTubeThumbnail(readerr[3].ToString());

                var request = WebRequest.Create(a);

                using (var response = request.GetResponse())
                    using (var stream = response.GetResponseStream())
                    {
                        vidsub.pictureBox1.Image = Bitmap.FromStream(stream);
                    }

                vidsub.Location = new Point(0, y);
                sbs.panel1.Controls.Add(vidsub);

                y += 200;
            }
            sbs.Location = new Point(259, 124);
            this.Controls.Add(sbs);
            readerr.Close();
            readerr.Dispose();
        }