Пример #1
0
            /// <inheritdoc/>
            public void Run()
            {
                DisplayProperties.LogicalDpiChanged += DisplayProperties_LogicalDpiChanged;

                // Specify the cursor type as the standard arrow cursor.
                window.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 0);

                // Activate the application window, making it visible and enabling it to receive events.
                window.Activate();

                // Enter the render loop.  Note that Metro style apps should never exit.
                while (true)
                {
                    // Process events incoming to the window.
                    window.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent);

                    if (window.GetAsyncKeyState(Windows.System.VirtualKey.Escape) == CoreVirtualKeyStates.Down)
                    {
                        break;
                    }

                    // Render the cube
                    target.RenderAll();

                    // Present the cube
                    target.Present();
                }
            }
Пример #2
0
            /// <inheritdoc/>
            public void Run()
            {
                DisplayProperties.LogicalDpiChanged += DisplayProperties_LogicalDpiChanged;

                // Specify the cursor type as the standard arrow cursor.
                window.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 0);

                // Activate the application window, making it visible and enabling it to receive events.
                window.Activate();

                // Run this method async
                // But because It was not possible to use correctly async here
                // we have to use a lock approach, which is far from ideal, but it is at least working.
                // The problem is described here: http://social.msdn.microsoft.com/Forums/mr-IN/winappswithcsharp/thread/d09dd944-f92b-484d-b2ef-d1850c4a587f
                RunAsync();

                // Enter the render loop.  Note that Metro style apps should never exit.
                while (true)
                {
                    // Process events incoming to the window.
                    window.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent);

                    if (window.GetAsyncKeyState(Windows.System.VirtualKey.Escape) == CoreVirtualKeyStates.Down)
                    {
                        break;
                    }

                    bool isInitOk = false;

                    // Check if initialization is done
                    lock (this)
                    {
                        isInitOk = IsInitialized;
                    }

                    // If done, perform rendering
                    if (isInitOk)
                    {
                        // Render the cube
                        target.RenderAll();

                        // Present the cube
                        target.Present();
                    }
                }
            }