Click here to Skip to main content
12,625,912 members (28,734 online)
Click here to Skip to main content

Stats

40.2K views
4K downloads
57 bookmarked
Posted

BSEtunes

, 24 Apr 2010 CPOL
BSEtunes is a MySQL based, full manageable, networkable single or multiuser jukebox application
BSE.Platten
BSE.Platten.vssscc
mssccprj.scc
vssver2.scc
BSE.CoverFlow.WPFLib
BSE.CoverFlow.WPFLib.csproj.user
BSE.CoverFlow.WPFLib.csproj.vspscc
mssccprj.scc
vssver2.scc
Images
close.png
exit.png
next.png
next_disabled.png
Note.jpg
pause.png
PlayButton.png
previous.png
previous_disabled.png
stop.png
vssver2.scc
Properties
vssver2.scc
Resources
vssver2.scc
BSE.Platten.Admin
BSE.Platten.Admin.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
Album16.gif
BSEadmin.ico
cdimport.png
cdrip.png
cd_hoeren.png
clearsearch.png
DataContainer_MoveFirsHS.png
DataContainer_MoveLastHS.png
DataContainer_MoveNextHS.png
DataContainer_MovePreviousHS.png
DataContainer_NewRecordHS.png
diskinfo.png
DRIVEDSC.png
DRIVENET.png
Edit_UndoHS.png
exportimage.png
findfile.png
FindHS.png
freedb.png
Genre16.png
Image.png
InsertPictureHS.png
Interpret16.png
OptionsHS.png
PieChart3DHS.png
PieChartHS.png
ProtectFormHS.png
RefreshDocViewHS.png
saveHS.png
search.png
song.png
system.png
tagger.png
tools_16.png
vssver2.scc
BSE.Platten.Admin.WinApp
BSE.Platten.Admin.WinApp.csproj.user
BSE.Platten.Admin.WinApp.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
BSEadmin.ico
vssver2.scc
BSE.Platten.Audio
bse.ico
BSE.Platten.Audio.csproj.vspscc
mssccprj.scc
vssver2.scc
Options
vssver2.scc
Player
vssver2.scc
Properties
vssver2.scc
Resources
FillDownHS.png
FillLeftHS.png
Folder256.png
FolderFind.png
FolderOpen256.png
GoLtrHS.png
MoveNext.png
MovePrevious.png
OptionsHS.png
PauseHS.png
PlayHS.png
Slider.gif
Start.png
StopHS.png
vssver2.scc
WinControls
vssver2.scc
WMFSDK
vssver2.scc
BSE.Platten.BO
BSE.Platten.BO.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
BSE.Platten.Common
BSE.Platten.Common.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
BSEsplash.png
DRIVEDSC.png
DRIVENET.png
Network.png
splash.png
vssver2.scc
BSE.Platten.Covers
BSE.Platten.Covers.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
BSE.Platten.FreeDb
BSE.Platten.FreeDb.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
OpenCD.png
vssver2.scc
BSE.Platten.Ripper
BSE.Platten.Ripper.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
OpenCD.png
OptionsHS.png
vssver2.scc
BSE.Platten.Statistik
BSE.Platten.Statistik.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
BSE.Platten.Tunes
BSE.Platten.Tunes.csproj.user
BSE.Platten.Tunes.csproj.vspscc
mssccprj.scc
vssver2.scc
Filters
vssver2.scc
Properties
vssver2.scc
Resources
About.png
Album16.gif
AudioCD.png
AudioFile.png
AutoList.png
broadcast.png
BSE.png
BSEAbout.png
BSEsplash.png
BSEtunes.ico
BSE_16.png
cd_hoeren.png
coverflow.png
DataContainer_MoveNextHS.png
delete.gif
diskinfo.png
Filter2HS.png
FindHS.png
Folder256.png
FolderOpen256.png
Genre16.gif
Interpret16.gif
keinBild.gif
NewPlaylist16.gif
OptionsHS.png
PauseHS.png
RefreshDocViewHS.png
Removabledrive.png
saveHS.png
search.png
shuffle.png
Shuffle_icon.png
song.png
splash1.png
StopHS.png
TaskHS.png
TrackInfo.gif
vssver2.scc
wiedergabe16.gif
BSEadminSetup
BSEadminSetup.vdproj
BSEadminSetup.vdproj.vspscc
mssccprj.scc
vssver2.scc
Debug
Release
BSEtunesSetup
BSEtunesSetup.vdproj
BSEtunesSetup.vdproj.vspscc
mssccprj.scc
vssver2.scc
Debug
Release
dll
BSE.CDDrives.DLL
BSE.Charts.DLL
BSE.Configuration.DLL
BSE.RemovableDrives.DLL
BSE.Shell.DLL
BSE.Windows.Forms.DLL
Lame
lame_enc.dll
vssver2.scc
lame-3.97
BSE.CoverFlow.WPFLib.csproj.user
close.png
exit.png
next.png
next_disabled.png
Note.jpg
pause.png
PlayButton.png
previous.png
previous_disabled.png
stop.png
vssver2.scc
vssver2.scc
vssver2.scc
BSE.Platten.Admin.csproj.user
vssver2.scc
Album16.gif
BSEadmin.ico
cdimport.png
cdrip.png
cd_hoeren.png
clearsearch.png
DataContainer_MoveFirsHS.png
DataContainer_MoveLastHS.png
DataContainer_MoveNextHS.png
DataContainer_MovePreviousHS.png
DataContainer_NewRecordHS.png
diskinfo.png
DRIVEDSC.png
DRIVENET.png
Edit_UndoHS.png
exportimage.png
findfile.png
FindHS.png
freedb.png
Genre16.png
Image.png
InsertPictureHS.png
Interpret16.png
OptionsHS.png
PieChart3DHS.png
PieChartHS.png
ProtectFormHS.png
RefreshDocViewHS.png
saveHS.png
search.png
song.png
system.png
tagger.png
tools_16.png
vssver2.scc
BSE.Platten.Admin.WinApp.csproj.user
vssver2.scc
BSEadmin.ico
vssver2.scc
bse.ico
BSE.Platten.Audio.csproj.user
vssver2.scc
vssver2.scc
vssver2.scc
FillDownHS.png
FillLeftHS.png
Folder256.png
FolderFind.png
FolderOpen256.png
GoLtrHS.png
MoveNext.png
MovePrevious.png
OptionsHS.png
PauseHS.png
PlayHS.png
Slider.gif
Start.png
StopHS.png
vssver2.scc
vssver2.scc
vssver2.scc
BSE.Platten.BO.csproj.user
vssver2.scc
BSE.Platten.Common.csproj.user
vssver2.scc
BSEsplash.png
DRIVEDSC.png
DRIVENET.png
Network.png
splash.png
vssver2.scc
BSE.Platten.Covers.csproj.user
vssver2.scc
BSE.Platten.FreeDb.csproj.user
vssver2.scc
OpenCD.png
vssver2.scc
AudioWriter
vssver2.scc
BSE.Platten.Ripper.csproj.user
Lame
vssver2.scc
vssver2.scc
OpenCD.png
OptionsHS.png
vssver2.scc
BSE.Platten.Statistik.csproj.user
vssver2.scc
BSE.Platten.Tunes.csproj.user
vssver2.scc
vssver2.scc
About.png
Album16.gif
AudioCD.png
AudioFile.png
AutoList.png
broadcast.png
BSE.png
BSEAbout.png
BSEsplash.png
BSEtunes.ico
BSE_16.png
cd_hoeren.png
coverflow.png
DataContainer_MoveNextHS.png
delete.gif
diskinfo.png
Filter2HS.png
FindHS.png
Folder256.png
FolderOpen256.png
Genre16.gif
Interpret16.gif
keinBild.gif
NewPlaylist16.gif
OptionsHS.png
PauseHS.png
RefreshDocViewHS.png
Removabledrive.png
saveHS.png
search.png
shuffle.png
Shuffle_icon.png
song.png
splash1.png
StopHS.png
TaskHS.png
TrackInfo.gif
vssver2.scc
wiedergabe16.gif
BSEadminSetup.vdproj
BSEtunesSetup.vdproj
BSE.CDDrives.DLL
BSE.Charts.DLL
BSE.Configuration.DLL
BSE.RemovableDrives.DLL
BSE.Shell.DLL
BSE.ThreadedShell.DLL
BSE.Windows.Forms.DLL
lame_enc.dll
MySQL.chm
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using BSE.Platten.Audio;
using BSE.Platten.BO;
using BSE.Platten.Common;

namespace BSE.Platten.Tunes
{
    public partial class ClipBoard : UserControl
    {
        #region EventsPublic

        public event EventHandler<AlbumSelectEventArgs> AlbumSelecting;

        #endregion

        #region FieldsPrivate

        private CEnvironment m_environment;
        private Control m_parentControl;
        private CTrack m_selectedTrack;
        private ToolStripMenuItem m_parentToolStripMenuItem;

        #endregion

        #region Properties

        public CPlayerManager PlayerManager
        {
            get { return this.m_playerManager; }
            set
            {
                this.m_playerManager = value;
                this.m_lstvClipBoard.PlayerManager = this.m_playerManager;
                if (this.m_trackInfo != null)
                {
                    this.m_trackInfo.PlayerManager = this.m_playerManager;
                }
            }
        }

        public CEnvironment Environment
        {
            get { return this.m_environment; }
            set
            {
                this.m_environment = value;
                if (this.m_trackInfo != null)
                {
                    this.m_trackInfo.Environment = this.m_environment;
                }
            }
        }

        public ToolStripMenuItem ParentToolStripMenuItem
        {
            get { return this.m_parentToolStripMenuItem; }
            set { this.m_parentToolStripMenuItem = value; }
        }

        #endregion

        #region MethodsPublic

        public ClipBoard()
        {
            InitializeComponent();
            this.m_lstvClipBoard.AlternatingBackColor = BSE.Platten.Common.BSEColors.AlternatingBackColor;
        }

        #endregion

        #region MethodsProtected

        protected void OnAlbumSelecting(AlbumSelectEventArgs e)
        {
            if (AlbumSelecting != null)
            {
                AlbumSelecting(this, e);
            }
        }

        #endregion

        #region MethodsPrivate

        private void CClipBoard_Load(object sender, EventArgs e)
        {
            this.m_parentControl = this.Parent;
            if (this.m_parentControl != null)
            {
                this.m_parentControl.VisibleChanged += new EventHandler(ClipBoardVisibleChanged);
            }
        }
        
        private void PlaySelectedTracksClick(object sender, EventArgs e)
        {
            PlaySelectedTracks(BSE.Platten.Audio.PlayMode.Playlist);
        }

        private void SelectAlbumClick(object sender, EventArgs e)
        {
            OnAlbumSelecting(new AlbumSelectEventArgs(this.m_selectedTrack.TitelId));
        }
        
        private void TrackInfoAlbumSelecting(object sender, AlbumSelectEventArgs e)
        {
            OnAlbumSelecting(new AlbumSelectEventArgs(e.TitelId));
        }

        private void ClipBoardDragDrop(object sender, DragEventArgs e)
        {
            BSE.Windows.Forms.CDataObject dataObject = e.Data as BSE.Windows.Forms.CDataObject;
            if (dataObject != null)
            {
                // get the currently hovered row that the items will be dragged to
                Point clientPoint = this.m_lstvClipBoard.PointToClient(new Point(e.X, e.Y));
                ListViewItem hoverListViewItem = this.m_lstvClipBoard.GetItemAt(clientPoint.X, clientPoint.Y);

                BSE.Windows.Forms.CDraggedListViewObjects draggedListViewObjects = null;
                //check the overload of the dataobject
                if (dataObject.GetDataPresent(typeof(BSE.Windows.Forms.CDraggedListViewObjects)))
                {
                    draggedListViewObjects
                        = (BSE.Windows.Forms.CDraggedListViewObjects)dataObject.GetData(
                        typeof(BSE.Windows.Forms.CDraggedListViewObjects));
                    if (draggedListViewObjects.ParentListView == null)
                    {
                        return;
                    }
                }
                if (dataObject.DragData != null)
                {
                    draggedListViewObjects
                        = (BSE.Windows.Forms.CDraggedListViewObjects)dataObject.DragData;

                    if (draggedListViewObjects.ParentListView == null)
                    {
                        return;
                    }
                }
                if (draggedListViewObjects != null)
                {
                    object dragObject = draggedListViewObjects.DragObjects[0];
                    //Wenn das Object vom Typ ListViewItem ist werden die ListViewItems in die ListView eingef�gt
                    if (dragObject is System.Windows.Forms.ListViewItem)
                    {
                        InsertListViewItems(hoverListViewItem, draggedListViewObjects);
                    }
                    PlayListDragDropData playListDragDropData = dragObject as PlayListDragDropData;
                    if (playListDragDropData != null)
                    {
                        switch (playListDragDropData.PlayListDragDropMode)
                        {
                            case PlayList.PlayListDragDropMode.Albums:
                                InsertListViewItemsAlbum(hoverListViewItem, playListDragDropData.Id);
                                break;
                            case PlayList.PlayListDragDropMode.PlayList:
                                InsertListViewItemTrack(hoverListViewItem, playListDragDropData.Id);
                                break;
                        }
                    }
                }
            }
        }
        private void ClipBoardDragEnter(object sender, DragEventArgs e)
        {
            if (e.Data is BSE.Windows.Forms.CDataObject)
            {
                this.m_lblInformation.Visible = false;
            }
        }

        private void ClipBoardDragLeave(object sender, EventArgs e)
        {
            if (this.m_lstvClipBoard.Items.Count == 0)
            {
                this.m_lblInformation.Visible = true;
            }
        }
        private void ClipBoardKeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)
            {
                foreach (ListViewItem listViewItem in this.m_lstvClipBoard.SelectedItems)
                {
                    this.m_lstvClipBoard.Items.Remove(listViewItem);
                }
                if (this.m_lstvClipBoard.Items.Count == 0)
                {
                    this.m_lblInformation.Visible = true;
                }
            }
            if (e.KeyCode == Keys.T && e.Modifiers == Keys.Control)
            {
                if (this.m_lstvClipBoard.SelectedItems.Count > 0)
                {
                    ListViewItem listViewItem = this.m_lstvClipBoard.SelectedItems[0];
                    if (listViewItem != null)
                    {
                        this.m_selectedTrack = (CTrack)listViewItem.Tag;
                        SelectAlbumClick(sender, e);
                    }
                }
            }
        }
        
        private void ClipBoardMouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (this.m_lstvClipBoard.SelectedItems.Count > 0)
                {
                    ListViewItem listViewItem = this.m_lstvClipBoard.SelectedItems[0];
                    if (listViewItem != null)
                    {
                        this.m_selectedTrack = (CTrack)listViewItem.Tag;
                    }
                    this.m_ctxPlayList.Show(this.m_lstvClipBoard, new Point(e.X, e.Y));
                }
            }
        }
        
        private void ClipBoardResize(object sender, EventArgs e)
        {
            this.m_clmnDuration.Width = 60;
            this.m_clmnTitle.Width = this.m_lstvClipBoard.Width - this.m_clmnDuration.Width - 2 * SystemInformation.Border3DSize.Width;

            this.m_lblInformation.Width = this.m_lstvClipBoard.Width - 20;
            this.m_lblInformation.Left = this.m_lstvClipBoard.Left + 10;
        }
        
        private void ClipBoardVisibleChanged(object sender, EventArgs e)
        {
            if (this.m_parentToolStripMenuItem != null)
            {
                this.m_parentToolStripMenuItem.Checked = this.Visible;
            }
        }
        
        private void PlaySelectedTracks(BSE.Platten.Audio.PlayMode eMode)
        {
            CTrackCollection tracksCollection = new CTrackCollection(this.m_lstvClipBoard.SelectedItems.Count);
            foreach (ListViewItem listViewItem in this.m_lstvClipBoard.SelectedItems)
            {
                if (listViewItem.Tag is CTrack)
                {
                    CTrack track = (CTrack)listViewItem.Tag;
                    tracksCollection.Add(track);
                }
            }
            if (tracksCollection.Count > 0)
            {
                if (this.m_playerManager != null)
                {
                    try
                    {
                        this.m_playerManager.PlayTracks(tracksCollection, eMode);
                    }
                    catch (Exception exception)
                    {
                        GlobalizedMessageBox.Show(this,exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }

        private void InsertListViewItemsAlbum(ListViewItem hoverListViewItem, int iAlbumId)
        {
            if (this.m_environment != null)
            {
                CTunesBusinessObject tunesBusinessObject = new CTunesBusinessObject(this.m_environment.GetConnectionString());
                try
                {
                    CTrack[] tracks = tunesBusinessObject.GetAlbumTracksForPlayListByTitelId(iAlbumId);
                    if (tracks != null)
                    {
                        string strAudioHomeDirectory = CAlbum.GetAudioHomeDirectory(this.m_environment);
                        if (hoverListViewItem == null)
                        {
                            foreach (BSE.Platten.BO.CTrack track in tracks)
                            {
                                track.FileFullName = strAudioHomeDirectory + track.FileName;
                                ListViewItem listViewItem = new ListViewItem();
                                listViewItem.Text = track.Title;
                                listViewItem.SubItems.Add(track.Duration.ToLongTimeString());
                                listViewItem.SubItems.Add(track.FileFullName);
                                listViewItem.Tag = track;

                                this.m_lstvClipBoard.Items.Add(listViewItem);
                            }
                        }
                        else
                        {
                            int iHoverIndex = hoverListViewItem.Index;
                            for (int i = tracks.Length - 1; i >= 0; i--)
                            {
                                tracks[i].FileFullName = strAudioHomeDirectory + tracks[i].FileName;
                                ListViewItem listViewItem = new ListViewItem();
                                listViewItem.Text = tracks[i].Title;
                                listViewItem.SubItems.Add(tracks[i].Duration.ToLongTimeString());
                                listViewItem.SubItems.Add(tracks[i].FileFullName);
                                listViewItem.Tag = tracks[i];

                                this.m_lstvClipBoard.Items.Insert(iHoverIndex, listViewItem);
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

        private void InsertListViewItemTrack(ListViewItem hoverListViewItem, int iLiedId)
        {
            if (this.m_environment != null)
            {
                CTunesBusinessObject tunesBusinessObject = new CTunesBusinessObject(this.m_environment.GetConnectionString());
                try
                {
                    CTrack track = tunesBusinessObject.GetTrackForPlayListByLiedId(iLiedId);
                    if (track != null)
                    {
                        string strAudioHomeDirectory = CAlbum.GetAudioHomeDirectory(this.m_environment);
                        if (hoverListViewItem == null)
                        {
                            track.FileFullName = strAudioHomeDirectory + track.FileName;
                            ListViewItem listViewItem = new ListViewItem();
                            listViewItem.Text = track.Title;
                            listViewItem.SubItems.Add(track.Duration.ToLongTimeString());
                            listViewItem.SubItems.Add(track.FileFullName);
                            listViewItem.Tag = track;

                            this.m_lstvClipBoard.Items.Add(listViewItem);

                        }
                        else
                        {
                            int iHoverIndex = hoverListViewItem.Index;

                            track.FileFullName = strAudioHomeDirectory + track.FileName;
                            ListViewItem listViewItem = new ListViewItem();
                            listViewItem.Text = track.Title;
                            listViewItem.SubItems.Add(track.Duration.ToLongTimeString());
                            listViewItem.SubItems.Add(track.FileFullName);
                            listViewItem.Tag = track;

                            this.m_lstvClipBoard.Items.Insert(iHoverIndex, listViewItem);

                        }
                    }
                }
                catch (Exception exception)
                {
                    GlobalizedMessageBox.Show(this,exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

        private void InsertListViewItems(ListViewItem hoverListViewItem, BSE.Windows.Forms.CDraggedListViewObjects draggedListViewObjects)
        {
            if (hoverListViewItem == null)
            {
                for (int i = 0; i < draggedListViewObjects.DragObjects.Count; i++)
                {
                    if (this.m_lstvClipBoard == draggedListViewObjects.ParentListView)
                    {
                        draggedListViewObjects.ParentListView.DragDropEffects = DragDropEffects.Move;
                    }
                    ListViewItem draggedListViewItem = (ListViewItem)draggedListViewObjects.DragObjects[i];
                    if (draggedListViewItem.Tag is CTrack)
                    {
                        CTrack track = (CTrack)draggedListViewItem.Tag;
                        ListViewItem newListViewItem = new ListViewItem();
                        newListViewItem.Text = track.Title;
                        newListViewItem.SubItems.Add(track.Duration.ToLongTimeString());
                        newListViewItem.SubItems.Add(track.FileFullName);
                        newListViewItem.Tag = track;
                        this.m_lstvClipBoard.Items.Add(newListViewItem);
                    }
                }
            }
            else
            {
                int iHoverIndex = hoverListViewItem.Index;
                if (this.m_lstvClipBoard == draggedListViewObjects.ParentListView)
                {
                    draggedListViewObjects.ParentListView.DragDropEffects = DragDropEffects.Move;
                }
                for (int i = draggedListViewObjects.DragObjects.Count - 1; i >= 0; i--)
                {
                    ListViewItem draggedListViewItem = (ListViewItem)draggedListViewObjects.DragObjects[i];
                    if (draggedListViewItem.Tag is CTrack)
                    {
                        CTrack track = (CTrack)draggedListViewItem.Tag;
                        ListViewItem newListViewItem = new ListViewItem();
                        newListViewItem.Text = track.Title;
                        newListViewItem.SubItems.Add(track.Duration.ToLongTimeString());
                        newListViewItem.SubItems.Add(track.FileFullName);
                        newListViewItem.Tag = track;
                        this.m_lstvClipBoard.Items.Insert(iHoverIndex, newListViewItem);
                    }
                }
            }

            if (draggedListViewObjects.ParentListView != null)
            {
                if (draggedListViewObjects.ParentListView.DragDropEffects == DragDropEffects.Move)
                {
                    foreach (ListViewItem listViewItemToRemove in draggedListViewObjects.ParentListView.SelectedItems)
                    {
                        draggedListViewObjects.ParentListView.Items.Remove(listViewItemToRemove);
                    }
                }
            }
        }

        #endregion

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Uwe Eichkorn
Switzerland Switzerland
No Biography provided

You may also be interested in...