public void Run() { CoreWindow window = CoreWindow.GetForCurrentThread(); window.Activate(); window.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessUntilQuit); }
/// <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(); } }
public void Run() { Task.Run(() => Compute()); _coreWindow.Activate(); _coreWindow.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessUntilQuit); }
public void Run() { _window.Activate(); Task.Run(() => Executor.Execute()); _window.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessUntilQuit); }
public static void ActivateWindow(int index) { CoreWindow cw = DXInteropApp.WindowList[index]; var nowait = cw.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { cw.Activate(); Window.Current.Activate(); }); }
/// <summary> /// Run our application until the user quits. /// </summary> public void Run() { // Make window active and hide mouse cursor. window.PointerCursor = null; window.Activate(); // Infinite loop to prevent the application from exiting. while (true) { // Dispatch all pending events in the queue. window.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent); // Quit if the users presses Escape key. if (window.GetAsyncKeyState(VirtualKey.Escape) == CoreVirtualKeyStates.Down) { return; } // Set the Direct2D drawing target. d2dContext.Target = d2dTarget; // Clear the target. d2dContext.BeginDraw(); d2dContext.Clear(Color.CornflowerBlue); // Draw a block of text that will be clipped against the specified layout rectangle. d2dContext.FillRectangle(new RectangleF(50, 50, 200, 200), backgroundBrush); d2dContext.DrawText("This text is long enough to overflow the designed region but will be clipped to the containing rectangle. Lorem ipsum dolor sit amet, consectetur adipiscing elit. ", textFormat, new RectangleF(50, 50, 200, 200), textBrush, DrawTextOptions.Clip); // Draw a block of text that will overflow the specified layout rectangle. d2dContext.FillRectangle(new RectangleF(50, 300, 200, 200), backgroundBrush); d2dContext.DrawText("However, this other text isn't going to be clipped: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean gravida dui id accumsan dictum.", textFormat, new RectangleF(50, 300, 200, 200), textBrush, DrawTextOptions.None); // Draw three lines of text with different measuring modes. d2dContext.FillRectangle(new RectangleF(300, 50, 400, 200), backgroundBrush); d2dContext.DrawText("MeasuringMode: Natural", textFormat, new RectangleF(300, 50, 400, 200), textBrush, DrawTextOptions.None, MeasuringMode.Natural); d2dContext.DrawText("MeasuringMode: GDI classic", textFormat, new RectangleF(300, 80, 400, 200), textBrush, DrawTextOptions.None, MeasuringMode.GdiClassic); d2dContext.DrawText("MeasuringMode: GDI natural", textFormat, new RectangleF(300, 110, 400, 200), textBrush, DrawTextOptions.None, MeasuringMode.GdiNatural); float layoutYOffset = (float)Math.Cos(layoutY) * 50.0f; // Draw moving text. d2dContext.FillRectangle(new RectangleF(300, 300, 400, 200), backgroundBrush); d2dContext.DrawTextLayout(new Vector2(300, 350 + layoutYOffset), textLayout1, textBrush); // Draw moving text without pixel snapping, thus giving a smoother movement. d2dContext.FillRectangle(new RectangleF(750, 300, 400, 200), backgroundBrush); d2dContext.DrawTextLayout(new Vector2(750, 350 + layoutYOffset), textLayout2, textBrush, DrawTextOptions.NoSnap); d2dContext.EndDraw(); layoutY += 1.0f / 60.0f; // Present the current buffer to the screen. swapChain.Present(1, PresentFlags.None); } }
/// <inheritdoc/> public void Run() { // Activate the application window, making it visible and enabling it to receive events. window.Activate(); // Prepare matrices var view = Matrix.LookAtLH(new Vector3(0, 0, -5), new Vector3(0, 0, 0), Vector3.UnitY); var proj = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, width / (float)height, 0.1f, 100.0f); var viewProj = Matrix.Multiply(view, proj); // 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(VirtualKey.Escape) == CoreVirtualKeyStates.Down) { break; } // Gets the current graphics context var graphicsContext = graphicsDevice.ImmediateContext; var time = (float)(clock.ElapsedMilliseconds / 1000.0); // Set targets (This is mandatory in the loop) graphicsContext.OutputMerger.SetTargets(renderTargetView); // Clear the views graphicsContext.ClearRenderTargetView(renderTargetView, Color.CornflowerBlue); // Calculate WorldViewProj Matrix worldViewProj = Matrix.RotationX(time) * Matrix.RotationY(time * 2.0f) * Matrix.RotationZ(time * .7f) * viewProj; worldViewProj.Transpose(); // Setup the pipeline graphicsContext.InputAssembler.SetVertexBuffers(0, vertexBufferBinding); graphicsContext.InputAssembler.InputLayout = layout; graphicsContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; graphicsContext.VertexShader.SetConstantBuffer(0, constantBuffer); graphicsContext.VertexShader.Set(vertexShader); graphicsContext.PixelShader.Set(pixelShader); // Update Constant Buffer graphicsContext.UpdateSubresource(ref worldViewProj, constantBuffer, 0); // Draw the cube graphicsContext.Draw(36, 0); // Present the backbuffer swapChain.Present(1, PresentFlags.None, new PresentParameters()); } }
/// <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(); } } }
internal void RunLoop() { SetCursor(Game.IsMouseVisible); _coreWindow.Activate(); while (true) { // Process events incoming to the window. _coreWindow.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent); Tick(); if (IsExiting) { break; } } }
void IFrameworkView.Run() { var applicationView = ApplicationView.GetForCurrentView(); applicationView.Title = _title; _coreWindow.Activate(); /*while (!_platform.ShouldExit) * { * _coreWindow.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent); * * // Tick * if (_activated) * { * _platform.Idle(); * } * }*/ }
/// <summary> /// Run our application until the user quits. /// </summary> public void Run() { // Make window active and hide mouse cursor. window.PointerCursor = null; window.Activate(); // Infinite loop to prevent the application from exiting. while (true) { // Dispatch all pending events in the queue. window.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent); // Quit if the users presses Escape key. if (window.GetAsyncKeyState(VirtualKey.Escape) == CoreVirtualKeyStates.Down) { return; } // Set the Direct2D drawing target. d2dContext.Target = d2dTarget; // Clear the target and draw some geometry with the brushes we created. d2dContext.BeginDraw(); d2dContext.Clear(Color.CornflowerBlue); // Calculate the center of the screen int halfWidth = this.swapChain.Description.ModeDescription.Width / 2; int halfHeight = this.swapChain.Description.ModeDescription.Height / 2; // Translate the origin of coordinates for drawing the bitmap filled rectangle d2dContext.Transform = Matrix3x2.Translation(halfWidth - 350, halfHeight); d2dContext.FillRectangle(new RectangleF(0, 0, 700, 70), terrainBrush); // Translate again for drawing the player bitmap d2dContext.Transform = Matrix3x2.Translation(halfWidth, halfHeight - playerBitmap.Size.Height); d2dContext.DrawBitmap(playerBitmap, 1.0f, SharpDX.Direct2D1.BitmapInterpolationMode.Linear); d2dContext.EndDraw(); // Present the current buffer to the screen. swapChain.Present(1, PresentFlags.None); } }
/// <summary> /// This method is called after the window becomes active. It oversees the /// update, draw, and present loop, and also oversees window message processing. /// </summary> public void Run() { CoreWindow window = CoreWindow.GetForCurrentThread(); window.Activate(); while (!windowClosed) { if (createShaders) { if (!createdShaders) { main.CreateVideoShaders(); createdShaders = true; } } else { window.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessOneAndAllPending); continue; } if (appViewConsolidated || mainWindowReactivated) { TryCloseWindow(); windowClosed = true; } else { window.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent); if (windowVisible && (null != holographicSpace)) { HolographicFrame frame = main.Update(); if (main.Render(ref frame)) { deviceResources.Present(ref frame); } } } } }
void IFrameworkView.Run() { // Specify the cursor type as the standard arrow cursor. // CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 0); // Activate the application window, making it visible and enabling it to receive events. CoreWindow.Activate(); bool windowIsClosed = false; CoreWindow.Closed += (sender, args) => windowIsClosed = true; // Enter the render loop. Note that Metro style apps should never exit. while (!windowIsClosed) { // Process events incoming to the window. CoreWindow.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent); RunCallback(); } }
/// <summary> /// A method that starts the app view. /// </summary> public void Run() { RenderLoop targetRenderLoop = m_mainWindowPainter.RenderLoop; Camera3DBase camera = targetRenderLoop.Camera; // Configure camera camera.Position = new Vector3(-5f, -5f, -5f); camera.Target = new Vector3(0f, 0.5f, 0f); camera.UpdateCamera(); targetRenderLoop.Scene.ManipulateSceneAsync((manipulator) => { // Create pallet geometry resource PalletType pType = new PalletType(); pType.ContentColor = Color4.Transparent; var resPalletGeometry = manipulator.AddResource <GeometryResource>( () => new GeometryResource(pType)); // Create pallet object GenericObject palletObject = manipulator.AddGeneric(resPalletGeometry); palletObject.Position = new Vector3(); palletObject.Color = Color4.GreenColor; palletObject.EnableShaderGeneratedBorder(); palletObject.BuildAnimationSequence() .RotateEulerAnglesTo(new Vector3(0f, EngineMath.RAD_180DEG, 0f), TimeSpan.FromSeconds(2.0)) .WaitFinished() .RotateEulerAnglesTo(new Vector3(0f, EngineMath.RAD_360DEG, 0f), TimeSpan.FromSeconds(2.0)) .WaitFinished() .CallAction(() => palletObject.RotationEuler = Vector3.Zero) .ApplyAndRewind(); }).FireAndForget(); targetRenderLoop.SceneComponents.Add( new FreeMovingCameraComponent()); m_mainWindow.Activate(); m_mainWindow.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessUntilQuit); }
/// <summary> /// Run our application until the user quits. /// </summary> public void Run() { // Make window active and hide mouse cursor. window.PointerCursor = null; window.Activate(); // Infinite loop to prevent the application from exiting. while (true) { // Dispatch all pending events in the queue. window.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent); // Quit if the users presses Escape key. if (window.GetAsyncKeyState(VirtualKey.Escape) == CoreVirtualKeyStates.Down) { return; } // Set the Direct2D drawing target. d2dContext.Target = d2dTarget; // Clear the target and draw some geometry with the brushes we created. d2dContext.BeginDraw(); d2dContext.Clear(Color.CornflowerBlue); d2dContext.FillRectangle(new RectangleF(50, 50, 450, 150), solidBrush); d2dContext.FillRoundedRectangle(new RoundedRectangle() { Rect = new RectangleF(50, 250, 450, 150), RadiusX = 10, RadiusY = 10 }, linearGradientBrush); d2dContext.FillEllipse(new Ellipse(new Vector2(250, 525), 100, 100), radialGradientBrush); d2dContext.EndDraw(); // Present the current buffer to the screen. swapChain.Present(1, PresentFlags.None); } }
public void OnActivated(CoreApplicationView CoreAppView, IActivatedEventArgs Args) { CoreWindow Window = CoreWindow.GetForCurrentThread(); Window.Activate(); }