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.Drawing;
using System.Drawing.Imaging;
using System.Data;
using System.Globalization;
using BSE.Platten.BO.Properties;

namespace BSE.Platten.BO
{
	/// <summary>
	/// Zusammendfassende Beschreibung f�r CCoverData.
	/// </summary>
	public class CCoverData
    {

        #region FieldsPrivate

        private string m_strExtension;
		
		#endregion
		
		#region Properties

        public string Extension
		{
            get
            {
                if (this.m_strExtension.StartsWith(".", StringComparison.OrdinalIgnoreCase) == false)
                {
                    this.m_strExtension = "." + this.m_strExtension;
                }
                return this.m_strExtension;
            }
            set { this.m_strExtension = value; }
		}

		public string Interpret
		{
			get;
			set;
		}

		public string Titel
		{
			get;
			set;
		}

		public string ImageFileName
		{
			get;
			set;
		}

		public Image Image
		{
			get;
			set;
		}

        public Image ThumbNail
        {
            get;
            set;
        }
        
        public static Size ThumbnailSize
        {
            get { return new Size(100, 100); }
        }
		#endregion

		#region MethodsPublic

		public CCoverData()
		{
		}

        public static bool IsAllowedCoverExtension(string strExtension)
        {
            System.Collections.ArrayList allowedCoverExtensions
                = new System.Collections.ArrayList(5);
            allowedCoverExtensions.Add(".bmp");
            allowedCoverExtensions.Add(".jpg");
            allowedCoverExtensions.Add(".jpeg");
            allowedCoverExtensions.Add(".gif");
            allowedCoverExtensions.Add(".png");

            bool bIsAllowedCoverExtension = false;
            if (String.IsNullOrEmpty(strExtension) == false)
            {
                if (allowedCoverExtensions.Contains(strExtension.ToLower(CultureInfo.InvariantCulture)) == true)
                {
                    bIsAllowedCoverExtension = true;
                }
            }
            return bIsAllowedCoverExtension;
        }

        public static Image GetImageFromFile(System.IO.FileSystemInfo fileInfo)
        {
            if (fileInfo == null)
            {
                throw new ArgumentNullException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IDS_ArgumentException,
                    "fileInfo"));
            }
            
            System.Drawing.Image image = null;
            try
            {
                using (System.IO.FileStream filestream = new System.IO.FileStream(
                    fileInfo.FullName,
                    System.IO.FileMode.Open,
                    System.IO.FileAccess.Read))
                {
                    Byte[] bytesPicture = new byte[filestream.Length];
                    filestream.Read(bytesPicture, 0, (int)filestream.Length);
                    image = GetImageFromBytes((byte[])bytesPicture);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return image;
        }

        public static Image GetThumbNailFromImage(Image image, Size imageSize)
        {
            if (image == null)
            {
                throw new ArgumentNullException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IDS_ArgumentException,
                    "image"));
            }
            
            System.Drawing.Image thumbImage = null;
            try
            {
                thumbImage = image.GetThumbnailImage(imageSize.Width, imageSize.Height, null, IntPtr.Zero);

            }
            catch (Exception)
            {
                throw;
            }
            return thumbImage;
        }

        public static Byte[] GetBytesFromImage(Image image, ImageFormat imageFormat)
        {
            if (image == null)
            {
                throw new ArgumentNullException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IDS_ArgumentException,
                    typeof(Image).Name));
            }
            
            Byte[] bytesFromImage = null;
            try
            {
                if (imageFormat == null)
                {
                    imageFormat = GetImageFormat(image);
                }
                using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
                {
                    image.Save(memoryStream, imageFormat);
                    bytesFromImage = new Byte[memoryStream.Length];
                    memoryStream.Position = 0;
                    memoryStream.Read(bytesFromImage, 0, (int)memoryStream.Length);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return bytesFromImage;
        }

        public static System.Drawing.Image GetImageFromBytes(Byte[] bytesToImage)
        {
            System.Drawing.Image image = null;
            try
            {
                image = Bitmap.FromStream(new System.IO.MemoryStream((byte[])bytesToImage));
            }
            catch (Exception)
            {
                throw;
            }
            return image;
        }

        public static System.Drawing.Image GetImageFromDbReader(
            IDataRecord dataReader,
            string strColumnName)
        {
            if (dataReader == null)
            {
                throw new ArgumentNullException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IDS_ArgumentException,
                    "dataReader"));
            }
            
            System.Drawing.Image image = null;
            try
            {
                object objectBlob = (object)dataReader[strColumnName];
                if (objectBlob != DBNull.Value)
                {
                    byte[] bytes = objectBlob as byte[];
                    if ((bytes != null) && (bytes.Length > 0))
                    {
                        image = GetImageFromBytes(bytes);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return image;
        }

        public static ImageFormat GetImageFormat(Image image)
        {
            if (image == null)
            {
                throw new ArgumentNullException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IDS_ArgumentException,
                    typeof(Image).Name));
            }
            
            ImageFormat imageFormat = image.RawFormat;
            if (imageFormat.Equals(ImageFormat.Bmp) == true)
            {
                imageFormat = ImageFormat.Bmp;
            }
            if (imageFormat.Equals(ImageFormat.Jpeg) == true)
            {
                imageFormat = ImageFormat.Jpeg;
            }
            if (imageFormat.Equals(ImageFormat.Gif) == true)
            {
                imageFormat = ImageFormat.Gif;
            }
            if (imageFormat.Equals(ImageFormat.Png) == true)
            {
                imageFormat = ImageFormat.Png;
            }
            return imageFormat;
        }

        public static Size GetCalculatedImageSize(Image image)
        {
            if (image == null)
            {
                throw new ArgumentNullException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IDS_ArgumentException,
                    typeof(Image).Name));
            }
            
            Size imageSize = ThumbnailSize;
            try
            {
                Single sThumbHeight = (Single)CCoverData.ThumbnailSize.Height;
                Single sThumbWidth = (Single)sThumbHeight / image.Height * image.Width;
                if (sThumbWidth > (Single)CCoverData.ThumbnailSize.Height)
                {
                    sThumbWidth = (Single)CCoverData.ThumbnailSize.Height;
                    sThumbHeight = (Single)sThumbWidth / image.Width * image.Height;
                }

                imageSize = new Size(Convert.ToInt32(sThumbWidth), Convert.ToInt32(sThumbHeight));
            }
            catch (Exception)
            {
                throw;
            }
            return imageSize;
        }

		#endregion

		#region MethodsPrivate

		#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 | Mobile
Web02 | 2.8.140827.1 | Last Updated 24 Apr 2010
Article Copyright 2009 by Uwe Eichkorn
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid