Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

BSEtunes

, 24 Apr 2010
BSEtunes is a MySQL based, full manageable, networkable single or multiuser jukebox application
BSE.Platten.zip
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
Settings.settings
vssver2.scc
Resources
vssver2.scc
BSE.Platten.Admin
BSE.Platten.Admin.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
Settings.settings
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
Settings.settings
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
Settings.settings
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
Settings.settings
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.Platten_en.zip
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
Settings.settings
vssver2.scc
vssver2.scc
BSE.Platten.Admin.csproj.user
Settings.settings
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
Settings.settings
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
Settings.settings
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
Settings.settings
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.zip
MySqlCreateDataBase5x.sql.zip
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.BO;
using BSE.Platten.Audio;
using System.Drawing.Imaging;
using BSE.Platten.Common;
using System.Globalization;
using BSE.Platten.Tunes.Properties;


namespace BSE.Platten.Tunes
{
    public partial class TrackInfo : UserControl
    {
        #region Delegates
        private delegate void DelegateRefreshTrackInfo();
        #endregion

        #region Events
        public event EventHandler<AlbumSelectEventArgs> AlbumSelecting;
        #endregion

        #region FieldsPrivate

        private Image m_imgTrackInfoBase;
        private Image m_imgOldThumbNail;
        private Image m_imgNewThumbNail;
        private System.Timers.Timer m_tmrFadeInTrackImage;
        private CEnvironment m_environment;
        private BSE.Platten.BO.CTrack m_currentTrack;
        private BSE.Platten.Audio.PlayMode m_playMode;
        private Queue<TrackInfoData> m_trackInfoDataToSelect = new Queue<TrackInfoData>(2);
        private WorkingState m_workingState;
        private Rectangle m_ImageRectangle;
        private float m_fTransparencyOut = 1.0f;
        private float m_fTransparencyCountOut = 1.0f;
        private float m_fTransparencyIn = 1.0f;
        private float m_fTransparencyCountIn;

        #endregion

        public CPlayerManager PlayerManager
        {
            get { return this.m_playerManager; }
            set { this.m_playerManager = value; }
        }

        public CEnvironment Environment
        {
            get { return this.m_environment; }
            set { this.m_environment = value; }
        }

        public TrackInfo()
        {
            InitializeComponent();

            this.m_lblInterpret.Visible = false;
            this.m_lblAlbum.Visible = false;
            this.m_lblTitle.Visible = false;
            this.m_pnlNotes.Visible = false;
            this.m_pnlNotes.IsClickable = false;
            this.m_picCover.Size = CCoverData.ThumbnailSize;
            this.m_imgTrackInfoBase = Properties.Resources.TrackInfo;
            this.m_picCover.Image = this.m_imgTrackInfoBase;

            this.m_tmrFadeInTrackImage = new System.Timers.Timer();
            this.m_tmrFadeInTrackImage.Interval = 10;
            this.m_tmrFadeInTrackImage.AutoReset = true;
            this.m_tmrFadeInTrackImage.Enabled = false;
            this.m_tmrFadeInTrackImage.Elapsed += new System.Timers.ElapsedEventHandler(FadeInTrackImageElapsed);

            this.m_ImageRectangle = new Rectangle(
                0,
                0,
                CCoverData.ThumbnailSize.Width,
                CCoverData.ThumbnailSize.Height);
        }

        #region MethodsProtected

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

        #endregion

        #region MethodsPrivate

        private void CTrackInfoBaseLoad(object sender, EventArgs e)
        {
            if (this.m_playerManager != null)
            {
                this.m_playerManager.PlayerManagerTrackChanged += new EventHandler<PlayerManagerStatusChangedEventArgs>(PlayerManagerTrackChanged);
            }
        }

        private void PlayerManagerTrackChanged(object sender, BSE.Platten.Audio.PlayerManagerStatusChangedEventArgs e)
        {
            this.m_lblInterpret.Visible = false;
            this.m_lblAlbum.Visible = false;
            this.m_lblTitle.Visible = false;
            this.m_pnlNotes.IsClickable = false;
            this.m_currentTrack = null;
            if (e.CurrentTrack != null)
            {
                this.m_playMode = e.PlayMode;
                if (this.m_picCover.Image != null)
                {
                    this.m_imgOldThumbNail = this.m_picCover.Image;
                }

                SetNotesPanelColors(this.m_playMode);

                TrackInfoData trackInfoData = new TrackInfoData();
                trackInfoData.CurrentTrack = e.CurrentTrack.Clone() as CTrack;
                trackInfoData.Environment = this.m_environment;
                this.m_trackInfoDataToSelect.Enqueue(trackInfoData);
                DequeueTrackInfoData();
            }
        }

        private void FadeInTrackImageElapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            m_fTransparencyOut = this.m_fTransparencyCountOut;
            m_fTransparencyIn = this.m_fTransparencyCountIn;
            if (this.m_fTransparencyCountOut > 0.05)
            {
                this.m_fTransparencyCountOut -= 0.05f;
                this.m_fTransparencyCountIn += 0.05f;
            }
            else
            {
                this.m_fTransparencyCountOut = 1.0f;
                this.m_fTransparencyCountIn = 0.0f;

                m_fTransparencyOut = 0.0f;
                m_fTransparencyIn = 1.0f;

                this.m_tmrFadeInTrackImage.Enabled = false;

                if (this.m_picCover.Image.Equals(this.m_imgNewThumbNail) == false)
                {
                    this.m_picCover.Image = this.m_imgNewThumbNail;
                }
            }
            this.m_picCover.Invalidate();
        }
        
        private void PicCoverPaint(object sender, PaintEventArgs e)
        {
            if (this.m_imgNewThumbNail != null)
            {
                using (ImageAttributes imageAttributes = new ImageAttributes())
                {
                    //Set alpha in the ColorMatrix
                    ColorMatrix colorMatrix = new ColorMatrix();
                    colorMatrix.Matrix33 = m_fTransparencyIn;

                    // Set color matrix of imageAttributes
                    imageAttributes.SetColorMatrix(
                        colorMatrix,
                        ColorMatrixFlag.Default,
                        ColorAdjustType.Bitmap);

                    e.Graphics.DrawImage(
                        this.m_imgNewThumbNail,
                        this.m_ImageRectangle,
                        0,
                        0,
                        CCoverData.ThumbnailSize.Width,
                        CCoverData.ThumbnailSize.Height,
                        GraphicsUnit.Pixel,
                        imageAttributes);
                }
            }

            if (this.m_imgOldThumbNail != null)
            {
                using (ImageAttributes imageAttributes = new ImageAttributes())
                {
                    //Set alpha in the ColorMatrix
                    ColorMatrix colorMatrix = new ColorMatrix();
                    colorMatrix.Matrix33 = m_fTransparencyOut;

                    // Set color matrix of imageAttributes
                    imageAttributes.SetColorMatrix(
                        colorMatrix,
                        ColorMatrixFlag.Default,
                        ColorAdjustType.Bitmap);

                    e.Graphics.DrawImage(
                        this.m_imgOldThumbNail,
                        this.m_ImageRectangle,
                        0,
                        0,
                        CCoverData.ThumbnailSize.Width,
                        CCoverData.ThumbnailSize.Height,
                        GraphicsUnit.Pixel,
                        imageAttributes);
                }
            }
        }
        
        private void ButtonToAlbumClick(object sender, EventArgs e)
        {
            if (this.m_currentTrack != null)
            {
                OnAlbumSelecting(new AlbumSelectEventArgs(this.m_currentTrack.TitelId));
            }
        }

        private void SetNotesPanelColors(PlayMode playMode)
        {
            switch (playMode)
            {
                case PlayMode.CD:
                    this.m_pnlNotes.BorderColor = Color.FromArgb(173,77,13);
                    this.m_pnlNotes.ColorGradientBegin = Color.FromArgb(249,202,164);
                    this.m_pnlNotes.ColorGradientEnd = Color.FromArgb(244,149,86);
                    break;
                case PlayMode.Playlist:
                    this.m_pnlNotes.BorderColor = Color.FromArgb(167,29,35);
                    this.m_pnlNotes.ColorGradientBegin = Color.FromArgb(241,174,175);
                    this.m_pnlNotes.ColorGradientEnd = Color.FromArgb(228,101,108);
                    break;
                case PlayMode.Random:
                    this.m_pnlNotes.BorderColor = Color.FromArgb(40, 81, 142);
                    this.m_pnlNotes.ColorGradientBegin = Color.FromArgb(180, 199, 237);
                    this.m_pnlNotes.ColorGradientEnd = Color.FromArgb(115, 156, 217);
                    break;
                default:
                    this.m_pnlNotes.BorderColor = Color.FromArgb(55, 126, 45);
                    this.m_pnlNotes.ColorGradientBegin = Color.FromArgb(193, 231, 187);
                    this.m_pnlNotes.ColorGradientEnd = Color.FromArgb(132, 209, 123);
                    break;
            }
        }

        private void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            TrackInfoData trackInfoData = e.Argument as TrackInfoData;
            if ((trackInfoData != null) && (trackInfoData.Environment != null) && (trackInfoData.CurrentTrack != null))
            {
                CTunesBusinessObject tunesBusinessObject = new CTunesBusinessObject(trackInfoData.Environment.GetConnectionString());
                try
                {
                    e.Result = tunesBusinessObject.GetTrackWithThumbNailById(trackInfoData.CurrentTrack);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }

        private void BackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                GlobalizedMessageBox.Show(this, e.Error.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                CTrack currentTrack = e.Result as CTrack;
                if (currentTrack != null)
                {
                    if (this.m_pnlNotes.Visible == false)
                    {
                        this.m_pnlNotes.Visible = true;
                    }
                    this.m_currentTrack = currentTrack;
                    this.m_pnlNotes.IsClickable = true;
                    if (String.IsNullOrEmpty(currentTrack.Interpret) == false)
                    {
                        this.m_lblInterpret.Visible = true;
                        this.m_lblInterpret.Text = String.Format(
                            CultureInfo.CurrentUICulture,
                            Resources.IDS_TrackInfoInterpret, currentTrack.Interpret);
                    }
                    if (String.IsNullOrEmpty(currentTrack.Album) == false)
                    {
                        this.m_lblAlbum.Visible = true;
                        this.m_lblAlbum.Text = String.Format(
                            CultureInfo.CurrentUICulture,
                            Resources.IDS_TrackInfoAlbum, currentTrack.Album);
                    }
                    if (this.m_playMode != PlayMode.CD)
                    {
                        if (String.IsNullOrEmpty(currentTrack.Title) == false)
                        {
                            this.m_lblTitle.Visible = true;
                            this.m_lblTitle.Text = String.Format(
                                CultureInfo.CurrentUICulture,
                                Resources.IDS_TrackInfoTrack, currentTrack.Title);
                        }
                    }
                    if (currentTrack.ThumbNail != null)
                    {
                        this.m_imgNewThumbNail = currentTrack.ThumbNail;
                    }
                    else
                    {
                        this.m_imgNewThumbNail = this.m_imgTrackInfoBase;
                    }
                    this.m_tmrFadeInTrackImage.Enabled = true;
                    this.m_workingState = WorkingState.None;
                    DequeueTrackInfoData();
                }
            }
        }

        private void DequeueTrackInfoData()
        {
            if (this.m_trackInfoDataToSelect.Count > 0)
            {
                if (this.m_workingState == WorkingState.Working)
                {
                    return;
                }
                else
                {
                    this.m_workingState = WorkingState.Working;
                    TrackInfoData trackInfoData = this.m_trackInfoDataToSelect.Dequeue();
                    if (trackInfoData != null)
                    {
                        this.m_backgroundWorker.RunWorkerAsync(trackInfoData);
                    }
                }
            }
        }

        internal class TrackInfoData
        {
            #region FieldsPrivate
            private CEnvironment m_environment;
            private CTrack m_currentTrack;
            #endregion

            #region Properties
            public CEnvironment Environment
            {
                get { return this.m_environment; }
                set { this.m_environment = value; }
            }
            public CTrack CurrentTrack
            {
                get { return this.m_currentTrack; }
                set { this.m_currentTrack = value; }
            }
            #endregion
        }

        #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)

About the Author

Uwe Eichkorn

Switzerland Switzerland
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140718.1 | Last Updated 24 Apr 2010
Article Copyright 2009 by Uwe Eichkorn
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid