using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls.UI;
using Telerik.WinControls;
using System.IO;
using System.Reflection;

namespace Telerik.QuickStart.WinControls
{
    public partial class CodeViewerForm : ShapedForm
    {
        //members
        private Image imageGrip;

        public CodeViewerForm()
        {
            InitializeComponent();
            this.Shape = new RoundRectShape( 7 );
            this.BorderWidth = 2;
            this.BackColor = Color.FromArgb( 19, 49, 52 );
            this.imageGrip = LoadImage( "Telerik.QuickStart.WinControls.Resources.Images.grip.bmp" );
        }

        //protected override void PaintFrame( Graphics g )
        //{
        //    base.PaintFrame( g );

        //    /*Rectangle rect = new Rectangle(4, this.Height - 20, this.Width - 8, 19);
        //    using (LinearGradientBrush brush = new LinearGradientBrush(rect, Color.White, Color.FromArgb(138, 199, 3), 90f))
        //    {
        //        g.FillRectangle(brush, rect);
        //        g.DrawLine(Pens.White, 4, this.Height - 20, this.Width - 8, this.Height - 20);
        //    }*/
        //    if (imageGrip != null)
        //    {
        //        g.DrawImage( imageGrip, this.Width - imageGrip.Width /*- 8*/, this.Height - imageGrip.Height /*- 8*/ );
        //    }
        //}

        protected override int GetHitTest( Point point )
        {
            Rectangle r = new Rectangle( this.Width - imageGrip.Width - 8, this.Height - imageGrip.Height - 8,
                imageGrip.Width, imageGrip.Height );

            if (r.Contains( point ))
                return 17;

            return base.GetHitTest( point );
        }

        private Image LoadImage( string name )
        {
            Stream stream = Assembly.GetAssembly( this.GetType() ).GetManifestResourceStream( name );
            if (stream == null)
            {
                throw new NullReferenceException( "Cannot find " + name );
            }
            return new Bitmap( stream );
        }
    }
}