예제 #1
0
        private void SignInButton_Click(object sender, EventArgs e)
        {
            string username = UserBox.Text;
            string password = PassBox.Text;

            try
            {
                string activeUser = Spotflix.AdminLogIn(username, password);
                if (activeUser != "")
                {
                    AdminLogIn = true;
                }
                else
                {
                    activeUser = Spotflix.LogIn(username, password);
                    UserLogIn  = true;
                }
                thisUser = Spotflix.GetUserDB[activeUser];
                FormMain main = new FormMain(thisUser);
                main.Show();
                Hide();
            }

            catch
            {
                MessageBoxButtons bts = MessageBoxButtons.OKCancel;
                MessageBox.Show("Que paso", "No se", bts);
            }
        }
        private void AddMedia_Click(object sender, EventArgs e)
        {
            string ofilename = openFileDialog1.FileName;
            string filename  = $"{NewPath}{Path.GetFileName(ofilename)}";

            File.Copy(ofilename, filename, true);

            if (MediaType == "song")
            {
                string format, duration, name, artist, album, genre, pubYear, label;

                format   = MetaGrid.Rows[1].Cells[1].Value.ToString();
                duration = MetaGrid.Rows[2].Cells[1].Value.ToString();
                name     = MetaGrid.Rows[3].Cells[1].Value.ToString();
                artist   = MetaGrid.Rows[4].Cells[1].Value.ToString();
                album    = MetaGrid.Rows[5].Cells[1].Value.ToString();
                genre    = MetaGrid.Rows[6].Cells[1].Value.ToString();
                pubYear  = MetaGrid.Rows[7].Cells[1].Value.ToString();
                label    = MetaGrid.Rows[8].Cells[1].Value.ToString();



                SongMetadata meta = new SongMetadata(name, artist, album, genre, pubYear, label);
                Song         song = new Song(filename, meta, format, duration);
            }

            else if (MediaType == "video")
            {
                string format, duration, name, creator, genre, category, studio, description, resolution, aspect, director, actors, pubYear;
                format      = MetaGrid.Rows[1].Cells[1].Value.ToString();
                duration    = MetaGrid.Rows[2].Cells[1].Value.ToString();
                name        = MetaGrid.Rows[3].Cells[1].Value.ToString();
                creator     = MetaGrid.Rows[4].Cells[1].Value.ToString();
                genre       = MetaGrid.Rows[5].Cells[1].Value.ToString();
                category    = MetaGrid.Rows[6].Cells[1].Value.ToString();
                actors      = MetaGrid.Rows[7].Cells[1].Value.ToString();
                director    = MetaGrid.Rows[8].Cells[1].Value.ToString();
                studio      = MetaGrid.Rows[9].Cells[1].Value.ToString();
                pubYear     = MetaGrid.Rows[10].Cells[1].Value.ToString();
                description = MetaGrid.Rows[11].Cells[1].Value.ToString();
                resolution  = MetaGrid.Rows[12].Cells[1].Value.ToString();
                aspect      = MetaGrid.Rows[13].Cells[1].Value.ToString();



                VideoMetadata meta = new VideoMetadata(name, creator, genre, category, studio, description,
                                                       resolution, aspect, director, actors, pubYear);
                Video video = new Video(filename, meta, format, duration);
            }
            Spotflix.Save("Spotflix.bin");
            panelAddMedia.Hide();
            MetaGrid.Rows.Clear();
        }
        private void NextButton_Click(object sender, EventArgs e)
        {
            Image img = Properties.Resources.icons8_pause_button_48;

            if (ActiveUser.GetQueue().Count() != 0)
            {
                ActiveMedia = ActiveUser.GetQueue().Dequeue();
                Media media = Spotflix.FindMedia(ActiveMedia.GetFileName());
                MediaControl.PlayMedia(media, axWindowsMediaPlayer1, MediaPlayingLabel, ArtistPlayingLabel, PlayButton, img);
                Filter      f  = new Filter();
                List <Type> ts = new List <Type>()
                {
                    typeof(Song), typeof(Video)
                };
                f.ObjGrid(f.CastToObj(ActiveUser.GetQueue()), QGrid, ts);
            }
        }
        private void artistToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem     submenuItem = (ToolStripMenuItem)sender;
            ToolStripDropDownMenu submenudrop = (ToolStripDropDownMenu)submenuItem.Owner;

            ToolStripMenuItem menuItem = (ToolStripMenuItem)submenudrop.OwnerItem;
            ContextMenuStrip  m        = (ContextMenuStrip)menuItem.Owner;
            DataGridView      grid     = (DataGridView)m.SourceControl;

            object sel = grid.Rows[SelectedRow].HeaderCell.Value;

            if (sel.GetType() == typeof(Artist))
            {
                Artist a = (Artist)sel;
                Spotflix.RemoveArtist(a);
            }
            else if (sel.GetType() == typeof(Song))
            {
            }
        }
        private void mediaToolStripMenuItem_Click(object sender, EventArgs e) //DeleteMediaMenuItem
        {
            ToolStripMenuItem     submenuItem = (ToolStripMenuItem)sender;
            ToolStripDropDownMenu submenudrop = (ToolStripDropDownMenu)submenuItem.Owner;

            ToolStripMenuItem menuItem = (ToolStripMenuItem)submenudrop.OwnerItem;
            ContextMenuStrip  m        = (ContextMenuStrip)menuItem.Owner;
            DataGridView      grid     = (DataGridView)m.SourceControl;

            object sel = grid.Rows[SelectedRow].HeaderCell.Value;

            if (sel == null)
            {
                return;
            }
            if (sel.GetType() == typeof(Song))
            {
                Song file = (Song)sel;
                Spotflix.DeleteMedia(file);
                File.Delete(file.GetFileName());
                Artist a = Spotflix.GetPeopleDB[file.GetMetadata().GetArtist()];
                a.RemoveWork(file);
                Album al = a.GetAlbums()[file.GetMetadata().GetAlbum()];
                al.RemoveSong(file);
                if (al.GetSongs().Count == 0)
                {
                    a.RemoveAlbum(al.GetName());
                }
                if (a.GetWork().Count == 0)
                {
                }
            }

            else if (sel.GetType() == typeof(Video))
            {
                Video file = (Video)sel;
                Spotflix.DeleteMedia(file);
                File.Delete(file.GetFileName());
            }
        }
예제 #6
0
        private void RegisterButton_Click(object sender, EventArgs e)
        {
            string username  = UserRegBox.Text;
            string password  = PassRegBox.Text;
            string email     = EmailRegBox.Text;
            bool   privateAc = PvtRegCheck.Checked;
            bool   premium   = PremiumCheck.Checked;

            try
            {
                User user = new User(username, email, password, privateAc, premium, false);
                Spotflix.AddUser(user);
                RegErrorLabel.Show();
                panelRegister.Hide();
                panelInicio.Show();
                Spotflix.Save("Spotflix.bin", Spotflix.GetUserDB);
            }
            catch (Exception)
            {
                RegErrorLabel.Text = "Missing or incorrect\nfields";
                RegErrorLabel.Show();
            }
        }
예제 #7
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);


            try
            {
                var load = Spotflix.Load("Spotflix.bin");

                Spotflix.SetUserDB(load.Item1);
                Spotflix.SetMediaDB(load.Item2);
                Spotflix.SetPeopleDB(load.Item3);
            }
            catch (Exception)
            {
            }
            Form1 f1 = new Form1();

            f1.Show();

            Application.Run();
        }
 private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
 {
     Spotflix.Save("Spotflix.bin");
     Application.Exit();
 }