Exemplo n.º 1
0
        private void UpdateSongListBase(PlatformData data)
        {
            SongListItem item;

            foreach (FormatData song in data.GetChanges(false))
            {
                SongData songdata = song.Song;
                item = null;
                foreach (ListViewItem songitem in SongList.Items)
                {
                    SongListItem songtag = songitem.Tag as SongListItem;
                    if (songtag.SongID == songdata.ID)
                    {
                        item = songtag;
                        break;
                    }
                }
                if (item == null)
                {
                    ListViewItem listitem = new ListViewItem("");
                    listitem.Tag = new SongListItem(listitem, song, songdata);
                    SongList.Items.Add(listitem);
                }
                else
                {
                    item.AddData(song, songdata);
                }
            }
            foreach (FormatData song in data.GetChanges(true))
            {
                foreach (ListViewItem songitem in SongList.Items)
                {
                    item = songitem.Tag as SongListItem;
                    if (item != null && item.HasData(song))
                    {
                        item.RemoveData(song);
                        if (!item.HasData())
                        {
                            SongList.Items.Remove(songitem);
                        }
                        break;
                    }
                }
            }
        }