Thanks to Rodrigo, Gonzalo, and Miguel's help, I got it to work...

I have attached SplashScreen.cs for peer review...

I also have a screenshot of the SplashScreen in action...

Here is my Main() logic:

                public static int Main (string[] args) {
                        string imageFilename = "SqlSharpForGtkSharpSplash.png";
                        Application.Init ();
                        SplashScreen splash = new SplashScreen (
                                SqlSharpGtk.ApplicationName,
                                imageFilename);
                        SqlSharpGtk sqlSharp = new SqlSharpGtk ();
                        sqlSharp.Show ();
                        splash.Destroy ();
                        Application.Run ();

                        return 0;
                }



-----Original Message-----
From: Rodrigo Moya [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 13, 2002 12:54 PM
To: Daniel Morgan
Cc: Gonzalo Paniagua Javier; Mono List
Subject: Re: [Mono-list] Mono SQL# For GTK# Splash Image


On Fri, 2002-12-13 at 18:22, Daniel Morgan wrote:
> Hi Gonzalo,
>
> Here's my image for SQL# For GTK#.
>
> I'm still working on the program that does the splashing...
> The image displays, but after my main window has already displayed.  Maybe
> displaying an image is an idle event?
>
a good approach might be:

* start the program an immediately create the splash screen, and install
an idle handler
* do all initialization and start GTK main loop
* when the idle callback is called, create the main window and destroy
the spash screen.

If that's too quick, and the splash screen is shown and destroyed too
quickly, you can use a timer instead of the idle handler.

cheers
--
Rodrigo Moya <[EMAIL PROTECTED]>
using System;
using Gtk;
using GtkSharp;

namespace Mono.GtkSharp.Goodies 
{
        public class SplashScreen 
        {
                Window window;
                VBox vbox;
                Gtk.Image image;
                
                public SplashScreen (string applicationName, string imageFilename) 
                {
                        window = new Window (applicationName);
                        window.DeleteEvent += new DeleteEventHandler (Window_Delete);
                        window.DefaultSize = new System.Drawing.Size (200, 200);

                        vbox = new VBox (false, 0);
                        window.Add (vbox);

                        try {
                                image = new Gtk.Image (imageFilename);
                        }
                        catch (Exception e) {
                                Console.WriteLine("Error: Image file not found.");
                        }
                        vbox.PackStart (image, false, false, 0);
                        window.ShowAll ();
                        while (Application.EventsPending ()) 
                                Application.RunIteration ();
                }

                public void Destroy () {
                        if (window != null) {
                                window.Destroy ();
                                window = null;
                        }
                }

                void Window_Delete (object o, DeleteEventArgs args) {
                        if (window != null) {
                                window.Destroy ();
                                window = null;
                        }
                }

        }
}

<<attachment: SqlSharpSplashscreenshot.png>>

Reply via email to