function MyApplication3() { }

MyApplication3.prototype = {

    Initialize: function(plugIn, userContext, rootElement)
    {
        // Hook up event handlers
        rootElement.AddEventListener("MouseEnter", 
                Silverlight.CreateDelegate(this, this.MyApplication3_MouseEnter));
        rootElement.AddEventListener("MouseLeave", 
                Silverlight.CreateDelegate(this, this.MyApplication3_MouseLeave));
        rootElement.AddEventListener("MouseLeftButtonDown", 
                Silverlight.CreateDelegate(this, this.MyApplication3_MouseLeftButtonDown));
        rootElement.AddEventListener("MouseLeftButtonUp", 
                Silverlight.CreateDelegate(this, this.MyApplication3_MouseLeftButtonUp));
        rootElement.AddEventListener("MouseMove", 
                Silverlight.CreateDelegate(this, this.MyApplication3_MouseMove));
    },
    
    MyApplication3_MouseEnter: function(sender, eventArgs)
    {
        // Display the mouse event data
        this.PrintMouseEventArgs("MouseEnter", sender, eventArgs);
    },
    
    MyApplication3_MouseLeave: function(sender, eventArgs)
    {
        // Display the mouse event data
        this.PrintMouseEventArgs("MouseLeave", sender, eventArgs);
    },
    
    MyApplication3_MouseLeftButtonDown: function(sender, eventArgs)
    {
        // Display the mouse event data
        this.PrintMouseEventArgs("MouseLeftButtonDown", sender, eventArgs);
    },
    
    MyApplication3_MouseLeftButtonUp: function(sender, eventArgs)
    {
        // Display the mouse event data
        this.PrintMouseEventArgs("MouseLeftButtonUp", sender, eventArgs);
    },
    
    MyApplication3_MouseMove: function(sender, eventArgs)
    {
        // Display the mouse event data
        this.PrintMouseEventArgs("MouseMove", sender, eventArgs);
    },
    
    PrintMouseEventArgs: function(eventName, sender, eventArgs)
    {
        sender.FindName("txtEventName").Text = eventName;
        
        if(eventName != "MouseLeave")
        {
            var position = eventArgs.GetPosition(sender);
            sender.FindName("txtCoordinates").Text = "X=" + position.X.toString() 
                    + ", Y=" + position.Y.toString();
            sender.FindName("txtModifiers").Text = "Shift: " + eventArgs.Shift.toString() 
                    + ", Ctrl: " + eventArgs.Ctrl.toString();
        }
        else
        {
            sender.FindName("txtCoordinates").Text = "";
            sender.FindName("txtModifiers").Text = "";
        }
    }
}