Powershell GUI fronted (WPF) to run categorized console scripts

⌈⌋ branch:  ClickyColoury


Artifact [2f8f91fa12]

Artifact 2f8f91fa1224458e14aa3bba11ce6c33cec95844:

  • File contrib/ActivityIndicator3000.ps1 — part of check-in [e076d85d3d] at 2018-05-16 18:08:49 on branch trunk — Swirly arrow indicator for Window title - when scripts are running. (user: mario size: 1047)

# encoding: utf-8
# api: clicky
# type: init-gui
# version: 0.2
# title: ActivityIndicator3000
# description: adapts title while scripts are running
# category: ui
# state: buggy
# hidden: 1
# nomenu: 1
#
# Starts timer in Start-Win (init-gui hook). This keeps it running
# continuosly. But task only really comes into action when $GUI.tasks[]
# queue contains a script.
# Then rewrites the window title with swirly arrows while active.
#

$GUI.act = @{
    timer = [System.Windows.Threading.DispatcherTimer]::new("Background")
    step = -1
    arrows = "⇘⇩⇙⇐⇖⇑⇗⇒"
}
$GUI.act.timer.Interval = 2500
$GUI.act.timer.Add_Tick({
    if ($GUI.tasks -and ($_title = $GUI.tasks[0].title)) {
        $GUI.act.step = ($GUI.act.step + 1) % $GUI.act.arrows.length;
        $GUI.w.title = $GUI.act.arrows[$GUI.act.step] + " $($cfg.main.title) → $_title"
    }
    elseif ($GUI.act.step -ge 0) {
        $GUI.w.title = "➱ $($cfg.main.title)"
        $GUI.act.step = -1
    }
})
$GUI.act.timer.Start()