public static void Show(ISplashForm DisplayForm) { //Singleton love baby if (!EnsureWorker() && worker.IsBusy) return; if (!(DisplayForm is Form)) throw new ArgumentException("DisplayForm must be a windows form", "DisplayForm"); displayForm = DisplayForm; ((Form)displayForm).Opacity = 0; fader.SynchronizingObject = displayForm; //Force the timer to run on the forms ui thread // Need to block the main thread until the worker // has created the window handle windowCreated = new ManualResetEvent(false); ((Form)displayForm).HandleCreated += SplashScreenController_HandleCreated; worker.RunWorkerAsync(displayForm); if (windowCreated.WaitOne(WAIT_TIME)) { ((Form)displayForm).HandleCreated -= SplashScreenController_HandleCreated; fader.Start(); } else { throw new ApplicationException("Did not create form handle within a reasonable time."); } }
public static void Show(ISplashForm DisplayForm) { //Singleton love baby if (!EnsureWorker() && worker.IsBusy) { return; } if (!(DisplayForm is Form)) { throw new ArgumentException("DisplayForm must be a windows form", "DisplayForm"); } displayForm = DisplayForm; ((Form)displayForm).Opacity = 0; fader.SynchronizingObject = displayForm; //Force the timer to run on the forms ui thread // Need to block the main thread until the worker // has created the window handle windowCreated = new ManualResetEvent(false); ((Form)displayForm).HandleCreated += SplashScreenController_HandleCreated; worker.RunWorkerAsync(displayForm); if (windowCreated.WaitOne(WAIT_TIME)) { ((Form)displayForm).HandleCreated -= SplashScreenController_HandleCreated; fader.Start(); } else { throw new ApplicationException("Did not create form handle within a reasonable time."); } }
private static void CreateInstance(Type FormType) { object obj = FormType.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null); m_SplashForm = obj as Form; m_SplashInterface = obj as ISplashForm; if (m_SplashForm == null) { throw (new Exception("Splash Screen must inherit from System.Windows.Forms.Form")); } if (m_SplashInterface == null) { throw (new Exception("must implement interface ISplashForm")); } if (!string.IsNullOrEmpty(m_TempStatus)) { m_SplashInterface.SetStatusInfo(m_TempStatus); } }
public static void Show(ISplashForm DisplayForm) { if (!EnsureWorker() && worker.IsBusy) { return; } if (!(DisplayForm is Form)) { throw new ArgumentException("Debe ser un windows form", "Display"); } displayForm = DisplayForm; windowCreated = new ManualResetEvent(false); ((Form)displayForm).HandleCreated += SplashScreenController_HandleCreated; worker.RunWorkerAsync(displayForm); if (windowCreated.WaitOne(WAIT_TIME)) { ((Form)displayForm).HandleCreated -= SplashScreenController_HandleCreated; } else { //throw new ApplicationException("Tiempo de espera agotado."); } }
/// <summary><para> /// This function initializes the give RenderForm instance, /// runs its main execution loop, and properly shuts it down. /// </para><para> /// It also properly disposes the Render Form and Splash Form when finished. /// </para></summary> /// <param name="args">The command line arguments from the application's main entry point.</param> /// <param name="mainForm">The main form of the application.</param> /// <param name="splash">The splash form displayed while the main form is initializing.</param> /// <returns>1 if a problem was encountered, 0 otherwise.</returns> public static int MainLoop(string[] args, RenderForm mainForm, ISplashForm splash) { if (mainForm == null) { return(1); } SetDefaultAppDomain(AppDomain.CurrentDomain); if (splash != null) { splash.Show(); splash.Update(); } using (mainForm) { if (!mainForm.Init(splash)) { if (splash != null) { splash.Close(); splash.Dispose(); } mainForm.Shutdown(true); return(1); } mainForm.IsRunning = true; bool keepRunning = true; keepRunning = mainForm.ProcessCommandLineArgs(args, keepRunning); mainForm.IsRunning = keepRunning; if (mainForm.IsRunning) { if (splash != null) { splash.Close(); splash.Dispose(); } mainForm.Show(); } while (mainForm.IsRunning) { Application.DoEvents(); mainForm.UpdateAndDraw(); } mainForm.Shutdown(false); } return(0); }
private static void CreateInstance(Type FormType) { object obj = FormType.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null); m_frmSplash = obj as frmSplash; m_pSplashInterface = obj as ISplashForm; if (m_frmSplash == null) { throw (new Exception("Splash Screen must inherit from System.Windows.Forms.Form")); } if (m_pSplashInterface == null) { throw (new Exception("must implement interface ISplashForm")); } }
private static void CreateInstance(Type FormType) { object obj = Activator.CreateInstance(FormType); m_SplashForm = obj as Form; m_SplashInterface = obj as ISplashForm; if (m_SplashForm == null) { throw new Exception("Splash Screen must inherit from System.Windows.Forms.Form"); } if (m_SplashInterface == null) { throw new Exception("must implement interface ISplashForm"); } if (!string.IsNullOrEmpty(m_TempStatus)) { m_SplashInterface.SetStatusInfo(m_TempStatus); } }
private static void CreateInstance(Type FormType) { //利用反射创建对象 object obj = Activator.CreateInstance(FormType); m_SplashForm = obj as Form; m_SplashInterface = obj as ISplashForm; if (m_SplashForm == null) { throw (new Exception("Splash必须继承自System.Windows.Forms.Form")); } if (m_SplashInterface == null) { throw (new Exception("must implement interface ISplashForm/必须实现界面异构")); } if (!string.IsNullOrEmpty(m_TempStatus)) { m_SplashInterface.SetStatusInfo(m_TempStatus); } }
public static void Show(ISplashForm DisplayForm) { if (!EnsureWorker() && worker.IsBusy) return; if (!(DisplayForm is Form)) throw new ArgumentException("Debe ser un windows form", "Display"); displayForm = DisplayForm; windowCreated = new ManualResetEvent(false); ((Form)displayForm).HandleCreated += SplashScreenController_HandleCreated; worker.RunWorkerAsync(displayForm); if (windowCreated.WaitOne(WAIT_TIME)) { ((Form)displayForm).HandleCreated -= SplashScreenController_HandleCreated; } else { //throw new ApplicationException("Tiempo de espera agotado."); } }
private static void CreateInstance(Type FormType) { object obj = FormType.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null); m_SplashForm = obj as Form; m_SplashInterface = obj as ISplashForm; if (m_SplashForm == null) { throw (new Exception("Splash Screen must inherit from System.Windows.Forms.Form")); } if (m_SplashInterface == null) { throw (new Exception("must implement interface ISplashForm")); } if (!string.IsNullOrEmpty(m_TempStatus)) m_SplashInterface.SetStatusInfo(m_TempStatus); }
/// <summary><para> /// This function initializes the give RenderForm instance, /// runs its main execution loop, and properly shuts it down. /// </para><para> /// It traps and displays any errors that occur. /// </para><para> /// It also properly disposes the Render Form and Splash Form when finished. /// </para></summary> /// <param name="args">The command line arguments from the application's main entry point.</param> /// <param name="mainForm">The main form of the application.</param> /// <param name="splash">The splash form displayed while the main form is initializing.</param> /// <returns>1 if a problem was encountered, 0 otherwise.</returns> public static int MainLoopSafe(string[] args, RenderForm mainForm, ISplashForm splash) { if (mainForm == null) { return(1); } SetDefaultAppDomain(AppDomain.CurrentDomain); if (splash != null) { splash.Show(); splash.Update(); } using (mainForm) { try { if (!mainForm.Init(splash)) { if (splash != null) { splash.Close(); splash.Dispose(); } mainForm.Shutdown(true); return(1); } mainForm.IsRunning = true; bool keepRunning = true; keepRunning = mainForm.ProcessCommandLineArgs(args, keepRunning); mainForm.IsRunning = keepRunning; if (mainForm.IsRunning) { if (splash != null) { splash.Close(); splash.Dispose(); } mainForm.Show(); } while (mainForm.IsRunning) { Application.DoEvents(); mainForm.UpdateAndDraw(); } } catch (Exception ex1) { try { // Display Crashed + Exception ExceptionHelper.ShowException(ex1, "Application Crashed"); mainForm.Shutdown(true); } catch (Exception ex2) { // Display Shutdown Failed + Exception ExceptionHelper.ShowException(ex2, "Application Shutdown Failed"); } return(1); } try { mainForm.Shutdown(false); } catch (Exception ex3) { // Display Shutdown Failed + Exception ExceptionHelper.ShowException(ex3, "Application Shutdown Failed"); return(1); } } return(0); }
/// <summary> /// Scene Initialization. /// The Game Engine, Rendering Panel, Scene Manager, Text Renderer, /// and other game engine dependent components /// are initialized here. /// </summary> /// <param name="splash">A splash form for displaying initialization messages.</param> /// <returns>True if all components were successfully initialized, /// False otherwise</returns> public bool Init(ISplashForm splash) { if (this.mRenderingPanel == null) { this.mRenderingPanel = new RenderPanelEx(); //return false; } if (splash != null) { splash.Message = "Initializing Game Engine..."; } string overrideUserDataPath = null; string installedGameUserDataDir = App.GetInstalledGameUserDataDir(); SharedInitialization.AddGimexSupport(); if (!string.IsNullOrEmpty(installedGameUserDataDir)) { string folderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); overrideUserDataPath = Path.Combine(folderPath, installedGameUserDataDir); } this.mStopWatch.Start(); float startTime = this.mStopWatch.GetElapsedMilliSecs() / 1000f; if (!App.InitApp("", "", this.mRenderingPanel.Width, this.mRenderingPanel.Height, IntPtr.Zero, 0, this.mRenderingPanel.Handle, true, null, overrideUserDataPath)) //if (!App.InitApp("", "", this.mRenderPanel.Width, this.mRenderPanel.Height, IntPtr.Zero, 0, this.mRenderPanel.Handle, true, null, App.StartupServices.ServicesFull, null, overrideUserDataPath, true)) { //throw new Exception("Failed to initialise CSHost"); return(false); } float endTime = this.mStopWatch.GetElapsedMilliSecs() / 1000f; this.mAppInitTime = endTime - startTime; App.StartProcessMessages(); this.mRenderingPanel.AttachToNativeCanvas(); this.mRenderingPanel.Resize += new EventHandler(RenderPanel_Resize); GameObjectFactory.Init(); SharedInitialization.RegisterResourceFactories(); if (splash != null) { splash.Message = "Initializing Scene..."; } this.mScene = new SceneManager(); if (!this.mScene.Init()) { return(false); } CameraTuning.InitializeTuningData(); this.InitializeScene(); ScriptCoreManager.Initialize(); if (splash != null) { splash.Message = "Reticulating Splines..."; } startTime = this.mStopWatch.GetElapsedMilliSecs() / 1000f; this.mSceneInitTime = startTime - endTime; this.mStopWatch.Stop(); this.mStopWatch.Reset(); this.mStopWatch.Start(); this.mTimeAtLastFrame = 0f; this.mTextRenderer = new Sims3.CSHost.Renderer.TextRenderer(); this.mGraphicsInitialized = true; return(this.InitExtra()); }
private static void createInstance(Type FormType) { object obj = FormType.InvokeMember(null, System.Reflection.BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null); splashForm = obj as Form; splashInterface = obj as ISplashForm; if (splashForm == null) { throw new Exception("启动窗体类型必须是System.Windows.Forms.Form的子类"); } if (splashInterface == null) { throw new Exception("启动窗体必须实现ISplashForm接口"); } if (!string.IsNullOrEmpty(tempStatus)) { splashInterface.SetStatusInfo(tempStatus); } }