コード例 #1
0
        private void RemoveSongs_Load(object sender, EventArgs e)
        {
            //Create the panels for the songs with the class
            BinaryFormatter bf = new BinaryFormatter();

            if (del == 2)
            {
                FileStream f = new FileStream("Files/Playlists/playlists.dat", FileMode.OpenOrCreate);
                try
                {
                    songList = (List <Song>)bf.Deserialize(f);
                }
                catch
                {
                    songList = new List <Song>();
                }
                f.Close();
                ap.AddPanels_OnGivenControl(this, flowLayoutPanel1, sender, e, true, new List <Song>(), false, songList);
            }
            else
            {
                FileStream f = new FileStream("Files/Songs/songs.dat", FileMode.OpenOrCreate);
                try
                {
                    songList = (List <Song>)bf.Deserialize(f);
                }
                catch
                {
                    songList = new List <Song>();
                }
                f.Close();
                ap.AddPanels_OnGivenControl(this, flowLayoutPanel1, sender, e, true, new List <Song>(), true, songList);
            }

            Button remove = new Button();

            remove.Location = new Point(this.Width / 2 + 30, this.Height - 60);
            remove.Size     = new Size(60, 60);
            remove.Click   += new EventHandler(Remove);
            if (del == 1)
            {
                remove.Text = "Create";
            }
            else
            {
                remove.Text = "Remove";
            }
            remove.BackColor = Color.LightGreen;
            this.Controls.Add(remove);

            Button exit = new Button();

            exit.Location  = new Point(this.Width / 2 - 90, this.Height - 60);
            exit.Size      = new Size(60, 60);
            exit.Click    += new EventHandler(Exit);
            exit.Text      = "Exit";
            exit.BackColor = Color.LightGreen;
            this.Controls.Add(exit);
        }
コード例 #2
0
        private void Allsongs_Load(object sender, EventArgs e)
        {
            //Create the panels for the songs with the class
            BinaryFormatter bf = new BinaryFormatter();
            FileStream f = new FileStream("Files/Songs/songs.dat", FileMode.OpenOrCreate);
            try
            {
                songList = (List<Song>)bf.Deserialize(f);
            }
            catch
            {
                songList = new List<Song>();
            }
            f.Close();
            if (all)
            {
                ap.AddPanels_OnGivenControl(this, flowLayoutPanel1, sender, e, false, new List<Song>(), true, songList);
            }
            else
            {
                songList = songList.OrderBy(d => d.TimesPlayed).ToList();  //Ascending order
                List<Song> reversed = new List<Song>();
                int min = 10;
                if (songList.Count - 1 >= 10) min = songList.Count - 1;
                for (int i = songList.Count() - 1; i >= min - 10; i--)
                {
                    reversed.Add(songList[i]);
                }
                ap.AddPanels_OnGivenControl(this, flowLayoutPanel1, sender, e, false, new List<Song>(), true, reversed);
            }

            Button play = new Button();
            play.Location = new Point(this.Width / 2 + 60, this.Height - 60);
            play.Size = new Size(60, 60);
            play.Click += new EventHandler(Play);
            play.Text = "Play";
            play.BackColor = Color.LightGreen;
            this.Controls.Add(play);

            Button exit = new Button();
            exit.Location = new Point(this.Width / 2 - 120, this.Height - 60);
            exit.Size = new Size(60, 60);
            exit.Click += new EventHandler(Exit);
            exit.Text = "Exit";
            exit.BackColor = Color.LightGreen;
            this.Controls.Add(exit);

            Button edit = new Button();
            edit.Location = new Point(this.Width / 2 - 30, this.Height - 60);
            edit.Size = new Size(60, 60);
            edit.Click += new EventHandler(Edit);
            edit.Text = "Edit";
            edit.BackColor = Color.LightGreen;
            this.Controls.Add(edit);
        }
コード例 #3
0
        private void Playlists_List_Load(object sender, EventArgs e)
        {
            //Create the panels for the songs with the class
            BinaryFormatter bf = new BinaryFormatter();
            FileStream      f  = new FileStream("Files/Playlists/playlists.dat", FileMode.OpenOrCreate);

            try
            {
                playlist = (List <Song>)bf.Deserialize(f);
            }
            catch
            {
                playlist = new List <Song>();
            }
            f.Close();
            ap.AddPanels_OnGivenControl(this, flowLayoutPanel1, sender, e, false, new List <Song>(), false, playlist);

            Button select = new Button();

            select.Location  = new Point(this.Width / 2 + 60, this.Height - 60);
            select.Size      = new Size(60, 60);
            select.Click    += new EventHandler(Select);
            select.Text      = "Play";
            select.BackColor = Color.LightGreen;
            this.Controls.Add(select);

            Button add = new Button();

            add.Location  = new Point(this.Width / 2 - 30, this.Height - 60);
            add.Size      = new Size(60, 60);
            add.Click    += new EventHandler(Create);
            add.Text      = "Add";
            add.BackColor = Color.LightGreen;
            this.Controls.Add(add);

            Button exit = new Button();

            exit.Location  = new Point(this.Width / 2 - 120, this.Height - 60);
            exit.Size      = new Size(60, 60);
            exit.Click    += new EventHandler(Exit);
            exit.Text      = "Exit";
            exit.BackColor = Color.LightGreen;
            this.Controls.Add(exit);
        }
コード例 #4
0
        private void PlayList_Load(object sender, EventArgs e)
        {
            //Create the panels for the songs with the class
            List <Song>     tmp;
            BinaryFormatter bf = new BinaryFormatter();
            FileStream      f  = new FileStream("Files/Playlists/playlists.dat", FileMode.OpenOrCreate);

            try
            {
                tmp = (List <Song>)bf.Deserialize(f);
                f.Close();
                FileStream f1 = new FileStream(tmp[caller.Index].Path, FileMode.OpenOrCreate);
                playlist = (List <Song>)bf.Deserialize(f1);
                f1.Close();
            }
            catch
            {
                playlist = new List <Song>();
            }
            finally
            {
                f.Close();
            }
            ap.AddPanels_OnGivenControl(this, flowLayoutPanel1, sender, e, true, playlist, true, songList);

            Button create = new Button();

            create.Location  = new Point(this.Width / 2 + 30, this.Height - 60);
            create.Size      = new Size(60, 60);
            create.Click    += new EventHandler(Create);
            create.Text      = "Create";
            create.BackColor = Color.LightGreen;
            this.Controls.Add(create);

            Button exit = new Button();

            exit.Location  = new Point(this.Width / 2 - 90, this.Height - 60);
            exit.Size      = new Size(60, 60);
            exit.Click    += new EventHandler(Exit);
            exit.Text      = "Cancel";
            exit.BackColor = Color.LightGreen;
            this.Controls.Add(exit);
        }