﻿if (!window.menus) menus = {};

menus.Page = function() 
{ 
}

menus.Page.prototype =
{
	//Gestion du préchargement
	onSourceDownloadProgressChanged : function(sender, eventArgs) 
	{
		//gestion du texte affiché
		sender.findName("percent_txt").Text =  "Loading: " + Math.round((eventArgs.progress * 1000)) / 10 + "%";
		//gestion de la barre de progression
		sender.findName("uxProgressBar").ScaleY = eventArgs.progress * 356;
	},
	
    	//gestion des erreurs
   	handleLoadError: function(sender, args)
   	 {
 		var errorDiv = document.getElementById("errorLocation");
        if (errorDiv != null)
		{
			var errorText = args.errorType + "- " + args.errorMessage;                    
         	if (args.ErrorType == "ParserError") 
			{
				errorText += "<br>File: " + args.xamlFile;
                errorText += ", line " + args.lineNumber;
                errorText += " character " + args.charPosition;
             }
             else if (args.ErrorType == "RuntimeError") 
			 {
                errorText += "<br>line " + args.lineNumber;
                errorText += " character " +  args.charPosition;
             }
            errorDiv.innerHTML = errorText;
		}
	 },

	//gestion du chargement
	handleLoad: function( control ) 
	{
		//on Stocke le control dans l'instance de la classe Page
		this.control = control;

        	//on récupère le Canvas principal
		this.rootElement = control.Content.findName('LayoutRoot');

	}

}

menus.Page.prototype.createRelegate = function (instance, method)
{
    var _params = [];
    
    for(var n = 0; n < arguments.length; ++n)
    {
        _params.push(arguments[n]);
    }
    
    return function()
    {
        _params.splice(0,2)
         _params.unshift(arguments[0],arguments[1]);
        return method.apply(instance,_params);
    }
        
}