1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
public class MyElement
{
public WebView contenu = new WebView();
public MyElement(MyCategorie cat)
{
categorie = cat.nom;
// pour le contenu
this.contenu.HorizontalAlignment = HorizontalAlignment.Left;
this.contenu.Width = 760;
this.contenu.Margin = new Thickness(0, 5, 0, 0);
this.contenu.ScriptNotify += contenu_ScriptNotify;
}
public void ajouterContenu(string variable)
{
// Définition du style et ajout du script pour connaitre la hauteur de la page
string debutHtml = "<html><body style='background-color:#000000;color:#FFFFFF;height:100%;font-family:Segoe UI Symbol;text-align:justify;margin-left:20;margin-right:20;margin-top:0;margin-bottom:0;padding:0;'>";
string scriptHtml = "<script type='text/javascript'>function getDocHeight() {var D = document;return Math.max(Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),Math.max(D.body.clientHeight, D.documentElement.clientHeight));}</script>";
string alerteHtml = "<script type='text/javascript'>window.external.notify(getDocHeight());</script>";
string finHtml = "</body></html>";
// Mise à jour de la variable
variable = debutHtml + scriptHtml + variable + alerteHtml + finHtml;
this.contenu.NavigateToString(variable);
}
private void contenu_ScriptNotify(object sender, NotifyEventArgs e)
{
//this.contenu.Height = Convert.ToInt32(e.Value);
this.contenu.Height = 50;
}
} |
Partager