public static void Run(string title, ApplicationDelegate applicationDelegate) { Application.Initialize(applicationDelegate); // Create the audio driver Audio.Driver = XAudio2Driver.Create(); // Create the window var window = new WindowsWindow(title); Window.Driver = window; applicationDelegate?.Start(); // Show the window window.Show(); // Main message loop: Win32.MSG msg = new Win32.MSG(); try { bool done = false; while (!done) { while (Win32.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0x0001) > 0) { if (msg.message == (int)Win32.WindowMessage.Quit) { done = true; break; } Win32.TranslateMessage(ref msg); Win32.DispatchMessage(ref msg); } // Rather than using WM_MOUSEMOVE we just get the cursor after all events messages // have been processed and create a single event for it. Win32.GetCursorPos(out var point); Win32.ScreenToClient(window._hwnd, out point); Window.MouseMoveEvent.Broadcast(new Vector2(point.X, point.Y)); Application.Step(); } } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } }
protected override IEnumerable <Assembly> GetBootstrapOwningAssemblies() { var result = base.GetBootstrapOwningAssemblies(); var bootstrapAssemblies = result.ToList(); if (!bootstrapAssemblies.Contains(ApplicationDelegate.GetType().GetTypeInfo().Assembly)) { bootstrapAssemblies.Add(ApplicationDelegate.GetType().GetTypeInfo().Assembly); } return(bootstrapAssemblies); }
void GameDeactivated(object sender, EventArgs e) { if (ApplicationDelegate != null) { ApplicationDelegate.ApplicationDidEnterBackground(this); } #if !IOS if (HandleMediaStateAutomatically) { CocosDenshion.CCSimpleAudioEngine.SharedEngine.RestoreMediaState(); } #endif }
void GameActivated(object sender, EventArgs e) { // Clear out the prior gamepad state because we don't want it anymore. priorGamePadState.Clear(); #if !IOS if (HandleMediaStateAutomatically) { CocosDenshion.CCSimpleAudioEngine.SharedEngine.SaveMediaState(); } #endif if (ApplicationDelegate != null) { ApplicationDelegate.ApplicationWillEnterForeground(this); } }
protected override void LoadContent() { if (!initialized) { CCContentManager.Initialize(Game.Content.ServiceProvider, Game.Content.RootDirectory); base.LoadContent(); if (ApplicationDelegate != null) { ApplicationDelegate.ApplicationDidFinishLaunching(this, this.MainWindow); } initialized = true; } else { base.LoadContent(); } }
private void MainWindow_OnClosed(object sender, EventArgs e) { ApplicationDelegate.Exit(); System.Environment.Exit(0); }
public static void Run(string[] args, ApplicationDelegate applicationDelegate) { Delegate = applicationDelegate; UIApplication.Main(args, null, "IOSAppDelegate"); }
/// <summary> /// Configures <see cref="IApplication"/> pipeline options. <see cref="Middleware"/> are executed in the order they are added. /// </summary> /// <param name="configure">The delegate for configuring the <see cref="IApplicationBuilder"/> that will be used to construct the <see cref="IApplication"/>.</param> public void Pipeline(ApplicationDelegate configure) { configure(_applicationBuilder); Application = _applicationBuilder.Build(); }
public IApplicationBuilder Use(ApplicationDelegate app) { _app = app ?? throw new ArgumentNullException(nameof(app)); return(this); }