示例#1
0
        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);
            }
        }
示例#2
0
        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);
        }
示例#3
0
        void GameDeactivated(object sender, EventArgs e)
        {
            if (ApplicationDelegate != null)
            {
                ApplicationDelegate.ApplicationDidEnterBackground(this);
            }

#if !IOS
            if (HandleMediaStateAutomatically)
            {
                CocosDenshion.CCSimpleAudioEngine.SharedEngine.RestoreMediaState();
            }
#endif
        }
示例#4
0
        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);
            }
        }
示例#5
0
        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();
            }
        }
示例#6
0
 private void MainWindow_OnClosed(object sender, EventArgs e)
 {
     ApplicationDelegate.Exit();
     System.Environment.Exit(0);
 }
示例#7
0
 public static void Run(string[] args, ApplicationDelegate applicationDelegate)
 {
     Delegate = applicationDelegate;
     UIApplication.Main(args, null, "IOSAppDelegate");
 }
示例#8
0
 /// <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);
 }