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

namespace VisimBoxControl
{
    public partial class VisimBoxControl : UserControl, IRenderWindow
    {
        IRenderContext renderc;
        Control NativeWin;

        public VisimBoxControl()
        {
            InitializeComponent();
        }


        #region IRenderWindow Members

        public IRenderContext RenderContext
        {
            get { return renderc; }
        }

        #endregion

        #region IRenderWindow Members


        public void AttachContext(IRenderContext rc, Control nativewin)
        {
            renderc = rc;
            NativeWin = nativewin;

            NativeWin.MouseDown += new MouseEventHandler(NativeWin_MouseDown);
            NativeWin.MouseUp += new MouseEventHandler(NativeWin_MouseUp);
            NativeWin.MouseMove += new MouseEventHandler(NativeWin_MouseMove);
            NativeWin.KeyDown += new KeyEventHandler(NativeWin_KeyDown);
            NativeWin.KeyPress += new KeyPressEventHandler(NativeWin_KeyPress);
            NativeWin.KeyUp += new KeyEventHandler(NativeWin_KeyUp);
            NativeWin.MouseWheel += new MouseEventHandler(NativeWin_MouseWheel);
            NativeWin.MouseClick += new MouseEventHandler(NativeWin_MouseClick);
            NativeWin.MouseDoubleClick += new MouseEventHandler(NativeWin_MouseDoubleClick);
            NativeWin.MouseHover += new EventHandler(NativeWin_MouseHover);
            //this.components.Add(nativewin);
        }

        void NativeWin_MouseHover(object sender, EventArgs e)
        {
            OnMouseHover(e);
        }

        void NativeWin_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            OnMouseDoubleClick(e);
        }

        void NativeWin_MouseClick(object sender, MouseEventArgs e)
        {
            OnMouseClick(e);
        }

        void NativeWin_MouseWheel(object sender, MouseEventArgs e)
        {
            OnMouseWheel(e);
        }

        void NativeWin_KeyUp(object sender, KeyEventArgs e)
        {
            OnKeyUp(e);
        }

        void NativeWin_KeyPress(object sender, KeyPressEventArgs e)
        {
            OnKeyPress(e);
        }

        void NativeWin_KeyDown(object sender, KeyEventArgs e)
        {
            OnKeyDown(e);
        }

        void NativeWin_MouseMove(object sender, MouseEventArgs e)
        {
            OnMouseMove(e);
        }

        void NativeWin_MouseUp(object sender, MouseEventArgs e)
        {
            OnMouseUp(e);
        }

        void NativeWin_MouseDown(object sender, MouseEventArgs e)
        {
            OnMouseDown(e);
        }

        #endregion
    }
}
