Archive for September, 2008
1
Sep
3
Splash screen in Gtk#
This sample shows how to create a splash screen using Monodelop and Gtk#. Create a new Window. Within its properties, unset the Decorator so that it won't have any title bar. Add a HBox or VBox inside the window with only one placeholder. Add a button inside and select Custom in the Button Type under the Button Properties. Add an image inside the button.
Source code that makes it work:
using System; using System.Threading; namespace sigaDesktopClient { public partial class MainWindow : Gtk.Window { public MainWindow() : base(Gtk.WindowType.Toplevel) { this.Build(); ThreadStart tStart = new ThreadStart(this.EndSplash); Thread t = new Thread(tStart); t.Start(); } public void EndSplash() { Thread.Sleep(2000); Gtk.Application.Invoke( delegate (object sender, EventArgs args) { StartApplication(); } ); } private void StartApplication() { // WRITE THE CODE TO OPEN THE MAIN GUI HERE this.Hide(); } protected virtual void OnClick (object sender, System.EventArgs e) { StartApplication(); } protected virtual void OnEntered (object sender, System.EventArgs e) { StartApplication(); } } }