public TryMoveFocus ( bool forward = true ) : bool | ||
forward | bool | If true then the manager will try to move forwards, otherwise backwards |
리턴 | bool |
/// <summary> /// Starts the app, asynchronously. /// </summary> /// <returns>A task that will complete when the app exits</returns> public override Task Start() { QueueAction(() => { if (_current != null) { throw new NotSupportedException("An application is already running on this thread."); } // ensures that the current app is set on the message pump thread _current = this; }); if (SetFocusOnStart) { QueueAction(() => { FocusManager.TryMoveFocus(); }); } Paint(); Task pumpTask = base.Start(); var cleanupTask = pumpTask.ContinueWith((t) => { ExitInternal(); }); return(cleanupTask); }
/// <summary> /// Handles key input for the application /// </summary> /// <param name="info">The key that was pressed</param> protected override void HandleKeyInput(ConsoleKeyInfo info) { if (FocusManager.GlobalKeyHandlers.TryIntercept(info)) { // great, it was handled } else if (info.Key == ConsoleKey.Tab) { FocusManager.TryMoveFocus(info.Modifiers.HasFlag(ConsoleModifiers.Shift) == false); } else if (info.Key == ConsoleKey.Escape) { Stop(); return; } else if (FocusManager.FocusedControl != null) { FocusManager.FocusedControl.HandleKeyInput(info); } else { // not handled } Paint(); }
/// <summary> /// Starts the app, asynchronously. /// </summary> /// <returns>A task that will complete when the app exits</returns> public override Promise Start() { QueueActionInFront(() => { if (_current != null) { throw new NotSupportedException("An application is already running on this thread."); } // ensures that the current app is set on the message pump thread _current = this; }); if (SetFocusOnStart) { QueueAction(() => { FocusManager.TryMoveFocus(); }); } Paint(); return(base.Start().Finally((p) => { ExitInternal(); })); }
/// <summary> /// Starts the app, asynchronously. /// </summary> /// <returns>A task that will complete when the app exits</returns> public override Promise Start() { QueueActionInFront(() => { if (_current != null) { throw new NotSupportedException("An application is already running on this thread."); } // ensures that the current app is set on the message pump thread _current = this; QueueAction(() => { AssertSizeRequirements(true); this.WindowResized.SubscribeForLifetime(() => this.AssertSizeRequirements(false), this); }); }); if (SetFocusOnStart) { QueueAction(() => { FocusManager.TryMoveFocus(); }); } Paint(); return(base.Start().Finally((p) => { ExitInternal(); })); }
/// <summary> /// Starts the app, asynchronously. /// </summary> /// <returns>A task that will complete when the app exits</returns> public override async Task Start() { if (SetFocusOnStart) { InvokeNextCycle(() => { FocusManager.TryMoveFocus(); }); } Paint(); await base.Start(); ExitInternal(); }
/// <summary> /// Starts the app, asynchronously. /// </summary> /// <returns>A task that will complete when the app exits</returns> public override Promise Start() { if (SetFocusOnStart) { QueueAction(() => { FocusManager.TryMoveFocus(); }); } Paint(); return(base.Start().Finally((p) => { ExitInternal(); })); }
/// <summary> /// Starts the app, asynchronously. /// </summary> /// <returns>A task that will complete when the app exits</returns> public override async Task Start() { if (SetFocusOnStart) { InvokeNextCycle(() => { FocusManager.TryMoveFocus(); }); } try { Invoke(Startup); await base.Start(); } finally { ExitInternal(); } }
public override void Run() { _current = this; if (SetFocusOnStart) { InvokeNextCycle(() => { FocusManager.TryMoveFocus(); }); } try { base.Run(); Invoke(Startup); } finally { ExitInternal(); } }
private void KeyPressed(ConsoleKeyInfo info) { if (FocusManager.GlobalKeyHandlers.TryIntercept(info)) { // great, it was handled } else if (info.Key == ConsoleKey.Tab) { FocusManager.TryMoveFocus(info.Modifiers.HasFlag(ConsoleModifiers.Shift) == false); } else if (info.Key == ConsoleKey.Escape) { MessagePump.Stop(); return; } else if (FocusManager.FocusedControl != null) { FocusManager.FocusedControl.HandleKeyInput(info); } Paint(); }