示例#1
0
        private void AddToPlaylist(int trackId, AddTracksToPlaylistType addtoPlaylistType)
        {
            AddCDTracksToPlaylistParameter addTracksParams = new AddCDTracksToPlaylistParameter();

            addTracksParams.AddTracksType = addtoPlaylistType;
            addTracksParams.PlayTrackId   = trackId;

            for (int i = 0; i < this.CD.Tracks.Count; i++)
            {
                if (this.CD.Type == AlbumType.AudioCD)
                {
                    this.CD.Tracks[i].CDDriveLetter = CDEngine.DriveLetter;
                }
                addTracksParams.Tracks.Add(this.CD.Tracks[i]);
            }

            addTracksParams.ClearPlaylist = true;
            addTracksParams.CD            = this.CD;
            Big3.Hitbase.SharedResources.HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, Application.Current.MainWindow);
        }
        public new void Drop(Controls.DragDrop.IDropInfo dropInfo)
        {
            if (dropInfo.Data is PlaylistItem)
            {
                Controls.DragDrop.DragDrop.DefaultDropHandler.Drop(dropInfo);
            }

            if (dropInfo.Data is Big3.Hitbase.CDUtilities.WishlistItem)
            {
                Big3.Hitbase.CDUtilities.WishlistItem wishlistItem = dropInfo.Data as Big3.Hitbase.CDUtilities.WishlistItem;

                AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter();
                addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex;
                addTracksParams.InsertIndex   = dropInfo.InsertIndex;

                addTracksParams.TrackIds.Add(wishlistItem.TrackID);
                HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this);
            }

            if (dropInfo.Data is AlbumViewItem)
            {
                AlbumViewItem item = dropInfo.Data as AlbumViewItem;
                CD            cd   = DataBase.GetCDById(item.ID);

                AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter();
                addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex;
                addTracksParams.InsertIndex   = dropInfo.InsertIndex;
                foreach (Track track in cd.Tracks)
                {
                    addTracksParams.TrackIds.Add(track.ID);
                }
                HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this);
            }

            if (dropInfo.Data is AlbumItem)
            {
                AlbumItem item = dropInfo.Data as AlbumItem;
                CD        cd   = DataBase.GetCDById(item.ID);

                AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter();
                addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex;
                addTracksParams.InsertIndex   = dropInfo.InsertIndex;
                foreach (Track track in cd.Tracks)
                {
                    addTracksParams.TrackIds.Add(track.ID);
                }
                HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this);
            }

            if (dropInfo.Data is Track || dropInfo.Data is List <Track> )
            {
                // Prüfen, ob ein Track einer CD gedropped wurde
                MainCDUserControl mainCDUserControl = VisualTreeExtensions.FindParent <MainCDUserControl>(dropInfo.DragInfo.VisualSource);
                if (mainCDUserControl != null)
                {
                    Track        track     = dropInfo.Data as Track;
                    List <Track> trackList = dropInfo.Data as List <Track>;

                    AddCDTracksToPlaylistParameter addTracksParams = new AddCDTracksToPlaylistParameter();
                    addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex;
                    addTracksParams.InsertIndex   = dropInfo.InsertIndex;

                    if (track != null)
                    {
                        addTracksParams.Tracks.Add(track);
                    }
                    if (trackList != null)
                    {
                        addTracksParams.Tracks.AddRange(trackList);
                    }
                    HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this);
                }
                else
                {
                    Track        track     = dropInfo.Data as Track;
                    List <Track> trackList = dropInfo.Data as List <Track>;

                    AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter();
                    addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex;
                    addTracksParams.InsertIndex   = dropInfo.InsertIndex;

                    if (track != null)
                    {
                        addTracksParams.TrackIds.Add(track.ID);
                    }

                    if (trackList != null)
                    {
                        foreach (Track trackItem in trackList)
                        {
                            addTracksParams.TrackIds.Add(trackItem.ID);
                        }
                    }

                    HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this);
                }
            }

            if (dropInfo.Data is MyMusicListItem)
            {
                MyMusicListItem item = dropInfo.Data as MyMusicListItem;

                AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter();
                addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex;
                addTracksParams.InsertIndex   = dropInfo.InsertIndex;
                addTracksParams.TrackIds.Add(item.ID);
                HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this);
            }

            if (dropInfo.Data is List <MyMusicListItem> )
            {
                List <MyMusicListItem> items = dropInfo.Data as List <MyMusicListItem>;

                AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter();
                addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex;
                addTracksParams.InsertIndex   = dropInfo.InsertIndex;
                foreach (MyMusicListItem item in items)
                {
                    addTracksParams.TrackIds.Add(item.ID);
                }
                HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this);
            }

            if (dropInfo.Data is DataObject)
            {
                DataObject dataObject = dropInfo.Data as DataObject;
                if (dataObject.GetDataPresent(DataFormats.FileDrop))
                {
                    AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter();
                    addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex;
                    addTracksParams.InsertIndex   = dropInfo.InsertIndex;
                    foreach (string item in dataObject.GetFileDropList())
                    {
                        addTracksParams.Filenames.Add(item);
                    }
                    HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this);
                }
            }
        }