using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Telerik.QuickStart.WinControls
{
	public partial class RadCustomPanel : Telerik.WinControls.UI.RadPanel
	{
		private string stringToDraw = String.Empty;

		[Category("Appearance")]
		[DefaultValue("")]
		[Browsable(true)]
		[Description("Gets or sets the string which will be drawn")]
		public string StringToDraw
		{
			get
			{
				return this.stringToDraw;
			}
			set
			{
				if (this.stringToDraw != value)
				{
					this.stringToDraw = value;
					this.Invalidate();
				}
			}
		}

		private Color borderColor = Color.FromArgb(210, 210, 210);
		[Category("Appearance")]
		[DefaultValue(typeof(Color), "Color.Empty")]
		[Browsable(true)]
		[Description("Gets or sets the border color")]
		public Color BorderColor
		{
			get
			{
				return this.borderColor;
			}
			set
			{
				this.borderColor = value;
				this.Invalidate();
			}
		}

		public RadCustomPanel()
		{
			this.ThemeName = "Examples";
			this.ForeColor = Color.FromArgb(200, 111, 61);
		}

		private Rectangle lineBounds = Rectangle.Empty;

		public Rectangle LineBounds
		{
			get
			{
				if (this.lineBounds == Rectangle.Empty)
				{
					lineBounds = new Rectangle(10, 30, this.Width - 10, 30);
				}

				return this.lineBounds;
			}
			set
			{
				this.lineBounds = value;
			}
		}

		protected override void OnPaint(PaintEventArgs e)
		{
			using (SolidBrush brush = new SolidBrush(this.ForeColor))
			{
				e.Graphics.DrawString(stringToDraw, this.Font, brush,
					new Rectangle(10, 15, this.Width, 20));
			}

			using (Pen pen = new Pen(borderColor))
			{
				e.Graphics.DrawLine(pen, this.lineBounds.X, this.lineBounds.Y, this.lineBounds.Width, this.lineBounds.Height);
			}
			base.OnPaint(e);
		}
	}
}
