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

BSEtunes

, 24 Apr 2010 CPOL
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
MySQL.chm
MySqlCreateDataBase5x.sql.zip
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using BSE.Platten.BO;
using BSE.Platten.Common;
using BSE.Configuration;
using BSE.Platten.Audio;
using System.Globalization;
using BSE.Windows.Forms;
using BSE.Platten.Tunes.Properties;
using System.IO;
using System.Windows.Interop;

namespace BSE.Platten.Tunes
{
    public partial class CTunes : BaseForm, IConfigurationSettings
    {
        #region Constants

        private const string m_strSettingsFileNameSettingsPart = ".Settings";

        #endregion

        #region Enumeratoren

        public enum EPlayerApp
        {
            Radio,
            Lied,
            CD
        }

        public enum PlayButtonMode
        {
            Start,
            Pause,
            Stop
        }

        #endregion

        #region Delegates

        private delegate void DelegateRefreshControls();
        private delegate void DelegateStopRadio();

        #endregion

        #region FieldsPrivate

        private CAlbum m_currentAlbum;
        private CTrackCollection m_trackCollectionByFilterSettings;
        private CEnvironment m_environment;
        private string m_strAudioHomeDirectory;
        private string m_strConnection;
        private Image m_imgSong;
        private System.Threading.Thread m_threadControlRefresh;

        #endregion

        #region Properties

        #region IConfigurationSettings

        public string ConfigurationFolder
        {
            get { return this.GetType().Namespace; }
        }

        public string ConfigurationFileName
        {
            get { return this.GetType().Namespace; }
        }

        public string SettingsFileName
        {
            get { return this.GetType().Namespace + m_strSettingsFileNameSettingsPart; }
        }
        #endregion

        internal string AudioHomeDirectory
        {
            get { return this.m_strAudioHomeDirectory; }
            set { this.m_strAudioHomeDirectory = value; }
        }
        
        internal string ConnectionString
        {
            get { return this.m_strConnection; }
            set { this.m_strConnection = value; }
        }

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

        internal CAlbum CurrentAlbum
        {
            get { return this.m_currentAlbum; }
            set { this.m_currentAlbum = value; }
        }

        internal CTrackCollection TrackCollectionByFilterSettings
        {
            get { return this.m_trackCollectionByFilterSettings; }
            set { this.m_trackCollectionByFilterSettings = value; }
        }

        #endregion

        #region MethodsPublic

        public CTunes() : base()
        {
            InitializeComponent();
            
            this.m_configuration.ApplicationSubDirectory = this.ConfigurationFolder;
            this.m_configuration.ConfigFileName = this.ConfigurationFileName;

            this.m_environment = new CEnvironment(this.m_configuration);

            this.m_settings.ApplicationSubDirectory = this.ConfigurationFolder;
            this.m_settings.ConfigFileName = this.SettingsFileName;

            this.m_imgSong = Properties.Resources.song;

            this.AllowDrop = true;
            this.KeyPreview = true;

            this.m_tsAudioPlayer.Stretch = true;
            this.m_tsAudioPlayer.GripStyle = ToolStripGripStyle.Hidden;
            ToolStripManager.Merge(this.m_tsSearch, this.m_tsMusic);
            ToolStripManager.Merge(this.m_tsMusic, this.m_tsAudioPlayer);

            this.m_pnlSearch.Tag = this.m_mnuView_Search;
            this.m_pnlPlayList.Tag = this.m_mnuView_PlaylistEditor;

            this.m_playList.PlayerManager = this.m_playerManager;
            this.m_albumProperties.PlayerManager = this.m_playerManager;
            this.m_clipBoard.PlayerManager = this.m_playerManager;

        }

        #endregion

        #region MethodsPrivate

        private void CTunes_Load(object sender, EventArgs e)
        {
            int iSplashStep = 0;
            int iSplashStepsTotal = 14;
            CSplashScreen.ShowSplashScreen();
            CSplashScreen.SetStatusMessage("Lade Systemsettings", iSplashStep++, iSplashStepsTotal);
            CTunesSettingsData settingsData = LoadSettings();
            try
            {
                this.m_mnuView.Enabled = false;
                this.m_mnuFilter.Enabled = false;
                this.m_mnuExtras_Statistik.Enabled = false;
                
                //Starte Payer
                CSplashScreen.SetStatusMessage("Starte Player", iSplashStep++, iSplashStepsTotal);
                this.m_playerManager.LoadPlayer(this.m_configuration);
                CSplashScreen.SetStatusMessage("Pr�fe Datenbankverbindung", iSplashStep++, iSplashStepsTotal);
                this.ConnectionString = this.m_environment.GetConnectionString();
                CSplashScreen.SetStatusMessage("Pr�fe Audio Home- Verzeichnis", iSplashStep++, iSplashStepsTotal);
                this.AudioHomeDirectory = this.m_environment.GetAudioHomeDirectory();

                CSplashScreen.SetStatusMessage("Pr�fe Datenbankhost", iSplashStep++, iSplashStepsTotal);
                if (this.m_ssMain.IsHostAvailable(this.m_environment) == true)
                {
                    this.m_mnuView.Enabled = true;
                    this.m_mnuFilter.Enabled = true;
                    this.m_mnuExtras_Statistik.Enabled = true;

                    CTunesBusinessObject tunesBusinessObject = new CTunesBusinessObject(this.ConnectionString);

                    //Lade Covers
                    CSplashScreen.SetStatusMessage("Lade Covers", iSplashStep++, iSplashStepsTotal);
                    GetCovers();

                    //l�dt Alben und Genres in den Tree
                    CSplashScreen.SetStatusMessage("Lade Alben", iSplashStep++, iSplashStepsTotal);
                    CInterpretData[] interpretsAndAlbums = tunesBusinessObject.GetInterpretsAndAlbums();
                    this.m_treeInterpretenTitel.SetInterpretsAndAlbums(interpretsAndAlbums);

                    //l�dt den TreeviewGenreInterpretsAndTitles
                    CSplashScreen.SetStatusMessage("Lade Genres", iSplashStep++, iSplashStepsTotal);
                    CGenreData[] genreWithAlbums = tunesBusinessObject.GetGenresWithAlbums();
                    this.m_treeInterpretenTitel.SetGenresWithAlbums(genreWithAlbums);

                    //l�dt den TreeviewYearInterpretsAndTitles
                    CSplashScreen.SetStatusMessage("Lade Jahr", iSplashStep++, iSplashStepsTotal);
                    CYearData[] yearsWithAlbums = tunesBusinessObject.GetYearsWithAlbums();
                    this.m_treeInterpretenTitel.SetYearsWithAlbums(yearsWithAlbums);

                    //l�scht alte Eintr�ge aus der Benutzerhistory
                    CSplashScreen.SetStatusMessage("L�sche History", iSplashStep++, iSplashStepsTotal);
                    tunesBusinessObject.DeleteTracksFromHistory(this.m_environment.UserName);

                    //l�dt die Benutzerhistory
                    CSplashScreen.SetStatusMessage("Lade History", iSplashStep++, iSplashStepsTotal);
                    SortableCollection<CTrack> trackCollection = tunesBusinessObject.GetHistoryTrackCollection(this.m_environment.UserName);
                    this.m_history.UpdateHistory(trackCollection);

                    //Lied Favorites
                    CSplashScreen.SetStatusMessage("Lade Favoriten", iSplashStep++, iSplashStepsTotal);
                    CFavorite[] singleFavorites
                        = tunesBusinessObject.GetFavoritesByFavoritId(10, (int)EPlayerApp.Lied, this.m_environment.UserName);
                    this.m_treeFavorites.SetFavorites(singleFavorites, ListMode.Singlecharts);

                    //CD Favorites
                    CFavorite[] albumFavorites
                        = tunesBusinessObject.GetFavoritesByFavoritId(10, (int)EPlayerApp.CD, this.m_environment.UserName);
                    this.m_treeFavorites.SetFavorites(albumFavorites, ListMode.Albumcharts);

                    //Playlisten
                    CSplashScreen.SetStatusMessage("Lade Wiedergabelisten", iSplashStep++, iSplashStepsTotal);
                    CPlaylist[] playLists = tunesBusinessObject.GetPlaylistsByUserName(this.m_environment.UserName);
                    this.m_treeFavorites.SetPlayLists(playLists);

                    //Filter
                    CSplashScreen.SetStatusMessage("Lade Filter", iSplashStep++, iSplashStepsTotal);
                    BSE.Platten.Tunes.Filters.FilterMain filter
                        = new BSE.Platten.Tunes.Filters.FilterMain();
                    Filters.FilterConfiguration filterConfiguration
                        = filter.GetFilterConfiguration(this.m_environment);
                    this.m_mnuFilter_Properties.Text = filterConfiguration.FilterName;
                    this.TrackCollectionByFilterSettings = filter.GetTracksByFilterSettings(this.m_environment, (FilterSettings)filterConfiguration);
                    if (this.TrackCollectionByFilterSettings.Count > 0)
                    {
                        int iIndex = this.TrackCollectionByFilterSettings.GetRandomIndex();
                        CTrack currentTrack = this.TrackCollectionByFilterSettings[iIndex] as CTrack;
                        if (currentTrack != null)
                        {
                            int iStartTitelId = currentTrack.TitelId;
                            GetSelectedTitle(iStartTitelId, true);
                        }
                    }

                    this.m_search.Environment = this.m_environment;
                    this.m_playList.Environment = this.m_environment;
                    this.m_history.Environment = this.m_environment;
                    this.m_clipBoard.Environment = this.m_environment;
                }
            }
            catch (BSE.Configuration.CConfigurationValueNotFoundException configurationValueNotFoundException)
            {
                if (CSplashScreen.SplashScreen != null)
                {
                    CSplashScreen.CloseSplashScreen(this);
                }
                DialogResult dialogResult = GlobalizedMessageBox.Show(this, configurationValueNotFoundException.Message, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                if (dialogResult == DialogResult.OK)
                {
                    OpenOptions();
                }
            }
            catch (Exception exception)
            {
                if (CSplashScreen.SplashScreen != null)
                {
                    CSplashScreen.CloseSplashScreen(this);
                }
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.m_ssMain.HostAvailabilityChanged += new EventHandler<HostAvailableEventArgs>(HostAvailable);
                this.m_plstMain.Expand(this.m_pnlHistory);

                RenderStyleConfigurationData formStyleConfigurationData =
                    BSE.Platten.Common.RenderStyleConfigurationControl.GetConfiguration(this.m_configuration) as RenderStyleConfigurationData;
                if (formStyleConfigurationData != null)
                {
                    SetFormStyleSettings(formStyleConfigurationData);
                }

                if (settingsData != null && settingsData.WindowState == FormWindowState.Maximized)
                {
                    this.WindowState = FormWindowState.Maximized;
                }

                if (CSplashScreen.SplashScreen != null)
                {
                    CSplashScreen.CloseSplashScreen(this);
                }
            }
        }
        
        private void CTunes_FormClosing(object sender, FormClosingEventArgs e)
        {
            SaveSettings();
            if (this.m_playerManager.HasPlayerStarted)
            {
                this.m_playerManager.Close();
            }
            Application.Exit();
        }

        private void CTunes_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.F12:
                    if (this.m_currentAlbum.Tracks != null)
                    {
                        this.m_ctxTunes.Items.Clear();
                        this.m_ctxTunes.Items.AddRange(GetToolStripMenuItemsLieder());
                        this.m_ctxTunes.Show(new Point(Cursor.Position.X, Cursor.Position.Y));
                    }
                    break;
            }
        }

        private void OptionenClick(object sender, EventArgs e)
        {
            OpenOptions();
        }

        private void OpenOptions()
        {
            Application.DoEvents();
            try
            {
                using (Options options = new Options(this.m_configuration))
                {
                    options.ConfigurationChanged += new EventHandler(this.OptionsConfigurationChanged);
                    options.AudioPlayerChanged += new EventHandler(this.AudioPlayerChanged);
                    options.FormStyleChanged += new EventHandler(this.FormStyleChanged);
                    options.ShowDialog(this);
                }
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void OptionsConfigurationChanged(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                //If the AudioHome Directory has changed
                string strAudioHomeDirectory = this.m_environment.GetAudioHomeDirectory();
                int iCompareAudioHomeDirectory = string.Compare(
                    this.AudioHomeDirectory,
                    strAudioHomeDirectory,
                    StringComparison.OrdinalIgnoreCase);

                if (iCompareAudioHomeDirectory.Equals(0) == false)
                {
                    this.AudioHomeDirectory = strAudioHomeDirectory;
                }

                //If the ConnectionString has changed
                string strConnection = this.m_environment.GetConnectionString();
                int iCompareConnectionString = string.Compare(
                    this.ConnectionString,
                    strConnection,
                    StringComparison.OrdinalIgnoreCase);

                if (iCompareConnectionString.Equals(0) == false)
                {
                    this.ConnectionString = strConnection;
                    if (this.m_ssMain.IsHostAvailable(this.m_environment) == true)
                    {
                        StartRefreshControlsThread();

                        this.m_mnuView.Enabled = true;
                        this.m_mnuFilter.Enabled = true;
                        this.m_mnuExtras_Statistik.Enabled = true;

                        this.m_search.Environment = this.m_environment;
                        this.m_playList.Environment = this.m_environment;
                        this.m_history.Environment = this.m_environment;
                        this.m_clipBoard.Environment = this.m_environment;
                    }
                }
            }
            catch (BSE.Configuration.CConfigurationValueNotFoundException configurationValueNotFoundException)
            {
                DialogResult dialogResult = GlobalizedMessageBox.Show(this, configurationValueNotFoundException.Message, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                if (dialogResult == DialogResult.OK)
                {
                    OpenOptions();
                }
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }

        private void AudioPlayerChanged(object sender, EventArgs e)
        {
            try
            {
                this.m_playerManager.LoadPlayer(this.m_configuration);
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void FormStyleChanged(object sender, EventArgs e)
        {
            RenderStyleConfigurationData formStyleConfigurationData = RenderStyleConfigurationControl.GetConfiguration(
                this.m_configuration) as RenderStyleConfigurationData;
            if (formStyleConfigurationData != null)
            {
                SetFormStyleSettings(formStyleConfigurationData);
            }
        }

        private void SetFormStyleSettings(RenderStyleConfigurationData renderStyleConfigurationData)
        {
            if ((ToolStripManager.VisualStylesEnabled == true) && (renderStyleConfigurationData != null))
            {
                RenderStyle renderStyle = renderStyleConfigurationData.RenderStyle;
                if (renderStyle != null)
                {
                    ToolStripProfessionalRenderer toolStripRenderer = null;
                    BSE.Windows.Forms.ProfessionalColorTable professionalColorTable = null;
                    BSE.Windows.Forms.PanelColors panelColors = null;
                    BSE.Windows.Forms.PanelStyle panelStyle = renderStyle.PanelStyle;

                    if (renderStyle.TypeProfessionalColorTable != null)
                    {
                        professionalColorTable =
                            Activator.CreateInstance(renderStyle.TypeProfessionalColorTable) as BSE.Windows.Forms.ProfessionalColorTable;
                        if (professionalColorTable != null)
                        {
                            panelColors = professionalColorTable.PanelColorTable;
                        }
                    }

                    if (renderStyle.TypeToolStripProfessionalRenderer != null)
                    {
                        if (professionalColorTable != null)
                        {
                            toolStripRenderer = Activator.CreateInstance(renderStyle.TypeToolStripProfessionalRenderer, new object[] { professionalColorTable }) as ToolStripProfessionalRenderer;
                        }
                        else
                        {
                            toolStripRenderer =
                                Activator.CreateInstance(renderStyle.TypeToolStripProfessionalRenderer) as ToolStripProfessionalRenderer;
                        }
                        if (toolStripRenderer != null)
                        {
                            if (professionalColorTable == null)
                            {
                                professionalColorTable = toolStripRenderer.ColorTable as BSE.Windows.Forms.ProfessionalColorTable;
                                if (professionalColorTable != null)
                                {
                                    panelColors = professionalColorTable.PanelColorTable;
                                }
                            }
                        }
                    }
                    if ((panelColors != null)
                        && (professionalColorTable != null)
                        && toolStripRenderer != null)
                    {
                        this.PanelStyle = panelStyle;
                        this.PanelColors = panelColors;
                        this.ProfessionalColorTable = professionalColorTable;
                        toolStripRenderer.RoundedEdges = false;
                        ToolStripManager.Renderer = toolStripRenderer;
                    }
                }
            }
        }

        private void StatistikClick(object sender, EventArgs e)
        {
            Application.DoEvents();
            CTunesBusinessObject tunesBusinessObject
                = new CTunesBusinessObject(this.ConnectionString);
            try
            {
                DataSet dataSet = tunesBusinessObject.GetDataSetStatisticInformation();
                using (Statistics statistik = new Statistics(dataSet))
                {
                    statistik.ProfessionalColorTable = this.ProfessionalColorTable;
                    statistik.ShowDialog();
                }
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void HelpAboutClick(object sender, EventArgs e)
        {
            Application.DoEvents();
            BSE.Windows.Forms.About about = new BSE.Windows.Forms.About();
            about.BackgroundImage = BSE.Platten.Tunes.Properties.Resources.BSEAbout;
            about.AlternatingBackColor = BSE.Platten.Common.BSEColors.AlternatingBackColor;
            about.ClientSize = about.BackgroundImage.Size;
            about.ShowInTaskbar = false;
            about.ShowDialog();
        }

        private void HostAvailable(object sender, HostAvailableEventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                DatabaseHostAvailability databaseHostAvailability = e.DatabaseHostAvailability;
                if (databaseHostAvailability != null)
                {
                    if (databaseHostAvailability.IsAvailable == false)
                    {
                        //Alle Controls die Daten manipulieren k�nnen werden disabled
                        foreach (Control control in this.m_tscMain.Controls)
                        {
                            if (control.Contains(this.m_mnuMain) == true)
                            {
                                foreach (Control subControl in control.Controls)
                                {
                                    MenuStrip menuStrip = subControl as MenuStrip;
                                    if (menuStrip != null)
                                    {
                                        foreach (ToolStripItem toolStripItem in menuStrip.Items)
                                        {
                                            toolStripItem.Enabled = false;
                                            if (toolStripItem == this.m_mnuDatei)
                                            {
                                                toolStripItem.Enabled = true;
                                            }
                                            if (toolStripItem == this.m_mnuExtras)
                                            {
                                                toolStripItem.Enabled = true;
                                            }
                                            if (toolStripItem == this.m_mnuHelp)
                                            {
                                                toolStripItem.Enabled = true;
                                            }
                                        }
                                    }
                                }
                            }
                            else if (control.Contains(this.m_ssMain) == true)
                            {
                                foreach (Control subControl in control.Controls)
                                {
                                    StatusStrip statusStrip = subControl as StatusStrip;
                                    if (statusStrip != null)
                                    {
                                        statusStrip.Enabled = true;
                                    }
                                }
                            }
                            else
                            {
                                control.Enabled = false;
                            }
                        }
                        this.m_mnuExtras_Statistik.Enabled = false;
                    }
                    else
                    {
                        foreach (Control control in this.m_tscMain.Controls)
                        {
                            control.Enabled = true;
                            if (control.Contains(this.m_mnuMain) == true)
                            {
                                foreach (Control subControl in control.Controls)
                                {
                                    MenuStrip menuStrip = subControl as MenuStrip;
                                    if (menuStrip != null)
                                    {
                                        foreach (ToolStripItem toolStripItem in menuStrip.Items)
                                        {
                                            toolStripItem.Enabled = true;
                                        }
                                    }
                                }
                            }
                        }
                        StartRefreshControlsThread();
                    }
                }
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        
        private void BSEAdminClick(object sender, EventArgs e)
        {
            if (this.m_currentAlbum != null)
            {
                Application.DoEvents();
                try
                {
                    using (BSE.Platten.Admin.Admin admin
                        = new BSE.Platten.Admin.Admin(
                        this.m_configuration,
                        this.m_currentAlbum.AlbumId))
                    {
                        if (this.PanelColors != null)
                        {
                            admin.PanelStyle = this.PanelStyle;
                            admin.PanelColors = this.PanelColors;
                        }
                        admin.ProfessionalColorTable = this.ProfessionalColorTable;
                        
                        admin.ShowInTaskbar = false;
                        admin.ShowDialog(this);
                    }
                }
                catch (Exception exception)
                {
                    GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

        private void m_mnuDatei_Beenden_Click(object sender, EventArgs e)
        {
            Application.DoEvents();
            this.Close();
        }
        
        private void FilterPropertiesClick(object sender, EventArgs e)
        {
            Application.DoEvents();
            try
            {
                using (BSE.Platten.Tunes.Filters.FilterMain filter
                    = new BSE.Platten.Tunes.Filters.FilterMain(this.m_environment))
                {
                    if (this.PanelColors != null)
                    {
                        filter.PanelStyle = this.PanelStyle;
                        filter.PanelColors = this.PanelColors;
                    }
                    filter.ProfessionalColorTable = this.ProfessionalColorTable;
                    
                    filter.FilterChanged -= new EventHandler<BSE.Platten.Tunes.Filters.FilterChangedEventArgs>(FilterChanged);
                    filter.FilterChanged += new EventHandler<BSE.Platten.Tunes.Filters.FilterChangedEventArgs>(FilterChanged);
                    filter.ShowDialog();
                }
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void FilterChanged(object sender, Filters.FilterChangedEventArgs e)
        {
            BSE.Platten.Tunes.Filters.FilterMain filter
                                   = new BSE.Platten.Tunes.Filters.FilterMain();
            try
            {
                BSE.Platten.Tunes.Filters.FilterConfiguration filterConfiguration
                    = filter.GetFilterConfiguration(this.m_environment);
                this.m_mnuFilter_Properties.Text = filterConfiguration.FilterName;
                this.TrackCollectionByFilterSettings = filter.GetTracksByFilterSettings(this.m_environment, (FilterSettings)filterConfiguration);

                //Wenn das Radio l�uft und der Filter ge�ndert wurde, werden die neuen Tracks dem PlayerManager �bergeben
                if (this.m_mnuMusik_Radio.Checked == true)
                {
                    this.m_playerManager.SetTracksToPlay(this.TrackCollectionByFilterSettings);
                }
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void PlayListEditorClick(object sender, EventArgs e)
        {
            XPanderPanelList parentList = this.m_pnlPlayList.Parent as XPanderPanelList;
            if (parentList == null)
            {
                this.m_plstMain.XPanderPanels.Add(this.m_pnlPlayList);
                if (this.PanelColors != null)
                {
                    this.m_pnlPlayList.SetPanelProperties(this.PanelColors);
                }
            }
            this.m_mnuView_PlaylistEditor.Checked = false;
            if (this.m_pnlPlayList.Expand == false)
            {
                this.m_plstMain.Expand(this.m_pnlPlayList);
            }
        }
        
        private void SearchClick(object sender, EventArgs e)
        {
            XPanderPanelList parentList = this.m_pnlSearch.Parent as XPanderPanelList;
            if (parentList == null)
            {
                this.m_plstMain.XPanderPanels.Add(this.m_pnlSearch);
                if (this.PanelColors != null)
                {
                    this.m_pnlSearch.SetPanelProperties(this.PanelColors);
                }
            }
            this.m_mnuView_Search.Checked = true;
            if (this.m_pnlSearch.Expand == false)
            {
                this.m_plstMain.Expand(this.m_pnlSearch);
            }
        }
        
        private void ShowListClick(object sender, EventArgs e)
        {
            this.m_pnlRight.Visible = !this.m_pnlRight.Visible;
        }

        private void ListVisibilityChanged(object sender, EventArgs e)
        {
            this.m_mnuView_List.Checked = this.m_pnlRight.Visible;
        }

        private void ListCloseClick(object sender, EventArgs e)
        {
            this.m_pnlRight.Visible = false;
        }

        private void ViewRefreshClick(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                StartRefreshControlsThread();
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }

        private void SearchExecuting(object sender, SearchExecuteEventArgs e)
        {
            this.m_search.SetSearchTerm(e.SearchTerm);
            SearchClick(sender, e);
        }
        
        private void SearchExecuted(object sender, SearchExecuteEventArgs e)
        {
            this.m_tsSearch.SetSearchTerm(e.SearchTerm);
        }

        private void RemovableDriveChanges(object sender, BSE.RemovableDrives.DriveChangeEventArgs e)
        {
            BSE.RemovableDrives.RemovableDrive removableDrive = e.RemovableDrive;
            if (removableDrive != null)
            {
                bool bIsNotInPanelList = true;
                foreach (BSE.Windows.Forms.XPanderPanel xpanderPanel in this.m_plstMain.XPanderPanels)
                {
                    XPanderPanelAudioDrive xPanderPanelAudioDrive = xpanderPanel as XPanderPanelAudioDrive;
                    if (xPanderPanelAudioDrive != null)
                    {
                        if (removableDrive.Equals(xPanderPanelAudioDrive.AudioDrive) == true)
                        {
                            bIsNotInPanelList = false;
                        }
                    }
                }
                if (bIsNotInPanelList == true)
                {
                    XPanderPanelAudioDrive xpanderPanel = new XPanderPanelAudioDrive();
                    xpanderPanel.ToolTipTextCloseIcon = Resources.IDS_TooltipPanelClose;
                    xpanderPanel.ToolTipTextExpandIconPanelCollapsed = Resources.IDS_TooltipPanelMaximize;
                    xpanderPanel.AudioDrive = removableDrive;
                    xpanderPanel.Environment = this.m_environment;
                    xpanderPanel.Settings = this.m_settings;
                    this.m_plstMain.XPanderPanels.Add(xpanderPanel);
                    this.m_plstMain.Expand(xpanderPanel);
                }
            }
        }

        private void RemovableDriveRemoved(object sender, BSE.RemovableDrives.DriveChangeEventArgs e)
        {
            BSE.RemovableDrives.RemovableDrive removableDrive = e.RemovableDrive;
            if (removableDrive != null)
            {
                foreach (BSE.Windows.Forms.XPanderPanel xpanderPanel in this.m_plstMain.XPanderPanels)
                {
                    XPanderPanelAudioDrive xPanderPanelAudioDrive = xpanderPanel as XPanderPanelAudioDrive;
                    if (xPanderPanelAudioDrive != null)
                    {
                        if (removableDrive.Equals(xPanderPanelAudioDrive.AudioDrive) == true)
                        {
                            xPanderPanelAudioDrive.AudioDrive = null;
                        }
                    }
                }
            }
        }

        private void RemovableDriveAdded(object sender, BSE.RemovableDrives.DriveChangeEventArgs e)
        {
            BSE.RemovableDrives.RemovableDrive removableDrive = e.RemovableDrive;
            if (removableDrive != null)
            {
                foreach (BSE.Windows.Forms.XPanderPanel xpanderPanel in this.m_plstMain.XPanderPanels)
                {
                    XPanderPanelAudioDrive xPanderPanelAudioDrive = xpanderPanel as XPanderPanelAudioDrive;
                    if (xPanderPanelAudioDrive != null)
                    {
                        if (xPanderPanelAudioDrive.VolumeName.Equals(removableDrive.VolumeName) == true)
                        {
                            xPanderPanelAudioDrive.AudioDrive = removableDrive;
                        }
                    }
                }
            }
        }

        private void RadioClick(object sender, EventArgs e)
        {
            try
            {
                if (this.m_mnuMusik_Radio.Checked == false)
                {
                    if (this.TrackCollectionByFilterSettings != null)
                    {
                        this.m_playerManager.PlayTracks(this.TrackCollectionByFilterSettings, PlayMode.Random);
                        this.m_mnuMusik_Radio.Checked = this.m_btnMusic_Radio.Checked = true;
                    }
                }
                else
                {
                    StopPlayingRadio();
                }
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                StopPlayingRadio();
            }
        }

        private void StopPlayingRadio()
        {
            this.m_mnuMusik_Radio.Checked = this.m_btnMusic_Radio.Checked = false;
            this.m_btnMusic_CoverFlow.Enabled = this.m_mnuView_Coverflow.Enabled = false;
            this.m_playerManager.Stop();
        }

        private void PlayCDClick(object sender, EventArgs e)
        {
            StopPlayingRadio();
            if (this.m_currentAlbum != null && this.CurrentAlbum.Tracks != null)
            {
                CTrackCollection trackCollection = new CTrackCollection(this.CurrentAlbum.Tracks.Length);
                foreach (CTrack track in this.CurrentAlbum.Tracks)
                {
                    if (String.IsNullOrEmpty(track.FileFullName) == false)
                    {
                        trackCollection.Add(track);
                    }
                }
                if (trackCollection.Count > 0)
                {
                    try
                    {
                        this.m_playerManager.PlayTracks(trackCollection, BSE.Platten.Audio.PlayMode.CD);
                    }
                    catch (Exception exception)
                    {
                        GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }

        private void PlaySongClick(object sender, EventArgs e)
        {
            StopPlayingRadio();
            ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem;
            if (toolStripMenuItem != null)
            {
                CTrack track = toolStripMenuItem.Tag as CTrack;
                if (track != null)
                {
                    try
                    {
                        this.m_playerManager.PlayTrack(track, BSE.Platten.Audio.PlayMode.Song);
                    }
                    catch (Exception exception)
                    {
                        GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }

        private void CoverFlowClick(object sender, EventArgs e)
        {
            using (BSE.CoverFlow.WPFLib.WindowCoverFlow windowCoverFlow = new BSE.CoverFlow.WPFLib.WindowCoverFlow())
            {
                WindowInteropHelper windowInteropHelper = new WindowInteropHelper(windowCoverFlow);
                windowInteropHelper.Owner = this.Handle;
                windowCoverFlow.WindowState = System.Windows.WindowState.Maximized;
                windowCoverFlow.WindowStyle = System.Windows.WindowStyle.None;
                windowCoverFlow.ShowInTaskbar = false;
                windowCoverFlow.ConnectionString = this.ConnectionString;
                windowCoverFlow.PlayerManager = this.m_playerManager;

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

        private void GetCovers()
        {
            CTunesBusinessObject tunesBusinessObject = new CTunesBusinessObject(this.ConnectionString);
            try
            {
                CAlbum[] albumsWithCovers = tunesBusinessObject.GetNewestAlbumsWithCovers(20);
                this.m_covers.LoadCoverBoxes(albumsWithCovers);
                this.m_covers.Invalidate();
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void PlayerManagerPlayerPlays(object sender, BSE.Platten.Audio.PlayerManagerStatusChangedEventArgs e)
        {
            this.m_btnMusic_CoverFlow.Enabled = this.m_mnuView_Coverflow.Enabled = false;
            if ((this.m_playerManager.PlayMode == PlayMode.Playlist)
                || (this.m_playerManager.PlayMode == PlayMode.Random))
            {
                this.m_btnMusic_CoverFlow.Enabled = this.m_mnuView_Coverflow.Enabled = true;
            }
        }

        private void PlayerManagerTrackChanged(object sender, BSE.Platten.Audio.PlayerManagerStatusChangedEventArgs e)
        {
            this.m_ssMain.SetTickerText(e.CurrentTrack, e.PlayMode);
            this.m_history.UpdateHistory(e.CurrentTrack, e.PlayMode);
        }

        private void PlayerManagerStopped(object sender, BSE.Platten.Audio.PlayerManagerStatusChangedEventArgs e)
        {
            if (this.InvokeRequired == true)
            {
                this.Invoke(new DelegateStopRadio(StopPlayingRadio));
            }
            else
            {
                StopPlayingRadio();
            }
        }

        private void PlayerManagerClosed(object sender, BSE.Platten.Audio.PlayerManagerStatusChangedEventArgs e)
        {
            if (e.PlayMode == BSE.Platten.Audio.PlayMode.Random)
            {
                StopPlayingRadio();
            }
        }

        private void TreeInterpretenTitelAfterSelect(object sender, TreeInterpretenTitelEventArgs e)
        {
            GetSelectedTitle(e.TitelId, false);
        }

        private void TreeFavoritesClick(object sender, TreeViewFavoritesEventArgs e)
        {
            ListMode listMode = e.ListMode;
            switch (listMode)
            {
                case ListMode.Singlecharts:
                case ListMode.Albumcharts:
                    GetSelectedTitle(e.Id, true);
                    break;
                case ListMode.Playlists:
                    this.m_playList.SetPlaylist(e.Id);
                    PlayListEditorClick(sender, e);
                    break;
            }
        }

        private void TreeFavoritesPlayListEvent(object sender, TreeViewFavoritesEventArgs e)
        {
            switch (e.TreeViewListEvent)
            {
                case TreeViewFavorites.TreeViewListEvent.AddPlayList:
                    this.m_playList.SetNewPlayList();
                    break;
                case TreeViewFavorites.TreeViewListEvent.DeletePlaylist:
                    this.m_playList.SetDeletePlayList();
                    break;
                case TreeViewFavorites.TreeViewListEvent.PlayTracks:
                    this.m_playList.SetPlayTracks();
                    break;
                case TreeViewFavorites.TreeViewListEvent.PlayRandomTracks:
                    this.m_playList.SetPlayRandomTracks();
                    break;
            }
        }

        private void PanelListControlRemoved(object sender, ControlEventArgs e)
        {
            XPanderPanel xpanderPanel = e.Control as XPanderPanel;
            if (xpanderPanel != null)
            {
                ToolStripMenuItem menuItem = xpanderPanel.Tag as ToolStripMenuItem;
                if (menuItem != null)
                {
                    menuItem.Checked = false;
                }
                XPanderPanelAudioDrive xPanderPanelAudioDrive = xpanderPanel as XPanderPanelAudioDrive;
                if (xPanderPanelAudioDrive != null)
                {
                    //Activates the next control. When treeview or listview has the focus,
                    //a handle exeption rises at disposing
                    this.m_tscMain.SelectNextControl(xPanderPanelAudioDrive, false, true, true, true);
                    xPanderPanelAudioDrive.Dispose();
                }
            }
        }

        private void CoversCoverClick(object sender, BSE.Platten.Covers.CoverBoxClickEventArgs e)
        {
            GetSelectedTitle(e.TitelId, true);
        }

        private void AlbumSelecting(object sender, AlbumSelectEventArgs e)
        {
            GetSelectedTitle(e.TitelId, true);
        }

        private void ClipBoardAlbumSelected(object sender, PlayListEventArgs e)
        {
            if (e.Track != null)
            {
                GetSelectedTitle(e.Track.TitelId, true);
            }
        }
        
        private void PlayListInserted(object sender, PlayListEventArgs e)
        {
            CTunesBusinessObject tunesBusinessObject = new CTunesBusinessObject(this.m_strConnection);
            CPlaylist[] playLists = tunesBusinessObject.GetPlaylistsByUserName(this.m_environment.UserName);
            this.m_treeFavorites.SetPlayLists(playLists,e.PlayList);
            if (this.m_pnlPlayList.Visible == false)
            {
                this.m_pnlPlayList.Visible = true;
            }
            if (this.m_pnlPlayList.Expand == false)
            {
                this.m_plstMain.Expand(this.m_pnlPlayList);
            }
        }

        private void PlayListDeleted(object sender, PlayListEventArgs e)
        {
            CTunesBusinessObject tunesBusinessObject = new CTunesBusinessObject(this.m_strConnection);
            CPlaylist[] playLists = tunesBusinessObject.GetPlaylistsByUserName(this.m_environment.UserName);
            this.m_treeFavorites.SetPlayLists(playLists);
        }

        private void GetSelectedTitle(int iTitelid, bool bWithTreeEvent)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                this.CurrentAlbum = this.GetCurrentAlbum(iTitelid);
                if (this.CurrentAlbum != null)
                {
                    this.m_mnuMusik_Tracks.DropDownItems.Clear();
                    this.m_btnMusic_Tracks.DropDownItems.Clear();
                    if ((this.CurrentAlbum.Tracks != null) && (this.CurrentAlbum.Tracks.Length > 0))
                    {
                        this.m_mnuMusik.Enabled = this.m_tsMusic.Enabled = true;
                        this.m_albumProperties.SetCurrentAlbum(this.CurrentAlbum);
                        this.m_mnuMusik_Tracks.DropDownItems.AddRange(GetToolStripMenuItemsLieder());
                        this.m_btnMusic_Tracks.DropDownItems.AddRange(GetToolStripMenuItemsLieder());

                        if (bWithTreeEvent == true)
                        {
                            this.m_treeInterpretenTitel.SetSelectedChildNode(this.m_currentAlbum.AlbumId);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }

        private CAlbum GetCurrentAlbum(int iTitelId)
        {
            CAlbum currentAlbum = null;
            CTunesBusinessObject tunesBusinessObject = new CTunesBusinessObject(this.m_strConnection);
            try
            {
                currentAlbum = tunesBusinessObject.GetAlbumById(iTitelId);
                if (currentAlbum != null)
                {
                    if (currentAlbum.Tracks != null)
                    {
                        string strAudioHomeDirectory = CAlbum.GetAudioHomeDirectory(this.m_environment);
                        foreach (BSE.Platten.BO.CTrack track in currentAlbum.Tracks)
                        {
                            if (string.IsNullOrEmpty(track.FileFullName) == false)
                            {
                                track.ThumbNail = currentAlbum.Thumbnail;
                                if (string.IsNullOrEmpty(track.FileName) == false)
                                {
                                    track.FileFullName = strAudioHomeDirectory + track.FileName;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return currentAlbum;
        }

        private ToolStripMenuItem[] GetToolStripMenuItemsLieder()
        {
            ToolStripMenuItem[] mnuLieder = null;
            if (this.m_currentAlbum.Tracks != null)
            {
                System.Collections.ArrayList aLieder
                    = new System.Collections.ArrayList(this.m_currentAlbum.Tracks.Length);
                foreach (CTrack track in this.m_currentAlbum.Tracks)
                {
                    ToolStripMenuItem mnuLied = new ToolStripMenuItem();
                    mnuLied.Image = this.m_imgSong;
                    if (track.Duration.ToString("T") != "00:00:00")
                    {
                        mnuLied.Text = string.Format(
                            CultureInfo.CurrentUICulture,
                            "{0} {1} ({2})",
                            track.TrackNumber.ToString("00",CultureInfo.CurrentUICulture),
                            track.Title.Replace("&", "&&"),
                            track.Duration.ToString("T",CultureInfo.CurrentUICulture));
                    }
                    else
                    {
                        mnuLied.Text = string.Format(
                            CultureInfo.CurrentUICulture,
                            "{0} {1}",
                            track.TrackNumber.ToString("00",CultureInfo.CurrentUICulture),
                            track.Title.Replace("&", "&&"));
                    }
                    if (String.IsNullOrEmpty(track.FileFullName) == true)
                    {
                        mnuLied.Enabled = false;
                    }
                    else
                    {
                        mnuLied.Tag = track;
                        mnuLied.Click += new EventHandler(PlaySongClick);
                    }
                    aLieder.Add(mnuLied);
                }
                if (aLieder.Count > 0)
                {
                    mnuLieder = new ToolStripMenuItem[aLieder.Count];
                    aLieder.CopyTo(mnuLieder);
                }
            }
            return mnuLieder;
        }

        private void StartRefreshControlsThread()
        {
            this.m_threadControlRefresh = null;
            this.m_threadControlRefresh = new System.Threading.Thread(
                new System.Threading.ThreadStart(this.InvokeRefreshControlsThread));
            this.m_threadControlRefresh.Start();
        }

        private void InvokeRefreshControlsThread()
        {
            System.Threading.Thread.Sleep(100);
            this.Invoke(new DelegateRefreshControls(this.RefreshControls));
            this.m_threadControlRefresh.Abort();
            this.m_threadControlRefresh.Join();
        }

        private void RefreshControls()
        {
            CTunesBusinessObject tunesBusinessObject = new CTunesBusinessObject(this.ConnectionString);
            try
            {
                //Lade Covers
                GetCovers();
                
                //l�dt Alben und Genres in den Tree
                CInterpretData[] interpretsAndAlbums = tunesBusinessObject.GetInterpretsAndAlbums();
                this.m_treeInterpretenTitel.SetInterpretsAndAlbums(interpretsAndAlbums);

                //l�dt den TreeviewGenreInterpretsAndTitles
                CGenreData[] genreWithAlbums = tunesBusinessObject.GetGenresWithAlbums();
                this.m_treeInterpretenTitel.SetGenresWithAlbums(genreWithAlbums);

                //l�dt den TreeviewYearInterpretsAndTitles
                CYearData[] yearsWithAlbums = tunesBusinessObject.GetYearsWithAlbums();
                this.m_treeInterpretenTitel.SetYearsWithAlbums(yearsWithAlbums);

                //l�dt die Benutzerhistory
                SortableCollection<CTrack> trackCollection = tunesBusinessObject.GetHistoryTrackCollection(this.m_environment.UserName);
                this.m_history.UpdateHistory(trackCollection);
                
                //Lied Favorites
                CFavorite[] singleFavorites
                    = tunesBusinessObject.GetFavoritesByFavoritId(10, (int)EPlayerApp.Lied, this.m_environment.UserName);
                this.m_treeFavorites.SetFavorites(singleFavorites, ListMode.Singlecharts);

                //CD Favorites
                CFavorite[] albumFavorites
                    = tunesBusinessObject.GetFavoritesByFavoritId(10, (int)EPlayerApp.CD, this.m_environment.UserName);
                this.m_treeFavorites.SetFavorites(albumFavorites, ListMode.Albumcharts);

                //Playlisten
                CPlaylist[] playLists = tunesBusinessObject.GetPlaylistsByUserName(this.m_environment.UserName);
                this.m_treeFavorites.SetPlayLists(playLists);

                //Filter
                BSE.Platten.Tunes.Filters.FilterMain filter
                    = new BSE.Platten.Tunes.Filters.FilterMain();
                BSE.Platten.Tunes.Filters.FilterConfiguration filterConfiguration
                    = filter.GetFilterConfiguration(this.m_environment);
                this.m_mnuFilter_Properties.Text = filterConfiguration.FilterName;
                this.TrackCollectionByFilterSettings = filter.GetTracksByFilterSettings(this.m_environment, (FilterSettings)filterConfiguration);
                if (this.TrackCollectionByFilterSettings.Count > 0)
                {
                    int iIndex = this.TrackCollectionByFilterSettings.GetRandomIndex();
                    CTrack currentTrack = this.TrackCollectionByFilterSettings[iIndex] as CTrack;
                    if (currentTrack != null)
                    {
                        int iStartTitelId = currentTrack.TitelId;
                        GetSelectedTitle(iStartTitelId, true);
                    }
                }

                this.m_search.Environment = this.m_environment;
                this.m_playList.Environment = this.m_environment;
                this.m_history.Environment = this.m_environment;
                this.m_clipBoard.Environment = this.m_environment;
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private CTunesSettingsData LoadSettings()
        {
            CTunesSettingsData tunesSettingsData = new CTunesSettingsData();
            //-------------------------------------------------------------------------------
            // Default Values
            //-------------------------------------------------------------------------------
            tunesSettingsData.WidthPnlLeft = this.m_pnlLeft.Width;
            tunesSettingsData.PanelClipBoardExpand = true;
            tunesSettingsData.PanelClipBoardVisible = true;
            tunesSettingsData.PanelClipBoardBounds = this.m_pnlRight.ClientRectangle;
            tunesSettingsData.PanelCoverExpand = true;
            tunesSettingsData.PanelCoverBounds = this.m_pnlCovers.ClientRectangle;
            tunesSettingsData.PanelMyListsExpand = true;
            tunesSettingsData.PanelMyListsBounds = this.m_pnlMyLists.ClientRectangle;
            tunesSettingsData.VisiblePnlPlayList = true;
            tunesSettingsData.VisiblePnlSearch = true;
            tunesSettingsData = tunesSettingsData.LoadSettings(this, this.m_settings, tunesSettingsData) as CTunesSettingsData;
            if (tunesSettingsData != null)
            {
                //-------------------------------------------------------------------------------
                // Background Image des Contents
                //-------------------------------------------------------------------------------
                this.ContentPanel.BackgroundImage = tunesSettingsData.BackgroundImage;
                if (this.ContentPanel.BackgroundImage != null)
                {
                    this.ContentPanel.BackgroundImageLayout = ImageLayout.Tile;
                }
                //-------------------------------------------------------------------------------
                // Breite des linken Panels
                //-------------------------------------------------------------------------------
                if (tunesSettingsData.WidthPnlLeft > 0)
                {
                    this.m_pnlLeft.Width = tunesSettingsData.WidthPnlLeft;
                }
                //-------------------------------------------------------------------------------
                // Breite des rechten Panels
                //-------------------------------------------------------------------------------
                bool bPanelClipBoardExpand = tunesSettingsData.PanelClipBoardExpand;
                this.m_pnlRight.Visible = tunesSettingsData.PanelClipBoardVisible;
                if (bPanelClipBoardExpand == false)
                {
                    this.m_pnlRight.Width = tunesSettingsData.PanelClipBoardBounds.Width;
                    this.m_pnlRight.Expand = bPanelClipBoardExpand;
                }
                else
                {
                    this.m_pnlRight.Width = tunesSettingsData.PanelClipBoardBounds.Width;
                }
                
                bool bPanelCoverExpand = tunesSettingsData.PanelCoverExpand;
                if (bPanelCoverExpand == false)
                {
                    this.m_pnlCovers.Height = tunesSettingsData.PanelCoverBounds.Height;
                    this.m_pnlCovers.Expand = bPanelCoverExpand;
                }
                else
                {
                    this.m_pnlCovers.Height = tunesSettingsData.PanelCoverBounds.Height;
                }
                //-------------------------------------------------------------------------------
                // H�he des MyLists Panels
                //-------------------------------------------------------------------------------
                bool bPanelMyListsExpand = tunesSettingsData.PanelMyListsExpand;
                if (bPanelMyListsExpand == false)
                {
                    this.m_pnlMyLists.Height = tunesSettingsData.PanelMyListsBounds.Height;
                    this.m_pnlMyLists.Expand = bPanelMyListsExpand;
                }
                else
                {
                    this.m_pnlMyLists.Height = tunesSettingsData.PanelMyListsBounds.Height;
                }
                //-------------------------------------------------------------------------------
                // Visibility des PlayList Panels
                //-------------------------------------------------------------------------------
                if (tunesSettingsData.VisiblePnlPlayList == false)
                {
                    this.m_plstMain.Controls.Remove(this.m_pnlPlayList);
                }
                //-------------------------------------------------------------------------------
                // Visibility des Search Panels
                //-------------------------------------------------------------------------------
                if (tunesSettingsData.VisiblePnlSearch == false)
                {
                    this.m_plstMain.Controls.Remove(this.m_pnlSearch);
                }
            }
            
            return tunesSettingsData;
        }

        private void SaveSettings()
        {
            CTunesSettingsData tunesSettingsData = new CTunesSettingsData();
            tunesSettingsData.BackgroundImage = this.ContentPanel.BackgroundImage;
            if ((this.WindowState == FormWindowState.Normal) ||
                (this.WindowState == FormWindowState.Maximized))
            {
                tunesSettingsData.WidthPnlLeft = this.m_pnlLeft.Width;

                tunesSettingsData.PanelClipBoardVisible = this.m_pnlRight.Visible;
                bool bPanelClipBoardExpand = this.m_pnlRight.Expand;
                tunesSettingsData.PanelClipBoardExpand = bPanelClipBoardExpand;
                if (bPanelClipBoardExpand == true)
                {
                    tunesSettingsData.PanelClipBoardBounds = this.m_pnlRight.ClientRectangle;
                }
                else
                {
                    tunesSettingsData.PanelClipBoardBounds = this.m_pnlRight.RestoreBounds;
                }
                
                bool bPanelCoverExpand = this.m_pnlCovers.Expand;
                tunesSettingsData.PanelCoverExpand = bPanelCoverExpand;
                if (bPanelCoverExpand == true)
                {
                    tunesSettingsData.PanelCoverBounds = this.m_pnlCovers.ClientRectangle;
                }
                else
                {
                    tunesSettingsData.PanelCoverBounds = this.m_pnlCovers.RestoreBounds;
                }

                bool bPanelMyListsExpand = this.m_pnlMyLists.Expand;
                tunesSettingsData.PanelMyListsExpand = bPanelMyListsExpand;
                if (bPanelMyListsExpand == true)
                {
                    tunesSettingsData.PanelMyListsBounds = this.m_pnlMyLists.ClientRectangle;
                }
                else
                {
                    tunesSettingsData.PanelMyListsBounds = this.m_pnlMyLists.RestoreBounds;
                }
            }
            if (this.m_pnlPlayList.Parent != null)
            {
                tunesSettingsData.VisiblePnlPlayList = true;
            }
            if (this.m_pnlSearch.Parent != null)
            {
                tunesSettingsData.VisiblePnlSearch = true;
            }
            tunesSettingsData.SaveSettings(this, this.m_settings, tunesSettingsData);
        }

        #endregion

        private void m_ssMain_RemovableDriveChanges(object sender, BSE.RemovableDrives.DriveChangeEventArgs e)
        {

        }

        private void m_ssMain_RemovableDriveRemoved(object sender, BSE.RemovableDrives.DriveChangeEventArgs e)
        {

        }

        
    }

    public class CTunesSettingsData : BaseFormSettingsData
    {
        #region FieldsPrivate
        private bool m_bPanelClipBoardExpand;
        private bool m_bPanelClipBoardVisible;
        private Rectangle m_PanelClipBoardBounds;
        private int m_iWidthPnlLeft;
        private bool m_bPanelCoverExpand;
        private Rectangle m_PanelCoverBounds;
        private bool m_bPanelMyListsExpand;
        private Rectangle m_PanelMyListsBounds;
        private bool m_bVisiblePnlPlayList;
        private bool m_bVisiblePnlSearch;
        #endregion

        #region Properties
        /// <summary>
        /// Breite des linken Panels
        /// </summary>
        public int WidthPnlLeft
        {
            get { return this.m_iWidthPnlLeft; }
            set { this.m_iWidthPnlLeft = value; }
        }
        /// <summary>
        /// Gets or sets a value indicating whether the Panel ClipBoard is expanded.
        /// </summary>
        public bool PanelClipBoardExpand
        {
            get { return this.m_bPanelClipBoardExpand; }
            set { this.m_bPanelClipBoardExpand = value; }
        }
        /// <summary>
        /// Gets or sets a value indicating whether the Panel ClipBoard is visible.
        /// </summary>
        public bool PanelClipBoardVisible
        {
            get { return this.m_bPanelClipBoardVisible; }
            set { this.m_bPanelClipBoardVisible = value; }
        }
        /// <summary>
        /// Gets or sets the size and location of the Panel ClipBoard.
        /// </summary>
        public Rectangle PanelClipBoardBounds
        {
            get { return this.m_PanelClipBoardBounds; }
            set { this.m_PanelClipBoardBounds = value; }
        }
        /// <summary>
        /// Gets or sets a value indicating whether the Panel Covers is expanded.
        /// </summary>
        public bool PanelCoverExpand
        {
            get { return this.m_bPanelCoverExpand; }
            set { this.m_bPanelCoverExpand = value; }
        }
        /// <summary>
        /// Gets or sets the size and location of the Panel Covers.
        /// </summary>
        public Rectangle PanelCoverBounds
        {
            get { return this.m_PanelCoverBounds; }
            set { this.m_PanelCoverBounds = value; }
        }
        /// <summary>
        /// Gets or sets a value indicating whether the Panel MyLists is expanded.
        /// </summary>
        public bool PanelMyListsExpand
        {
            get { return this.m_bPanelMyListsExpand; }
            set { this.m_bPanelMyListsExpand = value; }
        }
        /// <summary>
        /// Gets or sets the size and location of the Panel MyLists.
        /// </summary>
        public Rectangle PanelMyListsBounds
        {
            get { return this.m_PanelMyListsBounds; }
            set { this.m_PanelMyListsBounds = value; }
        }
        /// <summary>
        /// Visibility des PlayList Panels
        /// </summary>
        public bool VisiblePnlPlayList
        {
            get { return this.m_bVisiblePnlPlayList; }
            set { this.m_bVisiblePnlPlayList = value; }
        }
        /// <summary>
        /// Visibility des Search Panels
        /// </summary>
        public bool VisiblePnlSearch
        {
            get { return this.m_bVisiblePnlSearch; }
            set { this.m_bVisiblePnlSearch = value; }
        }
        #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