public void OnMouseClick(MouseClickEventArgs eventArgs)
        {
            if (selectedVisual.GetGlobalBounds().Contains(eventArgs.Args.X, eventArgs.Args.Y))
            {
                applicationManager.SetActiveApplication(applications[GetSelectedApplicationIndex()].ApplicationInstance);
            }

            if (leftVisual.GetGlobalBounds().Contains(eventArgs.Args.X, eventArgs.Args.Y))
            {
                applicationManager.SetActiveApplication(applications[GetLeftApplicationIndex()].ApplicationInstance);
            }

            if (rightVisual.GetGlobalBounds().Contains(eventArgs.Args.X, eventArgs.Args.Y))
            {
                applicationManager.SetActiveApplication(applications[GetRightApplicationIndex()].ApplicationInstance);
            }
        }
Esempio n. 2
0
        public void Run()
        {
            // Main game loop
            try
            {
                var timer = new Clock();

                while (window.IsOpen)
                {
                    window.DispatchEvents();

                    // Clear the previous frame
                    window.Clear(new Color(0xe9, 0xe9, 0xe9));

                    // Update, not sure extent of logic to do in this class
                    applicationManager.OnUpdate(0.016f);

                    // Draw, not sure extent of logic to do in this class
                    applicationManager.OnRender(window);

                    // Display updated frame
                    window.Display();
                }
            }
            catch (Exception e)
            {
                // Log the error
                Debug.WriteLine($"Application '{ActiveApplication.DisplayName}' exited with exception\n{e.InnerException}");

                // Cleanup the application & perform recovery where possible
                if (ActiveApplication.OnException())
                {
                    applicationManager.SetActiveApplication(ActiveApplication);
                }
                else
                {
                    applicationManager.SetActiveApplication(ActiveApplication);
                }

                Run();
            }
        }
Esempio n. 3
0
        public HomeScreen(
            IApplicationManager applicationManager,
            IEventService eventService,
            IApplicationService appService,
            List <ApplicationInstanceVisual> applicationInstances) : base()
        {
            this.applications         = applicationInstances;
            this.applicationDashboard = appService.Kernel.Get <ApplicationDashboard>(
                new ConstructorArgument("applications", applicationInstances));

            eventService.RegisterKeyboardCallback(Id, new KeyPressCallbackEventArgs(Keyboard.Key.Left), applicationDashboard.LeftKeyPressed);
            eventService.RegisterKeyboardCallback(Id, new KeyPressCallbackEventArgs(Keyboard.Key.Right), applicationDashboard.RightKeyPressed);
            eventService.RegisterMouseClickCallback(Id, new MouseClickCallbackEventArgs(Mouse.Button.Left), applicationDashboard.OnMouseClick);
            eventService.RegisterMouseWheelScrollCallback(Id, applicationDashboard.OnMouseWheelMove);

            eventService.RegisterKeyboardCallback(
                Id,
                new KeyPressCallbackEventArgs(Keyboard.Key.Enter),
                (_) => applicationManager.SetActiveApplication(selectedApplication));
        }