#region Copyright and GPL
/*************************************************************************
 * dataMagus - The open source database learning software
 * Copyright (C) 2007 by all authors
 * Authors: Monika Schwitter (monsy@gmx.ch)
 *          Jürg Zgraggen (j.zgraggen@ejaz.net)
 *          HSLU (Hochschule Luzern - Technik+Architektur)
 * 
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 * 
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *************************************************************************/
#endregion
using System;

namespace dataMagus.Forms
{
	/// <summary>
	/// This singelton class contains all global options in the application.
	/// </summary>
	internal sealed class ApplicationOptions
	{
		#region Members
		/// <summary>
		/// Singelton instance object.
		/// </summary>
		private static ApplicationOptions _instance = null;
		
        /// <summary>
        /// Lock object for thread safe access.
        /// </summary>
		private static readonly object _padlock = new object();
		
		/// <summary>
		/// Option for showing the relationship names.
		/// </summary>
		private bool _showRelationshipName = true;
		
		/// <summary>
		/// Option for showing the rolenames.
		/// </summary>
		private bool _showRolenames = true;
		
		/// <summary>
		/// Option for showing the cardinalities.
		/// </summary>
		private bool _showCardinalities = true;
        
		/// <summary>
		/// Option for forcing the control refresh on dragging.
		/// </summary>
		private bool _forceRefreshOnDrag = true;
        
		/// <summary>
		/// Option for adjusting the snap size.
		/// </summary>
		private ushort _snapSize = 10;
		#endregion
		
		#region Constructors / Destructors
		/// <summary>
		/// Default constructor.
		/// </summary>
		private ApplicationOptions()
		{
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Singelton instance object.
		/// </summary>
		public static ApplicationOptions Instance 
		{
			get
			{
				if (null == ApplicationOptions._instance)
				{
					lock (ApplicationOptions._padlock)
					{
						if (null == ApplicationOptions._instance)
						{
							ApplicationOptions._instance = new ApplicationOptions();
						}
					}
				}
				return ApplicationOptions._instance;
			}			
		}
		
		/// <summary>
		/// Option for showing the relationship names.
		/// </summary>
		public bool ShowRelationshipName 
		{
			get { return this._showRelationshipName; }
			set { this._showRelationshipName = value; }
		}
		
		/// <summary>
		/// Option for showing the rolenames.
		/// </summary>
		public bool ShowRolenames 
		{
			get { return this._showRolenames; }
			set { this._showRolenames = value; }
		}
		
		/// <summary>
		/// Option for showing the cardinalities.
		/// </summary>
		public bool ShowCardinalities 
		{
			get { return this._showCardinalities; }
			set { this._showCardinalities = value; }
		}
		
		/// <summary>
		/// Option for adjusting the snap size.
		/// </summary>
		public ushort SnapSize
		{
			get { return _snapSize; }
			set { _snapSize = value; }
		}

		/// <summary>
		/// Option for forcing the control refresh on dragging.
		/// </summary>
		public bool ForceRefreshOnDrag 
		{
			get { return this._forceRefreshOnDrag; }
			set { this._forceRefreshOnDrag = value; }
		}
		#endregion
	}
}
