Je travaille sur une petite application en Mono. J'aimerais avoir une image sur un arrière-plan et chaque fois que la taille de la fenêtre change, l'image doit être redessinée. Mais lorsque j'ajoute une méthode pour les chutes d'application ExposeEvent ou ConfigureEvent. Que pourrait-il être? Voici mon codeL'application GTK # se bloque après l'ajout d'un EventHandler
using System;
using System.IO;
using Gtk;
public partial class AuthWind: Gtk.Window
{
FileStream bgstream;
public AuthWind() : base (Gtk.WindowType.Toplevel)
{
bgstream = File.Open ("noise-texture.png", System.IO.FileMode.Open);
Build();
HBox mainCont = new HBox (false, 0);
ConfigureEvent += DrawBG;
Gdk.Pixbuf bgbuf = new Gdk.Pixbuf(bgstream, this.Allocation.Width, this.Allocation.Height);
Gdk.Pixmap bgmap = null;
Gdk.Pixmap useless = null;
bgbuf.RenderPixmapAndMask (out bgmap, out useless, 0);
Style st = new Style();
st.SetBgPixmap (StateType.Normal, bgmap);
this.Style = st;
}
void DrawBG(object obj, EventArgs e)
{
Gdk.Pixbuf bgbuf = new Gdk.Pixbuf(bgstream, this.Allocation.Width, this.Allocation.Height);
Gdk.Pixmap bgmap = null;
Gdk.Pixmap useless = null;
bgbuf.RenderPixmapAndMask (out bgmap, out useless, 0);
Style st = new Style();
st.SetBgPixmap (StateType.Normal, bgmap);
this.Style = st;
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit();
a.RetVal = true;
}
}
Il peut sembler bizarre, mais maintenant l'application compile et s'exécute normalement, mais ConfigureEvent ne démarre pas la méthode DrawBG. –