using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace US.Browser.IE
{

    #region IHTMLOMWindowServices Interface

    [ComVisible(true), ComImport()]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    [Guid("3050f625-98b5-11cf-bb82-00aa00bdce0b")]
    public interface HTMLWindowEvents2
    {
        void moveTo([In] int x, [In] int y);
        void moveBy([In] int x, [In] int y);
        void resizeTo([In] int x, [In] int y);
        void resizeBy([In] int x, [In] int y);
    }

    #endregion

    public delegate void HTMLOMWindowServicesEventHandler(object sender, HTMLOMWindowServicesEventArgs e);
    public class HTMLOMWindowServicesEventArgs : System.EventArgs
    {
        public HTMLOMWindowServicesEventArgs() { }
        public void SetParameters(int _x, int _y)
        {
            this.X = _x;
            this.Y = _y;
        }
        public int X = 0;
        public int Y = 0;
    }



    public class WebIfaces : WebBrowser, HTMLWindowEvents2
    {
        public event HTMLOMWindowServicesEventHandler HTMLOMWindowServices_moveTo = null;
        public event HTMLOMWindowServicesEventHandler HTMLOMWindowServices_moveBy = null;
        public event HTMLOMWindowServicesEventHandler HTMLOMWindowServices_resizeTo = null;
        public event HTMLOMWindowServicesEventHandler HTMLOMWindowServices_resizeBy = null;
        private HTMLOMWindowServicesEventArgs HTMLOMWindowServicesEvent = new HTMLOMWindowServicesEventArgs();

        #region IHTMLOMWindowServices Members

        void HTMLWindowEvents2.moveTo(int x, int y)
        {
            if (HTMLOMWindowServices_moveTo != null)
            {
                HTMLOMWindowServicesEvent.SetParameters(x, y);
                HTMLOMWindowServices_moveTo(this, HTMLOMWindowServicesEvent);
            }
        }

        void HTMLWindowEvents2.moveBy(int x, int y)
        {
            if (HTMLOMWindowServices_moveBy != null)
            {
                HTMLOMWindowServicesEvent.SetParameters(x, y);
                HTMLOMWindowServices_moveBy(this, HTMLOMWindowServicesEvent);
            }
        }

        void HTMLWindowEvents2.resizeTo(int x, int y)
        {
            if (HTMLOMWindowServices_resizeTo != null)
            {
                HTMLOMWindowServicesEvent.SetParameters(x, y);
                HTMLOMWindowServices_resizeTo(this, HTMLOMWindowServicesEvent);
            }
        }

        void HTMLWindowEvents2.resizeBy(int x, int y)
        {
            if (HTMLOMWindowServices_resizeBy != null)
            {
                HTMLOMWindowServicesEvent.SetParameters(x, y);
                HTMLOMWindowServices_resizeBy(this, HTMLOMWindowServicesEvent);
            }
        }

        #endregion



    }
}
