/// <summary> /// Build this form and run it /// </summary> /// <param name="appName"></param> /// <param name="appCopyright"></param> /// <param name="logo"></param> private static void ShowForm(string appName, string appCopyright, Image logo) { if (splashscreen != null) { return; } splashscreen = new DGUIGHFFormSplashScreen(appName, appCopyright, logo); Application.Run(splashscreen); }
/// <summary> /// Close the SplashScreen /// </summary> private static void CloseSplashScreen() { #if NETFRAMEWORK backgroundThread.Abort(); #endif backgroundThread = null; splashscreen = null; closeme = true; }
/// <summary> /// Attach activated event for first form, to close SplashScreen /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void FirstForm_Activated(object sender, EventArgs e) { //close the splash screen if one is active if (DGUIGHFFormSplashScreen.GetSplashScreen() != null) { DGUIGHFFormSplashScreen.CloseSplashScreen(); ((Form)sender).Activated -= new System.EventHandler(FirstForm_Activated); //activate the form ((Form)sender).Activate(); } }
/// <summary> /// Show the SplashScreen /// </summary> /// <param name="appName"></param> /// <param name="appCopyright"></param> /// <param name="logo"></param> private static void ShowSplashScreen(string appName, string appCopyright, Image logo) { if (splashscreen != null) { return; } backgroundThread = new Thread(() => DGUIGHFFormSplashScreen.ShowForm(appName, appCopyright, logo)); backgroundThread.IsBackground = true; #if NETFRAMEWORK backgroundThread.SetApartmentState(ApartmentState.STA); #endif backgroundThread.Start(); }
/// <summary> /// Display a SplashScreen /// </summary> /// <param name="firstForm"></param> /// <param name="appName"></param> /// <param name="appCopyright"></param> /// <param name="logo"></param> public static void DisplaySplashScreen(Form firstForm, string appName, string appCopyright, Image logo) { //view loading splash screen AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(SetSpashScreenStatus); DGUIGHFFormSplashScreen.ShowSplashScreen(appName, appCopyright, logo); Application.DoEvents(); AppDomain.CurrentDomain.AssemblyLoad -= SetSpashScreenStatus; DGUIGHFFormSplashScreen.SetStatus("Building UI and Opening DB Connections"); //show this screen at least 500ms Thread.Sleep(500); //attach the event to the first form displaied to close the splash screen firstForm.Activated += new System.EventHandler(FirstForm_Activated); }
/// <summary> /// Run the entry Form /// </summary> /// <param name="uighfApplication"></param> public static void Run(DGUIGHFApplication uighfApplication) { //attach the custom stackTracker if (uighfApplication.IsStackTracerEnabled) { Application.ThreadException += new ThreadExceptionEventHandler((sender, t) => ThreadException_Hanlder(sender, t, uighfApplication.StackTracerSenderFrom, uighfApplication.StackTracerSenderMail)); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler((sender, e) => CurrentDomainUnhandledException_Handler(sender, e, uighfApplication.StackTracerSenderFrom, uighfApplication.StackTracerSenderMail)); } Form form = (Form)Activator.CreateInstance(uighfApplication.m_entryFormType, uighfApplication.m_entryFormParameters); if (uighfApplication.m_displaySplashScreen) { DGUIGHFFormSplashScreen.DisplaySplashScreen(form, uighfApplication.AppProduct, uighfApplication.AppCopyright, uighfApplication.SplashScreenLogo); } Application.Run(form); }
/// <summary> /// Set SplashScreen Status /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void SetSpashScreenStatus(object sender, AssemblyLoadEventArgs e) { DGUIGHFFormSplashScreen.SetStatus(e.LoadedAssembly.GetName().Name); }