Click here to Skip to main content
15,881,173 members
Articles / Desktop Programming / Windows Forms

BSEtunes

Rate me:
Please Sign up or sign in to vote.
4.67/5 (11 votes)
24 Apr 2010CPOL4 min read 64.4K   4.3K   58  
BSEtunes is a MySQL based, full manageable, networkable single or multiuser jukebox application
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using BSE.Platten.Common.Properties;

namespace BSE.Platten.Common
{
    public partial class FileConfigurationControl : BaseConfigurationControl
    {
        #region Konstanten

        public const string EachAlbumGetsDirectoryElement = "EachAlbumGetsDirectory";
        public const string TitleAsFileNameElement = "TitleAsFileName";

        #endregion
        
        #region Events

        public event EventHandler<CheckBoxChangeEventArgs> CheckBoxChanged;

        #endregion

        #region Properties

        public bool EnableEditSaveOptions
        {
            get { return this.Enabled; }
            set { this.Enabled = value; }
        }

        #endregion

        #region MethodsPublic

        public FileConfigurationControl()
        {
            InitializeComponent();
        }

        public override void SaveConfigurationValues(BSE.Configuration.Configuration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IDS_ArgumentNullException, "configuration"));
            }
            FileConfigurationData configurationObject = new FileConfigurationData();
            configurationObject.EachAlbumGetsDirectory = this.m_chkEachAlbumGetsDirectory.Checked;
            configurationObject.TitleAsFileName = this.m_chkTitleAsFileName.Checked;

            configuration.SetValue(
                OptionsConfiguration,
                typeof(FileConfigurationData).Name,
                configurationObject);
            OnConfigChanging(new System.EventArgs());
        }

        public override void LoadConfigurationValues(BSE.Configuration.Configuration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IDS_ArgumentNullException, "configuration"));
            }
            FileConfigurationData configurationObject =
                GetConfiguration(configuration) as FileConfigurationData;
            
            if (configurationObject != null)
            {
                this.m_chkEachAlbumGetsDirectory.Checked = configurationObject.EachAlbumGetsDirectory;
                this.m_chkTitleAsFileName.Checked = configurationObject.TitleAsFileName;
            }
        }

        public static IConfigurationData GetConfiguration(BSE.Configuration.Configuration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IDS_ArgumentNullException, "configuration"));
            }
            return configuration.GetValue(
                OptionsConfiguration,
                typeof(FileConfigurationData).Name,
                new FileConfigurationData()) as FileConfigurationData;
        }
        
        public void SetSaveCheckBox(CheckBox changedCheckBox)
        {
            if (changedCheckBox == null)
            {
                throw new ArgumentNullException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IDS_ArgumentNullException, "changedCheckBox"));
            }
            foreach (Control control in this.m_grpDirectoryInfo.Controls)
            {
                CheckBox checkBox = control as CheckBox;
                if (checkBox != null)
                {
                    if (checkBox.Name == changedCheckBox.Name)
                    {
                        checkBox.Checked = changedCheckBox.Checked;
                    }
                }
            }
        }

        #endregion

        #region MethodsProtected

        protected virtual void OnCheckBoxChanged(CheckBoxChangeEventArgs e)
        {
            if (CheckBoxChanged != null)
            {
                CheckBoxChanged(this, e);
            }
        }

        #endregion

        #region MethodsPrivate

        private void Checkbox_Click(object sender, EventArgs e)
        {
            CheckBox changedCheckBox = (CheckBox)sender;
            OnConfigChanging(new EventArgs());
            OnCheckBoxChanged(new CheckBoxChangeEventArgs(changedCheckBox));
        }

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


Written By
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions