using System;
using System.Drawing;
using System.Runtime.InteropServices;

namespace CM2
{
	/// <summary>
	/// For converting colors of Borland notation.
	/// </summary>
	[ComVisible(false)]
	public class BorlandColorConverter
	{
		#region Colors
		public static Color clScrollBar					{ get{return SystemColors.ScrollBar;} }
		public static Color clBackground				{ get{return SystemColors.Desktop;} }
		public static Color clActiveCaption				{ get{return SystemColors.ActiveCaption;} }
		public static Color clInactiveCaption			{ get{return SystemColors.InactiveCaption;} }
		public static Color clMenu						{ get{return SystemColors.Menu;} }
		public static Color clWindow					{ get{return SystemColors.Window;} }
		public static Color clWindowFrame				{ get{return SystemColors.WindowFrame;} }
		public static Color clMenuText					{ get{return SystemColors.MenuText;} }
		public static Color clWindowText				{ get{return SystemColors.WindowText;} }
		public static Color clCaptionText				{ get{return SystemColors.ActiveCaptionText;} }
		public static Color clActiveBorder				{ get{return SystemColors.ActiveBorder;} }
		public static Color clInactiveBorder			{ get{return SystemColors.InactiveBorder;} }
		public static Color clAppWorkSpace				{ get{return SystemColors.AppWorkspace;} }
		public static Color clHighlight					{ get{return SystemColors.Highlight;} }
		public static Color clHighlightText				{ get{return SystemColors.HighlightText;} }
		public static Color clBtnFace					{ get{return SystemColors.Control;} }
		public static Color clBtnShadow					{ get{return SystemColors.ControlDark;} }
		public static Color clGrayText					{ get{return SystemColors.GrayText;} }
		public static Color clBtnText					{ get{return SystemColors.ControlText;} }
		public static Color clInactiveCaptionText		{ get{return SystemColors.InactiveCaptionText;} }
		public static Color clBtnHighlight				{ get{return SystemColors.ControlLight;} }
		public static Color cl3DDkShadow				{ get{return SystemColors.ControlDarkDark;} }
		public static Color cl3DLight					{ get{return SystemColors.ControlLightLight;} }
		public static Color clInfoText					{ get{return SystemColors.InfoText;} }
		public static Color clInfoBk					{ get{return SystemColors.Info;} }
		public static Color clHotLight					{ get{return SystemColors.HotTrack;} }

		public static Color clBlack						{ get{return ColorTranslator.FromWin32(0x00000000);} }
		public static Color clMaroon					{ get{return ColorTranslator.FromWin32(0x00000080);} }
		public static Color clGreen						{ get{return ColorTranslator.FromWin32(0x00008000);} }
		public static Color clOlive						{ get{return ColorTranslator.FromWin32(0x00008080);} }
		public static Color clNavy						{ get{return ColorTranslator.FromWin32(0x00800000);} }
		public static Color clPurple					{ get{return ColorTranslator.FromWin32(0x00800080);} }
		public static Color clTeal						{ get{return ColorTranslator.FromWin32(0x00808000);} }
		public static Color clGray						{ get{return ColorTranslator.FromWin32(0x00808080);} }
		public static Color clSilver					{ get{return ColorTranslator.FromWin32(0x00c0c0c0);} }
		public static Color clRed						{ get{return ColorTranslator.FromWin32(0x000000ff);} }
		public static Color clLime						{ get{return ColorTranslator.FromWin32(0x0000ff00);} }
		public static Color clYellow					{ get{return ColorTranslator.FromWin32(0x0000ffff);} }
		public static Color clBlue						{ get{return ColorTranslator.FromWin32(0x00ff0000);} }
		public static Color clFuchsia					{ get{return ColorTranslator.FromWin32(0x00ff00ff);} }
		public static Color clAqua						{ get{return ColorTranslator.FromWin32(0x00ffff00);} }
		public static Color clLtGray					{ get{return ColorTranslator.FromWin32(0x00c0c0c0);} }
		public static Color clDkGray					{ get{return ColorTranslator.FromWin32(0x00808080);} }
		public static Color clWhite						{ get{return ColorTranslator.FromWin32(0x00ffffff);} }
		public static Color clMoneyGreen				{ get{return ColorTranslator.FromWin32(0x00c0dcc0);} }
		public static Color clSkyBlue					{ get{return ColorTranslator.FromWin32(0x00f0caa6);} }
		public static Color clCream						{ get{return ColorTranslator.FromWin32(0x00f0fbff);} }
		public static Color clMedGray					{ get{return ColorTranslator.FromWin32(0x00a4a0a0);} }
		#endregion Colors

		public static Color StringToColor(string color)
		{
			if(color.StartsWith("$"))
			{
				return ColorTranslator.FromWin32(Convert.ToInt32(color.Substring(1), 16));
			}
			else if(color.ToLower().StartsWith("cl"))
			{
				switch(color.ToLower())
				{
					case "clblack":
						return clBlack;
					case "clmaroon":
						return clMaroon;
					case "clgreen":
						return clGreen;
					case "clolive":
						return clOlive;
					case "clnavy":
						return clNavy;
					case "clpurple":
						return clPurple;
					case "clteal":
						return clTeal;
					case "clgray":
						return clGray;
					case "clsilver":
						return clSilver;
					case "clred":
						return clRed;
					case "cllime":
						return clLime;
					case "clyellow":
						return clYellow;
					case "clblue":
						return clBlue;
					case "clfuchsia":
						return clFuchsia;
					case "claqua":
						return clAqua;
					case "clltgray":
						return clLtGray;
					case "cldkgray":
						return clDkGray;
					case "clwhite":
						return clWhite;
					case "clmoneygreen":
						return clMoneyGreen;
					case "clskyblue":
						return clSkyBlue;
					case "clcream":
						return clCream;
					case "clmedgray":
						return clMedGray;


					case "clscrollbar":
						return clScrollBar;
					case "clbackground":
						return clBackground;
					case "clactivecaption":
						return clActiveCaption;
					case "clinactivecaption":
						return clInactiveCaption;
					case "clmenu":
						return clMenu;
					case "clwindow":
						return clWindow;
					case "clwindowframe":
						return clWindowFrame;
					case "clmenutext":
						return clMenuText;
					case "clwindowtext":
						return clWindowText;
					case "clcaptiontext":
						return clCaptionText;
					case "clactiveborder":
						return clActiveBorder;
					case "clinactiveborder":
						return clInactiveBorder;
					case "clappworkspace":
						return clAppWorkSpace;
					case "clhighlight":
						return clHighlight;
					case "clhighlighttext":
						return clHighlightText;
					case "clbtnface":
						return clBtnFace;
					case "clbtnshadow":
						return clBtnShadow;
					case "clgraytext":
						return clGrayText;
					case "clbtntext":
						return clBtnText;
					case "clinactivecaptiontext":
						return clInactiveCaptionText;
					case "clbtnhighlight":
						return clBtnHighlight;
					case "cl3ddkshadow":
						return cl3DDkShadow;
					case "cl3dlight":
						return cl3DLight;
					case "clinfotext":
						return clInfoText;
					case "clinfobk":
						return clInfoBk;
					case "clhotlight":
						return clHotLight;
				}
			}

			return Color.Empty;
		}
	}
}
