using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace DataBaseComparer
{
	/// <summary>
	/// Description résumée de GraphText.
	/// </summary>
	public class TextRelief : System.Windows.Forms.UserControl
	{
		/// <summary> 
		/// Variable nécessaire au concepteur.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private string _text = String.Empty;
		private System.Drawing.Font _textFont = new System.Drawing.Font("Palatino Linotype", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
		private System.Drawing.Color _mainColor = System.Drawing.Color.White;
		public static Color MenuDarkColor2 = Color.FromArgb(0, 89, 230);
		public static Color MenuLightColor2 = Color.FromArgb(120, 0, 109, 255);
		public static Color MenuDarkColor = Color.FromKnownColor(KnownColor.ActiveCaption);
		public const string StyleDefault = "BACK";
		public const string StyleOrange = "ORANGE";
		private string _style = StyleDefault;
		private Boolean _isBackGround = true;
		private System.Resources.ResourceManager resources;
		public static Color CheckBoxColor = Color.FromArgb(255, 192, 111);
		public static Color DarkCheckBoxColor = Color.FromArgb(254, 128, 62);
		public static Color SelectionColor = Color.FromArgb(255,238,194);

		#region Declarations et méthodes génériques
		public TextRelief(Boolean isBackGround)
		{
			_isBackGround = isBackGround;
			InitializeComponent();
			AfterInitializeComponent();
		}

		public TextRelief()
		{
			InitializeComponent();
			AfterInitializeComponent();
		}

		/// <summary> 
		/// Nettoyage des ressources utilisées.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#endregion

		#region Code généré par le Concepteur de composants
		/// <summary> 
		/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas 
		/// le contenu de cette méthode avec l'éditeur de code.
		/// </summary>
		private void InitializeComponent()
		{
			resources = new System.Resources.ResourceManager(typeof(TextRelief));
			// 
			// TextRelief
			// 
			//			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.Name = "TextRelief";

		}
		#endregion

		private void AfterInitializeComponent()
		{
			if (_isBackGround)
			{
				this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			}
			Paint+=new PaintEventHandler(GraphText_Paint);
		}

		#region Propriétés du texte
		public void SetBackGround(Boolean isBackGround)
		{
			_isBackGround = isBackGround;
			if (isBackGround)
			{
				this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			} 
			else 
			{
				this.BackgroundImage = null;
			}
		}

		public string Style
		{
			get
			{
				return _style;
			}
			set
			{
				_style = value;
			}
		}

		public string Texte
		{
			get
			{
				return _text;
			}
			set
			{
				_text = value;
			}
		}

		public System.Drawing.Font Fonte
		{
			get
			{
				return _textFont;
			}
			set
			{
				_textFont = value;
			}
		}

		public System.Drawing.Color MainColor
		{
			get
			{
				return _mainColor;
			}
			set
			{
				_mainColor = value;
			}
		}

		#endregion

		#region Méthode Paint
		private void GraphText_Paint(object sender, PaintEventArgs e)
		{
			Graphics gr=e.Graphics;
			int width = Width;
			int height = Height;

			// set the picture coordinates
			int x = 4;
			int y = 4;
			RectangleF rectF = new RectangleF(x, y, width - x, height - y);
			if (_style == StyleOrange) 
			{
				Rectangle rectT = new Rectangle(0, 0, Width, Height);
				// Create the hover brush
				//				Brush b = new LinearGradientBrush(rectT, CheckBoxColor, DarkCheckBoxColor,90f, false);
				Brush b = new LinearGradientBrush(rectT, SelectionColor, DarkCheckBoxColor,90f, false);
				// Fill the rectangle
				gr.FillRectangle(b, rectT);
				ControlPaint.DrawBorder3D(gr,rectT,Border3DStyle.RaisedInner);
				b.Dispose();
				System.Drawing.Brush myBrush = new SolidBrush(MenuDarkColor);
				gr.DrawString(_text, _textFont, myBrush, rectF);
				myBrush.Dispose();
			} 
			else 
			{
				System.Drawing.Brush myBrush = new SolidBrush(_mainColor);
				gr.DrawString(_text, _textFont, myBrush, rectF);
				myBrush.Dispose();
			}
		}
		#endregion
	}
}
