Powershell GUI fronted (WPF) to run categorized console scripts

⌈⌋ ⎇ branch:  ClickyColoury


Artifact [85279b4b46]

Artifact 85279b4b463188a2213f3880be4ec32e43afadb6:

  • File contrib/CancelBtnExit.ps1 — part of check-in [e419d52757] at 2018-05-16 18:09:08 on branch trunk — Cancel button = currently just hangs both runspaces. (user: mario size: 796)

# encoding: utf-8
# api: clicky
# type: init
# version: 0.0
# title: Cancel=Exit
# description: hooks [Cancel] button event up to plain exit; call
# category: ui
# state: buggy
# hidden: 1
# nomenu: 1
#
# The [X] cancel UI button has no default handler. Triggering an
# exception across runspaces has proven difficult. Hence this plugin
# turns it into an elaborate exit call (effectively crashing main and
# WPF thread).
#

if ($GUI) {
    $plugins.before += {
        Unregister-Event "Gui.Cancel"
        Register-EngineEvent "Gui.Cancel" -Action {
            $GUI.w.close()
            $GUI.shell.Runspace.CloseAsync();
            $PSHost.CloseAsync();
            $GUI.shell.EndInvoke();
            $PSHost.Dispose();
            exit
        }
    }
}