private void PlList_Drop(object sender, DragEventArgs e)
        {
            Music           music   = (Music)e.Data.GetData(typeof(Music));
            PlaylistElement element = (PlaylistElement)e.Data.GetData(typeof(PlaylistElement));

            this.ListChange(music, element, sender);
        }
        private void ListViewItem_Drop(object sender, DragEventArgs e)
        {
            dropOnElement = true;
            Music           music   = (Music)e.Data.GetData(typeof(Music));
            PlaylistElement element = (PlaylistElement)e.Data.GetData(typeof(PlaylistElement));

            this.ListChange(music, element, sender);
        }
 private void ListChange(Music music, PlaylistElement element, object sender)
 {
     if (music != null)
     {
         if (!dropOnElement || sender.GetType() == typeof(ListViewItem))
         {
             if (sender.GetType() == typeof(ListViewItem))
             {
                 int          index    = this.PlList.Items.IndexOf(((ListViewItem)sender));
                 ListViewItem viewItem = new ListViewItem();
                 viewItem.Content = new PlaylistElement(music);
                 this.PlList.Items.Insert(index, viewItem);
             }
             else
             {
                 ListViewItem viewItem = new ListViewItem();
                 viewItem.Content = new PlaylistElement(music);
                 this.PlList.Items.Add(viewItem);
             }
         }
         else
         {
             dropOnElement = false;
         }
     }
     if (element != null)
     {
         if (!dropOnElement || sender.GetType() == typeof(ListViewItem))
         {
             if (sender.GetType() == typeof(ListViewItem))
             {
                 int indexSource = this.PlList.Items.IndexOf(DragDropHelper.DragSource);
                 int indexDest   = this.PlList.Items.IndexOf(((ListViewItem)sender));
                 this.PlList.Items.RemoveAt(indexSource);
                 ListViewItem viewItem = new ListViewItem();
                 viewItem.Content = element;
                 this.PlList.Items.Insert(indexDest, viewItem);
             }
             else
             {
                 int indexSource = this.PlList.Items.IndexOf(DragDropHelper.DragSource);
                 this.PlList.Items.RemoveAt(indexSource);
                 ListViewItem viewItem = new ListViewItem();
                 viewItem.Content = element;
                 this.PlList.Items.Add(viewItem);
             }
         }
         else
         {
             dropOnElement = false;
         }
     }
 }
예제 #4
0
        static public List<PlaylistElement> getPlaylist(int idPlaylist)
        {
            List<PlaylistElement> pElements = new List<PlaylistElement>();

            try
            {
                if (idPlaylist > 0)
                {
                    String query = "SELECT * FROM Content WHERE Playlist = " + idPlaylist + ";";
                    SqlDataReader myReader = null;
                    SqlCommand myCommand = new SqlCommand(query, _db);
                    myReader = myCommand.ExecuteReader();

                    while (myReader.Read())
                    {
                        int id = Convert.ToInt32(myReader["Media"]);
                        Music mus = singleMusic(id);
                        mus.Stretch = Convert.ToDouble(myReader["Stretch"]);
                        PlaylistElement tmp = new PlaylistElement(mus);


                        pElements.Add(tmp);
                    }

                    myReader.Close();
                    myCommand.Dispose();
                    ShareVar.IdPlaylist = idPlaylist;
                }
                else
                {
                    ShareVar.IdPlaylist = 0;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return pElements;
        }