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;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using BSE.Platten.BO;
using BSE.Platten.Common;
using System.Globalization;
using BSE.Platten.Tunes.Properties;

namespace BSE.Platten.Tunes.Filters
{
    public partial class FilterBase : UserControl, IFilterConfiguration
    {
        #region Events

        public event EventHandler<FilterCheckStateChangeEventArgs> FilterCheckStateChanged;
        public event EventHandler<FilterNotificationEventArgs> FilterAdded;

        #endregion

        private CheckBox m_checkBoxFilter;
        private string m_strFilterName;
        
        #region Properties

        public virtual string FilterName
        {
            get { return this.m_strFilterName; }
            set { this.m_strFilterName = value; }
        }

        public virtual FilterSettings.FilterMode FilterMode
        {
            get { return FilterSettings.FilterMode.None; }
        }

        #endregion

        #region MethodsPublic

        public FilterBase()
        {
            InitializeComponent();
            this.m_strFilterName = Resources.IDS_FilterNoActiceFilterText;
            this.m_lstvFilter.AlternatingBackColor = BSE.Platten.Common.BSEColors.AlternatingBackColor;
            this.m_checkBoxFilter = new CheckBox();
            this.m_checkBoxFilter.CheckAlign = ContentAlignment.TopLeft;
            this.m_checkBoxFilter.TextAlign = ContentAlignment.TopLeft;
            this.m_checkBoxFilter.AutoSize = true;

        }

        public virtual FilterConfiguration GetFilterConfiguration(BSE.Platten.BO.Environment environment)
        {
            FilterConfiguration filterConfiguration = new FilterConfiguration();
            filterConfiguration.UsedFilterMode = this.FilterMode;
            filterConfiguration.FilterName = this.FilterName;
            FilterSettings filterSettings = GetFilterSettings(environment);
            if (filterSettings != null)
            {
                filterConfiguration.IsUsed = filterSettings.IsUsed;
                filterConfiguration.Value = filterSettings.Value;
            }
            return filterConfiguration;
        }

        public virtual void SafeFilterConfiguration(BSE.Platten.BO.Environment environment, bool bUsedFilter)
        {
            if (environment == null)
            {
                throw new ArgumentNullException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IDS_ArgumentNullException, "environment"));
            }
            string strValue = string.Empty;
            foreach (ListViewItem listViewItem in this.m_lstvFilter.Items)
            {
                if (listViewItem.Checked)
                {
                    CFilter filter = (CFilter)listViewItem.Tag;
                    strValue = strValue + filter.Id + ",";
                }
            }
            if (String.IsNullOrEmpty(strValue) == false)
            {
                strValue = strValue.Remove(strValue.Length - 1, 1);
            }

            CTunesBusinessObject tunesBusinessObject = new CTunesBusinessObject(environment.GetConnectionString());
            try
            {
                FilterSettings filterSettings = new FilterSettings();
                filterSettings.UsedFilterMode = this.FilterMode;
                filterSettings.Value = strValue;
                filterSettings.IsUsed = bUsedFilter;
                filterSettings.Benutzer = environment.UserName;
                tunesBusinessObject.SaveFilterSettings(filterSettings);
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this,exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        public virtual void SetFilterValues(BSE.Platten.BO.Environment environment)
        {
            LoadFilterValues(environment);
        }
        
        #endregion

        #region MethodsProtected
        #endregion

        #region MethodsPrivate
        
        private void FilterLoad(object sender, EventArgs e)
        {
            Control parentControl = this.Parent;
            if (parentControl != null)
            {
                parentControl.Text = this.FilterName;
            }
        }
        
        private void FilterItemCheck(object sender, ItemCheckEventArgs e)
        {
            bool bCheckBoxState = false;
            if (e.CurrentValue == CheckState.Checked)
            {
                bCheckBoxState = false;
            }
            if (e.CurrentValue == CheckState.Unchecked)
            {
                bCheckBoxState = true;
            }
            CheckListViewStatus(bCheckBoxState);
        }

        private void FilterResize(object sender, EventArgs e)
        {
            if (this.m_lstvFilter.Columns.Count == 2)
            {
                BSE.Windows.Forms.ColumnHeader columnHeader1 = this.m_lstvFilter.Columns[0];
                BSE.Windows.Forms.ColumnHeader columnHeader2 = this.m_lstvFilter.Columns[1];
                columnHeader2.Width = this.Width - columnHeader1.Width - ( 2 * SystemInformation.Border3DSize.Width);
            }
        }

        private void LoadFilterValues(BSE.Platten.BO.Environment environment)
        {
            bool bUsedFilter = false;
            CTunesBusinessObject tunesBusinessObject = new CTunesBusinessObject(environment.GetConnectionString());
            try
            {
                CFilter[] filters = tunesBusinessObject.GetFilterByFilterMode(this.FilterMode);
                if (filters != null)
                {
                    FilterSettings filterSettings = GetFilterSettings(environment);
                    if (filterSettings != null)
                    {
                        bUsedFilter = filterSettings.IsUsed;
                    }
                    ArrayList aFilterOptions = GetFilterSettingsArrayList(filterSettings);
                    
                    if (filters.Length > 0)
                    {
                        this.m_checkBoxFilter.Tag = this.GetType();
                        this.m_checkBoxFilter.Checked = bUsedFilter;
                        this.m_checkBoxFilter.Text = this.FilterName;
                        if (this.FilterAdded != null)
                        {
                            this.FilterAdded(this, new FilterNotificationEventArgs(this.m_checkBoxFilter));
                        }
                        CheckListViewStatus(bUsedFilter);
                    }

                    foreach (CFilter filter in filters)
                    {
                        ListViewItem listViewItem = new ListViewItem();
                        listViewItem.Checked = false;
                        if (aFilterOptions.Contains(filter.Id))
                        {
                            listViewItem.Checked = true;
                            CheckListViewStatus(listViewItem.Checked);
                        }
                        listViewItem.Text = filter.Name;
                        listViewItem.SubItems.Add(filter.Number.ToString(CultureInfo.InvariantCulture));
                        listViewItem.Tag = filter;
                        this.m_lstvFilter.Items.Add(listViewItem);
                    }
                }
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this,exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private static ArrayList GetFilterSettingsArrayList(FilterSettings filterSettings)
        {
            ArrayList arrayList = new ArrayList();
            try
            {
                if (filterSettings != null)
                {
                    string strValue = filterSettings.Value;
                    if (String.IsNullOrEmpty(strValue) == false)
                    {
                        string[] strArray = strValue.Split(new Char[] { ',' });
                        foreach (string str in strArray)
                        {
                            arrayList.Add(int.Parse(str,CultureInfo.InvariantCulture));
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                IWin32Window owner = (IWin32Window)typeof(FilterBase);
                GlobalizedMessageBox.Show(owner, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return arrayList;
        }

        private FilterSettings GetFilterSettings(BSE.Platten.BO.Environment environment)
        {
            FilterSettings filterSettings = null;
            CTunesBusinessObject tunesBusinessObject = new CTunesBusinessObject(environment.GetConnectionString());
            try
            {
                filterSettings = tunesBusinessObject.GetFilterSettings(this.FilterMode, environment.UserName);
            }
            catch (Exception exception)
            {
                GlobalizedMessageBox.Show(this,exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return filterSettings;
        }
        
        private void CheckListViewStatus(bool bCheckBoxCheckState)
        {
            int iCountCheckedItems = 0;
            try
            {
                iCountCheckedItems = m_lstvFilter.CheckedIndices.Count;
            }
            catch (System.ArgumentException)
            {
                System.Diagnostics.Trace.WriteLine("Error");
            }
            if (iCountCheckedItems > 1)
            {
                foreach (ListViewItem listViewItem in this.m_lstvFilter.Items)
                {
                    if (listViewItem.Checked)
                    {
                        bCheckBoxCheckState = true;
                        break;
                    }
                }
            }
            if (FilterCheckStateChanged != null)
            {
                FilterCheckStateChanged(this, new FilterCheckStateChangeEventArgs(this.m_checkBoxFilter, bCheckBoxCheckState));
            }
        }
        #endregion

    }
}

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

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

License

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

Share

About the Author

Uwe Eichkorn

Switzerland Switzerland
No Biography provided

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