Beispiel #1
0
        public void loaduploads()
        {
            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");
            }

            homeview hmv = new homeview(this);

            hmv.Name             = "hmw";
            hmv.label4.BackColor = Color.Red;

            var connectionn = DBFunctions.OpenConnection();

            if (connectionn == null)
            {
                return;
            }


            int x     = 10;
            int y     = 10;
            int arjau = 0;

            string sqlText1 = string.Format("SELECT videos.name,videos.views,videos.ChannelID,videos.videolink,videos.uploaddate,logins.username FROM videos JOIN logins ON videos.channelid = logins.ID ORDER BY uploaddate DESC limit 16;");
            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 vidd = new vid();
                vidd.label1.Text     = readerr[1].ToString();
                vidd.linkLabel1.Text = readerr[0].ToString() + " views";
                vidd.linkLabel2.Text = readerr[5].ToString();
                vidd.linkLabel1.Name = readerr[3].ToString();
                vidd.linkLabel2.Name = readerr[2].ToString();
                if (active == true && Convert.ToUInt64(readerr[2]) == user.user_ID)
                {
                    vidd.button1.Visible = true;
                    vidd.button1.Name    = readerr[2].ToString();
                }
                else
                {
                    vidd.button1.Visible = false;
                }

                vidd.button1.Click    += Button1_Click;
                vidd.linkLabel2.Click += LinkLabel2_Click;
                vidd.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())
                    {
                        vidd.pictureBox1.Image = Bitmap.FromStream(stream);
                    }

                vidd.Location = new Point(x, y);
                hmv.panel1.Controls.Add(vidd);
                arjau++;
                x += 220;

                if (arjau == 4)
                {
                    x     = 10;
                    y    += 200;
                    arjau = 0;
                }
            }
            hmv.Location = new Point(259, 124);
            this.Controls.Add(hmv);
            readerr.Close();
            readerr.Dispose();
            connectionn.Close();
            connectionn.Dispose();
        }
Beispiel #2
0
        public void loadchannel(long id)
        {
            var connectionn = DBFunctions.OpenConnection();

            if (connectionn == null)
            {
                return;
            }
            channel chl    = new channel();
            int     x      = 10;
            int     y      = 10;
            int     arjau  = 0;
            string  sqlTxt = string.Format("SELECT username from logins where id = {0}", id);
            var     read   = DBFunctions.ExecuteSqlSelect(sqlTxt, connectionn);

            if (read == null)
            {
                return;
            }
            while (read.Read())
            {
                username = read[0].ToString();
            }
            read.Close();
            read.Dispose();

            string sqlText1 = string.Format("SELECT videos.name,videos.views,videos.ChannelID,videos.videolink,videos.uploaddate FROM videos WHERE channelID = {0};", 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 vidd = new vid();
                vidd.label1.Text     = readerr[1].ToString();
                vidd.linkLabel1.Text = readerr[0].ToString() + " views";
                vidd.linkLabel2.Text = username;
                vidd.linkLabel1.Name = readerr[3].ToString();
                vidd.linkLabel2.Name = readerr[2].ToString();
                if (active == true && Convert.ToUInt64(readerr[2]) == user.user_ID)
                {
                    vidd.button1.Visible = true;
                    vidd.button1.Name    = readerr[3].ToString();
                }
                else
                {
                    vidd.button1.Visible = false;
                }
                vidd.linkLabel1.Name   = readerr[3].ToString();
                vidd.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())
                    {
                        vidd.pictureBox1.Image = Bitmap.FromStream(stream);
                    }

                vidd.Location = new Point(x, y);

                chl.panel1.Controls.Add(vidd);
                arjau++;
                x += 220;

                if (arjau == 4)
                {
                    x     = 10;
                    y    += 200;
                    arjau = 0;
                }
            }

            readerr.Close();
            readerr.Dispose();
            connectionn.Close();
            connectionn.Dispose();
        }